a7d182007cfce345367cbb9d4d65b985defcb052
[vchess.git] / public / javascripts / variant.js
1 new Vue({
2 el: "#variantPage",
3 data: {
4 display: "play", //default: play!
5 problem: undefined, //current problem in view
6 },
7 created: function() {
8 const url = window.location.href;
9 const hashPos = url.indexOf("#");
10 if (hashPos >= 0)
11 this.setDisplay(url.substr(hashPos+1));
12 },
13 methods: {
14 showProblem: function(problemTxt) {
15 this.problem = JSON.parse(problemTxt);
16 this.display = "play";
17 },
18 setDisplay: function(elt) {
19 this.display = elt;
20 let menuToggle = document.getElementById("drawer-control");
21 if (!!menuToggle)
22 menuToggle.checked = false;
23 },
24 },
25 });