-
Notifications
You must be signed in to change notification settings - Fork 0
/
safw.js
112 lines (101 loc) · 3.17 KB
/
safw.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function save() {
let save = []
table.querySelectorAll('td').forEach((td) => {
if (td.classList.contains('wrong')) {
save.push('wrong')
}
else if (td.classList.contains('bulb')) {
save.push('bulb')
//save.push('coloured')
}
else if (td.classList.contains('coloured')) {
save.push('coloured')
}
else if (td.classList.contains('greenBorder')) {
save.push('greenBorder')
}
else {
save.push('none')
}
})
localStorage.setItem('save', JSON.stringify(save))
localStorage.setItem('maptype', JSON.stringify(maptype))
localStorage.setItem('timex', JSON.stringify(timex))
localStorage.setItem('namez', JSON.stringify(namez))
}
// function load() {
// let save = JSON.parse(localStorage.getItem('save'))
// let maptype = JSON.parse(localStorage.getItem('maptype'))
// let timex = JSON.parse(localStorage.getItem('timex'))
// let namez = JSON.parse(localStorage.getItem('namez'))
// document.getElementById("timeDisplay").innerHTML = Time(timex)
// setName(namez)
// if (maptype == 1) {
// map1()
// }
// else if (maptype == 2) {
// map2()
// }
// else if (maptype == 3) {
// map3()
// }
// let i = 0
// table.querySelectorAll('td').forEach((td) => {
// if (save[i] == 'bulb') {
// td.classList.add('bulb')
// td.classList.add('coloured')
// }
// else if (save[i] == 'coloured') {
// td.classList.add('coloured')
// }
// else if (save[i] == 'wrong') {
// td.classList.add('wrong')
// }
// else if (save[i] == 'greenBorder') {
// td.classList.add('greenBorder')
// }
// i++
// })
// keepChecking()
// }
//implement save and load functions
function load(x) {
let load = JSON.parse(localStorage.getItem('save'))
let maptypeLocal = JSON.parse(localStorage.getItem('maptype'))
setName(JSON.parse(localStorage.getItem('namez')))
document.getElementById("timeDisplay").innerHTML = Time(JSON.parse(localStorage.getItem('timex')))
if (x == 0) {
if (maptypeLocal == 1) {
map1()
maptype = 1
}
else if (maptypeLocal == 2) {
map2()
maptype = 2
}
else if (maptypeLocal == 3) {
map3()
maptype = 3
}
}
table.querySelectorAll('td').forEach((td, index) => {
if (load[index] === 'bulb') {
td.classList.add('bulb')
td.classList.add('coloured')
}
else if (load[index] === 'coloured') {
td.classList.add('coloured')
}
else if (load[index] === 'wrong') {
td.classList.add('wrong')
td.classList.add('bulb')
td.classList.add('coloured')
}
else if (load[index] === 'greenBorder') {
td.classList.add('greenBorder')
}
else {
return
}
})
}