Skip to content

Commit

Permalink
added commamnds
Browse files Browse the repository at this point in the history
  • Loading branch information
rishovchakraborty committed Apr 16, 2024
1 parent ebe3532 commit 675174a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 10 deletions.
73 changes: 73 additions & 0 deletions Eduversity/assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ for (let i = 0; i < whishlistBtns.length; i++) {

// accessibility js
var screenReaderEnabled = false;
var voiceRecognitionEnabled = false;

function toggleAccessibilityMenu() {
var menu = document.getElementById("accessibilityMenu");
Expand Down Expand Up @@ -142,3 +143,75 @@ form.addEventListener("submit", subscribe)
// Open the modal as soon as the page loads
window.onload = openModal();

// voice recog js

function toggleVoiceRecognition() {
voiceRecognitionEnabled = !voiceRecognitionEnabled;
var menuButton = document.getElementById("voiceRecognitionButton");
if (voiceRecognitionEnabled) {
startVoiceRecognition();
menuButton.innerText = "Disable voice recognition";
} else {
stopVoiceRecognition();
menuButton.innerText = "Enaable voice recognition";
toggleAccessibilityMenu();
}
}

function startVoiceRecognition() {
if (annyang) {
annyang.start();
speakText("Voice recognition enabled");
}
}

function stopVoiceRecognition() {
if (annyang) {
annyang.abort();
speakText("Voice recognition disabled");
}
}

// Voice commands
if (annyang) {
var commands = {
'go to home': () => {
navigateToPage('home');
},
'go to about us': () => {
navigateToPage('about');
},
'go to courses': () => {
navigateToPage('courses');
},
'go to find a job': () => {
navigateToPage('find-job');
},
'go to mini games': () => {
navigateToPage('mini-games');
},
'go to testimonials': () => {
navigateToPage('testimonials');
},
'go to contact us': () => {
navigateToPage('contact');
},
'go to log in': () => {
navigateToPage('login');
},
'go to sign up': () => {
navigateToPage('signup');
}
};
// Function to navigate to a specific page
function navigateToPage(pageId) {
const pageElement = document.getElementById(pageId);
if (pageElement) {
window.location.href = pageElement.href;
} else {
console.error(`Page ID "${pageId}" not found.`);
}
}
annyang.addCommands(commands);
annyang.debug(true);
}
20 changes: 10 additions & 10 deletions Eduversity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Urbanist:wght@400;500;600;700;800&display=swap" rel="stylesheet">

<script src="//cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js"></script>

</head>

Expand Down Expand Up @@ -56,31 +56,31 @@ <h1 class="hover-speak" onmouseover="speakText('Edeuversity')" onmouseleave="sto

<ul class="navbar-list">

<li class="navbar-item hover-speak" onmouseover="speakText('home')" onmouseleave="stopSpeaking()">
<li class="navbar-item hover-speak" onmouseover="speakText('home')" onmouseleave="stopSpeaking()" id="home">
<a href="#home" class="navbar-link" data-nav-toggler>Home</a>
</li>

<li class="navbar-item hover-speak" onmouseover="speakText('about us')" onmouseleave="stopSpeaking()">
<a href="#about" class="navbar-link" data-nav-toggler>About us</a>
<a href="#about" id="about" class="navbar-link" data-nav-toggler>About us</a>
</li>

<li class="navbar-item hover-speak" onmouseover="speakText('courses')" onmouseleave="stopSpeaking()">
<li class="navbar-item hover-speak" onmouseover="speakText('courses')" onmouseleave="stopSpeaking()"id="courses">
<a href="#courses" class="navbar-link" data-nav-toggler>Courses</a>
</li>

<li class="navbar-item hover-speak" onmouseover="speakText('find the job')" onmouseleave="stopSpeaking()">
<li class="navbar-item hover-speak" onmouseover="speakText('find the job')" onmouseleave="stopSpeaking()" id="find-job">
<a href="#event" class="navbar-link" data-nav-toggler>Find the JOB</a>
</li>

<li class="navbar-item hover-speak" onmouseover="speakText('mini games')" onmouseleave="stopSpeaking()">
<li class="navbar-item hover-speak" onmouseover="speakText('mini games')" onmouseleave="stopSpeaking()" id="mini-games">
<a href="#miniganes" class="navbar-link" data-nav-toggler>Mini Games</a>
</li>

<li class="navbar-item hover-speak" onmouseover="speakText('testimonials')" onmouseleave="stopSpeaking()">
<li class="navbar-item hover-speak" onmouseover="speakText('testimonials')" onmouseleave="stopSpeaking()" id="testimonials">
<a href="#testimonial" class="navbar-link" data-nav-toggler>Testimonial</a>
</li>

<li class="navbar-item hover-speak" onmouseover="speakText('contact us')" onmouseleave="stopSpeaking()">
<li class="navbar-item hover-speak" onmouseover="speakText('contact us')" onmouseleave="stopSpeaking()"id="contact">
<a href="/contact_us/contact.html" class="navbar-link" data-nav-toggler>Contact us</a>
</li>

Expand All @@ -95,7 +95,7 @@ <h1 class="hover-speak" onmouseover="speakText('Edeuversity')" onmouseleave="sto
<ion-icon name="search-outline"></ion-icon>
</button>

<a href="login.html" class="header-action-btn login-btn hover-speak"
<a href="login.html" id="login" class="header-action-btn login-btn hover-speak"
onmouseover="speakText('click here to login or register')" onmouseleave="stopSpeaking()">
<ion-icon name="person-outline" aria-hidden="true"></ion-icon>

Expand Down Expand Up @@ -128,7 +128,7 @@ <h1 class="hover-speak" onmouseover="speakText('Edeuversity')" onmouseleave="sto
<li><button class="hover-speak" onclick="toggleScreenReader()" id="screenReaderButton"
onmouseover="speakText('click here to change the screen reader mode')" onmouseleave="stopSpeaking()">Enable
Screen Reader</button></li>
<li><button onclick="toggleKeyboardNavigation()">Enable Voice Recognition</button></li>
<li><button onclick="toggleVoiceRecognition()" id="voiceRecognitionButton">Enable Voice Recognition</button></li>
</ul>
</div>

Expand Down
1 change: 1 addition & 0 deletions feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h1 class="feedback-heading">HOW WAS YOUR EXPERIENCE?</h1>
<!-- <div class="stars" id="stars-container"> -->
<!-- Stars will be added dynamically using JavaScript -->
<!-- </div> -->




Expand Down

0 comments on commit 675174a

Please sign in to comment.