This repository has been archived by the owner on May 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
73 lines (60 loc) · 1.68 KB
/
utils.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
var Utils = {
init: function() {
var fp2 = new Fingerprint2();
fp2.get(function(result) {
document.getElementById("fp2").value = result;
var oddResult = result.charCodeAt(result.length - 1) % 2 === 0;
if(oddResult) {
Utils.hide("even-survey");
Utils.show("odd-survey");
} else {
Utils.hide("odd-survey");
Utils.show("even-survey");
}
Utils.hide("preview");
Utils.initValidation();
});
},
initValidation: function() {
var submitButton = document.getElementById("submitButton");
if(submitButton) {
submitButton.onclick = this.validate();
}
},
validate: function() {
alert("Validating!");
return false;
},
toggle: function(id) {
var div = document.getElementById(id);
div.style.display = div.style.display == "none" ? "block" : "none";
},
toggleAll: function(className) {
var divs = document.getElementsByClassName(className);
for(var i = 0; i < divs.length; i++) {
divs[i].style.display = divs[i].style.display == "none" ? "block" : "none";
}
},
change: function(id, displayState) {
var div = document.getElementById(id);
div.style.display = displayState;
},
changeAll: function(className, displayState) {
var divs = document.getElementsByClassName(className);
for(var i = 0; i < divs.length; i++) {
divs[i].style.display = displayState;
}
},
show: function(id) {
this.change(id, "block");
},
showAll: function(className) {
this.changeAll(className, "block");
},
hide: function(id) {
this.change(id, "none");
},
hideAll: function(className) {
this.changeAll(className, "none");
},
};