-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
219 lines (180 loc) Β· 8.91 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
const body = document.querySelector("body"),
nav = document.querySelector("nav"),
modeToggle = document.querySelector(".dark-light"),
sidebarOpen = document.querySelector(".sidebarOpen"),
siderbarClose = document.querySelector(".siderbarClose");
let getMode = localStorage.getItem("mode");
if (getMode && getMode === "dark-mode") {
body.classList.add("dark");
}
// js code to toggle dark and light mode
modeToggle.addEventListener("click", () => {
modeToggle.classList.toggle("active");
body.classList.toggle("dark");
// js code to keep user selected mode even page refresh or file reopen
if (!body.classList.contains("dark")) {
localStorage.setItem("mode", "light-mode");
} else {
localStorage.setItem("mode", "dark-mode");
}
});
// js code to toggle sidebar
sidebarOpen.addEventListener("click", () => {
nav.classList.add("active");
});
body.addEventListener("click", (e) => {
let clickedElm = e.target;
if (
!clickedElm.classList.contains("sidebarOpen") &&
!clickedElm.classList.contains("menu")
) {
nav.classList.remove("active");
}
});
document.addEventListener("DOMContentLoaded", function () {
var questions = document.querySelectorAll(".question");
questions.forEach(function (question) {
var questionTitle = question.querySelector("h2");
var answer = question.querySelector(".answer");
questionTitle.addEventListener("click", function () {
answer.style.display =
answer.style.display === "block" ? "none" : "block";
});
});
});
document.addEventListener("DOMContentLoaded", function () {
var scrollToTopBtn = document.getElementById("scrollToTopBtn");
// Show or hide the button based on scroll position
window.addEventListener("scroll", function () {
if (
document.body.scrollTop > 20 ||
document.documentElement.scrollTop > 20
) {
scrollToTopBtn.style.display = "block";
} else {
scrollToTopBtn.style.display = "none";
}
});
// Scroll to the top when the button is clicked
scrollToTopBtn.addEventListener("click", function () {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
});
});
document.addEventListener("DOMContentLoaded", function () {
const toggleNavButton = document.getElementById("toggleNav");
const nav = document.querySelector("nav");
toggleNavButton.addEventListener("click", function () {
nav.style.display = nav.style.display === "block" ? "none" : "block";
});
});
const notifications = [
"In a world of noise, find your melody in silence πΆβ¨ Embrace the beauty of sign language and the power of connection beyond words. #SilentSymphony",
"Our hands tell stories that words cannot express ππ« Let's celebrate the richness of our culture and the resilience of our community. #HandsSpeakLouder",
"The sound of silence is the echo of strength πͺπ¬ Let's amplify our voices through unity, empowerment, and pride. #DeafAndMuteEmpowered",
"In every silence, there's a story waiting to be heard ππ€« Let's listen with our hearts, communicate with kindness, and embrace our differences. #SpeakWithLove",
"Our silence is not a barrier, but a canvas for creativity π¨π Let's paint a world of inclusion, acceptance, and endless possibilities. #SilentExpression",
"Diversity is our strength, and unity is our song ππ€ Let's harmonize our differences and create a symphony of acceptance and belonging. #TogetherInSilence",
"The language of the heart knows no sound ππ Let's communicate with compassion, understanding, and empathy, bridging gaps and building connections. #HeartSpeaksLouder",
"In the silence, we find our voice ππ£οΈ Let's amplify our message of love, acceptance, and equality for all. #SilentRevolution",
"Silence is not absence; it's the presence of profound expression π π¬ Let's cherish the power of our silence and the depth of our communication. #SilentStrength",
"With every sign, we speak volumes ππ€ Let's celebrate the beauty of sign language and the richness of our diverse community. #SignLanguageRocks",
"Our silence is not weakness but a testament to our resilience ππͺ Let's stand tall, speak boldly, and advocate for our rights with pride. #SilentWarriors",
"In silence, we discover the music of our souls π΅β¨ Let's dance to the rhythm of inclusion, celebrate diversity, and spread joy. #SilentMelodies",
"Words may fade, but the impact of our silence resonates forever ππ¬ Let's leave a legacy of understanding, acceptance, and unity. #SilentLegacy",
"Communication transcends sound; it's the meeting of minds and hearts ππ Let's connect beyond words, embrace diversity, and celebrate unity. #BeyondWords",
"In our silence, we find strength; in our unity, we find power ππ€ Let's amplify our voices, advocate for change, and create a world of equality and inclusion. #SilentSolidarity",
];
function showRandomNotification() {
const randomIndex = Math.floor(Math.random() * notifications.length);
const notificationText = notifications[randomIndex];
const notificationContainer = document.getElementById(
"notificationContainer"
);
const notification = document.createElement("div");
notification.classList.add("notification");
notification.innerText = notificationText;
const closeButton = document.createElement("span");
closeButton.classList.add("close-button");
closeButton.innerHTML = "×";
closeButton.onclick = function () {
notificationContainer.removeChild(notification);
};
notification.appendChild(closeButton);
notificationContainer.appendChild(notification);
setTimeout(() => {
notificationContainer.removeChild(notification);
}, 10000); // Close notification after 10 seconds
}
function showRandomNotificationAfterDelay() {
setTimeout(() => {
showRandomNotification();
showRandomNotificationAfterDelay(); // Recursively call to continue showing notifications
}, 10000); // Show notification after 10 seconds
}
// Initial call to start showing notifications after 10 seconds
showRandomNotificationAfterDelay();
// chatbot
var chatbotContainer = document.getElementById("chatbotContainer");
var sendButton = document.querySelector(".send-button");
var userInput = document.getElementById("userInput");
function sendMessage() {
var chat = document.getElementById("chat");
if (userInput.value.trim() === "") {
return;
}
var userMessage = document.createElement("div");
userMessage.classList.add("user-message");
userMessage.innerText = "You: " + userInput.value;
chat.appendChild(userMessage);
// Reset input field
userInput.value = "";
// Scroll to bottom
chat.scrollTop = chat.scrollHeight;
// Simulate bot response after 1 second
setTimeout(sendBotResponse, 1000);
}
function sendBotResponse() {
var botResponses = [
"HELLO - Greeting gesture with a wave of the hand",
"THANK YOU - Hand moves from lips outward in a flat hand motion",
"FRIEND - Two index fingers form an 'X' shape, indicating friendship",
"LOVE - Cross arms over the chest, forming an 'X', symbolizing love",
"HELP - Open hand moves upwards, palm facing up, indicating a request for assistance",
"YES - Nodding the head affirmatively",
"NO - Shaking the head from side to side",
"UNDERSTAND - Tap the forehead with an index finger, indicating comprehension",
"GOOD - Thumb and index finger form a circle, indicating something positive",
"BAD - Thumb and index finger form an 'X' shape, indicating something negative",
"NAME - Fingerspell each letter of the person's name",
"SCHOOL - Both hands in the 'A' handshape, tapping the temple twice",
"LEARN - Open hand moves towards the head, symbolizing acquiring knowledge",
"TEACHER - Open hand moves down the side of the face, indicating someone who imparts knowledge",
"STUDENT - Two fingers of the dominant hand tap the palm of the non-dominant hand",
"I'm still learning",
];
var randomIndex = Math.floor(Math.random() * botResponses.length);
var response = botResponses[randomIndex];
var chat = document.getElementById("chat");
var botMessage = document.createElement("div");
botMessage.classList.add("bot-message");
botMessage.innerText = "Chatbot: " + response;
chat.appendChild(botMessage);
// Scroll to bottom
chat.scrollTop = chat.scrollHeight;
}
function closeChatbot() {
chatbotContainer.style.display = "none";
// Reappear chatbot after two minutes
setTimeout(function () {
chatbotContainer.style.display = "block";
}, 120000); // 2 minutes in milliseconds
}
// Event listener for send button click
sendButton.addEventListener("click", sendMessage);
// Event listener for enter key press
userInput.addEventListener("keypress", function (event) {
if (event.key === "Enter") {
sendMessage();
}
});