4 display: "undefined", //default to main hall; see "created()" function
5 gameid: undefined, //...yet
9 // Settings initialized with values from localStorage
11 bcolor: localStorage
["bcolor"] || "lichess",
12 sound: parseInt(localStorage
["sound"]) || 2,
13 hints: parseInt(localStorage
["hints"]) || 1,
14 coords: !!eval(localStorage
["coords"]),
15 highlight: !!eval(localStorage
["highlight"]),
16 sqSize: parseInt(localStorage
["sqSize"]),
25 fen: V
.GenRandInitFen(),
28 if (!!localStorage
["variant"])
30 location
.hash
= "#game?id=" + localStorage
["gameId"];
31 this.display
= location
.hash
.substr(1);
35 window
.onhashchange
= this.setDisplay
;
36 this.myid
= "abcdefghij";
37 //console.log(this.myid + " " + variant);
38 //myid: localStorage.getItem("myid"), //our ID, always set
40 this.conn
= new WebSocket(socketUrl
+ "/?sid=" + this.myid
+ "&page=" + variant
.id
);
41 const socketCloseListener
= () => {
42 this.conn
= new WebSocket(socketUrl
+ "/?sid=" + this.myid
+ "&page=" + variant
.id
);
44 this.conn
.onclose
= socketCloseListener
;
46 //this.vr = new VariantRules( V.GenRandInitFen() );
49 updateSettings: function(event
) {
51 event
.target
.id
.substr(3).replace(/^\w/, c
=> c
.toLowerCase())
52 localStorage
[propName
] = ["highlight","coords"].includes(propName
)
53 ? event
.target
.checked
56 setDisplay: function() {
57 // Prevent set display if there is a running game
58 if (!!localStorage
["variant"])
61 location
.hash
= "#room"; //default
62 const hashParts
= location
.hash
.substr(1).split("?");
63 this.display
= hashParts
[0];
64 this.queryHash
= hashParts
[1]; //may be empty, undefined...
65 // Close menu on small screens:
66 let menuToggle
= document
.getElementById("drawer-control");
68 menuToggle
.checked
= false;
73 //const continuation = (localStorage.getItem("variant") === variant.name);
74 // if (continuation) //game VS human has priority
75 // this.continueGame("human");