-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
499 lines (379 loc) · 11.6 KB
/
script.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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
const quizDB = [
{
level: "LEVEL 1",
question: " Q1 Read the passage and answer the question given below:\nThis country now needs a new equilibrium, a new spirit of national reconciliation that can be brought about only by moving forward to the new frontiers of true equality, fuller opportunity and greater compassion for the weaker sections of its people. Our goal is total freedom for the people that can fully reflect their urges and aspirations for a better life. We cannot remain content by merely reliving our past even under the condition of complete freedom, without a matching concept of the present and the future. We can survive only by seizing every constructive opportunity that can offer a creative alternative to the legacies of the past. It is only through such a lofty endeavour that the country can discover itself with a new sense of adventure and faith in ourselves.\n The aim of the nation is _________.",
ans: "better life",
uni: "SOLUTION: better life"
},
{
level: "LEVEL 2",
question: "Q2 Look at this series:\n 21, 9, 21, 11, 21, 13, 21, ... What number should come next?",
ans: "15",
uni: "CLUE: See the Difference"
},
{
level: "LEVEL 3",
question: "Q3 Check the Grammer:\nI could not put up at a hotel.",
ans: "Grammar",
uni: "CLUE: Read the question again"
},
{
level: "LEVEL 4",
question: "Q4 A man has $ 10,000 to invest. He invests $ 4000 at 5 % and $ 3500 at 4 %. In order to have a yearly income of $ 500, he must invest the remainder at: (DO NOT WRITE % IN ANSWER)",
ans: "6.4",
uni: "CLUE: Interest = Principal * Rate * Time"
},
{
level: "LEVEL 5",
question: "Q5 Go to the official YouTube page of Mr. Narendra Modi and Answer is in About Section.",
ans: "Description",
uni: "CLUE: The sub-section starting with D"
},
{
level: "LEVEL 6",
question: "Q6 Find the Treasure.",
ans: "Ans",
uni: "CLUE: It is in this Page"
},
{
level: "LEVEL 7",
question: "Q7 Four jolly men sat down to play and played all night,'til the break of day. They played for cash and not for fun, with a separate score for everyone. When it came time to square accounts, they'd all had made quite fair amounts. Not one had lost and all had gained, so tell me how.\n Can you explain?",
ans: "The men were in a band",
uni: "dead_end1"
},
{
level: "LEVEL 8",
question: "Q8 What word contains all of the twenty-six letters?",
ans: "Alphabet",
uni: "dead_end2"
}
];
const question = document.querySelector('.question');
const level = document.querySelector('.level')
const uni = document.querySelector('#uni');
const myInput = document.getElementById("myInput");
const submit = document.querySelector('#submit');
const answers = document.querySelectorAll('.answer');
const showScore = document.querySelector('#showScore');
let submitCount = 0;
let loadHintCount = 0;
let questionCount = 0;
let score = 0;
let accuracy = 100 - ((submitCount/8)*100);
const array = []
let cminutes = 0;
let csec = 0;
let chours = 0;
var timer;
var ele = document.getElementById('timer');
var sec = 0;
var minutes = 0;
var hours = 0;
(function (){
clearInterval(timer);
timer = setInterval(()=>{
ele.innerHTML = hours + ':' + minutes + ':' + sec;
sec ++;
if (sec == 60){
sec = 0;
minutes++;
}
if ( minutes == 60 ){
minutes = 0;
hours++;
}
cminutes = minutes;
csec = sec;
chours = hours;
}, 1000)
})()
const loadQuestion = () =>{
//const uniList = quizDB[questionCount];
const questionList = quizDB[questionCount];
question.innerText = questionList.question;
level.innerText = questionList.level;
//answers.innerText = questionList.ans;
//uni.innerText = questionList.uni;
}
loadQuestion();
const loadHint = () => {
const questionList = quizDB[questionCount];
uni.innerText = questionList.uni;
loadHintCount++;
}
myInput.addEventListener("input", () =>{
array.push(myInput.value);
});
uni.addEventListener('click', () =>{
loadHint();
//<h3> You Score ${score}/${quizDB.length} </h3>
})
const getCheckAnswer = () => {
return array;
}
myInput.addEventListener("input", () =>{
array.push(myInput.value);
});
restart.addEventListener('click', () =>{
questionCount = 0;
sec = 0;
minutes = 0;
hours = 0;
score = 0;
submitCount = 0;
loadHintCount = 0;
loadQuestion();
})
// const exithome = () => {
// }
// exit.addEventListener('click', () =>{
// <a href="file:///C:/elitmus/home/home.html"></a>
// // exithome();
// })
let flag = 0;
submit.addEventListener('click', () => {
submitCount++;
const checkedAnswer = getCheckAnswer();
let flag = 0;
if (array[array.length - 1] === quizDB[questionCount].ans){
flag = 1
}
if (flag === 1){
score++;
questionCount++;
}
const deselectAll = () => {
// myInput.innerText.reset() ;
uni.innerHTML = "HINT";
}
deselectAll();
if(questionCount < quizDB.length){
if(questionCount === 5){
q6.innerHTML = `
<h3> Ans </h3>
`;
q6.classList.remove('q6');
}
loadQuestion();
if (questionCount !== 5){
q6.innerText = ``
}
}else{
clearInterval(timer);
showScore.innerHTML = `
<h3>!You found all ${score} Clues!</h3>
<h3>HINTS USED: ${loadHintCount}</h3>
<h3>ACCURACY: ${accuracy}% </h3>
<h3>TIME TAKEN ${chours}:${cminutes}:${csec}</h3>
<h3>solve puzzle to find the</h3>
<h3>TREASURE CHEST</h3>
<a href="puzzlegame.html">SOLVE PUZZLE</a>
`;
showScore.classList.remove('scoreArea');
}
})
// const exit = () => {
// <a href="file:///C:/elitmus/home/home.html"></a>
// }
// quit.addEventListener('click', () => {
// exit();
// })
// const preventDefault = () => {
// questionCount = questionCount;
// score = score;
// }
// window.onbeforeunload = (event) => {
// event.preventDefault();
// return"";
// }
// const quizDB = [
// {
// question: "Q1",
// ans: "1",
// uni: "1"
// },
// {
// question: "Q2",
// ans: "2",
// uni: "clue1"
// },
// {
// question: "Q3",
// ans: "3",
// uni: "clue2"
// },
// {
// question: "Q4",
// ans: "4",
// uni: "clue3"
// },
// {
// question: "Q5",
// ans: "5",
// uni: "clue4"
// },
// {
// question: "Q6",
// ans: "6",
// uni: "clue5"
// },
// {
// question: "Q7",
// ans: "7",
// uni: "dead_end1"
// },{
// question: "Q8",
// ans: "8",
// uni: "dead_end2"
// }
// ];
// const question = document.querySelector('.question');
// const uni = document.querySelector('#uni');
// const myInput = document.getElementById("myInput");
// const submit = document.querySelector('#submit');
// const answers = document.querySelectorAll('.answer');
// const showScore = document.querySelector('#showScore');
// let questionCount = 0;
// let score = 0;
// const array = [];
// const loadQuestion = () =>{
// //const uniList = quizDB[questionCount];
// const questionList = quizDB[questionCount];
// question.innerText = questionList.question;
// answer.innerText = questionList.ans;
// //uni.innerText = questionList.uni;
// }
// const loadHint = () => {
// const questionList = quizDB[questionCount];
// uni.innerText = questionList.uni;
// }
// uni.addEventListener('click', () =>{
// loadHint();
// //<h3> You Score ${score}/${quizDB.length} </h3>
// })
// loadQuestion();
// const getCheckAnswer = () => {
// return array;
// }
// myInput.addEventListener("input", () =>{
// array.push(myInput.value);
// });
// let flag = 0;
// let i = 0
// submit.addEventListener('click', () => {
// const checkedAnswer = getCheckAnswer();
// let flag = 0;
// if (array[array.length - 1] === quizDB[questionCount].ans){
// flag = 1
// }
// i += 2
// if (flag === 1){
// score++;
// questionCount++;
// }
// if(questionCount < quizDB.length){
// loadQuestion();
// }else{
// showScore.innerHTML = `
// <h3> You Score ${score}/${quizDB.length} </h3>
// <button class = "btn" onclick = "location.reload()"> LAST LEVEL </button>
// `;
// showScore.classList.remove('scoreArea');
// }
// })
// // const quizDB = [
// // {
// // question: "Q1",
// // ans: "a"
// // },
// // {
// // question: "Q2",
// // ans: "b"
// // },
// // {
// // question: "Q3",
// // ans: "c"
// // },
// // {
// // question: "Q4",
// // ans: "d"
// // },
// // {
// // question: "Q5",
// // ans: "e"
// // },
// // {
// // question: "Q6",
// // ans: "f"
// // },
// // {
// // question: "Q7",
// // ans: "g"
// // },{
// // question: "Q8",
// // ans: "h"
// // }
// // ];
// // const question = document.querySelector('.question');
// // const myInput = document.getElementById("myInput");
// // const submit = document.querySelector('#submit');
// // const answers = document.querySelectorAll('.answer');
// // const showScore = document.querySelector('#showScore');
// // let questionCount = 0;
// // let score = 0;
// // const array = [];
// // const loadQuestion = () =>{
// // const questionList = quizDB[questionCount];
// // question.innerText = questionList.question;
// // // answer.innerText = questionList.ans;
// // }
// // loadQuestion();
// // myInput.addEventListener("input", () =>{
// // array.push(myInput.value);
// // });
// // const getCheckAnswer = () => {
// // return array;
// // }
// // let flag = 0;
// // submit.addEventListener('click', () => {
// // myInput.addEventListener("input", () =>{
// // array.push(myInput.value);
// // });
// // if (array.length === quizDB[questionCount].ans.length){
// // let i = 0;
// // let j = 0;
// // while(i < array.length && j < quizDB[questionCount].ans.length){
// // if (array[i] !== quizDB[questionCount].ans[i]){
// // flag = 1;
// // break;
// // }
// // i += 1;
// // j += 1;
// // }
// // }else{
// // flag = 1;
// // }
// // for(let i = 0; i < quizDB[questionCount].ans.length; i++){
// // for(let j = 0; j < array.length; j++ ){
// // if(quizDB[questionCount].ans[i] === array[j]){
// // flag = 1;
// // }else{
// // flag = 0;
// // break;
// // }
// // }
// // }
// // if (flag === 0){
// // score++;
// // questionCount++;
// // }
// // if(questionCount < quizDB.length){
// // loadQuestion();
// // }else{
// // showScore.innerHTML = `
// // <h3> You Score ${score}/${quizDB.length} </h3>
// // <button class = "btn" onclick = "location.reload()"> LEVEL 9 </button>
// // `;
// // showScore.classList.remove('scoreArea');
// // }
// // })