X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fvariant.js;fp=public%2Fjavascripts%2Fvariant.js;h=5a6c224a020e77bb68effe242dbe6424ec18108b;hp=606c1b9a2520cb7beff1ea44e93967dcbac65ae8;hb=a3ab5fdb6e9d614f55bb7ecef5887ddb7875df4b;hpb=d337a94cd6d38bb743a8935017d03fe21d4ad324 diff --git a/public/javascripts/variant.js b/public/javascripts/variant.js index 606c1b9a..5a6c224a 100644 --- a/public/javascripts/variant.js +++ b/public/javascripts/variant.js @@ -1,11 +1,13 @@ new Vue({ el: "#VueElement", data: { - display: "undefined", //default to main hall; see "created()" function + display: "", //default to main hall; see "created()" function gameid: undefined, //...yet queryHash: "", conn: null, - + mode: "analyze", + allowChat: false, + allowMovelist: true, // Settings initialized with values from localStorage settings: { bcolor: localStorage["bcolor"] || "lichess", @@ -15,14 +17,6 @@ new Vue({ highlight: !!eval(localStorage["highlight"]), sqSize: parseInt(localStorage["sqSize"]), }, - - // TEMPORARY: DEBUG - mode: "analyze", - orientation: "w", - userColor: "w", - allowChat: false, - allowMovelist: true, - fen: V.GenRandInitFen(), }, created: function() { if (!!localStorage["variant"]) @@ -33,17 +27,13 @@ new Vue({ else this.setDisplay(); window.onhashchange = this.setDisplay; - this.myid = "abcdefghij"; -//console.log(this.myid + " " + variant); - //myid: localStorage.getItem("myid"), //our ID, always set - + // 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; - - //this.vr = new VariantRules( V.GenRandInitFen() ); }, methods: { updateSettings: function(event) { @@ -53,6 +43,11 @@ new Vue({ ? event.target.checked : event.target.value; }, + // Game is over, clear storage and put it in indexedDB + archiveGame: function() { + // TODO: ... + //clearStorage(); + }, setDisplay: function() { // Prevent set display if there is a running game if (!!localStorage["variant"]) @@ -69,7 +64,3 @@ new Vue({ }, }, }); - -//const continuation = (localStorage.getItem("variant") === variant.name); -// if (continuation) //game VS human has priority -// this.continueGame("human");