X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariant.js;h=74c4298c03ef00af6456afdf462dab06d65416d7;hb=4608eed94432356bd2df8c144d7d233913c6483c;hp=453656cab7d3c84d8dbfa181c7af74e29f7cee25;hpb=baba60703f661aab20f2327098c3a0af572f0704;p=vchess.git diff --git a/public/javascripts/variant.js b/public/javascripts/variant.js index 453656ca..74c4298c 100644 --- a/public/javascripts/variant.js +++ b/public/javascripts/variant.js @@ -2,27 +2,43 @@ new Vue({ el: "#VueElement", data: { display: "undefined", //default to main hall; see "created()" function - gameid: "undefined", //...yet - + gameid: undefined, //...yet + + conn: null, + // TEMPORARY: DEBUG - vr: null, mode: "analyze", orientation: "w", userColor: "w", - gameOver: false, + + allowChat: false, + allowMovelist: false, + fen: V.GenRandInitFen(), }, created: function() { // TODO: navigation becomes a little more complex - const url = window.location.href; - const hashPos = url.indexOf("#"); - const page = (hashPos >= 0 ? url.substr(hashPos+1) : "room"); - this.setDisplay(page); + this.setDisplay(); + window.onhashchange = this.setDisplay; + + this.myid = "abcdefghij"; +//console.log(this.myid + " " + variant); - this.vr = new VariantRules( V.GenRandInitFen() ); + 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: { - setDisplay: function(elt) { - this.display = elt; + setDisplay: function() { + +//TODO: prevent set display if there is a running game + + if (!location.hash) + location.hash = "#room"; //default + this.display = location.hash.substr(1); // Close menu on small screens: let menuToggle = document.getElementById("drawer-control"); if (!!menuToggle)