- const vname = this.$route.params["vname"];
- //const idxOfVar = this.st.variants.indexOf(e => e.name == vname);
- //this.variant = this.st.variants[idxOfVar]; //TODO: is it the right timing?!
- this.variant.name = vname;
- const vModule = await import("@/variants/" + vname + ".js");
- window.V = vModule.VariantRules;
- // Method to replace diagrams in loaded HTML
- const replaceByDiag = (match, p1, p2) => {
- const args = this.parseFen(p2);
- return getDiagram(args);
- };
- // (AJAX) Request to get rules content (plain text, HTML)
- this.content =
- // TODO: why doesn't this work? require("raw-loader!pug-plain-loader!@/rules/"...)
- require("raw-loader!@/rules/" + vname + "/" + this.st.lang + ".pug")
- .replace(/(fen:)([^:]*):/g, replaceByDiag);
+ this.re_setVariant(this.$route.params["vname"]);
+ },
+ computed: {
+ showAnalyzeBtn: function() {
+ return (this.display=='rules' && (!this.V || this.V.CanAnalyze));
+ },
+ 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, this.replaceByDiag)
+ );
+ }