SingleEntryFill() base algorithms

This commit is contained in:
ReznoRMichael 2021-07-02 23:19:25 +02:00
parent b73fdc16e4
commit fc222b6252
4 changed files with 95 additions and 10 deletions

View file

@ -240,17 +240,17 @@ function CurrentDataBlank() {
function CheckPlayTime(divId, playTime) { function CheckPlayTime(divId, playTime) {
/* let icon = "<i class='icon-clock'></i>";
divId.playTimeIcon = icon; */
var seconds = Math.floor(playTime); var seconds = Math.floor(playTime);
var minutes = Math.floor(seconds / 60 % 60); var minutes = Math.floor(seconds / 60 % 60);
var hours = Math.floor(seconds / 3600); var hours = Math.floor(seconds / 3600);
var sec = Math.floor(seconds % 60); var sec = Math.floor(seconds % 60);
divId.entries.timePlayed.timeH = hours;
divId.entries.timePlayed.timeM = minutes;
divId.entries.timePlayed.timeS = sec;
if (sec < 10) sec = "0" + sec; if (sec < 10) sec = "0" + sec;
if (minutes < 10) minutes = "0" + minutes; if (minutes < 10) minutes = "0" + minutes;
var textFill = "Time Played:" + pSpan + "<b>" + hours + " h " + minutes + " min " + sec + " sec</b>"; var textFill = "Time Played:" + pSpan + "<b>" + hours + " h " + minutes + " min " + sec + " sec</b>";
divId.playTime = hours + " h " + minutes + " min " + sec + " sec"; // document.getElementById(divId.id).innerHTML += divStart + icon + textFill + divEnd; divId.entries.timePlayed.spoiler = hours + " h " + minutes + " min " + sec + " sec";
document.getElementById(divId.id).innerHTML += divStart + SYMBOL_CLOCK + textFill + divEnd; document.getElementById(divId.id).innerHTML += divStart + SYMBOL_CLOCK + textFill + divEnd;
} }
/** /**
@ -2474,8 +2474,9 @@ var HK = {
maxPercent: 112, maxPercent: 112,
entries: { entries: {
timePlayed: { timePlayed: {
icon: "clock",
name: "Time Played:", name: "Time Played:",
spoiler: "0 h 0 min 0 sec\"", spoiler: "0 h 0 min 0 sec",
timeH: 0, timeH: 0,
timeM: 0, timeM: 0,
timeS: 0 timeS: 0
@ -2486,25 +2487,30 @@ var HK = {
text: "(out of 112 %)" text: "(out of 112 %)"
}, },
saveVersion: { saveVersion: {
icon: "none",
name: "Save Version:", name: "Save Version:",
spoiler: "0.0.0.0" spoiler: "0.0.0.0"
}, },
health: { health: {
icon: "none",
name: "Health:", name: "Health:",
spoiler: "", spoiler: "",
masks: 5 masks: 5
}, },
soul: { soul: {
icon: "none",
name: "Soul:", name: "Soul:",
spoiler: "", spoiler: "",
amount: 99 amount: 99
}, },
notches: { notches: {
icon: "none",
name: "Notches:", name: "Notches:",
spoiler: "", spoiler: "",
amount: 3 amount: 3
}, },
geo: { geo: {
icon: "none",
name: "Geo:", name: "Geo:",
spoiler: "", spoiler: "",
amount: 0 amount: 0
@ -4967,19 +4973,54 @@ function SingleEntryFill(entry) {
var iconRed = SYMBOL_FALSE; var iconRed = SYMBOL_FALSE;
var iconClock = SYMBOL_CLOCK; var iconClock = SYMBOL_CLOCK;
var iconNull = SYMBOL_EMPTY; var iconNull = SYMBOL_EMPTY;
if (entry.hasOwnProperty("icon")) {
switch (entry.icon) {
case "clock":
icon = iconClock;
break;
case "green":
icon = iconGreen;
break;
case "red":
icon = iconRed;
break;
default:
icon = iconNull;
}
} else {
icon = iconNull;
}
var textPrefix = ""; var textPrefix = "";
var textSuffix = ""; var textSuffix = "";
var wiki = ""; var wiki = "";
if (entry.hasOwnProperty("name")) {
textPrefix = entry.name;
}
if (entry.hasOwnProperty("spoiler")) {
textSuffix = entry.spoiler;
}
if (entry.hasOwnProperty("wiki")) {
wiki = entry.wiki;
}
var b = ["<b>", "</b>"]; var b = ["<b>", "</b>"];
if (!textPrefix.length) b = ["", ""]; if (!textPrefix.length) b = ["", ""];
if (wiki.length) b = ["<a class=\"wiki\" href=\"".concat(WIKI_LINK).concat(wiki, "\" target=\"_blank\">"), "</a>"]; if (wiki.length) b = ["<a class=\"wiki\" href=\"".concat(WIKI_LINK).concat(wiki, "\" target=\"_blank\">"), "</a>"];
var p = ["<span class='p-left-small'>", "</span>"]; var p = "<span class='p-left-small'></span>";
var span = ["<span class='spoiler-span'>", "</span>"]; var span = ["<span class='spoiler-span'>", "</span>"];
var spoiler = ["<span class='spoiler-text'>", "</span>"]; // let dash = ""; var spoiler = ["<span class='spoiler-text'>", "</span>"]; // let dash = "";
if (textSuffix.length && textPrefix.length) textSuffix = "— " + textSuffix; if (textSuffix.length && textPrefix.length) textSuffix = "— " + textSuffix;
if (textPrefix.includes("<del>")) textSuffix = "<del>".concat(textSuffix, "</del>"); if (textPrefix.includes("<del>")) textSuffix = "<del>".concat(textSuffix, "</del>");
return "\n <div class=\"single-entry\">\n ".concat(icon, "\n ").concat(b[0], "\n </div>\n "); return "\n <div class=\"single-entry\">\n ".concat(icon, "\n ").concat(b[0]).concat(textPrefix).concat(b[1], "\n ").concat(span[0], "\n ").concat(p, "\n ").concat(spoiler[0], "\n ").concat(textSuffix, "\n ").concat(spoiler[1], "\n ").concat(span[1], "\n </div>\n ");
} }
/** /**
* Adds HTML string to an element with a given ID. * Adds HTML string to an element with a given ID.

File diff suppressed because one or more lines are too long

View file

@ -16,6 +16,7 @@ const HK = {
maxPercent: 112, maxPercent: 112,
entries: { entries: {
timePlayed: { timePlayed: {
icon: "clock",
name: "Time Played:", name: "Time Played:",
spoiler: "0 h 0 min 0 sec", spoiler: "0 h 0 min 0 sec",
timeH: 0, timeH: 0,
@ -28,25 +29,30 @@ const HK = {
text: "(out of 112 %)" text: "(out of 112 %)"
}, },
saveVersion: { saveVersion: {
icon: "none",
name: "Save Version:", name: "Save Version:",
spoiler: "0.0.0.0" spoiler: "0.0.0.0"
}, },
health: { health: {
icon: "none",
name: "Health:", name: "Health:",
spoiler: "", spoiler: "",
masks: 5 masks: 5
}, },
soul: { soul: {
icon: "none",
name: "Soul:", name: "Soul:",
spoiler: "", spoiler: "",
amount: 99 amount: 99
}, },
notches: { notches: {
icon: "none",
name: "Notches:", name: "Notches:",
spoiler: "", spoiler: "",
amount: 3 amount: 3
}, },
geo: { geo: {
icon: "none",
name: "Geo:", name: "Geo:",
spoiler: "", spoiler: "",
amount: 0 amount: 0

View file

@ -278,15 +278,47 @@ function SingleEntryFill(entry) {
let iconClock = SYMBOL_CLOCK; let iconClock = SYMBOL_CLOCK;
let iconNull = SYMBOL_EMPTY; let iconNull = SYMBOL_EMPTY;
if (entry.hasOwnProperty("icon")) {
switch (entry.icon) {
case "clock":
icon = iconClock;
break;
case "green":
icon = iconGreen;
break;
case "red":
icon = iconRed;
break;
default:
icon = iconNull;
}
} else {
icon = iconNull;
}
let textPrefix = ""; let textPrefix = "";
let textSuffix = ""; let textSuffix = "";
let wiki = ""; let wiki = "";
if (entry.hasOwnProperty("name")) {
textPrefix = entry.name;
}
if (entry.hasOwnProperty("spoiler")) {
textSuffix = entry.spoiler;
}
if (entry.hasOwnProperty("wiki")) {
wiki = entry.wiki;
}
let b = ["<b>", "</b>"]; let b = ["<b>", "</b>"];
if (!textPrefix.length) b = ["", ""]; if (!textPrefix.length) b = ["", ""];
if (wiki.length) b = [`<a class="wiki" href="${WIKI_LINK}${wiki}" target="_blank">`, "</a>"]; if (wiki.length) b = [`<a class="wiki" href="${WIKI_LINK}${wiki}" target="_blank">`, "</a>"];
let p = ["<span class='p-left-small'>", "</span>"]; let p = "<span class='p-left-small'></span>";
let span = ["<span class='spoiler-span'>", "</span>"]; let span = ["<span class='spoiler-span'>", "</span>"];
let spoiler = ["<span class='spoiler-text'>", "</span>"]; let spoiler = ["<span class='spoiler-text'>", "</span>"];
@ -297,7 +329,13 @@ function SingleEntryFill(entry) {
return ` return `
<div class="single-entry"> <div class="single-entry">
${icon} ${icon}
${b[0]} ${b[0]}${textPrefix}${b[1]}
${span[0]}
${p}
${spoiler[0]}
${textSuffix}
${spoiler[1]}
${span[1]}
</div> </div>
`; `;