X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=js%2Findex.js;h=09f0c17e657aa9b5dcf590d6edc42f0db908723e;hb=496ab82e42360d209fdf66cb2cfca519ce3a7c02;hp=5f1870430d9a59514d354a96c1640d4c2e2c13b1;hpb=d940eb68fd6f58a6f637261854a6da615d087dea;p=westcastle.git diff --git a/js/index.js b/js/index.js index 5f18704..09f0c17 100644 --- a/js/index.js +++ b/js/index.js @@ -76,10 +76,10 @@ new Vue({
- -
@@ -110,10 +110,10 @@ new Vue({
- - @@ -122,6 +122,14 @@ new Vue({
`, methods: { + // TODO: clic sur "Valider" télécharge la ronde courante + // TODO: mémoriser les appariements passés pour éviter que les mêmes joueurs se rencontrent plusieurs fois + // --> dans la base: tableau rounds, rounds[0] : {tables[0,1,...], chacune contenant 4 indices de joueurs; + sessions[0,1,...]} + // --> devrait séparer les components en plusieurs fichiers... + // cas à 5 joueurs : le joueur exempt doit tourner (c'est fait automatiquement en fait) + cancelRound: function() { + + }, doPairings: function() { // Simple case first: 4 by 4 let tables = []; @@ -233,13 +241,17 @@ new Vue({ return { time: 0, //remaining time, in seconds running: false, + initialTime: 90, //1h30, in minutes + setter: false, + setterTime: 0, //to input new initial time }; }, template: `
-
+
{{ formattedTime }}
+
`, @@ -257,6 +269,11 @@ new Vue({ }, }, methods: { + setTime: function() { + this.initialTime = this.setterTime; + this.setter = false; + this.reset(); + }, padToZero: function(a) { if (a < 10) return "0" + a; @@ -269,7 +286,7 @@ new Vue({ }, reset: function(e) { this.running = false; - this.time = 5400; //1:30 + this.time = this.initialTime * 60; }, start: function() { if (!this.running) @@ -280,6 +297,8 @@ new Vue({ this.running = false; return; } + if (this.time == this.initialTime) + new Audio("sounds/gong.mp3").play(); //gong at the beginning setTimeout(() => { if (this.running) this.time--; @@ -288,8 +307,27 @@ new Vue({ }, }, created: function() { + this.setterTime = this.initialTime; this.reset(); }, + mounted: function() { + let timer = document.getElementById("timer"); + let keyDict = { + 32: () => { this.setter = true; }, //Space + 27: () => { this.setter = false; }, //Esc + }; + document.addEventListener("keyup", e => { + if (timer.style.display !== "none") + { + let func = keyDict[e.keyCode]; + if (!!func) + { + e.preventDefault(); + func(); + } + } + }); + }, }, 'my-ranking': { props: ['players','sortByScore','commitScores'],