X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FRules.vue;h=2edd8a880764e8437047061ccde150bd9e6c4721;hb=70c9745d34b705eb8a4dc72b6e4655739d31347c;hp=c48feb08849c446d8492b339a6e8fd2c8cdfe4f1;hpb=07052665845283c65b50a76537669d0602ba436b;p=vchess.git diff --git a/client/src/views/Rules.vue b/client/src/views/Rules.vue index c48feb08..2edd8a88 100644 --- a/client/src/views/Rules.vue +++ b/client/src/views/Rules.vue @@ -26,7 +26,7 @@ main | {{ st.tr["Analysis mode"] }} .row .col-sm-12.col-md-8.col-md-offset-2.col-lg-6.col-lg-offset-3 - h4#variantName {{ gameInfo.vname }} + h4#variantName(v-show="display=='rules'") {{ gameInfo.vname }} div( v-show="display=='rules'" v-html="content" @@ -44,6 +44,7 @@ import ComputerGame from "@/components/ComputerGame.vue"; import { store } from "@/store"; import { replaceByDiag } from "@/utils/printDiagram"; import { CompgameStorage } from "@/utils/compgameStorage"; +import afterRawLoad from "@/utils/afterRawLoad"; export default { name: "my-rules", components: { @@ -77,19 +78,13 @@ export default { }, content: function() { if (!this.gameInfo.vname) return ""; //variant not set yet - // (AJAX) Request to get rules content (plain text, HTML) return ( - require( - "raw-loader!@/translations/rules/" + - this.gameInfo.vname + "/" + - this.st.lang + ".pug" - ) - // Next two lines fix a weird issue after last update (2019-11) - .replace(/\\n/g, " ") - .replace(/\\"/g, '"') - .replace('module.exports = "', "") - .replace(/"$/, "") - .replace(/(fen:)([^:]*):/g, replaceByDiag) + afterRawLoad( + require( + "raw-loader!@/translations/rules/" + + this.gameInfo.vname + "/" + this.st.lang + ".pug" + ).default + ).replace(/(fen:)([^:]*):/g, replaceByDiag) ); } }, @@ -99,6 +94,10 @@ export default { else if (this.gameInProgress) this.display = "computer"; }, re_setVariant: async function(vname) { + const key = "rr_" + vname; + if (!localStorage.getItem(key)) + // Mark rules as "read" + localStorage.setItem(key, '1'); await import("@/variants/" + vname + ".js") .then((vModule) => { this.V = window.V = vModule[vname + "Rules"]; @@ -128,7 +127,7 @@ export default { this.$refs["compgame"].launchGame(); } }, - // user wants to stop the game: + // The user wants to stop the game: stopGame: function() { this.$refs["compgame"].gameOver("?", "Undetermined result"); }, @@ -148,86 +147,14 @@ export default { }; - + -figure.diagram-container - margin: 15px 0 15px 0 +