This repository was archived by the owner on Sep 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
388 lines (364 loc) · 11.6 KB
/
script.js
File metadata and controls
388 lines (364 loc) · 11.6 KB
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
var $total = -1
var pontos = -1
var correta = 0;
var errada = 0;
var usuario = "";
var cont = 1;
var flag = 1;
var pontos = 0;
var perguntasTotal = "0";
var totalCertas = "0";
var totalErradas = "0";
var desc = '0';
var ac = ""; bc = ""; cc = ""; dc = ""; ec = ""; fc = ""; gc = ""; hc = ""; ic = ""; jc = "";
var ae = ""; be = ""; ce = ""; de = ""; ee = ""; fe = ""; ge = ""; he = ""; ie = ""; je = "";
var descj = "";
var desca = ""; descb = ""; descc = ""; descd = ""; desce = ""; descf = ""; descg = ""; desch = ""; desci = "";
/* PARA ACERTAR O BUG DO BOTÃO É SÓ COLOCAR TUDO EM BUTTON
/************************************************ */
console.log($("[id*='ctl00_hnlPerfil']", window.parent.document).html());
var user = $("[id*='ctl00_hnlPerfil']", window.parent.document).html();
/****************TESTES************************* */
/*cont = 0 vai ser a primeira questão*/
function Cont() {
cont++;
return cont;
}
function Flag() {
flag++;
return flag;
}
function Time1() {
setTimeout(function () {
document.getElementById('pag0').style.display = 'none';
}, 400);
}
function Time2() {
setTimeout(function () {
document.getElementById('pag1').style.display = 'none';
}, 400);
}
function Time3() {
setTimeout(function () {
document.getElementById('pag2').style.display = 'none';
}, 400);
}
function Time4() {
setTimeout(function () {
document.getElementById('pag3').style.display = 'none';
}, 400);
}
function Time5() {
setTimeout(function () {
document.getElementById('pag4').style.display = 'none';
}, 400);
}
function Time6() {
setTimeout(function () {
document.getElementById('pag5').style.display = 'none';
}, 400);
}
function Time7() {
setTimeout(function () {
document.getElementById('pag6').style.display = 'none';
}, 400);
}
function Time8() {
setTimeout(function () {
document.getElementById('pag7').style.display = 'none';
}, 400);
}
function Time9() {
setTimeout(function () {
document.getElementById('pag8').style.display = 'none';
}, 400);
}
$(document).ready(function () {
$('.btn3').click(function () {
setTimeout(function () {
document.getElementById('pagA').style.display = 'none';
document.getElementById('pag0').style.display = 'block';
}, 400);
});
$('.absolute').click(function () {
$("body").css({ "position": "absolute" });
});
//get total of questions
var $questionNumber = $('h2').length;
console.log($questionNumber);
//caching final score
var $totalScore = 0;
$('li').click(function () {
//caching variables
var $parent = $(this).parent();
var $span = $(this).find('.fa');
//deactivate options on click
$parent.find('li').off("click");
//check for .correct class
//if yes
if ($(this).hasClass('correct')) {/* Função perguntas certas e erradas */
//add .correctAnswer class
$(this).addClass('correctAnswer');
//find next span and change icon
$span.removeClass('fa fa-square-o').addClass('fa fa-check-square-o');
//reduce opacity of siblings
$(this).siblings().addClass('fade');
//show answer
var $answerReveal = $parent.next('.answerReveal').show();
var $toShowCorrect = $answerReveal.find('.quizzAnswerC');
var $toShowFalse = $answerReveal.find('.quizzAnswerF');
$toShowCorrect.show();
$toShowFalse.remove();
//add 1 to total score
$totalScore += 1;
//console.log($totalScore);
var cabAcertou = "acertou"
/********************/
correta += 1;
/************ */
var soundID = "bonus";
function loadSound() {
createjs.Sound.registerSound("bonus.mp3", soundID);
}
/*loadSound();*/
function playSound() {
createjs.Sound.play(soundID);
}
/*playSound();*/
var certa = correta - 1;
if (correta > certa && cont == 1) {
ac = '1, ';
pontos += 10
document.getElementById("pontos").style.display = 'block';
document.getElementById("pontos").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 2) {
bc = '2, ';
pontos += 10
document.getElementById("pontos1").style.display = 'block';
document.getElementById("pontos1").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 3) {
cc = '3, ';
pontos += 10
document.getElementById("pontos2").style.display = 'block';
document.getElementById("pontos2").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 4) {
dc = '4, ';
pontos += 10
document.getElementById("pontos3").style.display = 'block';
document.getElementById("pontos3").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 5) {
ec = '5, ';
pontos += 10
document.getElementById("pontos4").style.display = 'block';
document.getElementById("pontos4").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 6) {
fc = '6, ';
pontos += 10
document.getElementById("pontos5").style.display = 'block';
document.getElementById("pontos5").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 7) {
gc = '7, ';
pontos += 10
document.getElementById("pontos6").style.display = 'block';
document.getElementById("pontos6").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 8) {
hc = '8, ';
pontos += 10
document.getElementById("pontos7").style.display = 'block';
document.getElementById("pontos7").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 9) {
ic = '9, ';
pontos += 10
document.getElementById("pontos8").style.display = 'block';
document.getElementById("pontos8").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}
if (correta > certa && cont == 10) {
jc = ' 10';
pontos += 10
document.getElementById("pontos9").style.display = 'block';
document.getElementById("pontos9").innerHTML = "Você ganhou " + pontos + " pontos!"
playSound();
}// final do if
setTimeout(function () {
var div = $(".pontos");
div.animate({ height: '105px', opacity: '0.4' }, "slow");
div.animate({ width: '175px', opacity: '0.8' }, "slow");
div.animate({ height: '95px', opacity: '0.4' }, "slow");
div.animate({ width: '160px', opacity: '0.8' }, "slow");
}, 1200);
/********************************************************************************** */
} else {
//add .wrongAnswer class
$(this).addClass('wrongAnswer').addClass('fade');
//change icon
$span.removeClass('fa fa-square-o').addClass('fa fa-check-square-o');
//reduce opacity of its siblings
$(this).siblings().addClass('fade');
//show wrong Message
var $answerReveal = $parent.next('.answerReveal').show();
var $toShowCorrect = $answerReveal.find('.quizzAnswerC');
var $toShowFalse = $answerReveal.find('.quizzAnswerF');
$toShowCorrect.remove();
$toShowFalse.show();
//locate correct answer and highlight
$parent.find('.correct').addClass('correctAnswer');
errada += 1;
var erro = errada - 1;
if (erro < errada && flag == 1) {
ae = " 1, ";
$('#pag0').on('click', '#n1', function () { /* FUNCIONA COM CLASSE TAMBÉM */
desca = ae;
alert(desca);
});
}
if (erro < errada && flag == 2) {
be = " 2, ";
$('#pag1').on('click', '#n2', function () {
descb = be;
alert(descb);
});
}
if (erro < errada && flag == 3) {
ce = " 3, ";
$('#pag2').on('click', '#n3', function () {
descc = ce;
alert(descc);
});
}
if (erro < errada && flag == 4) {
de = " 4, ";
$('#pag3').on('click', '#n4', function () {
descd = de;
alert(descd);
});
}
if (erro < errada && flag == 5) {
ee = " 5, ";
$('#pag4').on('click', '#n5', function () {
desce = ee;
alert(desce);
});
}
if (erro < errada && flag == 6) {
fe = " 6, ";
$('#pag5').on('click', '#n6', function () {
descf = fe;
alert(descf);
});
}
if (erro < errada && flag == 7) {
ge = " 7, ";
$('#pag6').on('click', '#n7', function () {
descg = ge;
alert(descg);
});
}
if (erro < errada && flag == 8) {
he = " 8, ";
$('#pag7').on('click', '#n8', function () {
desch = he;
alert(desch);
});
}
if (erro < errada && flag == 9) {
ie = " 9, ";
$('#pag8').on('click', '#n9', function () {
desci = ie;
alert(desci + errada);
});
}
if (erro < errada && flag == 10) {
je = "10";
$('.absolute').on('click', '#n10', function () {
descj = je;
alert(descj);
setTimeout(function () {
descj = je;
}, 1000);
});
}
};// Final do else
});//final da função perguntas certas e erradas
//print Results
function printResult() {
var resultText = '<p style="color: #800000; font-size:larger;">';
if ($totalScore === $questionNumber) {
resultText += 'Você acertou ' + $totalScore + ' de um total de ' + $questionNumber + ' perguntas ! </p>';
$('.resultContainer').append(resultText);
$('#halfText').append('<p style="color: #00008B">parabens Voçe conhece muito sobre risco</p>');
} else if ($totalScore >= 5 && $totalScore < $questionNumber) {
resultText += 'Você acertou ' + $totalScore + ' de um total de ' + $questionNumber + ' perguntas! </p>';
$('.resultContainer').append(resultText);
$('#halfText').append('<p style="color: #00008B">Parabéns continue melhorando!</p>')
} else if ($totalScore < 5) {
resultText += 'Você acertou ' + $totalScore + ' de um total de ' + $questionNumber + ' perguntas! </p>';
$('.resultContainer').append(resultText);
$('#halfText').append('<p style="color: #00008B">Tente refazer os testes com mais calma.</p>');
}
};//Final da função result - resultado final
//final score
$('.absolute').click(function () {
setTimeout(function () {
document.getElementById('pag9').style.display = 'none';
}, 4000);
/************************************ */
setTimeout(function () {
document.getElementById('final').style.display = 'block';
}, 1000);
});
$('.absolute').last().click(function () {
//prevent further clicks on this
$(this).off('click');
//show result after last li is clicked
var $height = $('.finalResult').height();
printResult();
$('.finalResult').show();
/*$('html, body').animate({
scrollTop: $(document).height() - $height
},
15000);*/
function email() {
/*perguntasTotal = a + "-" + b + "-" + c + "-" + d + "-" + e + "-" + f + "-" + g + "-" + h + "-" + i + "-" + j + "";*/
totalCertas = ac + "" + bc + "" + cc + "" + dc + "" + ec + "" + fc + "" + gc + "" + hc + "" + ic + "" + jc + "";
totalErradas = ae + "" + be + "" + ce + "" + de + "" + ee + "" + fe + "" + ge + "" + he + "" + ie + "" + je + "";
desc = desca + "" + descb + "" + descc + "" + descd + "" + desce + "" + descf + "" + descg + "" + desch + "" + desci + "" + descj + "";
pontos = parseInt($totalScore) * 10;
alert("teste usuario" + user);
usuario = "" + user + "";
}//final da função email
email();
desc = desca + descb + descc + descd + desce + descf + descg + desch + desci + descj + "";
var templateParams = {
"user": usuario,
"TotalErrada": errada,
"TotalCertas": correta,
"Pontos": pontos,
"Certas": totalCertas,
"Erradas": totalErradas,
"Desconhecidas": desc
};
emailjs.send('gmail', 'vander', templateParams)
.then(function (response) {
alert('Concluído!', response.status, response.text);
}, function (error) {
console.log('FAILED...', error);
});
});// fim da função click
}); //end dom ready - fim do dom