Browse Source

Mass CSS n bugfixin. Also my first public commit here, hi!

Brendan Abolivier 9 years ago
parent
commit
0173b3e6e4
12 changed files with 574 additions and 148 deletions
  1. 17
    16
      web/api/model/class.categorie.php
  2. 105
    0
      web/css/game.css
  3. 34
    12
      web/css/main.css
  4. 13
    10
      web/index.htm
  5. 70
    36
      web/js/game.js
  6. 37
    27
      web/js/multi.js
  7. 57
    28
      web/multi.php
  8. 47
    0
      web/palmares.htm
  9. 46
    19
      web/play.htm
  10. 41
    0
      web/rules.htm
  11. 44
    0
      web/solo.htm
  12. 63
    0
      web/testapi.htm

+ 17
- 16
web/api/model/class.categorie.php View File

@@ -43,28 +43,29 @@ class Categorie {
43 43
 
44 44
 	public static function randSelect() {
45 45
 		$bdd = new Connector();
46
-		$arrayCat = $bdd->Select("*", "categorie");
46
+		$options = array(
47
+			"order by" => array("rand()"),
48
+		);
49
+		$arrayCat = $bdd->Select("*", "categorie", $options);
47 50
 		$return = array();
48 51
 		$catIndex = -1;
49 52
 		$previousIndex = -1;
50
-		for($i = 0; $i < 2; $i++) {
51
-			do {
52
-				$filled = true;
53
-				$previousIndex = $catIndex;
54
-				$catIndex = rand(0, sizeof($arrayCat)-1);
55
-				$category = new Categorie($arrayCat[$catIndex]['nom_cat']);
56
-				if(sizeof($category->getArray()['themes']) >=2) {
57
-					foreach($category->getArray()['themes'] as $theme) {
58
-						if(sizeof($theme['questions']) < 3) {
59
-							$filled = false;
60
-						}
53
+		for($i = 0; $i < sizeof($arrayCat); $i++) {
54
+			$category = new Categorie($arrayCat[$i]['nom_cat']);
55
+			if(sizeof($category->getArray()['themes']) >=2) {
56
+				foreach($category->getArray()['themes'] as $theme) {
57
+					if(sizeof($theme['questions']) < 3) {
58
+						array_splice($arrayCat, $i, 1);
61 59
 					}
62
-				} else {
63
-					$filled = false;
64 60
 				}
65
-			} while(($catIndex == $previousIndex) || !$filled);
66
-			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
61
+			} else {
62
+				array_splice($arrayCat, $i, 1);
63
+			}
67 64
 		}
65
+		for($i = 0; $i < 2; $i++) {
66
+			array_push($return, new Categorie($arrayCat[$i]['nom_cat']));
67
+		}
68
+
68 69
 		return $return;
69 70
 	}
70 71
 

+ 105
- 0
web/css/game.css View File

@@ -0,0 +1,105 @@
1
+section#navbar li.current:last-child #score {
2
+  display:inline;
3
+  padding-top:17px;
4
+  padding-left:30px;
5
+  padding-right:30px;
6
+  padding-bottom:18px;
7
+  background: #ffab19;
8
+}
9
+
10
+section#game input[type="submit"]#play {
11
+  border:none;
12
+  background-color:#09b22b;
13
+  color:white;
14
+  padding:20px;
15
+  font-size:170%;
16
+  cursor:pointer;
17
+}
18
+
19
+section#game {
20
+  text-align:center;
21
+}
22
+
23
+div#category {
24
+  font-size:170%;
25
+  font-family:'Lato';
26
+  font-weight:300;
27
+  margin-top:20px;
28
+}
29
+
30
+p#question {
31
+  font-size:120%;
32
+}
33
+
34
+ul#answers {
35
+  padding-left:0px;
36
+}
37
+
38
+ul#answers li {
39
+  display:inline-block;
40
+  background: #b087ff;
41
+  width:16%;
42
+  padding:20px;
43
+  padding-top:38px;
44
+  height:42px;
45
+  font-size:110%;
46
+  color:white;
47
+  font-weight:bold;
48
+  margin-right:20px;
49
+  line-height: 20px;
50
+  vertical-align: middle;
51
+  cursor: pointer;
52
+}
53
+
54
+ul#answers li.good-answer {
55
+  background: #57cc6b;
56
+}
57
+
58
+ul#answers li.wrong-answer {
59
+  background: #cc5757;
60
+}
61
+
62
+h2#score {
63
+  margin-top: 100px;
64
+  font-size:220%;
65
+  margin-bottom:10px;
66
+}
67
+
68
+p#registerScore, p#conDenied {
69
+  width: 40%;
70
+  margin: auto;
71
+}
72
+
73
+p.success {
74
+  padding-top: 30px;
75
+  background:#57cc6b;
76
+  padding-bottom: 30px;
77
+}
78
+
79
+p.error {
80
+  padding-top: 30px;
81
+  background:#cc5757;
82
+  padding-bottom: 30px;
83
+  color:white;
84
+}
85
+
86
+p#conDenied {
87
+  margin-top:70px;
88
+}
89
+
90
+@media all and (max-width: 799px) {
91
+  ul#answers li {
92
+    display:block;
93
+    margin:auto;
94
+    margin-bottom:10px;
95
+    width:80%;
96
+    padding-top:15px;
97
+    height: 20px;
98
+  }
99
+}
100
+
101
+@media all and (min-width: 800px) {
102
+  ul#answers li:last-child {
103
+    margin-right:0px;
104
+  }
105
+}

