Skip to content

Commit 17ae93b

Browse files
committed
Testing sweetalert2
1 parent c823183 commit 17ae93b

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

script.js

+32-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1-
2-
var mysterious_number = Math.floor(Math.random() * 10);
1+
var mysterious_number = 0;
32
var attempts = 4;
43
var found = false;
54

6-
// Resposta do valor para testar: document.getElementById("clue").innerHTML = numero;
5+
// Resposta do valor para testar: document.getElementById("clue").innerHTML = mysterious_number;
76

8-
function playGame(){
9-
checkAttempts();
7+
document.querySelector('body').onload = function(){
8+
var tex = ".: REGRAS :<br>"+
9+
"1. O jogo de adivinhação onde o valor será algum valor de 0 a 9. <br/>"+
10+
"2. Você possui apenas 4 tentativas para descobrir. <br/>"+
11+
"3. Após acertar o número a ser descorberto, o jogo será reiniciado. <br/>"+
12+
"4. Após as 4 tentativas e você não conseguir descobrir, o jogo se reinicia.";
13+
14+
swal({
15+
title: 'Seja Bem Vindo!',
16+
type: 'info',
17+
html: tex
18+
});
1019
}
1120

21+
22+
document.querySelector('button.btnSubmit').onclick = function(){
23+
mysterious_number = Math.floor(Math.random() * 10);
24+
25+
checkAttempts();
26+
}
27+
1228
function getValue(){
1329
var num = document.getElementById("value").value;
1430
return num;
@@ -18,10 +34,17 @@ function setMessage(text){
1834
document.getElementById("clue").innerHTML = text;
1935
}
2036

37+
function showSucessMessage(){
38+
swal({
39+
title: 'Você Acertou!',
40+
type: 'success',
41+
html: "Parabéns você acertou! O Jogo será reiniciado"
42+
});
43+
}
2144

2245
function checkItsDone(){
2346
if(getValue() == mysterious_number){
24-
setMessage("--> Parabéns você acertou! O Jogo será reiniciado");
47+
showSucessMessage();
2548
found = true;
2649

2750
restart();
@@ -78,7 +101,7 @@ function checkNumberAttempts(cont){
78101
}
79102

80103
function restart(){
81-
mysterious_number = Math.floor(Math.random() * 10);
82-
attempts = 4;
83-
document.getElementById("value").value = "";
104+
var mysterious_number = Math.floor(Math.random() * 10);
105+
var attempts = 4;
106+
var found = false;
84107
}

0 commit comments

Comments
 (0)