|
@@ -3,7 +3,7 @@ var id_cat = 0, id_theme = 0, id_quest = 0;
|
3
|
3
|
// Shortcuts
|
4
|
4
|
var json, category, theme;
|
5
|
5
|
// Timer
|
6
|
|
-var timing = 5, secRestantes, timer;
|
|
6
|
+var timing = 5, secRestantes = 0, timer;
|
7
|
7
|
var questions = 0, currentQuestion = 1;
|
8
|
8
|
var baseWidth;
|
9
|
9
|
|
|
@@ -13,7 +13,6 @@ var canClick = true;
|
13
|
13
|
|
14
|
14
|
function play() {
|
15
|
15
|
apiReq();
|
16
|
|
- console.log(json);
|
17
|
16
|
$("#play").remove();
|
18
|
17
|
if(json.status != 1) {
|
19
|
18
|
var message;
|
|
@@ -81,7 +80,6 @@ function apiReq() {
|
81
|
80
|
function loadCat(id) {
|
82
|
81
|
if(id === 0) category = json.cat1;
|
83
|
82
|
if(id === 1) category = json.cat2;
|
84
|
|
- console.log(category);
|
85
|
83
|
$("#game").html("<div id=\"timer\"></div>");
|
86
|
84
|
$("#game").append("<div id=\"category\">Catégorie : "+category.nom_cat+"</div>");
|
87
|
85
|
$("#game").append("<div id=\"theme\"></div>");
|
|
@@ -120,11 +118,9 @@ function checkAnswer() {
|
120
|
118
|
$("#rep2").off('click');
|
121
|
119
|
$("#both").off('click');
|
122
|
120
|
stopTimer();
|
123
|
|
- console.log(reponseUser == bonneReponse);
|
124
|
121
|
if(reponseUser == bonneReponse) {
|
125
|
122
|
score += secRestantes+1;
|
126
|
123
|
}
|
127
|
|
- console.log(score);
|
128
|
124
|
if(score > 1) {
|
129
|
125
|
$("#score").html("Score : "+score+" miams");
|
130
|
126
|
$("#score-responsive").html(score+" miams");
|
|
@@ -180,12 +176,12 @@ function nextQuestion() {
|
180
|
176
|
}
|
181
|
177
|
|
182
|
178
|
function startTimer() {
|
183
|
|
- baseWidth = $("#timer").width();
|
184
|
179
|
$("#timer").removeClass();
|
185
|
180
|
var elm = document.getElementById("timer"),
|
186
|
181
|
newone = elm.cloneNode(true);
|
187
|
182
|
elm.parentNode.replaceChild(newone, elm);
|
188
|
183
|
$("#timer").addClass("timer");
|
|
184
|
+ baseWidth = $("#timer").width();
|
189
|
185
|
timer = window.setTimeout(checkAnswer, timing*1000);
|
190
|
186
|
}
|
191
|
187
|
|
|
@@ -193,7 +189,6 @@ function stopTimer() {
|
193
|
189
|
window.clearTimeout(timer);
|
194
|
190
|
$("#timer").addClass("pause");
|
195
|
191
|
secRestantes = Math.round($("#timer").width()/baseWidth*timing);
|
196
|
|
- console.log(secRestantes);
|
197
|
192
|
}
|
198
|
193
|
|
199
|
194
|
function endGame() {
|