+ 34
- 12
web/css/main.css View File

@@ -5,11 +5,20 @@ body {
5 5
   background: #fffdc6;
6 6
 }
7 7
 
8
+p a, #game a, p a:visited, p a:visited {
9
+  text-decoration: underline;
10
+  color:black;
11
+}
12
+
8 13
 a, a:visited {
9 14
   color: white;
10 15
   text-decoration: none;
11 16
 }
12 17
 
18
+a:active{
19
+  background:transparent
20
+}
21
+
13 22
 section#navbar a:hover {
14 23
   text-decoration:none;
15 24
 }
@@ -24,13 +33,6 @@ header {
24 33
   padding-bottom: 10px;
25 34
 }
26 35
 
27
-section#responsive-navbar img {
28
-  margin-right:10px;
29
-  margin-top:8px;
30
-  float:right;
31
-  height: 1.3em;
32
-}
33
-
34 36
 section#responsive-navbar {
35 37
   display: none;
36 38
   margin-top:0px;
@@ -43,6 +45,8 @@ section#responsive-navbar ul {
43 45
   margin-top:0px;
44 46
   list-style-type:none;
45 47
   padding-left:0px;
48
+  width:100%;
49
+  margin-bottom:0px;
46 50
 }
47 51
 
48 52
 section#responsive-navbar ul li {
@@ -54,14 +58,19 @@ section#responsive-navbar ul li {
54 58
 }
55 59
 
56 60
 section#responsive-navbar ul li a {
61
+  display:block;
57 62
   width:100%;
58 63
 }
59 64
 
60
-section#responsive-navbar ul li.play {
65
+section#responsive-navbar ul li:last-child {
61 66
   background: #ff9619;
62 67
 }
63 68
 
64
-section#responsive-navbar ul li.play:hover {
69
+section#responsive-navbar ul li:last-child.current {
70
+  background: #ffab19;
71
+}
72
+
73
+section#responsive-navbar ul li:last-child:hover {
65 74
   background: #ffab19;
66 75
 }
67 76
 
@@ -69,7 +78,7 @@ section#responsive-navbar ul li:hover, section#responsive-navbar ul li.current {
69 78
   background: #9556f9;
70 79
 }
71 80
 
72
-section#responsive-navbar ul li:first-child, section#responsive-navbar ul li:first-child:hover {
81
+section#responsive-navbar ul li:first-child, section#responsive-navbar ul li:first-child:hover, section#responsive-navbar ul li:first-child:active {
73 82
   background-color: #7e19ff;
74 83
   background-image: url('../assets/burger-menu.png');
75 84
   background-size: 25px;
@@ -126,7 +135,7 @@ section#navbar li:last-child {
126 135
   background: #ff9619;
127 136
 }
128 137
 
129
-section#navbar li:last-child:hover a {
138
+section#navbar li:last-child:hover a, section#navbar li.current:last-child a {
130 139
   background: #ffab19;
131 140
 }
132 141
 
@@ -135,7 +144,12 @@ section#page {
135 144
   margin: auto;
136 145
 }
137 146
 
138
-section#page h2 {
147
+h1 {
148
+  text-align: center;
149
+  font-size: 400%;
150
+}
151
+
152
+h2 {
139 153
   text-align: center;
140 154
   font-size: 200%;
141 155
 }
@@ -166,7 +180,15 @@ article#jouer {
166 180
   margin:auto;
167 181
 }
168 182
 
183
+section#page ol {
184
+  text-align:center;
185
+  font-size: 120%;
186
+}
187
+
169 188
 @media all and (max-width: 799px) {
189
+  header {
190
+    background-size: 68%;
191
+  }
170 192
   section#responsive-navbar {
171 193
     display: block;
172 194
   }

+ 13
- 10
web/index.htm View File

@@ -7,36 +7,38 @@
7 7
     <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
8 8
     <script src="js/jquery-2.1.4.min.js"></script>
9 9
     <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
10 11
   </head>
11 12
   <body>
12 13
     <header>
13 14
     </header>
14 15
     <section id="navbar">
15 16
       <ul>
16
-        <li class="current"><a href="#">Accueil</a></li>
17
-        <li><a href="#">Règles</a></li>
18
-        <li><a href="#">Meilleurs scores</a></li>
19
-        <li><a href="#">Jouer</a></li>
17
+        <li class="current"><a href="index.htm">Accueil</a></li>
18
+        <li><a href="rules.htm">Règles</a></li>
19
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li><a href="play.htm">Jouer</a></li>
20 21
       </ul>
21 22
     </section>
22 23
     <section id="responsive-navbar">
23 24
       <ul>
24 25
         <li class="name"><a href="#">Menu</a></li>
25
-        <li class="current"><a href="#">Accueil</a></li>
26
-        <li><a href="#">Règles</a></li>
27
-        <li><a href="#">Meilleurs scores</a></li>
28
-        <li class="play"><a href="#">Jouer</a></li>
26
+        <li class="current"><a href="index.htm">Accueil</a></li>
27
+        <li><a href="rules.htm">Règles</a></li>
28
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li><a href="play.htm">Jouer</a></li>
29 30
       </ul>
30 31
     </section>
31 32
     <section id="page">
32 33
       <article>
33 34
         <h2>Accueil</h2>
