-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
93 lines (81 loc) · 1.8 KB
/
Copy pathapp.js
File metadata and controls
93 lines (81 loc) · 1.8 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const progress = document.getElementById("progress");
const prev = document.getElementById("prev");
const next = document.getElementById("next");
const circles = document.querySelectorAll(".circle");
let currentActive = 1;
next.addEventListener("click", () => {
currentActive++;
if (currentActive > circles.length) {
currentActive = circles.length;
}
update();
});
prev.addEventListener("click", () => {
currentActive--;
if (currentActive < 1) {
currentActive = 1;
}
update();
});
function update() {
circles.forEach((circle, idx) => {
if (idx < currentActive) {
circle.classList.add("active");
} else {
circle.classList.remove("active");
}
});
const actives = document.querySelectorAll(".active");
progress.style.width =
((actives.length - 1) / (circles.length - 1)) * 100 + "%";
if (currentActive === 1) {
prev.disabled = true;
} else if (currentActive === circles.length) {
next.disabled = true;
} else {
prev.disabled = false;
next.disabled = false;
}
}
update();
//star rating
const stars = document.querySelectorAll(".star-wrapper span");
console.log(stars);
let state = false;
stars.forEach((star) => {
console.log(star);
star.addEventListener("click", (e) => {
starcolor(e);
});
});
const wrapper = document.querySelector("star-wrapper");
function starcolor(e) {
let c = 5;
for (let i = 0; i < c; i++) {
stars[i].style.color = "black";
}
let a = e.target.id;
console.log(a);
let b;
switch (a) {
case "star1":
b = 1;
break;
case "star2":
b = 2;
break;
case "star3":
b = 3;
break;
case "star4":
b = 4;
break;
case "star5":
b = 5;
break;
}
console.log(b);
for (let i = 0; i < b; i++) {
stars[i].style.color = "orange";
}
}