add cleanHTML()

This commit is contained in:
ReznoRMichael 2020-08-26 00:57:59 +02:00
parent 80a4f10e70
commit e5fc0fa864
2 changed files with 16 additions and 14 deletions

View file

@ -203,9 +203,7 @@ function HKCheckCompletion(jsonObject) {
let countBegin = new Date();
// Pre-Cleaning all divs for safety
for (i in DIV_ID) {
document.getElementById(DIV_ID[i]).innerHTML = "";
}
cleanHTML(DIV_ID);
// Shallow Clone const objects (used for destructive functions)
let HK_BOSSES_temp = Object.assign({}, HK_BOSSES);
@ -328,6 +326,12 @@ function HKCheckCompletion(jsonObject) {
console.info("HKCheckCompletion() time (ms) =", countEnd - countBegin);
}
function cleanHTML(jsObj) {
for (i in jsObj) {
document.getElementById(jsObj[i]).innerHTML = "";
}
}
function fillHTML(divId = "", textPrefix = "Unknown Completion Element: ", textSuffix = "") {
document.getElementById(divId).innerHTML += divStart + completionSymbol + strongStart + textPrefix + "" + strongEnd + currentData + textSuffix + divEnd;
}

View file

@ -1,10 +1,11 @@
var jsonObj;
var jsonObj = "";
/**
* Reads the .json file and parses it to a JS object (jsonObj).
* @param callback Asynchronous function.
*/
function loadJSON(callback) {
jsonObj = "";
// new Http request object (asynchronous), both the web page and the XML file it tries to load, must be located on the same server.
var xobj = new XMLHttpRequest();
@ -41,19 +42,16 @@ loadJSON(
);
function HKReadTextArea() {
jsonObj = "";
cleanHTML(DIV_ID);
let textAreaId = "save-area";
let contents = document.getElementById(textAreaId).value;
if(contents.length > 0) {
jsonObj = contents;
loadJSON(
function JSONparse(response) {
// Parse JSON string into object
jsonObj = JSON.parse(response);
HKCheckCompletion(jsonObj);
// console.log(jsonObj);
}
);
jsonObj = JSON.parse(contents);
HKCheckCompletion(jsonObj);
// console.log(jsonObj);
}
}