-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
79 lines (68 loc) · 2.2 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
let animationStart = document.getElementById("education");
window.addEventListener("scroll", function () {
var winScrollTop = document.documentElement.scrollTop;
// console.log("top:" + winScrollTop);
if (winScrollTop >= 1887) {
animationStart.style.display = "block";
} else {
animationStart.style.display = "none";
}
});
// script.js
document.addEventListener("DOMContentLoaded", function () {
const progressListItems =
document.querySelectorAll("#progressbar li");
// console.log("itme " + progressListItems.length);
const progressBar =
document.querySelector(".progress-bar");
let currentStep = 0;
// console.log("cuu " + currentStep);
function updateProgress() {
const percent =
(currentStep / (progressListItems.length - 1)) * 100;
progressBar.style.width = percent + "%";
// console.log("p " + percent);
progressListItems.forEach((item, index) => {
if (index === currentStep) {
item.classList.add("active");
} else {
item.classList.remove("active");
}
});
}
function showStep(stepIndex) {
const steps =
document.querySelectorAll(".step-container fieldset");
steps.forEach((step, index) => {
if (index === stepIndex) {
step.style.display = "block";
} else {
step.style.display = "none";
}
});
}
function nextStep() {
if (currentStep < progressListItems.length - 1) {
currentStep++;
showStep(currentStep);
updateProgress();
}
}
function prevStep() {
if (currentStep > 0) {
currentStep--;
showStep(currentStep);
updateProgress();
}
}
const nextStepButtons =
document.querySelectorAll(".next-step");
const prevStepButtons =
document.querySelectorAll(".previous-step");
nextStepButtons.forEach((button) => {
button.addEventListener("click", nextStep);
});
prevStepButtons.forEach((button) => {
button.addEventListener("click", prevStep);
});
});