-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom.js
More file actions
56 lines (47 loc) · 2.28 KB
/
dom.js
File metadata and controls
56 lines (47 loc) · 2.28 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
52
53
54
55
56
window.onload = function () {
const infoModal = document.getElementById("infoModal");
const algorithmModal = document.getElementById("algorithmModal");
const cancelModalButton = document.getElementById("cancelModalButton");
const closeAlgorithmModalButton = document.getElementById(
"closeAlgorithmModalButton"
);
const settingsButton = document.getElementById("settingsButton");
const infoButton = document.getElementById("infoButton");
const stages = document.querySelectorAll(".breadcrumb ul li");
const stageContents = document.querySelectorAll(".stage-content");
// Open the info modal on page load
infoModal.classList.add("is-active");
// When "Let's go" is clicked, close the info modal and open the algorithm modal
cancelModalButton.addEventListener("click", () => {
infoModal.classList.remove("is-active");
algorithmModal.classList.add("is-active");
});
// When "Close" is clicked in the algorithm modal, close it
closeAlgorithmModalButton.addEventListener("click", () => {
algorithmModal.classList.remove("is-active");
});
// When settings icon is clicked, open the info modal
settingsButton.addEventListener("click", () => {
infoModal.classList.add("is-active");
});
// When info icon is clicked, open the algorithm modal
infoButton.addEventListener("click", () => {
algorithmModal.classList.add("is-active");
});
// Add event listeners to each breadcrumb item
stages.forEach((stage, index) => {
stage.addEventListener("click", (event) => {
event.preventDefault(); // Prevent default link behavior
// Remove 'is-active' class from all stages
stages.forEach((s) => s.classList.remove("is-active"));
// Add 'is-active' class to the clicked stage
stage.classList.add("is-active");
// Hide all stage contents
stageContents.forEach((content) =>
content.classList.add("is-hidden")
);
// Show the content for the clicked stage
stageContents[index].classList.remove("is-hidden");
});
});
};