Skip to content

Commit

Permalink
Update advanced.html
Browse files Browse the repository at this point in the history
  • Loading branch information
yjf2002ghty authored Jun 19, 2024
1 parent 82f561e commit e455631
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions public/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@
var fgs = window.fairyground.SavedGamesParsingFeature;
let themes = [[], [], []];
let themenames = [[], []];
let variantsettings = [[], [], [], []];
let variantsettings = [[], [], [], [], []];
let allvariants = [];
const $ = (...args) => document.querySelector(...args);

Expand Down Expand Up @@ -1462,7 +1462,7 @@
continue;
}
variantdescriptionitem = rawText[i].split("|");
if (variantdescriptionitem.length != 4) {
if (variantdescriptionitem.length != 5) {
console.warn(
`At line ${i + 1} in variantsettings.txt: Syntax error.`,
);
Expand Down Expand Up @@ -1496,6 +1496,7 @@
variantsettings[1].push(variantdescriptionitem[1]);
variantsettings[2].push(variantdescriptionitem[2]);
variantsettings[3].push(variantdescriptionitem[3]);
variantsettings[4].push(variantdescriptionitem[4]);
}
//console.log(variantsettings);
} else {
Expand Down Expand Up @@ -1794,6 +1795,22 @@
}
}

function getVariantWikiPageURL(variant, useplaceholder) {
if (typeof variant != "string" || typeof useplaceholder != "boolean") {
return null;
}
let index = variantsettings[0].indexOf(variant);
if (index < 0) {
if (useplaceholder) {
return "";
} else {
return undefined;
}
} else {
return variantsettings[4][index];
}
}

const App = () => {
let stockfish = null;
let stockfish_state = "INIT"; // 'READY', 'FAILED'
Expand Down Expand Up @@ -4257,10 +4274,24 @@
$("#dropdown-variant").value,
false,
);
let wiki = getVariantWikiPageURL(
$("#dropdown-variant").value,
false,
);
if (description) {
window.alert(
`Variant ${name} (ID: ${$("#dropdown-variant").value}):\n${description}`,
);
if (wiki) {
if (
window.confirm(
`Variant ${name} (ID: ${$("#dropdown-variant").value}):\n${description}\n\nWiki: ${wiki}\n\nDo you want to visit the wiki page?`,
)
) {
window.open(wiki, "_blank");
}
} else {
window.alert(
`Variant ${name} (ID: ${$("#dropdown-variant").value}):\n${description}`,
);
}
} else {
window.alert(
"This variant does not provide a description. You can upload a variantsettings.txt yourself to add a description for it.",
Expand Down

0 comments on commit e455631

Please sign in to comment.