浏览代码

Major score bug fixed

父节点
当前提交
253f553865
共有 2 个文件被更改,包括 4 次插入10 次删除
  1. 2
    7
      web/js/game.js
  2. 2
    3
      web/js/multi.js

+ 2
- 7
web/js/game.js 查看文件

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

+ 2
- 3
web/js/multi.js 查看文件

94
 // Shortcuts
94
 // Shortcuts
95
 var json, category, theme;
95
 var json, category, theme;
96
 // Timer
96
 // Timer
97
-var timing = 5, secRestantes, timer;
97
+var timing = 5, secRestantes = 0, timer;
98
 var nbQuestions = 0, currentQuestion = 1;
98
 var nbQuestions = 0, currentQuestion = 1;
99
 var baseWidth;
99
 var baseWidth;
100
 
100
 
104
 function loadCat(id) {
104
 function loadCat(id) {
105
   if(id === 0) category = json.cat1;
105
   if(id === 0) category = json.cat1;
106
   if(id === 1) category = json.cat2;
106
   if(id === 1) category = json.cat2;
107
-  console.log(category);
108
   $("#game").html("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
107
   $("#game").html("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
109
   $("#game").append("<div id=\"category\">Catégorie : "+category.nom_cat+"</div>");
108
   $("#game").append("<div id=\"category\">Catégorie : "+category.nom_cat+"</div>");
110
   $("#game").append("<div id=\"theme\"></div>");
109
   $("#game").append("<div id=\"theme\"></div>");
257
 }
256
 }
258
 
257
 
259
 function startTimer() {
258
 function startTimer() {
260
-  baseWidth = $("#timer").width();
261
   $("#timer").removeClass();
259
   $("#timer").removeClass();
262
   var elm = document.getElementById("timer"),
260
   var elm = document.getElementById("timer"),
263
       newone = elm.cloneNode(true);
261
       newone = elm.cloneNode(true);
264
   elm.parentNode.replaceChild(newone, elm);
262
   elm.parentNode.replaceChild(newone, elm);
265
   $("#timer").addClass("timer");
263
   $("#timer").addClass("timer");
264
+  baseWidth = $("#timer").width();
266
   timer = window.setTimeout(checkAnswer, timing*1000);
265
   timer = window.setTimeout(checkAnswer, timing*1000);
267
 }
266
 }
268
 
267