% display on sections code refactor

This commit is contained in:
ReznoRMichael 2022-01-20 19:58:03 +01:00
parent 92d8929bca
commit 915c4ba0a6
3 changed files with 113 additions and 26 deletions

View file

@ -12108,22 +12108,39 @@ function CompletionFillNoSave(section) {
var h2id = ""; var h2id = "";
var mp = ""; // max Percent var mp = ""; // max Percent
var symbol = "%"; // let cl = ""; // class var symbol = ""; // let cl = ""; // class
id = section.id; id = section.id;
h2 = section.h2; h2 = section.h2;
h2id = "h2-" + section.id; h2id = "h2-" + section.id;
/* Do not display % when showing Hunter's Journal entries */ /* Display % only when showing Main Game Completion % sections */
switch (section.id) {
case "hk-intro":
case "hk-bosses":
case "hk-charms":
case "hk-equipment":
case "hk-nailupgrades":
case "hk-nailarts":
case "hk-spells":
case "hk-maskshards":
case "hk-vesselfragments":
case "hk-dreamnail":
case "hk-warriordreams":
case "hk-dreamers":
case "hk-colosseum":
case "hk-grimmtroupe":
case "hk-lifeblood":
case "hk-godmaster":
symbol = "%";
break;
default:
symbol = "";
}
if (section.id === "hk-journal") symbol = "";
mp = "<div class='percent-box'>".concat(id === "hk-intro" ? 0 : section.maxPercent).concat(symbol, "</div>"); mp = "<div class='percent-box'>".concat(id === "hk-intro" ? 0 : section.maxPercent).concat(symbol, "</div>");
if (!section.hasOwnProperty("maxPercent")) mp = ""; if (!section.hasOwnProperty("maxPercent")) mp = "";
/* return [
`<div id="${id}" ${cl}>`,
`<h2 id='${h2id}'>${h2}${mp}</h2>`,
"</div>\n"
].join(""); */
return "<h2 id='".concat(h2id, "'>").concat(h2).concat(mp, "</h2>"); return "<h2 id='".concat(h2id, "'>").concat(h2).concat(mp, "</h2>");
} }
/** /**
@ -12141,9 +12158,9 @@ function CompletionFill(section) {
var mp = 0; // max Percent var mp = 0; // max Percent
var symbol = "%"; var symbol = "";
var fillText = ""; var fillText = "";
section.hasOwnProperty("percent") ? cp = section.percent : cp = 0; // Don't use percent-box for Essentials, Achievements, Statistics section.hasOwnProperty("percent") ? cp = section.percent : cp = 0; // Don't use percent-box for Essentials, Achievements, Statistics etc.
if (!section.hasOwnProperty("maxPercent")) { if (!section.hasOwnProperty("maxPercent")) {
fillText = ""; fillText = "";
@ -12170,9 +12187,32 @@ function CompletionFill(section) {
if (section.id !== "hk-intro") cp += "/"; if (section.id !== "hk-intro") cp += "/";
/* Do not display % when showing Hunter's Journal entries */ /* Display % only when showing Main Game Completion % sections */
switch (section.id) {
case "hk-intro":
case "hk-bosses":
case "hk-charms":
case "hk-equipment":
case "hk-nailupgrades":
case "hk-nailarts":
case "hk-spells":
case "hk-maskshards":
case "hk-vesselfragments":
case "hk-dreamnail":
case "hk-warriordreams":
case "hk-dreamers":
case "hk-colosseum":
case "hk-grimmtroupe":
case "hk-lifeblood":
case "hk-godmaster":
symbol = "%";
break;
default:
symbol = "";
}
if (section.id === "hk-journal") symbol = "";
fillText = "<div class='percent-box".concat(cl, "'>").concat(section.id === "hk-intro" ? cp : "".concat(cp).concat(section.maxPercent)).concat(symbol, "</div>"); fillText = "<div class='percent-box".concat(cl, "'>").concat(section.id === "hk-intro" ? cp : "".concat(cp).concat(section.maxPercent)).concat(symbol, "</div>");
} }

