DSatishchandra commited on
Commit
c4d6896
·
verified ·
1 Parent(s): 0e194dc

Update templates/dashboard.html

Browse files
Files changed (1) hide show
  1. templates/dashboard.html +50 -43
templates/dashboard.html CHANGED
@@ -12,7 +12,6 @@
12
  margin: 0;
13
  padding: 0;
14
  }
15
-
16
  /* Container for the dashboard content */
17
  .dashboard-container {
18
  max-width: 900px;
@@ -23,21 +22,18 @@
23
  border-radius: 8px;
24
  text-align: center;
25
  }
26
-
27
  /* Heading Style */
28
  h1 {
29
  font-size: 2.5rem;
30
  color: #333;
31
  margin-bottom: 20px;
32
  }
33
-
34
  /* Paragraph Style */
35
  p {
36
  font-size: 1.2rem;
37
  color: #666;
38
  margin-bottom: 30px;
39
  }
40
-
41
  /* Link Style */
42
  a {
43
  text-decoration: none;
@@ -46,13 +42,11 @@
46
  font-size: 1.2rem;
47
  transition: color 0.3s;
48
  }
49
-
50
  a:hover {
51
  color: #45a049;
52
  }
53
-
54
  /* Button for listening */
55
- #listen-btn {
56
  padding: 10px 20px;
57
  background-color: #4CAF50;
58
  color: white;
@@ -60,9 +54,9 @@
60
  border-radius: 5px;
61
  cursor: pointer;
62
  font-size: 1.2rem;
 
63
  }
64
-
65
- #listen-btn:hover {
66
  background-color: #45a049;
67
  }
68
  </style>
@@ -76,49 +70,62 @@
76
 
77
  <!-- Button for triggering voice recognition -->
78
  <button id="listen-btn">Say "Go to Menu"</button>
 
 
 
79
  </div>
80
 
81
  <script>
82
- // Speech Recognition and Speech Synthesis for voice interaction
83
-
84
  // Check for SpeechRecognition support
85
  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
86
- const recognition = new SpeechRecognition();
87
- recognition.lang = 'en-US';
88
- recognition.interimResults = false;
89
- recognition.maxAlternatives = 1;
90
-
91
- // Function to speak the message
92
- function speak(text) {
93
- const msg = new SpeechSynthesisUtterance(text);
94
- msg.rate = 1; // Speed of speech
95
- window.speechSynthesis.speak(msg);
96
- }
97
-
98
- // Button for listening to user input
99
- const listenButton = document.getElementById("listen-btn");
100
 
101
- listenButton.addEventListener("click", () => {
102
- speak("Please say 'Go to Menu' to navigate to the menu.");
103
- recognition.start();
104
- });
 
 
 
 
 
 
 
 
 
 
105
 
106
- // Handle speech recognition result
107
- recognition.onresult = (event) => {
108
- const command = event.results[0][0].transcript.toLowerCase();
109
- console.log("User said:", command);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
- // If user says "Go to Menu", navigate to the menu
112
- if (command.includes("go to menu")) {
113
- window.location.href = "/menu";
114
- }
115
- };
116
 
117
- // Handle errors in speech recognition
118
- recognition.onerror = (event) => {
119
- console.error("Speech recognition error:", event.error);
120
- speak("Sorry, I couldn't understand that. Please try again.");
121
- };
122
  </script>
123
 
124
  </body>
 
12
  margin: 0;
13
  padding: 0;
14
  }
 
15
  /* Container for the dashboard content */
16
  .dashboard-container {
17
  max-width: 900px;
 
22
  border-radius: 8px;
23
  text-align: center;
24
  }
 
25
  /* Heading Style */
26
  h1 {
27
  font-size: 2.5rem;
28
  color: #333;
29
  margin-bottom: 20px;
30
  }
 
31
  /* Paragraph Style */
32
  p {
33
  font-size: 1.2rem;
34
  color: #666;
35
  margin-bottom: 30px;
36
  }
 
37
  /* Link Style */
38
  a {
39
  text-decoration: none;
 
42
  font-size: 1.2rem;
43
  transition: color 0.3s;
44
  }
 
45
  a:hover {
46
  color: #45a049;
47
  }
 
48
  /* Button for listening */
49
+ #listen-btn, #logout-btn {
50
  padding: 10px 20px;
51
  background-color: #4CAF50;
52
  color: white;
 
54
  border-radius: 5px;
55
  cursor: pointer;
56
  font-size: 1.2rem;
57
+ margin-top: 20px;
58
  }
59
+ #listen-btn:hover, #logout-btn:hover {
 
60
  background-color: #45a049;
61
  }
62
  </style>
 
70
 
71
  <!-- Button for triggering voice recognition -->
72
  <button id="listen-btn">Say "Go to Menu"</button>
73
+
74
+ <!-- Logout Button -->
75
+ <button id="logout-btn" onclick="logout()">Logout</button>
76
  </div>
77
 
78
  <script>
 
 
79
  // Check for SpeechRecognition support
80
  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
+ if (!SpeechRecognition) {
83
+ alert("Your browser does not support speech recognition. Please use Chrome.");
84
+ } else {
85
+ const recognition = new SpeechRecognition();
86
+ recognition.lang = 'en-US';
87
+ recognition.interimResults = false;
88
+ recognition.maxAlternatives = 1;
89
+
90
+ // Function to speak the message
91
+ function speak(text) {
92
+ const msg = new SpeechSynthesisUtterance(text);
93
+ msg.rate = 1; // Speed of speech
94
+ window.speechSynthesis.speak(msg);
95
+ }
96
 
97
+ // Button for listening to user input
98
+ const listenButton = document.getElementById("listen-btn");
99
+ listenButton.addEventListener("click", () => {
100
+ speak("Please say 'Go to Menu' to navigate to the menu.");
101
+ recognition.start();
102
+ });
103
+
104
+ // Handle speech recognition result
105
+ recognition.onresult = (event) => {
106
+ const command = event.results[0][0].transcript.toLowerCase();
107
+ console.log("User said:", command);
108
+ // If user says "Go to Menu", navigate to the menu
109
+ if (command.includes("go to menu")) {
110
+ window.location.href = "/menu";
111
+ }
112
+ };
113
+
114
+ // Handle errors in speech recognition
115
+ recognition.onerror = (event) => {
116
+ console.error("Speech recognition error:", event.error);
117
+ speak("Sorry, I couldn't understand that. Please try again.");
118
+ };
119
+ }
120
 
121
+ // Logout function
122
+ function logout() {
123
+ // Example of clearing session storage or cookies (if applicable)
124
+ // sessionStorage.clear(); // Uncomment if using sessionStorage
 
125
 
126
+ // Redirect to the login page or any other page for logout
127
+ window.location.href = "/login"; // Modify with actual logout route
128
+ }
 
 
129
  </script>
130
 
131
  </body>