-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddHtmlElements.js
401 lines (365 loc) · 13 KB
/
addHtmlElements.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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
const initialBalance = 5000
function addPageElements(){
const FONT = '"Avant Garde", Avantgarde, "Century Gothic", CenturyGothic, AppleGothic, sans-serif'
document.body.style.backgroundColor = "black"
var containerDiv = document.createElement("div")
containerDiv.id = "container"
containerDiv.style.position = "relative"
containerDiv.style.background = 'linear-gradient(0deg, rgba(0,0,0,0.8), rgba(38,137,64,1)), url("images/bg.png") repeat'
containerDiv.style.width = "1000px"
containerDiv.style.minHeight = "700px"
containerDiv.style.borderRadius = "5px"
containerDiv.style.margin = "0 auto"
containerDiv.style["boxShadow"] = "inset 0px 0px 4px 27px rgba(73,49,28,1)"
document.body.appendChild(containerDiv)
//message
var message = document.createElement("p")
message.id = "message"
message.style.position = "absolute"
message.style.top = "150px"
message.style.left = "460px"
message.style.padding = "8px"
message.style.visibility = "hidden"
message.style.fontFamily = FONT
message.style.fontSize = "20px"
message.style.color = "white"
containerDiv.appendChild(message)
//-----------dealer div-----------
var dealerDiv = document.createElement("div")
dealerDiv.id = "dealer-area"
dealerDiv.style.width = "42%"
dealerDiv.style.marginLeft = "8%"
dealerDiv.style.minHeight = "400px"
dealerDiv.style.cssFloat = "left"
dealerDiv.style.perspective = "1000px"
containerDiv.appendChild(dealerDiv)
//dealer score display
var dealerScoreDisplay = document.createElement("div")
dealerScoreDisplay.id = "dealer-display"
dealerScoreDisplay.style.position = "relative"
dealerDiv.appendChild(dealerScoreDisplay)
var dealerScoreMessage = document.createElement("p")
dealerScoreMessage.id = "dealer-score"
dealerScoreMessage.style.position = "absolute"
dealerScoreMessage.style.left = "50px"
dealerScoreMessage.style.top = "40px"
dealerScoreMessage.style.fontSize = "18px"
dealerScoreMessage.style.color = "transparent"
dealerScoreMessage.style.fontFamily = FONT
dealerScoreMessage.innerHTML = "Dealer"
dealerScoreDisplay.appendChild(dealerScoreMessage)
//-----------player div-----------
var playerDiv = document.createElement("div")
playerDiv.id = "player-area"
//playerDiv.style.position = "relative"
playerDiv.style.width = "50%"
playerDiv.style.minHeight = "400px"
playerDiv.style.cssFloat = "left"
containerDiv.appendChild(playerDiv)
//player score display
var playerScoreDisplay = document.createElement("div")
playerScoreDisplay.id = "player-display"
playerScoreDisplay.style.position = "absolute"
playerScoreDisplay.style.right = "150px"
playerScoreDisplay.style.top = "40px"
playerDiv.appendChild(playerScoreDisplay)
var playerScoreMessage = document.createElement("p")
playerScoreMessage.id = "player-score"
playerScoreMessage.style.fontSize = "16px"
playerScoreMessage.style.color = "white"
playerScoreMessage.style.fontFamily = FONT
playerScoreDisplay.appendChild(playerScoreMessage)
//-----------chip div-----------
var chipDiv = document.createElement("div")
chipDiv.id = "chip-area"
chipDiv.style.width = "320px"
chipDiv.style.height = "250px"
chipDiv.style.cssFloat = "left"
chipDiv.style.marginLeft = "150px"
containerDiv.appendChild(chipDiv)
var chipIndexes = [1, 5, 25, 100, 500]
var chipsArray = []
for(let i=0;i<chipIndexes.length;i++){
chipsArray[i] = new Chip(chipIndexes[i])
}
//reset wager button
var resetWager = document.createElement("button")
resetWager.id = "resetWager"
resetWager.style.display = "inline-block"
resetWager.style.minWidth = "130px"
resetWager.style.marginTop = "20px"
resetWager.style.padding = "8px"
resetWager.style.borderRadius = "10px"
resetWager.style.backgroundColor = "transparent"
resetWager.style.color = "white"
resetWager.style.fontFamily = FONT
resetWager.style.fontSize = "16px"
resetWager.style.marginLeft = "15px"
resetWager.innerHTML = "Reset Wager"
chipDiv.appendChild(resetWager)
// balance display
var startingBalance = document.createElement("p")
startingBalance.id = "balance"
startingBalance.style.position = "absolute"
startingBalance.style.top = "480px"
startingBalance.style.left = "600px"
startingBalance.style.boxSizing = "border-box"
startingBalance.style.width = "600px"
startingBalance.style.height = "160px"
startingBalance.style.padding = "10px"
startingBalance.style.borderRadius = "10px"
startingBalance.style.color = "white"
startingBalance.style.lineHeight = "40px"
startingBalance.style.fontFamily = FONT
startingBalance.style.fontSize = "18px"
chipDiv.appendChild(startingBalance)
changeBalanceDisplay(initialBalance)
//-----------button div-----------
var buttonDiv = document.createElement("div")
buttonDiv.id = "button-area"
buttonDiv.style.width = "400px"
buttonDiv.style.boxSizing = "border-box"
buttonDiv.style.paddingLeft = "80px"
buttonDiv.style.paddingTop = "40px"
buttonDiv.style.cssFloat = "left"
containerDiv.appendChild(buttonDiv)
//dealButton
var dealButton = document.createElement("button")
dealButton.id = "deal"
dealButton.innerHTML = "DEAL"
dealButton.style.width = "60px"
dealButton.style.borderRadius = "10px"
dealButton.style.height = "60px"
dealButton.style.color = "white"
dealButton.style.backgroundColor = "transparent"
dealButton.style.fontFamily = FONT
dealButton.style.fontSize = "15px"
dealButton.style.marginLeft = "15px"
buttonDiv.appendChild(dealButton)
//hitButton
var hitButton = document.createElement("button")
hitButton.id = "hit"
hitButton.innerHTML = "HIT"
hitButton.style.width = "60px"
hitButton.style.borderRadius = "10px"
hitButton.style.height = "60px"
hitButton.style.color = "white"
hitButton.style.backgroundColor = "transparent"
hitButton.style.fontFamily = FONT
hitButton.style.fontSize = "15px"
hitButton.style.marginLeft = "15px"
buttonDiv.appendChild(hitButton)
//standButton
var standButton = document.createElement("button")
standButton.id = "stand"
standButton.innerHTML = "STAND"
standButton.style.width = "80px"
standButton.style.borderRadius = "10px"
standButton.style.height = "60px"
standButton.style.color = "white"
standButton.style.backgroundColor = "transparent"
standButton.style.fontFamily = FONT
standButton.style.fontSize = "15px"
standButton.style.marginLeft = "15px"
buttonDiv.appendChild(standButton)
//menu area
var menuArea = document.createElement('div')
menuArea.id="menu-area"
menuArea.style.width="100%"
menuArea.style.height = "200px"
menuArea.style.position = "absolute"
menuArea.style.transition = "1s"
buttonDiv.appendChild(menuArea)
//menu button
var menuBtn = document.createElement('button')
menuBtn.id = "menu-button"
menuBtn.style.position = "absolute"
menuBtn.style.top = "50px"
menuBtn.style.boxSizing = "border-box"
menuBtn.style.left = "50px"
menuBtn.style.width = "150px"
menuBtn.innerHTML = "Menu"
menuBtn.style.padding = "15px"
menuBtn.style.borderRadius = "5px"
menuBtn.style.fontFamily = FONT
menuBtn.style.fontSize = "20px"
menuBtn.style.color = "green"
menuBtn.style.backgroundColor = "white"
menuArea.appendChild(menuBtn)
//overlay
var overlayArea = document.createElement('div')
overlayArea.id = "overlay-area"
overlayArea.style.width = "220px"
overlayArea.style.top = "250px"
overlayArea.style.left = "420px"
overlayArea.style.height = "220px"
overlayArea.style.position = "absolute"
overlayArea.style.backgroundColor = "white"
overlayArea.style.opacity = 0
overlayArea.style.transition = "1s"
containerDiv.appendChild(overlayArea)
//reset button
var resetBtn = document.createElement('button')
resetBtn.id = "reset-button"
resetBtn.style.position = "absolute"
resetBtn.style.top = "50px"
resetBtn.style.boxSizing = "border-box"
resetBtn.style.left = "40px"
resetBtn.style.width = "140px"
resetBtn.innerHTML = "Reset"
resetBtn.style.padding = "5px"
resetBtn.style.borderRadius = "5px"
resetBtn.style.fontFamily = FONT
resetBtn.style.fontSize = "16px"
resetBtn.style.color = "green"
resetBtn.style.backgroundColor = "white"
overlayArea.appendChild(resetBtn)
//submit button
var submitBtn = document.createElement('button')
submitBtn.id = "submit-button"
submitBtn.style.position = "absolute"
submitBtn.style.top = "100px"
submitBtn.style.boxSizing = "border-box"
submitBtn.style.left = "40px"
submitBtn.style.width = "140px"
submitBtn.innerHTML = "Submit Balance"
submitBtn.style.padding = "5px"
submitBtn.style.borderRadius = "5px"
submitBtn.style.fontFamily = FONT
submitBtn.style.fontSize = "16px"
submitBtn.style.color = "green"
submitBtn.style.backgroundColor = "white"
overlayArea.appendChild(submitBtn)
//leader button
var leaderBtn = document.createElement('button')
leaderBtn.id = "leader-button"
leaderBtn.style.position = "absolute"
leaderBtn.style.top = "150px"
leaderBtn.style.boxSizing = "border-box"
leaderBtn.style.left = "40px"
leaderBtn.style.width = "140px"
leaderBtn.innerHTML = "Leader Board"
leaderBtn.style.padding = "5px"
leaderBtn.style.borderRadius = "5px"
leaderBtn.style.fontFamily = FONT
leaderBtn.style.fontSize = "16px"
leaderBtn.style.color = "green"
leaderBtn.style.backgroundColor = "white"
overlayArea.appendChild(leaderBtn)
//close menu button
var closeBtn = document.createElement('button')
closeBtn.id = "close-button"
closeBtn.style.position = "absolute"
closeBtn.style.boxSizing = "border-box"
closeBtn.style.right = "0px"
closeBtn.style.outline = "none"
closeBtn.style.border = "none"
closeBtn.innerHTML = "❎"
closeBtn.style.padding = "5px"
//closeBtn.style.borderRadius = "5px"
closeBtn.style.fontFamily = FONT
closeBtn.style.fontSize = "40px"
closeBtn.style.color = "green"
closeBtn.style.backgroundColor = "transparent"
overlayArea.appendChild(closeBtn)
//form area
var formArea = document.createElement('div')
formArea.id="form-area"
formArea.style.top = "220px"
formArea.style.left= "120px"
formArea.style.width="400px"
formArea.style.height = "200px"
formArea.style.position = "absolute"
formArea.style.opacity = 0
formArea.style.transition = "0.3s"
containerDiv.appendChild(formArea)
//submit form
var form = document.createElement('div')
form.id = "submit-form"
form.style.position = "absolute"
form.style.top = "50px"
form.style.boxSizing = "border-box"
form.style.left = "20px"
form.style.width = "300px"
form.style.height = "200px"
form.style.padding = "5px"
form.style.borderRadius = "5px"
form.style.fontFamily = FONT
form.style.fontSize = "16px"
form.style.color = "green"
form.style.backgroundColor = "white"
formArea.appendChild(form)
//label
var nameInput = document.createElement('label')
nameInput.id = "user-name-label"
nameInput.innerHTML = "Enter name:"
nameInput.style.position = "absolute"
nameInput.style.top = "10px"
nameInput.style.boxSizing = "border-box"
nameInput.style.left = "20px"
nameInput.style.width = "140px"
nameInput.style.padding = "5px"
nameInput.style.borderRadius = "5px"
nameInput.style.fontFamily = FONT
nameInput.style.fontSize = "16px"
nameInput.style.color = "green"
nameInput.style.backgroundColor = "white"
form.appendChild(nameInput)
//input
var nameInput = document.createElement('input')
nameInput.id = "user-name"
nameInput.style.position = "absolute"
nameInput.style.top = "40px"
nameInput.style.boxSizing = "border-box"
nameInput.style.left = "20px"
nameInput.style.width = "180px"
nameInput.style.padding = "5px"
nameInput.style.borderRadius = "5px"
nameInput.style.fontFamily = FONT
nameInput.style.fontSize = "16px"
nameInput.style.color = "green"
nameInput.style.backgroundColor = "white"
form.appendChild(nameInput)
//balance paragraph
var currentBalance = document.createElement('p')
currentBalance.id = "current-balance"
currentBalance.style.position = "absolute"
currentBalance.style.top = "70px"
currentBalance.style.boxSizing = "border-box"
currentBalance.style.left = "20px"
currentBalance.style.fontFamily = FONT
currentBalance.style.fontSize = "16px"
currentBalance.style.color = "black"
form.appendChild(currentBalance)
//submit score button
var submitBalanceBtn = document.createElement('button')
submitBalanceBtn.id = "submit-balance-button"
submitBalanceBtn.style.position = "absolute"
submitBalanceBtn.style.top = "120px"
submitBalanceBtn.style.boxSizing = "border-box"
submitBalanceBtn.style.left = "20px"
submitBalanceBtn.style.width = "140px"
submitBalanceBtn.innerHTML = "Submit Now"
submitBalanceBtn.style.padding = "5px"
submitBalanceBtn.style.borderRadius = "5px"
submitBalanceBtn.style.fontFamily = FONT
submitBalanceBtn.style.fontSize = "16px"
submitBalanceBtn.style.color = "white"
submitBalanceBtn.style.backgroundColor = "green"
form.appendChild(submitBalanceBtn)
//close menu button
var closeSubBtn = document.createElement('button')
closeSubBtn.id = "close-submition-button"
closeSubBtn.style.position = "absolute"
closeSubBtn.style.boxSizing = "border-box"
closeSubBtn.style.right = "0px"
closeSubBtn.style.outline = "none"
closeSubBtn.style.border = "none"
closeSubBtn.innerHTML = "❎"
closeSubBtn.style.padding = "5px"
closeSubBtn.style.fontFamily = FONT
closeSubBtn.style.fontSize = "40px"
closeSubBtn.style.color = "green"
closeSubBtn.style.backgroundColor = "transparent"
form.appendChild(closeSubBtn)
}