quick loop fill from database

This commit is contained in:
ReznoRMichael 2021-07-01 20:38:07 +02:00
parent 3acd8a626e
commit 757fb1ef77
3 changed files with 91 additions and 40 deletions

View file

@ -1255,40 +1255,60 @@ function HKReadTextArea() {
} }
/** /**
* Populate all HTML with given ID and their initial data set as false (used at DOM load) * Populate all HTML with given ID and their initial data set as false (used at DOM load)
* @param {object} divIdObj JavaScript Object containing all HTML IDs to populate * @param {object} sections JavaScript Object containing all HTML IDs to populate
*/ */
function InitialHTMLPopulate(divIdObj) { function InitialHTMLPopulate(sections) {
var sFillText = ""; var sFillText = "";
CurrentDataFalse(); CurrentDataFalse();
(0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.PrefillHTML)(divIdObj); // Play Time (0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.PrefillHTML)(sections); // Play Time
CheckPlayTime(divIdObj.intro, 0); // Game Completion CheckPlayTime(sections.intro, 0); // Game Completion
CheckCompletionPercent(divIdObj.intro, 0); // Save File Version CheckCompletionPercent(sections.intro, 0); // Save File Version
CheckSaveFileVersion(divIdObj.intro); // Fleur Divide CheckSaveFileVersion(sections.intro); // Fleur Divide
(0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(divIdObj.intro, FLEUR_DIVIDE); // Health Masks (0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(sections.intro, FLEUR_DIVIDE); // Health Masks
CheckHealthMasks(divIdObj.intro); // Soul Orbs CheckHealthMasks(sections.intro); // Soul Orbs
CheckSoulOrbs(divIdObj.intro, 99); // Charm Notches CheckSoulOrbs(sections.intro, 99); // Charm Notches
CheckNotches(divIdObj.intro); // Geo CheckNotches(sections.intro); // Geo
CheckGeo(divIdObj.intro); // Keep symbol False CheckGeo(sections.intro); // Keep symbol False
CurrentDataFalse(); // First Hint Only CurrentDataFalse(); // First Hint Only
(0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(divIdObj.hints, divIdObj.hints.entries.fireballLevel.spoiler); (0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(sections.hints, sections.hints.entries.fireballLevel.spoiler);
/* // Temp arrays storing references (addresses) to objects for looping through them (duplicates important) var entries = {};
for (var section in sections) {
entries = sections[section].entries;
switch (section) {
case "intro":
case "hints":
break;
default:
for (var entry in entries) {
sFillText += PrepareHTMLString(sections[section], entries[entry].name, entries[entry].spoiler, entries[entry].wiki);
}
(0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(sections[section], sFillText);
}
sFillText = "";
}
/*
// Temp arrays storing references (addresses) to objects for looping through them (duplicates important)
let hkObjArray = [HK.BOSSES, HK.CHARMS, HK.EQUIPMENT, HK.NAILARTS, HK.MASKSHARDS, HK.MASKSHARDS_WORLD, HK.VESSELFRAGMENTS, HK.VESSELFRAGMENTS_WORLD, HK.DREAMERS, HK.COLOSSEUM, HK.DREAMNAIL, HK.WARRIORDREAMS, HK.GRIMMTROUPE, HK.LIFEBLOOD, HK.GODMASTER, HK.ESSENTIAL, HK.ACHIEVEMENTS, HK.STATISTICS, HK.GODHOME_STATISTICS]; let hkObjArray = [HK.BOSSES, HK.CHARMS, HK.EQUIPMENT, HK.NAILARTS, HK.MASKSHARDS, HK.MASKSHARDS_WORLD, HK.VESSELFRAGMENTS, HK.VESSELFRAGMENTS_WORLD, HK.DREAMERS, HK.COLOSSEUM, HK.DREAMNAIL, HK.WARRIORDREAMS, HK.GRIMMTROUPE, HK.LIFEBLOOD, HK.GODMASTER, HK.ESSENTIAL, HK.ACHIEVEMENTS, HK.STATISTICS, HK.GODHOME_STATISTICS];
// duplicates and order important - must be the same as in hkObjArray[] // duplicates and order important - must be the same as in hkObjArray[]
let divObjArray = [divIdObj.bosses, divIdObj.charms, divIdObj.equipment, divIdObj.nailArts, divIdObj.maskShards, divIdObj.maskShards, divIdObj.vesselFragments, divIdObj.vesselFragments, divIdObj.dreamers, divIdObj.colosseum, divIdObj.dreamNail, divIdObj.warriorDreams, divIdObj.grimmTroupe, divIdObj.lifeblood, divIdObj.godmaster, divIdObj.essential, divIdObj.achievements, divIdObj.statistics, divIdObj.godhomeStatistics]; */ let divObjArray = [divIdObj.bosses, divIdObj.charms, divIdObj.equipment, divIdObj.nailArts, divIdObj.maskShards, divIdObj.maskShards, divIdObj.vesselFragments, divIdObj.vesselFragments, divIdObj.dreamers, divIdObj.colosseum, divIdObj.dreamNail, divIdObj.warriorDreams, divIdObj.grimmTroupe, divIdObj.lifeblood, divIdObj.godmaster, divIdObj.essential, divIdObj.achievements, divIdObj.statistics, divIdObj.godhomeStatistics];
// Looped filling to reduce redundancy
/* // Looped filling to reduce redundancy
do { do {
for (let entry in hkObjArray[0]) { for (let entry in hkObjArray[0]) {
if (entry === "mrMushroomState") continue; if (entry === "mrMushroomState") continue;
@ -1321,11 +1341,13 @@ function InitialHTMLPopulate(divIdObj) {
// Mr Mushroom 1 - 7 // Mr Mushroom 1 - 7
sFillText = CheckMrMushroomState(divIdObj.achievements, divIdObj.achievements.entries.mrMushroomState); sFillText = CheckMrMushroomState(divIdObj.achievements, divIdObj.achievements.entries.mrMushroomState);
AppendHTML(divIdObj.achievements, sFillText); AppendHTML(divIdObj.achievements, sFillText);
*/
// Fleur Dividers // Fleur Dividers
AppendHTML(divIdObj.godmaster, FLEUR_DIVIDE);
AppendHTML(divIdObj.essential, FLEUR_DIVIDE);
AppendHTML(divIdObj.achievements, FLEUR_DIVIDE); */ (0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(sections.godmaster, FLEUR_DIVIDE);
// Check local storage first to set proper checkbox state before the below functions start (default is always unchecked) (0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(sections.essential, FLEUR_DIVIDE);
(0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.AppendHTML)(sections.achievements, FLEUR_DIVIDE); // Check local storage first to set proper checkbox state before the below functions start (default is always unchecked)
if ((0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.StorageAvailable)('localStorage')) { if ((0,_page_functions_js__WEBPACK_IMPORTED_MODULE_1__.StorageAvailable)('localStorage')) {
if (localStorage.getItem("hkCheckboxHints") === "checked") document.getElementById("checkbox-hints").checked = true; if (localStorage.getItem("hkCheckboxHints") === "checked") document.getElementById("checkbox-hints").checked = true;

File diff suppressed because one or more lines are too long

View file

@ -1292,53 +1292,80 @@ function HKReadTextArea(textAreaId = "") {
/** /**
* Populate all HTML with given ID and their initial data set as false (used at DOM load) * Populate all HTML with given ID and their initial data set as false (used at DOM load)
* @param {object} divIdObj JavaScript Object containing all HTML IDs to populate * @param {object} sections JavaScript Object containing all HTML IDs to populate
*/ */
function InitialHTMLPopulate(divIdObj) { function InitialHTMLPopulate(sections) {
let sFillText = ""; let sFillText = "";
CurrentDataFalse(); CurrentDataFalse();
PrefillHTML(divIdObj); PrefillHTML(sections);
// Play Time // Play Time
CheckPlayTime(divIdObj.intro, 0) CheckPlayTime(sections.intro, 0)
// Game Completion // Game Completion
CheckCompletionPercent(divIdObj.intro, 0); CheckCompletionPercent(sections.intro, 0);
// Save File Version // Save File Version
CheckSaveFileVersion(divIdObj.intro); CheckSaveFileVersion(sections.intro);
// Fleur Divide // Fleur Divide
AppendHTML(divIdObj.intro, FLEUR_DIVIDE); AppendHTML(sections.intro, FLEUR_DIVIDE);
// Health Masks // Health Masks
CheckHealthMasks(divIdObj.intro); CheckHealthMasks(sections.intro);
// Soul Orbs // Soul Orbs
CheckSoulOrbs(divIdObj.intro, 99); CheckSoulOrbs(sections.intro, 99);
// Charm Notches // Charm Notches
CheckNotches(divIdObj.intro); CheckNotches(sections.intro);
// Geo // Geo
CheckGeo(divIdObj.intro); CheckGeo(sections.intro);
// Keep symbol False // Keep symbol False
CurrentDataFalse(); CurrentDataFalse();
// First Hint Only // First Hint Only
AppendHTML(divIdObj.hints, divIdObj.hints.entries.fireballLevel.spoiler); AppendHTML(sections.hints, sections.hints.entries.fireballLevel.spoiler);
/* // Temp arrays storing references (addresses) to objects for looping through them (duplicates important) let entries = {};
for (let section in sections) {
entries = sections[section].entries;
switch(section) {
case "intro":
case "hints":
break;
default:
for (let entry in entries) {
sFillText += PrepareHTMLString(sections[section], entries[entry].name, entries[entry].spoiler, entries[entry].wiki);
}
AppendHTML(sections[section], sFillText);
}
sFillText = "";
}
/*
// Temp arrays storing references (addresses) to objects for looping through them (duplicates important)
let hkObjArray = [HK.BOSSES, HK.CHARMS, HK.EQUIPMENT, HK.NAILARTS, HK.MASKSHARDS, HK.MASKSHARDS_WORLD, HK.VESSELFRAGMENTS, HK.VESSELFRAGMENTS_WORLD, HK.DREAMERS, HK.COLOSSEUM, HK.DREAMNAIL, HK.WARRIORDREAMS, HK.GRIMMTROUPE, HK.LIFEBLOOD, HK.GODMASTER, HK.ESSENTIAL, HK.ACHIEVEMENTS, HK.STATISTICS, HK.GODHOME_STATISTICS]; let hkObjArray = [HK.BOSSES, HK.CHARMS, HK.EQUIPMENT, HK.NAILARTS, HK.MASKSHARDS, HK.MASKSHARDS_WORLD, HK.VESSELFRAGMENTS, HK.VESSELFRAGMENTS_WORLD, HK.DREAMERS, HK.COLOSSEUM, HK.DREAMNAIL, HK.WARRIORDREAMS, HK.GRIMMTROUPE, HK.LIFEBLOOD, HK.GODMASTER, HK.ESSENTIAL, HK.ACHIEVEMENTS, HK.STATISTICS, HK.GODHOME_STATISTICS];
// duplicates and order important - must be the same as in hkObjArray[] // duplicates and order important - must be the same as in hkObjArray[]
let divObjArray = [divIdObj.bosses, divIdObj.charms, divIdObj.equipment, divIdObj.nailArts, divIdObj.maskShards, divIdObj.maskShards, divIdObj.vesselFragments, divIdObj.vesselFragments, divIdObj.dreamers, divIdObj.colosseum, divIdObj.dreamNail, divIdObj.warriorDreams, divIdObj.grimmTroupe, divIdObj.lifeblood, divIdObj.godmaster, divIdObj.essential, divIdObj.achievements, divIdObj.statistics, divIdObj.godhomeStatistics]; */ let divObjArray = [divIdObj.bosses, divIdObj.charms, divIdObj.equipment, divIdObj.nailArts, divIdObj.maskShards, divIdObj.maskShards, divIdObj.vesselFragments, divIdObj.vesselFragments, divIdObj.dreamers, divIdObj.colosseum, divIdObj.dreamNail, divIdObj.warriorDreams, divIdObj.grimmTroupe, divIdObj.lifeblood, divIdObj.godmaster, divIdObj.essential, divIdObj.achievements, divIdObj.statistics, divIdObj.godhomeStatistics];
/* // Looped filling to reduce redundancy // Looped filling to reduce redundancy
do { do {
for (let entry in hkObjArray[0]) { for (let entry in hkObjArray[0]) {
if (entry === "mrMushroomState") continue; if (entry === "mrMushroomState") continue;
@ -1376,10 +1403,12 @@ function InitialHTMLPopulate(divIdObj) {
sFillText = CheckMrMushroomState(divIdObj.achievements, divIdObj.achievements.entries.mrMushroomState); sFillText = CheckMrMushroomState(divIdObj.achievements, divIdObj.achievements.entries.mrMushroomState);
AppendHTML(divIdObj.achievements, sFillText); AppendHTML(divIdObj.achievements, sFillText);
*/
// Fleur Dividers // Fleur Dividers
AppendHTML(divIdObj.godmaster, FLEUR_DIVIDE); AppendHTML(sections.godmaster, FLEUR_DIVIDE);
AppendHTML(divIdObj.essential, FLEUR_DIVIDE); AppendHTML(sections.essential, FLEUR_DIVIDE);
AppendHTML(divIdObj.achievements, FLEUR_DIVIDE); */ AppendHTML(sections.achievements, FLEUR_DIVIDE);
// Check local storage first to set proper checkbox state before the below functions start (default is always unchecked) // Check local storage first to set proper checkbox state before the below functions start (default is always unchecked)
if (StorageAvailable('localStorage')) { if (StorageAvailable('localStorage')) {