X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariant.js;h=510ea290e7cd8eb531f18ea5610c7b7e740750b7;hb=81da2786f2f497b4416e0488c34a48fb794c28df;hp=f9d23d8bf67a175c2d4ef706527b7d4262c33b82;hpb=f5d3e4f539355d166baf38bab97480582e90e4af;p=vchess.git diff --git a/public/javascripts/variant.js b/public/javascripts/variant.js index f9d23d8b..510ea290 100644 --- a/public/javascripts/variant.js +++ b/public/javascripts/variant.js @@ -1,7 +1,30 @@ new Vue({ el: "#variantPage", - data: { display: "" }, //do not show anything... - // TODO: listen event "show problem", avec le probleme stringifié en arg - // Alors: display=game, mode=friend, newGame(fen, turn, ...), - // et set Instructions+Soluce + data: { + display: "room", //default: main hall + gameid: "undefined", //...yet + }, + created: function() { + // TODO: navigation becomes a little more complex + const url = window.location.href; + const hashPos = url.indexOf("#"); + if (hashPos >= 0) + this.setDisplay(url.substr(hashPos+1)); + }, + methods: { + setDisplay: function(elt) { + this.display = elt; + // Close menu on small screens: + let menuToggle = document.getElementById("drawer-control"); + if (!!menuToggle) + menuToggle.checked = false; + }, + }, }); + +const continuation = (localStorage.getItem("variant") === variant); + if (continuation) //game VS human has priority + this.continueGame("human"); + +// TODO: +// si quand on arrive il y a une continuation "humaine" : display="game" et retour à la partie !