-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.js
51 lines (45 loc) · 1.29 KB
/
global.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
const nav = document.getElementById("nav");
fetch("nav.html")
.then((res) => res.text()) // Invoke text() to get the text content
.then((data) => {
nav.innerHTML = data;
})
.catch((error) => {
console.error("Error fetching nav bar content:", error);
});
const footer = document.getElementById("footer");
fetch("footer.html")
.then((res) => res.text()) // Invoke text() to get the text content
.then((data) => {
footer.innerHTML = data;
})
.catch((error) => {
console.error("Error fetching footer content:", error);
});
// Loader
function showLoader() {
const loader = document.getElementById("loader");
loader.style.display = "flex";
document.body.style.overflow = "hidden";
}
//showLoader();
function hideLoader() {
const loader = document.getElementById("loader");
loader.style.display = "none";
document.body.style.overflowY = "auto";
}
function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function showAndLoad(event, element) {
event.preventDefault();
showLoader();
// await delay(200);
window.location.href = element.href;
}
async function showAndLoadForm(event, element) {
event.preventDefault();
showLoader();
await delay(1200); // Assuming you have a delay function defined elsewhere
element.submit();
}