-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat.js
53 lines (48 loc) · 1.87 KB
/
chat.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
document.addEventListener("DOMContentLoaded", function () {
welcomeMessage();
});
function welcomeMessage() {
addMessage("Welcome! How can I assist you today?");
}
function sendMessage() {
var userInput = document.getElementById("userInput").value;
if (userInput.trim() !== "") {
addMessage("User: " + userInput);
processUserInput(userInput.toLowerCase());
document.getElementById("userInput").value = "";
}
}
function addMessage(message) {
var chatbox = document.getElementById("chatbox");
var newMessage = document.createElement("div");
newMessage.className = "message";
newMessage.textContent = message;
chatbox.appendChild(newMessage);
chatbox.scrollTop = chatbox.scrollHeight;
}
function processUserInput(userInput) {
if (userInput.includes("home")) {
addMessage("Navigating to the Home page...");
window.location.href="home.html"
} else if (userInput.includes("about")) {
addMessage("Navigating to the About Us page...");
window.location.href="about.html"
} else if (userInput.includes("events")) {
addMessage("Navigating to the Events page...");
window.location.href="EVENT.HTML"
} else if (userInput.includes("gallery")) {
addMessage("Navigating to the gallery page...");
window.location.href="gallery.html"}
else if (userInput.includes("notification")) {
addMessage("Navigating to the gallery page...");
window.location.href="notification.html"}
else if (userInput.includes("help")) {
showHelp();
} else {
addMessage("My apologies. Please type 'help' for assistance.");
}
}
function showHelp() {
addMessage("You can navigate by typing keywords like 'home', 'about', 'events', etc.");
addMessage("Feel free to ask for help anytime!");
}