+// Javascript for index page: mostly counters updating
new Vue({
el: "#indexPage",
data: {
},
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,
},
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);
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);
};
},
});
+
+// 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 ?)