-
Notifications
You must be signed in to change notification settings - Fork 2
/
schedule2.js
53 lines (47 loc) · 1.48 KB
/
schedule2.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
if(!localStorage.getItem('Data')){
let emptyMat=[
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
[0,0,0,0,0,0,0],
]
localStorage.setItem('Data',JSON.stringify(emptyMat))
}
function stateSet(row,column,state){
let matrix=JSON.parse( localStorage.getItem('Data'));
matrix[row][column]=state;
localStorage.setItem('Data',JSON.stringify(matrix));
}
function User(row,column){
let usrSaidYes=confirm('set this task as done?');
if(usrSaidYes){
stateSet(row,column,1);
document.querySelectorAll('td')[(row+1)*8+column+1].style.color='green'
}else{
stateSet(row,column,-1);
document.querySelectorAll('td')[(row+1)*8+column+1].style.color='red'
}
}
function stateGet(row,column) {
return JSON.parse(localStorage.getItem('Data'))[row][column]
}
function colorise(){
let weekData=JSON.parse( localStorage.getItem('Data'));
for(let row=0;row<11;row++){
for(let col=0;col<7;col++){
let state=weekData[row][col];
if(state==1) document.querySelectorAll('td')[(row+1)*8+col+1].style.color='green'
else if(state==-1) document.querySelectorAll('td')[(row+1)*8+col+1].style.color='red'
// else if(state==0) document.querySelectorAll('td')[(row+1)*8+col+1].style.color='yellow'
// else debugger
}
}
}
colorise()