});
}
});
- // TODO: why is this wrong? (Maybe because $route still uninitialized?)
- //store.initialize(this.$route.path);
+ // NOTE: store.initialize(this.$route.path); doesn't work
store.initialize(window.location.href.split("#")[1].split("?")[0]);
- // NOTE: at this point, variants and tr(anslations) might be uninitialized
},
}).$mount("#app");
this.state.user.email = res.email;
this.state.user.notify = res.notify;
});
+ const supportedLangs = ["en","es","fr"];
+ this.state.lang = localStorage["lang"] ||
+ (supportedLangs.includes(navigator.language)
+ ? navigator.language
+ : "en");
+ this.setTranslations();
+ // Initialize connection (even if the current page doesn't need it)
this.state.conn = new WebSocket(params.socketUrl + "/?sid=" + mysid +
"&page=" + encodeURIComponent(page));
// Settings initialized with values from localStorage
"&page=" + encodeURIComponent(page));
};
this.state.conn.onclose = this.socketCloseListener;
- const supportedLangs = ["en","es","fr"];
- this.state.lang = localStorage["lang"] ||
- (supportedLangs.includes(navigator.language)
- ? navigator.language
- : "en");
- this.setTranslations();
},
updateSetting: function(propName, value) {
this.state.settings[propName] = value;
this.curFen = this.game.fen;
this.adjustFenSize();
this.vr = new V(this.game.fen);
+ this.game.mycolor = this.vr.turn;
this.$set(this.game, "fenStart", this.gameRef.fen);
},
adjustFenSize: function() {
switch (data.code)
{
case "duplicate":
- this.st.conn.send(JSON.stringify({code:"duplicate"}));
+ this.st.conn.send(JSON.stringify({code:"duplicate",
+ page:"/game/" + this.game.id}));
alert(this.st.tr["Warning: multi-tabs not supported"]);
break;
// 0.2] Receive clients list (just socket IDs)
switch (data.code)
{
case "duplicate":
- this.st.conn.send(JSON.stringify({code:"duplicate"}));
+ this.st.conn.send(JSON.stringify({code:"duplicate", page:"/"}));
this.st.conn.send = () => {};
alert(this.st.tr["Warning: multi-tabs not supported"]);
break;
// Turn off message listening, and send disconnect if needed:
socket.removeListener("message", messageListener);
socket.removeListener("close", closeListener);
+ // From obj.page to clients[sid].page (TODO: unclear)
if (clients[sid].page != obj.page)
{
- notifyRoom(clients[sid].page, "disconnect");
- if (clients[sid].page.indexOf("/game/") >= 0)
+ notifyRoom(obj.page, "disconnect");
+ if (obj.page.indexOf("/game/") >= 0)
notifyRoom("/", "gdisconnect");
}
break;