X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fgame.js;h=deccd5da0c6bd5686b914ad8f614682c157bf9db;hb=15c1295af871a5f416b0e5b43127512c8095497a;hp=208e04824cfda2b5e37c8f8570b97b23e6d711f1;hpb=331fc58c932d6d7055b202d0c6dc0d77212a89f8;p=vchess.git diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index 208e0482..deccd5da 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -25,7 +25,7 @@ Vue.component('my-game', { }, render(h) { const [sizeX,sizeY] = VariantRules.size; - const smallScreen = (screen.width <= 420); + const smallScreen = (window.innerWidth <= 420); // Precompute hints squares to facilitate rendering let hintSquares = doubleArray(sizeX, sizeY, false); this.possibleMoves.forEach(m => { hintSquares[m.end.x][m.end.y] = true; }); @@ -779,7 +779,7 @@ Vue.component('my-game', { created: function() { const url = socketUrl; const continuation = (localStorage.getItem("variant") === variant); - this.myid = continuation ? localStorage.getItem("myid") : getRandString(); + this.myid = (continuation ? localStorage.getItem("myid") : getRandString()); if (!continuation) { // HACK: play a small silent sound to allow "new game" sound later @@ -808,6 +808,12 @@ Vue.component('my-game', { const data = JSON.parse(msg.data); switch (data.code) { + case "duplicate": + // We opened another tab on the same game + this.mode = "idle"; + this.vr = null; + alert("Already playing a game in this variant on another tab!"); + break; case "newgame": //opponent found // oppid: opponent socket ID this.newGame("human", data.fen, data.color, data.oppid); @@ -1051,7 +1057,7 @@ Vue.component('my-game', { document.getElementById("modal-newgame").checked = false; } this.oppid = oppId; - this.oppConnected = true; + this.oppConnected = !continuation; this.mycolor = color; this.seek = false; if (!!moves && moves.length > 0) //imply continuation