X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Findex.js;h=64489262663e9237bd420d3ebeb5ece157830537;hp=e24995bea71671d7575f7076a4aac35236241d91;hb=b6487fb9c41705187cf97215fc9e8f86a59057c7;hpb=772d7245d92f65c0b27c6c4aaaf64dc2fe9a9057 diff --git a/public/javascripts/index.js b/public/javascripts/index.js index e24995be..64489262 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -1,3 +1,4 @@ +// Javascript for index page: mostly counters updating new Vue({ el: "#indexPage", data: { @@ -7,7 +8,12 @@ new Vue({ }, computed: { sortedCounts: function () { - const variantsCounts = variantArray.map( v => { + // TODO: priorité aux parties corr où c'est à nous de jouer ! + const variantsCounts = variantArray + .filter( v => { + return v.name.startsWith(this.curPrefix); + }) + .map( v => { return { name: v.name, desc: v.description, @@ -24,8 +30,7 @@ new Vue({ }, created: function() { const url = socketUrl; - // random enough (TODO: function) - const sid = (Date.now().toString(36) + Math.random().toString(36).substr(2, 7)).toUpperCase(); + const sid = getRandString(); this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index"); const socketMessageListener = msg => { const data = JSON.parse(msg.data); @@ -37,7 +42,6 @@ new Vue({ this.counts[data.vname]--; }; const socketCloseListener = () => { - console.log("Lost connection -- reconnect"); this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index"); this.conn.addEventListener('message', socketMessageListener); this.conn.addEventListener('close', socketCloseListener); @@ -73,3 +77,8 @@ new Vue({ }; }, }); + +// TODO: +// 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) +// (fonction "getNextCol()" dans base_rules.js ?)