generated from Zitishk/temp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange.js
103 lines (77 loc) · 2.03 KB
/
change.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
let x =new Array(0,0,0,0,0,0,0,0);
function clicked(id){
console.log("click");
if(x[id-1]==1&&id==8)
{}
else
{
if(x[id-1]==1)
{
if(x[id]==0)
{
remove(id);
}
else{
for(i=parseInt(id)+1;i<=8;i++)
{
remove(i.toString());
}
}
}
else{
for(i=1;i<=id;i++)
add(i);
}
}
water=0,ht=0;
for( i=0;i<8;i++)
{
if(x[i]==1)
{
water+=0.25;
ht++ ;
}
}
if(ht!=0)
{
filled.style.visibility="visible";
}
else{
filled.style.visibility="hidden";
}
console.log(ht*1.0/8);
document.getElementById("lt").innerHTML=2-water+"L";
document.getElementById("pcnt").innerHTML=(ht*100/8.0)+"%";
//filled.style.height=`{ht*300/100.0}`;
filled.style.height=`${(100*ht*1.0/8)}%`
// console.log(ht*1.0/8));
//remained.style.height=`${300-(ht*300/100.0)}px`;
remained.style.height=`${100*(8-ht)*1/8.0}%`;
/*if(ht!=0)
{
document.getElementById("remained").style.borderBottomRightRadius = "0px";
document.getElementById("remained").style.borderBottomLeftRadius = "0px";
}
else{
document.getElementById("remained").style.borderBottomRightRadius = "40px";
document.getElementById("remained").style.borderBottomLeftRadius = "40px";
}*/
if (ht==8)
{
document.getElementById("lt").style.visibility = "hidden";
document.getElementById("text").style.visibility = "hidden";
}
else{
document.getElementById("lt").style.visibility = "visible";
document.getElementById("text").style.visibility = "visible";
}
}
function add(id){
x[id-1]=1;
document.getElementById(id).style.backgroundColor = "powderblue";
}
function remove(id)
{
x[id-1]=0;
document.getElementById(id).style.backgroundColor = "white";
}