X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Findex.js;h=0e2a2631dde814d5b701ac4c3620de49ed81895b;hb=b955c65b942d09d24b5c3bed0d755d4f2f8f71f1;hp=3d35c456a7912142cd71d4abd414566c6b8b1f4a;hpb=26b8e4f7c71030d49e44fe1d89632ef91b886d67;p=vchess.git diff --git a/public/javascripts/index.js b/public/javascripts/index.js index 3d35c456..0e2a2631 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -5,10 +5,10 @@ new Vue({ counts: {}, curPrefix: "", conn: null, + display: "variants", }, computed: { sortedCounts: function () { - // TODO: priorité aux parties corr où c'est à nous de jouer ! const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => c.toUpperCase()); const variantsCounts = variantArray .filter( v => { @@ -30,6 +30,9 @@ new Vue({ }, }, created: function() { + this.setDisplay(); + window.onhashchange = this.setDisplay; + const url = socketUrl; const sid = getRandString(); this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index"); @@ -38,9 +41,9 @@ new Vue({ if (data.code == "counts") this.counts = data.counts; else if (data.code == "increase") - this.counts[data.vname]++; + this.counts[data.vid]++; else if (data.code == "decrease") - this.counts[data.vname]--; + this.counts[data.vid]--; }; const socketCloseListener = () => { this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index"); @@ -50,9 +53,18 @@ new Vue({ this.conn.onmessage = socketMessageListener; this.conn.onclose = socketCloseListener; - // TODO: + // TODO: AJAX call get corr games (all variants) // si dernier lastMove sur serveur n'est pas le mien et nextColor == moi, alors background orange // ==> background orange si à moi de jouer par corr (sur main index) // (helper: static fonction "GetNextCol()" dans base_rules.js) + + }, + methods: { + setDisplay: function() { + if (!location.hash) + location.hash = "#variants"; //default + this.display = location.hash.substr(1); + }, + }, });