-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.js
More file actions
53 lines (44 loc) · 1.75 KB
/
project.js
File metadata and controls
53 lines (44 loc) · 1.75 KB
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
document.addEventListener('DOMContentLoaded', () => {
const dropdowns = document.querySelectorAll('.nav-item');
dropdowns.forEach(dropdown => {
dropdown.addEventListener('mouseenter', () => {
dropdown.querySelector('.dropdown-content').style.display = 'block';
});
dropdown.addEventListener('mouseleave', () => {
timer = setTimeout(() => {
dropdown.querySelector('.dropdown-content').style.display = 'none';
}, 100); // Adds a slight delay before hiding the dropdown
});
});
});
function includeHTML() {
const elements = document.querySelectorAll('[data-include]');
elements.forEach((element) => {
const file = element.getAttribute('data-include');
fetch(file)
.then((response) => {
if (!response.ok) throw new Error('Failed to fetch ' + file);
return response.text();
})
.then((data) => {
element.innerHTML = data;
//CHATBOT- Execute scripts in the included HTML
element.querySelectorAll('script').forEach((script) => {
const newScript = document.createElement('script');
Array.from(script.attributes).forEach(attr => {
newScript.setAttribute(attr.name, attr.value);
});
newScript.textContent = script.textContent;
document.head.appendChild(newScript);
});
//CHATBOT ENDS
})
.catch((error) => console.error(error));
});
}
// Call includeHTML on page load
document.addEventListener('DOMContentLoaded', includeHTML);
// Function to handle login button click (redirect to login page)
function handleLogin() {
window.location.href = "user-type.html";
}