-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
34 lines (29 loc) · 856 Bytes
/
main.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
let path = window.location.pathname;
let fullPath = window.location.href;
let page = path.split("/").pop();
if (page.endsWith("index") || path.endsWith("//")) {
window.location.replace("/");
}
if (page.endsWith(".html")) {
window.location.replace(page.slice(0, -5));
}
if (fullPath.match(/#$/)) {
var newURL = fullPath.replace(/#$/, "");
window.location.replace(newURL);
}
fetch("menubar.html")
.then(function (response) {
return response.text();
})
.then(function (data) {
let tempDiv = document.createElement("div");
tempDiv.innerHTML = data;
let navElement = tempDiv.querySelector("nav");
if (navElement) {
document.body.prepend(navElement);
document.querySelector(".main").style.display = "block";
}
})
.catch(function (error) {
console.error("Error fetching menubar.html:", error);
});