X-Git-Url: https://git.auder.net/?p=westcastle.git;a=blobdiff_plain;f=js%2Findex.js;h=42a376efedf07f383b047fbb4c0fabc80fb3f9d9;hp=659a0dd7f5ca9bb7f67d265cf791148676e548e9;hb=48b3a536373c1ee477fdff3e1f30bc3515d9e568;hpb=2caa3889307c969ae089b6c261ab8096ae49107a diff --git a/js/index.js b/js/index.js index 659a0dd..42a376e 100644 --- a/js/index.js +++ b/js/index.js @@ -45,88 +45,6 @@ new Vue({ }, }, }, - 'my-ranking': { - props: ['players','sortByScore','writeScoreToDb'], - template: ` -
- - - - - - - - - - - - - -
RangJoueurPointsMini-pts
{{ p.rank }}{{ p.prenom }} {{ p.nom }}{{ p.pdt }}{{ p.session }}
-
- - -
-
- `, - computed: { - sortedPlayers: function() { - let res = this.rankPeople(); - // Add rank information (taking care of ex-aequos) - let rank = 1; - for (let i=0; i { return Object.assign({}, p); }) //to not alter original array - .sort(this.sortByScore); - }, - resetPlayers: function() { - this.players - .slice(1) //discard Toto - .forEach( p => { - p.pdt = 0; - p.session = 0; - p.available = 1; - }); - this.writeScoreToDb(); - document.getElementById("runPairing").click(); //TODO: hack... - }, - restoreLast: function() { - let xhr = new XMLHttpRequest(); - let self = this; - xhr.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) - { - let players = JSON.parse(xhr.responseText); - if (players.length > 0) - { - players.unshift({ //add ghost 4th player for 3-players tables - prenom: "Toto", - nom: "", - pdt: 0, - session: 0, - available: 0, - }); - self.players = players; - } - } - }; - xhr.open("GET", "scripts/rw_players.php?restore=1", true); - xhr.send(null); - }, - }, - }, 'my-pairings': { props: ['players','writeScoreToDb'], data: function() { @@ -272,7 +190,7 @@ new Vue({ }; }, template: ` -
+
{{ formattedTime }}
@@ -299,7 +217,7 @@ new Vue({ }, reset: function(e) { this.running = false; - this.time = 10; //1:30 + this.time = 5400; //1:30 }, start: function() { if (!this.running) @@ -321,6 +239,88 @@ new Vue({ this.reset(); }, }, + 'my-ranking': { + props: ['players','sortByScore','writeScoreToDb'], + template: ` +
+ + + + + + + + + + + + + +
RangJoueurPointsMini-pts
{{ p.rank }}{{ p.prenom }} {{ p.nom }}{{ p.pdt }}{{ p.session }}
+
+ + +
+
+ `, + computed: { + sortedPlayers: function() { + let res = this.rankPeople(); + // Add rank information (taking care of ex-aequos) + let rank = 1; + for (let i=0; i { return Object.assign({}, p); }) //to not alter original array + .sort(this.sortByScore); + }, + resetPlayers: function() { + this.players + .slice(1) //discard Toto + .forEach( p => { + p.pdt = 0; + p.session = 0; + p.available = 1; + }); + this.writeScoreToDb(); + document.getElementById("runPairing").click(); //TODO: hack... + }, + restoreLast: function() { + let xhr = new XMLHttpRequest(); + let self = this; + xhr.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) + { + let players = JSON.parse(xhr.responseText); + if (players.length > 0) + { + players.unshift({ //add ghost 4th player for 3-players tables + prenom: "Toto", + nom: "", + pdt: 0, + session: 0, + available: 0, + }); + self.players = players; + } + } + }; + xhr.open("GET", "scripts/rw_players.php?restore=1", true); + xhr.send(null); + }, + }, + }, }, created: function() { let xhr = new XMLHttpRequest();