X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=f401c6ef28ea1e8db393516285b6d28dc24be6a8;hb=1112f1fdd39a4599cebc4b0b03bee1d28f1236ee;hp=d0cabb46d8099789751b8f323ff4352f12453496;hpb=3f22c2c3939dfd6bd66da26e6d6d9848c6da86d2;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index d0cabb46..f401c6ef 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -73,10 +73,14 @@ main ) fieldset(v-if="st.user.id > 0") label(for="selectPlayers") {{ st.tr["Play with"] }} - select#selectPlayersInList(v-model="newchallenge.to") + select#selectPlayersInList( + v-model="newchallenge.to" + @change="changeChallTarget()" + ) option(value="") option( v-for="p in Object.values(people)" + v-if="!!p.name" :value="p.name" ) | {{ p.name }} @@ -263,9 +267,14 @@ export default { }); if (!this.newchallenge.V && this.newchallenge.vid > 0) this.loadNewchallVariant(); + }, + $route: function(to, from) { + if (to.path != "/") this.cleanBeforeDestroy(); } }, created: function() { + document.addEventListener('visibilitychange', this.visibilityChange); + window.addEventListener("beforeunload", this.cleanBeforeDestroy); if (this.st.variants.length > 0 && this.newchallenge.vid > 0) this.loadNewchallVariant(); const my = this.st.user; @@ -300,7 +309,6 @@ export default { this.conn.addEventListener("close", this.socketCloseListener); }, mounted: function() { - document.addEventListener('visibilitychange', this.visibilityChange); ["peopleWrap", "infoDiv", "newgameDiv"].forEach(eltName => { document.getElementById(eltName) .addEventListener("click", processModalClick); @@ -384,10 +392,14 @@ export default { ); }, beforeDestroy: function() { - document.removeEventListener('visibilitychange', this.visibilityChange); - this.send("disconnect"); + this.cleanBeforeDestroy(); }, methods: { + cleanBeforeDestroy: function() { + document.removeEventListener('visibilitychange', this.visibilityChange); + window.removeEventListener("beforeunload", this.cleanBeforeDestroy); + this.send("disconnect"); + }, getRandomnessClass: function(pc) { return { ["random-" + pc.randomness]: true @@ -453,6 +465,13 @@ export default { if (!!this.curChallToAccept.fen) return { "margin-top": "10px" }; return {}; }, + changeChallTarget: function() { + if (!this.newchallenge.to) { + // Reset potential FEN + diagram + this.newchallenge.fen = ""; + this.newchallenge.diag = ""; + } + }, cadenceFocusIfOpened: function() { if (event.target.checked) document.getElementById("cadence").focus(); @@ -903,7 +922,7 @@ export default { position: parsedFen.position, orientation: parsedFen.turn }); - } + } else this.newchallenge.diag = ""; }, newChallFromPreset(pchall) { this.partialResetNewchallenge();