vid: parseInt(localStorage.getItem("vid")) || 0,
to: "", //name of challenged player (if any)
cadence: localStorage.getItem("cadence") || "",
- randomness: parseInt(localStorage.getItem("randomness")) || 2,
+ randomness: parseInt(localStorage.getItem("challRandomness")) || 2,
// VariantRules object, stored to not interfere with
// diagrams of targetted challenges:
V: null,
mounted: function() {
document.addEventListener('visibilitychange', this.visibilityChange);
["peopleWrap", "infoDiv", "newgameDiv"].forEach(eltName => {
- let elt = document.getElementById(eltName);
- elt.addEventListener("click", processModalClick);
+ document.getElementById(eltName)
+ .addEventListener("click", processModalClick);
});
document.querySelectorAll("#predefinedCadences > button").forEach(b => {
b.addEventListener("click", () => {
dispCorr || localStorage.getItem("type-challenges") || "live";
const showGtype =
dispCorr || localStorage.getItem("type-games") || "live";
- this.setDisplay("c", showCtype);
- this.setDisplay("g", showGtype);
+ this.setDisplay('c', showCtype);
+ this.setDisplay('g', showGtype);
+ // Attempt to show something (at least a few correspondance challenges):
+ setTimeout(
+ () => {
+ const types = ["corr", "live"];
+ for (let i of [0,1]) {
+ if (
+ this.gdisplay == types[i] &&
+ this.games.length > 0 &&
+ this.games.every(g => g.type == types[1-i])
+ ) {
+ this.setDisplay('g', types[1-i]);
+ }
+ if (
+ this.cdisplay == types[i] &&
+ this.challenges.length > 0 &&
+ this.challenges.every(c => c.type == types[1-i])
+ ) {
+ this.setDisplay('c', types[1-i]);
+ }
+ }
+ },
+ 1500
+ );
},
beforeDestroy: function() {
document.removeEventListener('visibilitychange', this.visibilityChange);
const vModule = await import("@/variants/" + vname + ".js");
this.newchallenge.V = vModule.VariantRules;
this.newchallenge.vname = vname;
- if (!!cb)
- cb();
+ if (!!cb) cb();
},
trySetNewchallDiag: function() {
if (!this.newchallenge.fen) {
this.newchallenge.vid = pchall.vid;
this.newchallenge.cadence = pchall.cadence;
this.newchallenge.randomness = pchall.randomness;
- this.issueNewChallenge();
+ this.loadNewchallVariant(this.issueNewChallenge);
},
issueNewChallenge: async function() {
if (!!(this.newchallenge.cadence.match(/^[0-9]+$/)))
// Remember cadence + vid for quicker further challenges:
localStorage.setItem("cadence", chall.cadence);
localStorage.setItem("vid", chall.vid);
- localStorage.setItem("randomness", chall.randomness);
+ localStorage.setItem("challRandomness", chall.randomness);
document.getElementById("modalNewgame").checked = false;
// Show the challenge if not on current display
if (