34
-        <p>Skevent dleout danvez biz-yod rumm goz gar tabut bazh mil skrijañ, Menez Du dec'h ehan kreisteiz neud tad eil huanadiñ bed lizherenn. Lies gwinegr c'hoar-gaer. Houlenn Menez Mikael anv koumoul, broust brumenn daoust ha. Ret ki lazhañ dianav gwenn hor beg-douar arabat skubañ ken truez tre kar hon leue droug-mor, chom hennezh hag Bro-saoz. Ma fazi geot kein gwechall, rak mil c'hwezhañ e fri hor kae diwar-benn mousc'hoarzhin mat bloaz plijadur hol kant eost noz dre mae nerzh kaeraat, kenwerzh nec'h hir diriaou c'hoar-gaer, a-benn diwar ar maez derc'hel digor pesketaer dir pri start karrezek. Pegement kontañ giz kluchañ n'eus forzh.</p>
35
+        <p>Créé dans le cadre du projet de fin d'année de la promo 2018 de CIR2 de l'ISEN Brest/Rennes, le Burger Quizz est une adaptation numérique du jeu télévisé éponyme, plus précisément d'une épreuve spécifique de ce jeu : le "Sel ou Poivre".</p>
36
+        <p>Dans cette épreuve de rapidité, les joueurs sont confrontés à des jeux de questions correspondant à plusieurs thèmes sur différentes catégories. Pour plus d'informations, consulter la rubrique <a href="rules.htm">"Règles"</a> du site.</p>
35 37
       </article>
36 38
       <article id="jouer">
37 39
         <h2>Jouer</h2>
38 40
         <div class="button">
39
-          <a href="play.htm">
41
+          <a href="solo.htm">
40 42
             <div class="firstword">
41 43
               Solo
42 44
             </div>
@@ -51,6 +53,7 @@
51 53
             2 joueurs
52 54
           </a>
53 55
         </div>
56
+      </article>
54 57
     </section>
55 58
   </body>
56 59
 </html>

+ 70
- 36
web/js/game.js View File

@@ -4,6 +4,7 @@ var id_cat = 0, id_theme = 0, id_quest = 0;
4 4
 var json, category, theme;
5 5
 // Timer
6 6
 var timing = 5, secRestantes, timer;
7
+var questions = 0, currentQuestion = 1;
7 8
 var baseWidth;
8 9
 
9 10
 var score = 0;
@@ -11,9 +12,8 @@ var reponseUser = -1, bonneReponse;
11 12
 var canClick = true;
12 13
 
