-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetailed-reviews.js
More file actions
44 lines (38 loc) · 1.09 KB
/
detailed-reviews.js
File metadata and controls
44 lines (38 loc) · 1.09 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
function rating(el, setnum) {
var starIndex = parseInt(el.id.replace(setnum + "_", ''), 10);
var container = el.parentNode;
var stars = container.querySelectorAll('a');
stars.forEach(function(star, index) {
if (index < starIndex) {
star.classList.add('hovered');
} else {
star.classList.remove('hovered');
}
});
}
function rolloff(el, setnum) {
var container = el.parentNode;
var stars = container.querySelectorAll('a');
var selected = parseInt(document.getElementById(setnum + "_rating").value, 10);
stars.forEach(function(star, index) {
star.classList.remove('hovered');
if (index < selected) {
star.classList.add('selected');
} else {
star.classList.remove('selected');
}
});
}
function rateIt(el, setnum) {
var starIndex = parseInt(el.id.replace(setnum + "_", ''), 10);
document.getElementById(setnum + "_rating").value = starIndex;
var container = el.parentNode;
var stars = container.querySelectorAll('a');
stars.forEach(function(star, index) {
if (index < starIndex) {
star.classList.add('selected');
} else {
star.classList.remove('selected');
}
});
}