X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fgame.js;h=e412525fa301c400822b51e62302523a3733cf89;hp=ab8605727efef0b288095b2b55d4f210d12ee584;hb=01a135e2aa21365c0a96931fbb6be76876e7c2a1;hpb=cd4cad0468612cf00c6e6879554e3cee58d4b1f9 diff --git a/public/javascripts/components/game.js b/public/javascripts/components/game.js index ab860572..e412525f 100644 --- a/public/javascripts/components/game.js +++ b/public/javascripts/components/game.js @@ -203,32 +203,6 @@ Vue.component('my-game', { // elementArray.push(reserve); // } const eogMessage = this.getEndgameMessage(this.score); - let elemsOfEog = - [ - h('label', - { - attrs: { "for": "modal-eog" }, - "class": { "modal-close": true }, - } - ), - h('h3', - { - "class": { "section": true }, - domProps: { innerHTML: eogMessage }, - } - ) - ]; - if (this.score != "*") - { - elemsOfEog.push( - h('p', //'textarea', //TODO: selectable! - { - domProps: { innerHTML: this.vr.getPGN(this.mycolor, this.score, this.fenStart) }, - //attrs: { "readonly": true }, - } - ) - ); - } const modalEog = [ h('input', { @@ -244,7 +218,20 @@ Vue.component('my-game', { { "class": { "card": true, "smallpad": true }, }, - elemsOfEog + [ + h('label', + { + attrs: { "for": "modal-eog" }, + "class": { "modal-close": true }, + } + ), + h('h3', + { + "class": { "section": true }, + domProps: { innerHTML: eogMessage }, + } + ) + ] ) ] ) @@ -299,6 +286,23 @@ Vue.component('my-game', { actionArray ); elementArray.push(actions); + if (this.score != "*") + { + elementArray.push( + h('div', + { }, + [ + h('p', + { + domProps: { + innerHTML: this.vr.getPGN(this.mycolor, this.score, this.fenStart, this.mode) + } + } + ) + ] + ) + ); + } return h( 'div', { @@ -426,7 +430,7 @@ Vue.component('my-game', { this.score = score; let modalBox = document.getElementById("modal-eog"); modalBox.checked = true; - //setTimeout(() => { modalBox.checked = false; }, 2000); //disabled, to show PGN + setTimeout(() => { modalBox.checked = false; }, 2000); if (this.mode == "human") this.clearStorage(); this.mode = "idle"; @@ -485,13 +489,12 @@ Vue.component('my-game', { if (this.mode == "human") return; //no newgame while playing if (this.seek) + { delete localStorage["newgame"]; //cancel game seek + this.seek = false; + } else - { - localStorage["newgame"] = variant; this.newGame("human"); - } - this.seek = !this.seek; }, clickComputerGame: function() { if (this.mode == "human") @@ -507,11 +510,12 @@ Vue.component('my-game', { const storageVariant = localStorage.getItem("variant"); if (!!storageVariant && storageVariant !== variant) { - // TODO: find a better way to ensure this. Newgame system is currently a mess. alert("Finish your " + storageVariant + " game first!"); return; } // Send game request and wait.. + localStorage["newgame"] = variant; + this.seek = true; this.clearStorage(); //in case of try { this.conn.send(JSON.stringify({code:"newgame", fen:fen}));