-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
276 lines (231 loc) · 10.8 KB
/
app.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
var myDom = document.getElementById("body")
console.log(myDom, "myDom")
var hr1 =document.createElement("hr")
var hr2 =document.createElement("hr")
var h1 =document.createElement("h1")
var div1 = document.createElement("div")
div1.setAttribute("id","mainTopDetail")
var p1= document.createElement("p")
p1.setAttribute("id","score")
var p2= document.createElement("p")
p2.setAttribute("id","lifelIne")
var div1Child = document.createElement("div")
console.log(div1Child)
div1Child.setAttribute("id","randomColor")
var p3 = document.createElement("p")
p3.setAttribute("id","Timer")
var div2 = document.createElement("div")
div2.setAttribute("id","wrapper")
div2.setAttribute("class","container-fluid")
//---------------------------------------
var div2Child = document.createElement("div")
div2Child.setAttribute("id","main1")
div2Child.setAttribute("class","container")
var div2Child_div1 = document.createElement("div")
div2Child_div1.setAttribute("class","box")
div2Child_div1.setAttribute("id","ballon-1")
div2Child_div1.setAttribute("onClick","Ballons('ballon-1')")
var div2Child_div2 = document.createElement("div")
div2Child_div2.setAttribute("class","box")
div2Child_div2.setAttribute("id","ballon-2")
div2Child_div2.setAttribute("onClick","Ballons('ballon-2')")
var div2Child_div3 = document.createElement("div")
div2Child_div3.setAttribute("class","box")
div2Child_div3.setAttribute("id","ballon-3")
div2Child_div3.setAttribute("onClick","Ballons('ballon-3')")
var div2Child_div4 = document.createElement("div")
div2Child_div4.setAttribute("class","box")
div2Child_div4.setAttribute("id","ballon-4")
div2Child_div4.setAttribute("onClick","Ballons('ballon-4')")
var div2Child_div5 = document.createElement("div")
div2Child_div5.setAttribute("class","box")
div2Child_div5.setAttribute("id","ballon-5")
div2Child_div5.setAttribute("onClick","Ballons('ballon-5')")
var div2Child_div6 = document.createElement("div")
div2Child_div6.setAttribute("class","box")
div2Child_div6.setAttribute("id","ballon-6")
div2Child_div6.setAttribute("onClick","Ballons('ballon-6')")
var div2Child_div7 = document.createElement("div")
div2Child_div7.setAttribute("class","box")
div2Child_div7.setAttribute("id","ballon-7")
div2Child_div7.setAttribute("onClick","Ballons('ballon-7')")
var div2Child_div8 = document.createElement("div")
div2Child_div8.setAttribute("class","box")
div2Child_div8.setAttribute("id","ballon-8")
div2Child_div8.setAttribute("onClick","Ballons('ballon-8')")
//---------------------------------------
var div2Child_div2_mian2 = document.createElement("div")
div2Child_div2_mian2.setAttribute("id","main2")
var div2Child_div2_main2_div1 = document.createElement("div")
div2Child_div2_main2_div1.setAttribute("class","box")
div2Child_div2_main2_div1.setAttribute("id","ballon-9")
div2Child_div2_main2_div1.setAttribute("onClick","Ballons('ballon-9')")
var div2Child_div2_main2_div2 = document.createElement("div")
div2Child_div2_main2_div2.setAttribute("class","box")
div2Child_div2_main2_div2.setAttribute("id","ballon-10")
div2Child_div2_main2_div2.setAttribute("onClick","Ballons('ballon-10')")
var div2Child_div2_main2_div3 = document.createElement("div")
div2Child_div2_main2_div3.setAttribute("class","box")
div2Child_div2_main2_div3.setAttribute("id","ballon-11")
div2Child_div2_main2_div3.setAttribute("onClick","Ballons('ballon-11')")
var div2Child_div2_main2_div4 = document.createElement("div")
div2Child_div2_main2_div4.setAttribute("class","box")
div2Child_div2_main2_div4.setAttribute("id","ballon-12")
div2Child_div2_main2_div4.setAttribute("onClick","Ballons('ballon-12')")
var div2Child_div2_main2_div5 = document.createElement("div")
div2Child_div2_main2_div5.setAttribute("class","box")
div2Child_div2_main2_div5.setAttribute("id","ballon-13")
div2Child_div2_main2_div5.setAttribute("onClick","Ballons('ballon-13')")
var div2Child_div2_main2_div6 = document.createElement("div")
div2Child_div2_main2_div6.setAttribute("class","box")
div2Child_div2_main2_div6.setAttribute("id","ballon-14")
div2Child_div2_main2_div6.setAttribute("onClick","Ballons('ballon-14')")
var div2Child_div2_main2_div7 = document.createElement("div")
div2Child_div2_main2_div7.setAttribute("class","box")
div2Child_div2_main2_div7.setAttribute("id","ballon-15")
div2Child_div2_main2_div7.setAttribute("onClick","Ballons('ballon-15')")
var div2Child_div2_main2_div8 = document.createElement("div")
div2Child_div2_main2_div8.setAttribute("class","box")
div2Child_div2_main2_div8.setAttribute("id","ballon-16")
div2Child_div2_main2_div8.setAttribute("onClick","Ballons('ballon-16')")
//---------------------------------------
var div2Child_div2_mian3 = document.createElement("div")
div2Child_div2_mian3.setAttribute("id","main3")
var div2Child_div2_main3_div1 = document.createElement("div")
div2Child_div2_main3_div1.setAttribute("class","box")
div2Child_div2_main3_div1.setAttribute("id","ballon-17")
div2Child_div2_main3_div1.setAttribute("onClick","Ballons('ballon-17')")
var div2Child_div2_main3_div2 = document.createElement("div")
div2Child_div2_main3_div2.setAttribute("class","box")
div2Child_div2_main3_div2.setAttribute("id","ballon-18")
div2Child_div2_main3_div2.setAttribute("onClick","Ballons('ballon-18')")
var div2Child_div2_main3_div3 = document.createElement("div")
div2Child_div2_main3_div3.setAttribute("class","box")
div2Child_div2_main3_div3.setAttribute("id","ballon-19")
div2Child_div2_main3_div3.setAttribute("onClick","Ballons('ballon-19')")
var div2Child_div2_main3_div4 = document.createElement("div")
div2Child_div2_main3_div4.setAttribute("class","box")
div2Child_div2_main3_div4.setAttribute("id","ballon-20")
div2Child_div2_main3_div4.setAttribute("onClick","Ballons('ballon-20')")
var div2Child_div2_main3_div5 = document.createElement("div")
div2Child_div2_main3_div5.setAttribute("class","box")
div2Child_div2_main3_div5.setAttribute("id","ballon-21")
div2Child_div2_main3_div5.setAttribute("onClick","Ballons('ballon-21')")
var div2Child_div2_main3_div6 = document.createElement("div")
div2Child_div2_main3_div6.setAttribute("class","box")
div2Child_div2_main3_div6.setAttribute("id","ballon-22")
div2Child_div2_main3_div6.setAttribute("onClick","Ballons('ballon-22')")
var div2Child_div2_main3_div7 = document.createElement("div")
div2Child_div2_main3_div7.setAttribute("class","box")
div2Child_div2_main3_div7.setAttribute("id","ballon-23")
div2Child_div2_main3_div7.setAttribute("onClick","Ballons('ballon-23')")
var div2Child_div2_main3_div8 = document.createElement("div")
div2Child_div2_main3_div8.setAttribute("class","box")
div2Child_div2_main3_div8.setAttribute("id","ballon-24")
div2Child_div2_main3_div8.setAttribute("onClick","Ballons('ballon-24')")
var p3Text = document.createTextNode("Timer:0")
var textH1 = document.createTextNode("Ballon Game")
var textP1 = document.createTextNode("Score:0")
var textP2 = document.createTextNode("Life Line:")
h1.appendChild(textH1)
p1.appendChild(textP1)
p2.appendChild(textP2)
p3.appendChild(p3Text)
myDom.appendChild(h1)
myDom.appendChild(hr1)
myDom.appendChild(div1)
div1.appendChild(p1)
div1.appendChild(p2)
div1.appendChild(div1Child)
myDom.appendChild(p3)
myDom.appendChild(hr2)
myDom.appendChild(div2)
div2.appendChild(div2Child)
div2Child.appendChild(div2Child_div1)
div2Child.appendChild(div2Child_div2)
div2Child.appendChild(div2Child_div3)
div2Child.appendChild(div2Child_div4)
div2Child.appendChild(div2Child_div5)
div2Child.appendChild(div2Child_div6)
div2Child.appendChild(div2Child_div7)
div2Child.appendChild(div2Child_div8)
div2Child.appendChild(div2Child_div2)
div2.appendChild(div2Child_div2_mian2)
div2Child_div2_mian2.append(div2Child_div2_main2_div1)
div2Child_div2_mian2.append(div2Child_div2_main2_div2)
div2Child_div2_mian2.append(div2Child_div2_main2_div3)
div2Child_div2_mian2.append(div2Child_div2_main2_div4)
div2Child_div2_mian2.append(div2Child_div2_main2_div5)
div2Child_div2_mian2.append(div2Child_div2_main2_div6)
div2Child_div2_mian2.append(div2Child_div2_main2_div7)
div2Child_div2_mian2.append(div2Child_div2_main2_div8)
div2.appendChild(div2Child_div2_mian3)
div2Child_div2_mian3.append(div2Child_div2_main3_div1)
div2Child_div2_mian3.append(div2Child_div2_main3_div2)
div2Child_div2_mian3.append(div2Child_div2_main3_div3)
div2Child_div2_mian3.append(div2Child_div2_main3_div4)
div2Child_div2_mian3.append(div2Child_div2_main3_div5)
div2Child_div2_mian3.append(div2Child_div2_main3_div6)
div2Child_div2_mian3.append(div2Child_div2_main3_div7)
div2Child_div2_mian3.append(div2Child_div2_main3_div8)
var colorArrayy = [
"lightblue",
"lightgreen",
"blue",
"pink",
"brown",
"pink",
"pink",
"gray",
"yellow"
]
var lifeLineArray = ['❤️', '❤️', '❤️', '❤️', '❤️']
document.getElementById("lifelIne").innerText = "Life Line: " + lifeLineArray.join('');
var findColor = colorArrayy[Math.floor(Math.random() * colorArrayy.length)]
console.log(findColor)
for (let i = 1; i <= 24; i++) {
var randomColor = colorArrayy[Math.floor(Math.random() * colorArrayy.length)];
document.getElementById("ballon-" + i).style.backgroundColor = randomColor;
}
var boxRandom = document.getElementById("randomColor");
boxRandom.style.backgroundColor = findColor;
var score = 0;
function Ballons(ballonPick) {
var ballonColors = document.getElementById(ballonPick);
if (findColor.toLowerCase() === ballonColors.style.backgroundColor) {
score = score + 1;
document.getElementById("score").innerText = "Score: " + score;
ballonColors.style.backgroundColor = "lightgreen";
}
else {
score = score - 1;
document.getElementById("score").innerText = "Score: " + score;
lifeLineArray.pop();
document.getElementById("lifelIne").innerText = "Life Line: " + lifeLineArray.join('');
var randomColor = colorArrayy[Math.floor(Math.random() * colorArrayy.length)];
ballonColors.style.backgroundColor = randomColor;
if (lifeLineArray == '') {
document.getElementById("lifelIne").innerText = "Life Line: " + "😞";
}
}
}
var startingMintes = 1;
var time = startingMintes * 60;
var countDown = document.getElementById("Timer");
var settime = setInterval(updateCountDown, 1000)
function updateCountDown() {
var minutes = Math.floor(time / 60)
let second = time % 60;
second = second < 1 ? '0' + second : second;
countDown.innerText = `${minutes} : ${second}`;
time--;
if (minutes === 0 && second == 00) {
clearInterval(settime);
if (score >= 1){
document.getElementById("score").innerText = "You Win 🏆";
}
else if(score <= 0){
document.getElementById("score").innerText = "You Lose 💔"
}
}
}