13 14
 function play() {
14
-  $("#play").remove();
15
-  $("#multi").remove();
16 15
   apiReq();
16
+  $("#play").remove();
17 17
   if(json.status != 1) {
18 18
     var message;
19 19
     switch(json.source) {
@@ -64,6 +64,12 @@ function apiReq() {
64 64
     dataType: 'json',
65 65
     success: function(data) {
66 66
       json = data;
67
+      json.cat1.themes.forEach(function(theme) {
68
+        questions += theme.questions.length;
69
+      });
70
+      json.cat2.themes.forEach(function(theme) {
71
+        questions += theme.questions.length;
72
+      });
67 73
     }
68 74
   });
69 75
 }
@@ -72,10 +78,10 @@ function loadCat(id) {
72 78
   if(id === 0) category = json.cat1;
73 79
   if(id === 1) category = json.cat2;
74 80
   console.log(category);
75
-  $("#game").html("<p id=\"category\">Catégorie : "+category.nom_cat+"</p>");
81
+  $("#game").html("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
82
+  $("#game").append("<div id=\"category\">Catégorie : "+category.nom_cat+"</div>");
76 83
   $("#game").append("<div id=\"theme\"></div>");
77
-  $("#game").append("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
78
-  $("#game").append("<div id=\"score\">Score : "+score+"</div>");
84
+  $(".current").html("<div id=\"score\">Score : "+score+" miam</div>");
79 85
   loadTheme(id_theme);
80 86
 }
81 87
 
@@ -83,7 +89,8 @@ function loadTheme(id) {
83 89
   theme = category.themes[id];
84 90
   $("#theme").html("<p id=\"question\"></p>");
85 91
   $("#theme").append("<ul id=\"answers\"><li id=\"rep1\">"+theme.reponse1+"</li>"
86
-    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>");
92
+    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>"
93
+    +"<p id=\"question-count\">Question 0/0</p>");
87 94
   quest(id_quest);
88 95
 }
89 96
 
@@ -91,8 +98,9 @@ function quest(id) {
91 98
   $("#question").html(theme.questions[id].intitule);
92 99
   startTimer();
93 100
   bonneReponse = parseInt(theme.questions[id].bonneReponse);
94
-  console.info('Question ' + (id_quest + 1) + '/' + theme.questions.length + ' : '
101
+  console.info('Question ' + currentQuestion + '/' + theme.questions.length + ' : '
95 102
     +theme.questions[id].intitule);
103
+  $("#question-count").html("Question "+currentQuestion+"/"+questions);
96 104
   if(canClick) {
97 105
     $("#rep1").off('click');
98 106
     $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); });
@@ -112,7 +120,11 @@ function checkAnswer() {
112 120
   if(reponseUser == bonneReponse) {
113 121
     score += secRestantes+1;
114 122
   }
115
-  $("#score").html("Score : "+score);
123
+  if(score > 1) {
124
+    $("#score").html("Score : "+score+" miams");
125
+  } else {
126
+    $("#score").html("Score : "+score+" miam");
127
+  }
116 128
   switch(bonneReponse) {
117 129
     case 0:   $("#rep1").addClass("wrong-answer");
118 130
               $("#rep2").addClass("wrong-answer");
@@ -135,6 +147,7 @@ function nextQuestion() {
135 147
   $("#rep2").removeClass();
136 148
   $("#both").removeClass();
137 149
   canClick = true;
150
+  currentQuestion++;
138 151
   // Dernière question du thème en cours
139 152
   if((id_quest+1) == theme.questions.length)  {
140 153
     // Dernier thème de la catégorie en cours
@@ -185,39 +198,60 @@ function endGame() {
185 198
 }
186 199
 
187 200
 function scoreConfirm() {
188
-  console.log("qsfd");
189
-  addScore($("#login").val(), score);
190
-  var message = json.message;
191 201
   $("#registerScore").fadeOut();
192
-  console.log(message);
193
-  if(message == "score_add_success") {
194
-    window.setTimeout(function() {
195
-      $("#registerScore").addClass("success");
196
-      $("#registerScore").html("Votre score a bien été enregistré<br />"+
197
-      "<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
198
-    }, 400);
199
-  } else {
200
-    if(message === "higher_score_present") {
202
+  if($("#login").val() != "") {
203
+    addScore($("#login").val(), score);
204
+    var message = json.message;
205
+    if(message == "score_add_success") {
201 206
       window.setTimeout(function() {
202
-        $("#registerScore").addClass("error");
203
-        $("#registerScore").html("Un score supérieur ou égal existe déjà avec ce pseudonyme<br />"
204
-        +"Essayez avec un autre pseudonyme : <input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
205
-        +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
206
-        +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
207
-        $("#sendScore").on('click', scoreConfirm);
208
-        $("#login").on('keypress', function(event) {
209
-          if(event.which == 13) {
210
-            scoreConfirm();
211
-          }
212
-        });
213
-      }, 400);
214
-    } else {
215
-      window.setTimeout(function() {
216
-        $("#registerScore").addClass("error");
217
-        $("#registerScore").html("Une erreur est survenue ("+status.message+")<br />"+
207
+        $("#registerScore").removeClass();
208
+        $("#registerScore").addClass("success");
209
+        $("#registerScore").html("Votre score a bien été enregistré.<br />"+
218 210
         "<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
219 211
       }, 400);
212
+    } else {
213
+      if(message === "higher_score_present") {
214
+        window.setTimeout(function() {
215
+          $("#registerScore").removeClass();
216
+          $("#registerScore").addClass("error");
217
+          $("#registerScore").html("Un score supérieur ou égal existe déjà avec ce pseudonyme.<br />"
218
+          +"Essayez avec un autre pseudonyme :<br />"
219
+          +"<input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
220
+          +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
221
+          +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
222
+          $("#sendScore").on('click', scoreConfirm);
223
+          $("#login").on('keypress', function(event) {
224
+            if(event.which == 13) {
225
+              scoreConfirm();
226
+            }
227
+          });
228
+        }, 400);
229
+      } else {
230
+        window.setTimeout(function() {
231
+          $("#registerScore").removeClass();
232
+          $("#registerScore").addClass("error");
233
+          $("#registerScore").html("Une erreur est survenue ("+status.message+")<br /> Réessayer :"
234
+          +"<input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
235
+          +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
236
+          +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
237
+        }, 400);
238
+      }
220 239
     }
240
+  } else {
241
+    window.setTimeout(function() {
242
+      $("#registerScore").removeClass();
243
+      $("#registerScore").addClass("error");
244
+      $("#registerScore").html("Merci de renseigner un pseudonyme : <br />"
245
+      +"<input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
246
+      +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
247
+      +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
248
+      $("#sendScore").on('click', scoreConfirm);
249
+      $("#login").on('keypress', function(event) {
250
+        if(event.which == 13) {
251
+          scoreConfirm();
252
+        }
253
+      });
254
+    }, 400);
221 255
   }
222 256
   $("#registerScore").fadeIn();
223 257
 }

+ 37
- 27
web/js/multi.js View File

@@ -15,7 +15,7 @@ var reponseUser = -1, bonneReponse;
15 15
 
16 16
 function init() {
17 17
 
18
-    var hostname = $('script')[1]['src'].match(/http:\/\/(.+)\:/)[1];
18
+    var hostname = $('script')[$('script').length-3]['src'].match(/http:\/\/(.+)\:/)[1];
19 19
 
20 20
     // Connexion à socket.io
21 21
     socket = io.connect('http://'+hostname+':8000');
@@ -23,8 +23,12 @@ function init() {
23 23
     // Gestion des evenements
24 24
     setEventHandlers();
25 25
 
26
+    window.clearTimeout(refresh);
27
+
26 28
     // On demande le pseudo a l'utilisateur, on l'envoie au serveur et on l'affiche dans le titre
27
-    $("#game").html("<input type=\"text\" id=\"pseudo\" placeholder=\"Nom ou pseudonyme\" /><input type=\"submit\" id=\"start\" value=\"Valider\" />");
29
+    $("#game").html("<h2>Jeu multijoueur</h2>"
30
+    +"<p>Merci de rentrer un nom ou pseudonyme :</p>"
31
+    +"<input type=\"text\" id=\"pseudo\" placeholder=\"Nom ou pseudonyme\" /><input type=\"submit\" id=\"start\" value=\"Valider\" />");
28 32
     $("#start").on("click", function() {
29 33
       pseudo = $("#pseudo").val();
30 34
       socket.emit('nouveau', pseudo);
@@ -89,30 +93,20 @@ var id_cat = 0, id_theme = 0, id_quest = 0;
89 93
 var json, category, theme;
90 94
 // Timer
91 95
 var timing = 5, secRestantes, timer;
96
+var nbQuestions = 0, currentQuestion = 1;
92 97
 var baseWidth;
93 98
 
94 99
 var score = 0;
95 100
 var canClick = true;
96 101
 
97
-function apiReq() {
98
-  $.ajax({
99
-    async: false,
100
-    url: "../../api/",
101
-    dataType: 'json',
102
-    success: function(data) {
103
-      json = data;
104
-    }
105
-  });
106
-}
107
-
108 102
 function loadCat(id) {
109 103
   if(id === 0) category = json.cat1;
110 104
   if(id === 1) category = json.cat2;
111 105
   console.log(category);
112
-  $("#game").html("<p id=\"category\">Catégorie : "+category.nom_cat+"</p>");
106
+  $("#game").html("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
107
+  $("#game").append("<div id=\"category\">Catégorie : "+category.nom_cat+"</div>");
113 108
   $("#game").append("<div id=\"theme\"></div>");
114
-  $("#game").append("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
115
-  $("#game").append("<div id=\"score\"></div>");
109
+  $(".current").html("<div id=\"score\">Score : "+score+" miam</div>");
116 110
   loadTheme(id_theme);
117 111
 }
118 112
 
@@ -120,7 +114,8 @@ function loadTheme(id) {
120 114
   theme = category.themes[id];
121 115
   $("#theme").html("<p id=\"question\"></p>");
122 116
   $("#theme").append("<ul id=\"answers\"><li id=\"rep1\">"+theme.reponse1+"</li>"
123
-    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>");
117
+    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>"
118
+    +"<p id=\"question-count\">Question 0/0</p>");
124 119
   quest(id_quest);
125 120
 }
126 121
 
@@ -128,8 +123,9 @@ function quest(id) {
128 123
   $("#question").html(theme.questions[id].intitule);
129 124
   startTimer();
130 125
   bonneReponse = parseInt(theme.questions[id].bonneReponse);
131
-  console.info('Question ' + (id_quest + 1) + '/' + theme.questions.length + ' : '
126
+  console.info('Question ' + currentQuestion + '/' + theme.questions.length + ' : '
132 127
     +theme.questions[id].intitule);
128
+  $("#question-count").html("Question "+currentQuestion+"/"+nbQuestions);
133 129
   if(canClick) {
134 130
     $("#rep1").off('click');
135 131
     $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); socket.emit('nextQuestion'); });
@@ -149,7 +145,11 @@ function checkAnswer() {
149 145
   if(reponseUser == bonneReponse) {
150 146
     score += secRestantes+1;
151 147
   }
152
-  $("#score").html("Score : "+score);
148
+  if(score > 1) {
149
+    $("#score").html("Score : "+score+" miams");
150
+  } else {
151
+    $("#score").html("Score : "+score+" miam");
152
+  }
153 153
   switch(bonneReponse) {
154 154
     case 0:   $("#rep1").addClass("wrong-answer");
155 155
               $("#rep2").addClass("wrong-answer");
@@ -172,6 +172,7 @@ function nextQuestion() {
172 172
   $("#rep2").removeClass();
173 173
   $("#both").removeClass();
174 174
   canClick = true;
175
+  currentQuestion++;
175 176
   // Dernière question du thème en cours
176 177
   if((id_quest+1) == theme.questions.length)  {
177 178
     // Dernier thème de la catégorie en cours
@@ -198,6 +199,14 @@ function nextQuestion() {
198 199
 
199 200
 function play(questions) {
200 201
   json = questions;
202
+
203
+  json.cat1.themes.forEach(function(theme) {
204
+    nbQuestions += theme.questions.length;
205
+  });
206
+  json.cat2.themes.forEach(function(theme) {
207
+    nbQuestions += theme.questions.length;
208
+  });
209
+
201 210
   loadCat(id_cat);
202 211
 }
203 212
 
@@ -224,21 +233,22 @@ function pauseGame() {
224 233
 
225 234
 function endGame() {
226 235
   stopTimer();
227
-  $("#game").html("<h2 id=\"score\">Vous avez marqué "+score+" miams</h2>"
228
-  +"<p id=\"registerScore\">");
236
+  var str = "<h2 id=\"score\">Vous avez marqué "+score+" miams</h2>"
237
+    +"<p id=\"registerScore\">";
229 238
   if(disconnect) {
230
-    $("#game").append(gameInfos[0]+" s'est déconnecté.");
239
+    str += gameInfos[0]+" s'est déconnecté.";
240
+    stopTimer();
231 241
   } else {
232
-    $("#game").append("Votre adversaire a marqué "+scoreAdversaire+" miams.<br />Le gagnant est... ");
242
+    str += "Votre adversaire a marqué "+scoreAdversaire+" miams.<br />Le gagnant est... ";
233 243
     if(score > scoreAdversaire) {
234
-      $("#game").append(pseudo+" (vous).");
244
+      str += pseudo+" (vous).";
235 245
     } else if(score < scoreAdversaire) {
236
-      $("#game").append(gameInfos[0]+".");
246
+      str += gameInfos[0]+".";
237 247
     } else {
238
-      $("#game").append("personne (égalité).");
248
+      str += "personne (égalité).";
239 249
     }
240 250
   }
241
-  $("#game").append("</p>");
251
+  $("#game").html(str+"</p>");
242 252
 }
243 253
 
244 254
 function addScore(userLogin, userScore) {

+ 57
- 28
web/multi.php View File

@@ -1,30 +1,59 @@
1
-<!DOCTYPE html>
1
+<!doctype html>
2 2
 <html>
3
-    <head>
4
-        <meta charset="utf-8" />
5
-        <title>Burger</title>
6
-        <style type="text/css">
7
-          .good-answer {
8
-            color:green;
9
-          }
10
-          .wrong-answer {
11
-            color:red;
12
-          }
13
-        </style>
14
-    </head>
15
-    <body>
16
-        <div id="game">
17
-          Connexion au serveur...
18
-        </div>
19
-        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
20
-        <?php
21
-          $params = file_get_contents("./params.cfg");
22
-    		  preg_match_all('/node_host\: (.+)/', $params, $matches);
23
-          echo '<script src="http://'.$matches[1][0].':8000/socket.io/socket.io.js"></script>';
24
-         ?>
25
-         <script src="js/multi.js"></script>
26
-         <script>
27
-          init();
28
-          </script>
29
-    </body>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Jeu solo</title>
6
+    <link rel="stylesheet" href="css/game.css">
7
+    <link rel="stylesheet" href="css/main.css">
8
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
9
+    <link href='http://fonts.googleapis.com/css?family=Lato:100,400,300,700' rel='stylesheet' type='text/css'>
10
+    <script src="js/jquery-2.1.4.min.js"></script>
11
+    <script src="js/responsive.js"></script>
12
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
13
+    <script>
14
+      var refresh;
15
+    </script>
16
+  </head>
17
+  <body>
18
+    <header>
19
+    </header>
20
+    <section id="navbar">
21
+      <ul>
22
+        <li><a href="index.htm">Accueil</a></li>
23
+        <li><a href="rules.htm">Règles</a></li>
24
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
25
+        <li class="current"><a href="play.htm">Jouer</a></li>
26
+      </ul>
27
+    </section>
28
+    <section id="responsive-navbar">
29
+      <ul>
30
+        <li class="name"><a href="#">Menu</a></li>
31
+        <li><a href="index.htm">Accueil</a></li>
32
+        <li><a href="rules.htm">Règles</a></li>
33
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
34
+        <li class="current"><a href="play.htm">Jouer</a></li>
35
+      </ul>
36
+    </section>
37
+    <section id="game">
38
+      <p id="conDenied" class="error">
39
+        Erreur :<br />
40
+        Connexion au serveur multijoueur impossible
41
+        <script>
42
+          refresh = window.setTimeout(function() {
43
+            window.location = "";
44
+          }, 5000);
45
+        </script>
46
+      </p>
47
+    </section>
48
+    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
49
+      <?php
50
+        $params = file_get_contents("./params.cfg");
51
+    	   preg_match_all('/node_host\: (.+)/', $params, $matches);
52
+         echo '<script src="http://'.$matches[1][0].':8000/socket.io/socket.io.js"></script>';
53
+      ?>
54
+    <script src="js/multi.js"></script>
55
+    <script>
56
+      init();
57
+    </script>
58
+  </body>
30 59
 </html>

+ 47
- 0
web/palmares.htm View File

@@ -0,0 +1,47 @@
1
+<!doctype html>
2
+<html>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Palmares</title>
6
+    <link rel="stylesheet" href="css/main.css">
7
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
8
+    <script src="js/jquery-2.1.4.min.js"></script>
9
+    <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
11
+  </head>
12
+  <body>
13
+    <header>
14
+    </header>
15
+    <section id="navbar">
16
+      <ul>
17
+        <li><a href="index.htm">Accueil</a></li>
18
+        <li><a href="rules.htm">Règles</a></li>
19
+        <li class="current"><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li><a href="play.htm">Jouer</a></li>
21
+      </ul>
22
+    </section>
23
+    <section id="responsive-navbar">
24
+      <ul>
25
+        <li class="name"><a href="#">Menu</a></li>
26
+        <li><a href="index.htm">Accueil</a></li>
27
+        <li><a href="rules.htm">Règles</a></li>
28
+        <li class="current"><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li><a href="play.htm">Jouer</a></li>
30
+      </ul>
31
+    </section>
32
+    <section id="page">
33
+      <article>
34
+        <h2>Meilleurs scores</h2>
35
+        <ol></ol>
36
+      </article>
37
+    </section>
38
+
39
+    <script type="text/javascript">
40
+      $.get("./api/?page=palmares", function(data) {
41
+        for(var i = 0; i < 10; i++) {
42
+          $("ol").append("<li>"+data[i].login+" - "+data[i].score+"</li>");
43
+        }
44
+      });
45
+    </script>
46
+  </body>
47
+</html>

+ 46
- 19
web/play.htm View File

@@ -1,27 +1,54 @@
1 1
 <!doctype html>
2 2
 <html>
3 3
   <head>
4
-    <title>Burger Quizz - Jouer</title>
5
-    <meta charset="utf-8" />
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Accueil</title>
6
+    <link rel="stylesheet" href="css/main.css">
7
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
6 8
     <script src="js/jquery-2.1.4.min.js"></script>
7
-    <script src="js/game.js"></script>
8
-    <style type="text/css">
9
-      .good-answer {
10
-        color:green;
11
-      }
12
-      .wrong-answer {
13
-        color:red;
14
-      }
15
-    </style>
9
+    <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
16 11
   </head>
17 12
   <body>
18
-    <div id="game"></div>
19
-    <input type="submit" id="play" value="Solo (un joueur)" /><br />
20
-    <form action="multi.php"><input type="submit" id="multi" value="Multi (deux joueurs)" /></form>
21
-    <script type="text/javascript">
22
-      $("#play").click(function() {
23
-        play();
24
-      });
25
-    </script>
13
+    <header>
14
+    </header>
15
+    <section id="navbar">
16
+      <ul>
17
+        <li><a href="index.htm">Accueil</a></li>
18
+        <li><a href="rules.htm">Règles</a></li>
19
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li class="current"><a href="play.htm">Jouer</a></li>
21
+      </ul>
22
+    </section>
23
+    <section id="responsive-navbar">
24
+      <ul>
25
+        <li class="name"><a href="#">Menu</a></li>
26
+        <li><a href="index.htm">Accueil</a></li>
27
+        <li><a href="rules.htm">Règles</a></li>
28
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li class="current"><a href="play.htm">Jouer</a></li>
30
+      </ul>
31
+    </section>
32
+    <section id="page">
33
+      <article id="jouer">
34
+        <h1>Jouer</h1>
35
+        <div class="button">
36
+          <a href="solo.htm">
37
+            <div class="firstword">
38
+              Solo
39
+            </div>
40
+            1 joueur
41
+          </a>
42
+        </div>
43
+        <div class="button">
44
+          <a href="multi.php">
45
+            <div class="firstword">
46
+              Multi
47
+            </div>
48
+            2 joueurs
49
+          </a>
50
+        </div>
51
+      </article>
52
+    </section>
26 53
   </body>
27 54
 </html>

+ 41
- 0
web/rules.htm View File

@@ -0,0 +1,41 @@
1
+<!doctype html>
2
+<html>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Règles</title>
6
+    <link rel="stylesheet" href="css/main.css">
7
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
8
+    <script src="js/jquery-2.1.4.min.js"></script>
9
+    <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
11
+  </head>
12
+  <body>
13
+    <header>
14
+    </header>
15
+    <section id="navbar">
16
+      <ul>
17
+        <li><a href="index.htm">Accueil</a></li>
18
+        <li class="current"><a href="rules.htm">Règles</a></li>
19
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li><a href="play.htm">Jouer</a></li>
21
+      </ul>
22
+    </section>
23
+    <section id="responsive-navbar">
24
+      <ul>
25
+        <li class="name"><a href="#">Menu</a></li>
26
+        <li><a href="index.htm">Accueil</a></li>
27
+        <li class="current"><a href="rules.htm">Règles</a></li>
28
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li><a href="play.htm">Jouer</a></li>
30
+      </ul>
31
+    </section>
32
+    <section id="page">
33
+      <article>
34
+        <h2>Règles</h2>
35
+        <p>Skevent dleout danvez biz-yod rumm goz gar tabut bazh mil skrijañ, Menez Du dec'h ehan kreisteiz neud tad eil huanadiñ bed lizherenn. Lies gwinegr c'hoar-gaer. Houlenn Menez Mikael anv koumoul, broust brumenn daoust ha. Ret ki lazhañ dianav gwenn hor beg-douar arabat skubañ ken truez tre kar hon leue droug-mor, chom hennezh hag Bro-saoz. Ma fazi geot kein gwechall, rak mil c'hwezhañ e fri hor kae diwar-benn mousc'hoarzhin mat bloaz plijadur hol kant eost noz dre mae nerzh kaeraat, kenwerzh nec'h hir diriaou c'hoar-gaer, a-benn diwar ar maez derc'hel digor pesketaer dir pri start karrezek. Pegement kontañ giz kluchañ n'eus forzh.</p>
36
+        <p>Hep patatez nav kroc'hen. Hon tre karrez talvoudus. Ruz aozañ e-lec'h mel va Doue mat mall kelenner. Mat eil doñjer chaseour rak koumanant a-hed kloued rev pignat yod bras gwrierez tal prizius, e-mesk kemener c'hoarvezout. Gwerenn saout pleg-mor aet poan dor merc'hed giz sukr mat he gervel poultrenn kontadenn, chaseal ti-hent-houarn aer soudard kêr giz gwelloc'h dreist-holl kig tremen gouelañ rev huchal nemet war aes re tro-c'houzoug he goulenn jod beuziñ siminal. Aotrou ar muiañ spi gourc'hemenn, beuziñ fiziañs rev tamm-ha-tamm, mignonez ni distreiñ, kasoni adaozañ degouezhout. Stlakañ loa anzav da gentañ, per kegin kontadenn gwiskamant me ki a-us da noz e-lec'h mat a-hed seizhvet spi kerkoulz ha ker kann distreiñ eus distreiñ te enebour kein gouelañ, a-wechoù c'hoar-gaer eñ huanadiñ aes gwerenn liv gwer. Merc'hed pevar-ugent niz kempenn aon sell kluchañ kemener he prizius moereb abardaez, ober goap eured Krouer respont skouer Sun tre du laezh merc'her kêr goz regiñ kae neuze, da ken na penn-araok kalonek bod dienn Mor Breizh den ar re gouel.</p>
37
+        <p>Leziregezh diskar park dra Krouer, tal pomper miz bale, kibell ler kennebeut mab kaout tog digor tud plijout Baz taol. Kotoñs mab-bihan ober war-dro. Fuzuilh koulz-amzer ki beajour pe ali reiñ kreskiñ eil kardeur ti fresk, logod kav kar leskiñ keniterv. Gwazh hi gar poull patatez. Giz sachañ tachenn-c'hoari, pegen kêr Nedeleg den dale, anv treuziñ ober e venoz kêr echuiñ klevout enebour. Met doñv gavr ruz ober goap. Eus ezhomm sevel eor butuniñ sul hep dre kelc'h talvoudus. Chase mor gwelloc'h e kezeg, pevarzek bleud homañ kempenn azezañ.</p>
38
+      </article>
39
+    </section>
40
+  </body>
41
+</html>

+ 44
- 0
web/solo.htm View File

@@ -0,0 +1,44 @@
1
+<!doctype html>
2
+<html>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Jeu solo</title>
6
+    <link rel="stylesheet" href="css/game.css">
7
+    <link rel="stylesheet" href="css/main.css">
8
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
9
+    <link href='http://fonts.googleapis.com/css?family=Lato:100,400,300,700' rel='stylesheet' type='text/css'>
10
+    <script src="js/jquery-2.1.4.min.js"></script>
11
+    <script src="js/responsive.js"></script>
12
+    <script src="js/game.js"></script>
13
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
14
+  </head>
15
+  <body>
16
+    <header>
17
+    </header>
18
+    <section id="navbar">
19
+      <ul>
20
+        <li><a href="index.htm">Accueil</a></li>
21
+        <li><a href="rules.htm">Règles</a></li>
22
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
23
+        <li class="current"><a href="play.htm">Jouer</a></li>
24
+      </ul>
25
+    </section>
26
+    <section id="responsive-navbar">
27
+      <ul>
28
+        <li class="name"><a href="#">Menu</a></li>
29
+        <li><a href="index.htm">Accueil</a></li>
30
+        <li><a href="rules.htm">Règles</a></li>
31
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
32
+        <li class="current"><a href="play.htm">Jouer</a></li>
33
+      </ul>
34
+    </section>
35
+    <section id="game">
36
+      <h2>Jeu solo</h2>
37
+      <input type="submit" id="play" value="Lancer la partie !" />
38
+    </section>
39
+
40
+    <script type="text/javascript">
41
+      $("#play").on("click", play);
42
+    </script>
43
+  </body>
44
+</html>

+ 63
- 0
web/testapi.htm View File

@@ -0,0 +1,63 @@
1
+<strong>Fails / Requ&ecirc;tes :</strong> <span id="fail">0</span>/<span id="tries">0</span><br />
2
+D&eacute;lai entre deux requ&ecirc;tes : <input type="text" id="ms" maxlength="4" style="width:40px" value="1" />ms <input type="submit" id="go" value="Go!" /><br />
3
+<p>Fail si :
4
+  <ul>
5
+    <li>Noms de cat&eacute;gories identiques</li>
6
+    <li>Une (au moins) cat&eacute;gorie vide</li>
7
+    <li>Pas assez de questions</li>
8
+    <li>Pas assez de th&egrave;mes</li>
9
+  </ul>
10
+</p>
11
+
12
+<script src="js/jquery-2.1.4.min.js"></script>
13
+<script>
14
+var tries = 0;
15
+var fail = 0;
16
+var goon = false;
17
+var delay = 1;
18
+
19
+function yolo() {
20
+  tries++;
21
+  $.ajax({
22
+    async: false,
23
+    url: './api/',
24
+    dataType: 'json',
25
+    success: function(json) {
26
+      var questions = 0;
27
+      var themes = json.cat1.themes.length + json.cat2.themes.length;
28
+      json.cat1.themes.forEach(function(theme) {
29
+        question += theme.questions.length;
30
+      });
31
+      json.cat2.themes.forEach(function(theme) {
32
+        question += theme.questions.length;
33
+      });
34
+      if(json.cat1.nom_cat === json.cat2.nom_cat || json.cat1.nom_cat === "" || json.cat2.nom_cat === ""
35
+          || questions < 2*2*3 || themes < 2*2) {
36
+        fail++;
37
+      }
38
+    }
39
+  })
40
+
41
+  $("#fail").html(fail);
42
+  $("#tries").html(tries);
43
+  if(goon) window.setTimeout(yolo, delay);
44
+}
45
+
46
+$("#go").on("click", function() {
47
+  if(!goon) $("#go").val("Stop!");
48
+  if(goon) $("#go").val("Go!");
49
+  delay = $("#ms").val()
50
+  goon = !goon;
51
+  yolo();
52
+});
53
+
54
+$(document).on("keypress", function(event) {
55
+  if(event.which === 32) {
56
+    if(!goon) $("#go").val("Stop!");
57
+    if(goon) $("#go").val("Go!");
58
+    delay = $("#ms").val()
59
+    goon = !goon;
60
+    yolo();
61
+  }
62
+});
63
+</script>