X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariant.js;h=e24dfc688433da348a93d5ccf1e245a3300599bb;hb=d44df0b01732d1948525daef5df62211ea6e1f64;hp=7d30d73102090b614f0167dfb7177c1f8c60df77;hpb=81bc1102368a5a8b9358f58b77c241f82f3c2c4b;p=vchess.git diff --git a/public/javascripts/variant.js b/public/javascripts/variant.js index 7d30d731..e24dfc68 100644 --- a/public/javascripts/variant.js +++ b/public/javascripts/variant.js @@ -2,7 +2,7 @@ new Vue({ el: "#VueElement", data: { display: "undefined", //default to main hall; see "created()" function - gameid: "undefined", //...yet + gameid: undefined, //...yet conn: null, @@ -10,25 +10,35 @@ new Vue({ mode: "analyze", orientation: "w", userColor: "w", + + 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(); + + + this.myid = "abcdefghij"; +//console.log(this.myid + " " + variant); - this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id); + this.conn = new WebSocket(socketUrl + "/?sid=" + this.myid + "&page=" + variant.id); const socketCloseListener = () => { - this.conn = new WebSocket(url + "/?sid=" + this.myid + "&page=" + variant._id); + this.conn = new WebSocket(socketUrl + "/?sid=" + this.myid + "&page=" + variant.id); } this.conn.onclose = socketCloseListener; - this.vr = new VariantRules( V.GenRandInitFen() ); + window.onhashchange = this.setDisplay; + //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 + + const page = (location.hash || "#room").substr(1); + this.display = page; // Close menu on small screens: let menuToggle = document.getElementById("drawer-control"); if (!!menuToggle)