File diff suppressed because one or more lines are too long

View file

@ -746,24 +746,45 @@ function CompletionFillNoSave(section) {
let h2 = ""; let h2 = "";
let h2id = ""; let h2id = "";
let mp = ""; // max Percent let mp = ""; // max Percent
let symbol = "%"; let symbol = "";
// let cl = ""; // class // let cl = ""; // class
id = section.id; id = section.id;
h2 = section.h2; h2 = section.h2;
h2id = "h2-" + section.id; h2id = "h2-" + section.id;
/* Do not display % when showing Hunter's Journal entries */ /* Display % only when showing Main Game Completion % sections */
if (section.id === "hk-journal") symbol = ""; switch (section.id) {
case "hk-intro":
case "hk-bosses":
case "hk-charms":
case "hk-equipment":
case "hk-nailupgrades":
case "hk-nailarts":
case "hk-spells":
case "hk-maskshards":
case "hk-vesselfragments":
case "hk-dreamnail":
case "hk-warriordreams":
case "hk-dreamers":
case "hk-colosseum":
case "hk-grimmtroupe":
case "hk-lifeblood":
case "hk-godmaster":
symbol = "%";
break;
default:
symbol = "";
}
mp = `<div class='percent-box'>${(id === "hk-intro") ? 0: section.maxPercent}${symbol}</div>`; mp = `<div class='percent-box'>${(id === "hk-intro") ? 0: section.maxPercent}${symbol}</div>`;
if (!section.hasOwnProperty("maxPercent")) mp = ""; if (!section.hasOwnProperty("maxPercent")) mp = "";
/* return [
`<div id="${id}" ${cl}>`,
`<h2 id='${h2id}'>${h2}${mp}</h2>`,
"</div>\n"
].join(""); */
return `<h2 id='${h2id}'>${h2}${mp}</h2>`; return `<h2 id='${h2id}'>${h2}${mp}</h2>`;
} }
@ -779,12 +800,12 @@ function CompletionFill(section) {
let clRed = "box-red"; let clRed = "box-red";
let cp = 0; // current Percent let cp = 0; // current Percent
let mp = 0; // max Percent let mp = 0; // max Percent
let symbol = "%"; let symbol = "";
let fillText = ""; let fillText = "";
(section.hasOwnProperty("percent")) ? cp = section.percent: cp = 0; (section.hasOwnProperty("percent")) ? cp = section.percent: cp = 0;
// Don't use percent-box for Essentials, Achievements, Statistics // Don't use percent-box for Essentials, Achievements, Statistics etc.
if (!section.hasOwnProperty("maxPercent")) { if (!section.hasOwnProperty("maxPercent")) {
fillText = ""; fillText = "";
} }
@ -815,8 +836,34 @@ function CompletionFill(section) {
// needed for Game Status to show percentage properly (adds a slash for all boxes except the Game Status one) // needed for Game Status to show percentage properly (adds a slash for all boxes except the Game Status one)
if (section.id !== "hk-intro") cp += "/"; if (section.id !== "hk-intro") cp += "/";
/* Do not display % when showing Hunter's Journal entries */ /* Display % only when showing Main Game Completion % sections */
if (section.id === "hk-journal") symbol = ""; switch (section.id) {
case "hk-intro":
case "hk-bosses":
case "hk-charms":
case "hk-equipment":
case "hk-nailupgrades":
case "hk-nailarts":
case "hk-spells":
case "hk-maskshards":
case "hk-vesselfragments":
case "hk-dreamnail":
case "hk-warriordreams":
case "hk-dreamers":
case "hk-colosseum":
case "hk-grimmtroupe":
case "hk-lifeblood":
case "hk-godmaster":
symbol = "%";
break;
default:
symbol = "";
}
fillText = `<div class='percent-box${cl}'>${(section.id === "hk-intro") ? cp: `${cp}${section.maxPercent}`}${symbol}</div>`; fillText = `<div class='percent-box${cl}'>${(section.id === "hk-intro") ? cp: `${cp}${section.maxPercent}`}${symbol}</div>`;
} }