- .replace(/\\[n"]/g, " ")
- .replace('module.exports = "', '').replace(/"$/, "")
- .replace(/(fen:)([^:]*):/g, replaceByDiag);
+ .replace(/\\n/g, " ")
+ .replace(/\\"/g, '"')
+ .replace('module.exports = "', "")
+ .replace(/"$/, "")
+ .replace(/(fen:)([^:]*):/g, replaceByDiag)
+ );
+ }
+ },
+ methods: {
+ clickReadRules: function() {
+ if (this.display != "rules") this.display = "rules";
+ 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"];
+ this.gameInfo.vname = vname;
+ })
+ .catch((err) => {
+ // Soon after component creation, st.tr might be uninitialized.
+ // Set a timeout to let a chance for the message to show translated.
+ const text = "Mispelled variant name";
+ setTimeout(() => {
+ alert(this.st.tr[text] || text);
+ this.$router.replace("/variants");
+ }, 500);
+ });