-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (32 loc) · 1.15 KB
/
script.js
File metadata and controls
38 lines (32 loc) · 1.15 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
document.addEventListener("DOMContentLoaded", function () {
const toggle = document.getElementById("toggle-lang");
// Get saved language from localStorage
const savedLang = localStorage.getItem("lang");
// Update toggle state on load
if (savedLang === "en") {
toggle.checked = true;
} else if (savedLang === "gr") {
toggle.checked = false;
}
// On toggle change
toggle.addEventListener("change", function () {
if (this.checked) {
localStorage.setItem("lang", "en");
location.href = "index-en.html";
} else {
localStorage.setItem("lang", "gr");
location.href = "index.html";
}
});
});
// Highlight the active page link in gray
document.addEventListener("DOMContentLoaded", function () {
const currentPage = window.location.pathname.split("/").pop();
const navLinks = document.querySelectorAll(".nav-link");
navLinks.forEach(link => {
const linkPage = link.getAttribute("href");
if (linkPage === currentPage) {
link.classList.add("active-page");
}
});
});