- display: getCookie("display-"+variant,""), //default: do not show anything...
- problem: undefined, //current problem in view
+ display: "", //default to main hall; see "created()" function
+ gameRef: undefined, //...for now
+ probId: undefined,
+ conn: null,
+ mode: "analyze",
+ allowChat: false,
+ allowMovelist: true,
+ // Settings initialized with values from localStorage
+ settings: {
+ bcolor: localStorage["bcolor"] || "lichess",
+ sound: parseInt(localStorage["sound"]) || 2,
+ hints: parseInt(localStorage["hints"]) || 1,
+ coords: !!eval(localStorage["coords"]),
+ highlight: !!eval(localStorage["highlight"]),
+ sqSize: parseInt(localStorage["sqSize"]),
+ },
+ },
+ created: function() {
+ window.onhashchange = this.setDisplay;
+ if (!!localStorage["variant"])
+ location.hash = "#game?id=" + localStorage["gameId"];
+ else
+ this.setDisplay();
+ // Our ID, always set (DB id if registered, collision-free random string otherwise)
+ this.myid = user.id || localStorage["myid"] || "anon-" + getRandString();
+ this.conn = new WebSocket(socketUrl + "/?sid=" + this.myid + "&page=" + variant.id);
+ const socketCloseListener = () => {
+ this.conn = new WebSocket(socketUrl + "/?sid=" + this.myid + "&page=" + variant.id);
+ }
+ this.conn.onclose = socketCloseListener;