-
Notifications
You must be signed in to change notification settings - Fork 0
/
reloadit.js
54 lines (49 loc) · 1.81 KB
/
reloadit.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
window.onload = function() {
update_debug();
/* Event Handle Functions */
var reset_button = document.getElementById("reset");
reset_button.addEventListener("click", function() {
//Empty the value of the "code" field.
var form = document.getElementById('control_form');
form.code.value='';
form.submit();
});
var debug_checkbox = document.getElementById("debug_checkbox");
debug_checkbox.addEventListener("click", function() {
var state = debug_checkbox.checked;
localStorage.debug = state;
update_debug();
});
}
/* updates the debug features of the document:
1. set the debug checkbox
2. enable/disable form validation
3. show/hide ALL .debug_wrapper elements. */
function update_debug() {
if (localStorage.debug == undefined) {
localStorage.debug = "false"; //default value
}
var cb = document.getElementById("debug_checkbox");
var form = document.getElementById('control_form');
var nodelist = document.getElementsByClassName('debug_wrapper');
NodeList.prototype.forEach = Array.prototype.forEach; //we will be using the forEach method of Array
if (localStorage.debug == "true") {
form.setAttribute('novalidate', '');
cb.setAttribute('checked', 'true');
nodelist.forEach(function(node) {
node.style.display = 'block';
});
}
else {
form.removeAttribute('novalidate');
cb.removeAttribute('checked');
nodelist.forEach(function(node) {
node.style.display = 'none';
});
}
}
/*Not used. Inline prefered.
usage: onclick="submit_prizeid('<?=INDEX_FILE?>', <?=$prizeid?>);"*/
function submit_prizeid(action, prize_id) {
document.location = action + '?prizeid=' + prize_id ;
}