forked from gmct/gmct.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomp.js
54 lines (50 loc) · 2.24 KB
/
comp.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
var events = ["2x2", "3x3", "4x4", "3BLD", "Square-1", "Clock", "3x3OH", "Pyraminx", "Skewb", "2GEN", "LSE", "COLL"];
var weeklyRotation = ["5x5", "7x7", "Megaminx"];
var bonusEvents = ["3x3 Mirror Blocks/Bump", "F2L", "6x6", "Kilominx", "4x4 OH", "3x3x4", "3x3x5", "Void Cube", "2-3-4 Relay", "FMC", "3x3 With Feet", "3x3x2", "3x3 Relay of 3", "PLL Time Attack"];
var selectedEvents = [];
function makeCheckList(array) {
// Create the list element:
var checkList = document.createElement('div');
for(var i = 0; i < array.length; i++) {
// Create the list item:
var container = document.createElement("div");
//container.align="center";
var check = document.createElement('input');
check.setAttribute("type", "checkbox");
var item = document.createElement('label');
// Set its contents:
check.setAttribute("id", array[i]);
item.appendChild(document.createTextNode(array[i]));
item.setAttribute("for", array[i]);
container.appendChild(check);
container.appendChild(item);
// Add it to the list:
checkList.appendChild(container);
}
// Finally, return the constructed list.
return checkList;
}
function getSelected(){
for(var i = 0; i < events.length; i++){
if (document.getElementById(events[i]).checked){
selectedEvents.push(events[i]);
}
}
for(var i = 0; i < weeklyRotation.length; i++){
if (document.getElementById(weeklyRotation[i]).checked){
selectedEvents.push(weeklyRotation[i]);
}
}
for(var i = 0; i < bonusEvents.length; i++){
if (document.getElementById(bonusEvents[i]).checked){
selectedEvents.push(bonusEvents[i]);
}
}
}
// Add the contents of options[0] to #foo:
console.info(JSON.stringify(weeklyRotation));
document.getElementById('weekly').appendChild(makeCheckList(events));
document.getElementById('cycle').appendChild(makeCheckList(weeklyRotation));
document.getElementById('bonus').appendChild(makeCheckList(bonusEvents));
document.getElementById('enterTimes').onclick = function() {getSelected();
location.href="timeEntry.html?selected="+JSON.stringify(selectedEvents);};