X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=js%2Findex.js;h=0d2adad0026adcdd1c931675ff836ca2f7d9a7d9;hb=ce0473b4fac73ad9ac63cf8fa480548817349804;hp=659a0dd7f5ca9bb7f67d265cf791148676e548e9;hpb=2caa3889307c969ae089b6c261ab8096ae49107a;p=westcastle.git diff --git a/js/index.js b/js/index.js index 659a0dd..0d2adad 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() { @@ -165,7 +83,7 @@ new Vue({ {{ players[tables[currentIndex][i]].prenom }} {{ players[tables[currentIndex][i]].nom }} - +
@@ -175,7 +93,7 @@ new Vue({
Attention: un score a déjà été enregistré. Les points indiqués ici s'ajouteront : il faut d'abord - restaurer l'état précédent. + restaurer l'état précédent. Si c'est déjà fait, ignorer ce message :)
@@ -236,8 +154,8 @@ new Vue({ }, setScore: function() { let sortedSessions = this.sessions[this.currentIndex] - .map( (s,i) => { return {value:s, index:i}; }) - .sort( (a,b) => { return parseInt(b.value) - parseInt(a.value); }); + .map( (s,i) => { return {value:parseInt(s), index:i}; }) + .sort( (a,b) => { return b.value - a.value; }); let pdts = [4, 2, 1, 0]; // NOTE: take care of ex-aequos (spread points subtotal) let curSum = 0, curCount = 0, start = 0; @@ -262,6 +180,9 @@ new Vue({ this.currentIndex = -1; this.writeScoreToDb(); }, + clickRestore: function() { + document.getElementById('restoreBtn').click(); + }, }, }, 'my-timer': { @@ -272,7 +193,7 @@ new Vue({ }; }, template: ` -
+
{{ formattedTime }}
@@ -285,6 +206,9 @@ new Vue({ let minutes = Math.floor(this.time / 60); return this.padToZero(minutes) + ":" + this.padToZero(seconds); }, + textHeight: function() { + return screen.height; + }, }, methods: { padToZero: function(a) { @@ -299,7 +223,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 +245,93 @@ 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 { + p.pdt = 0; + p.session = 0; + p.available = 1; + }); + this.writeScoreToDb(); + document.getElementById("runPairing").click(); + }, + 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, + }); + // NOTE: Vue warning "do not mutate property" if direct self.players = players + for (let i=1; i { return Object.assign({}, p); }) //deep (enough) copy .sort(this.sortByScore); xhr.send("players="+encodeURIComponent(JSON.stringify(orderedPlayers))); },