X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Findex.js;h=0e2a2631dde814d5b701ac4c3620de49ed81895b;hb=4608eed94432356bd2df8c144d7d233913c6483c;hp=bc4cd9e1d2a23b4940fbb2193643742faf4f5c10;hpb=fd08ab2c5b8931bb8c95cf7e9f2f95122647f991;p=vchess.git diff --git a/public/javascripts/index.js b/public/javascripts/index.js index bc4cd9e1..0e2a2631 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -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"); @@ -54,5 +57,14 @@ new Vue({ // 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); + }, + }, });