From 3493f0bcc3eb0426b26d448c5ce8bc7d99327d00 Mon Sep 17 00:00:00 2001 From: ReznoRMichael Date: Fri, 28 Aug 2020 22:19:18 +0200 Subject: [PATCH] readme.md --- .gitignore | 6 +----- HKCheckCompletion.js | 6 ++++-- README => README.md | 0 loadJson.js | 9 ++++----- 4 files changed, 9 insertions(+), 12 deletions(-) rename README => README.md (100%) diff --git a/.gitignore b/.gitignore index 572bf73..ceefa46 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,4 @@ fontello-7bf7a0b6/ css/ font/ images/ -plain.json -reznor88banish.json -reznor112grimm.json -reznor100.json -reznor0.json \ No newline at end of file +save/ \ No newline at end of file diff --git a/HKCheckCompletion.js b/HKCheckCompletion.js index 5153d9b..d0b210b 100644 --- a/HKCheckCompletion.js +++ b/HKCheckCompletion.js @@ -239,6 +239,8 @@ function HKCheckCompletion(jsonObject) { fillHTML(DIV_ID.intro, "Hollow Knight Completion: ", " %"); } + // ---------------- Time Played ----------------- // + if (i === "playTime") { let seconds = Math.floor(HKPlayerData.playTime); let minutes = Math.floor((seconds / 60) % 60); @@ -247,7 +249,7 @@ function HKCheckCompletion(jsonObject) { if (sec <= 10) sec = "0" + sec; if (minutes <= 10) minutes = "0" + minutes; currentDataTrue(); - fillHTML(DIV_ID.intro, "Time Played: " + hours + "h " + minutes + "min " + sec + "sec"); + fillHTML(DIV_ID.intro, "Time Played: " + hours + " h " + minutes + " min " + sec + " sec"); } // ---------------- Bosses (Base Game) --------------------- // @@ -395,7 +397,7 @@ function HKReadTextArea() { let textAreaId = "save-area"; let contents = document.getElementById(textAreaId).value; - if(contents.length) { + if (contents.length) { let jsonObject = JSON.parse(contents); HKCheckCompletion(jsonObject); // console.log(jsonObject); diff --git a/README b/README.md similarity index 100% rename from README rename to README.md diff --git a/loadJson.js b/loadJson.js index 5259734..36458bc 100644 --- a/loadJson.js +++ b/loadJson.js @@ -1,24 +1,23 @@ var jsonObj = ""; +var fileName = ["save/reznor88banish.json", "save/reznor112grimm.json", "save/reznor100.json", "save/reznor0.json"]; /** * Reads the .json file and parses it to a JS object (jsonObj). * @param callback Asynchronous function. */ -function loadJSON(callback) { +function loadJSON(filename, callback) { // 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(); xobj.overrideMimeType("application/json"); - let fileName = ["reznor88banish.json", "reznor112grimm.json", "reznor100.json", "reznor0.json"]; - // Specifies the request /* method: the request type GET or POST url: the file location async: true (asynchronous) or false (synchronous) user: optional user name psw: optional password */ - xobj.open('GET', fileName[1], true); // Path to the file + xobj.open('GET', filename, true); // Path to the file // Defines a function to be called when the readyState property changes xobj.onreadystatechange = function GetResponseText() { @@ -32,7 +31,7 @@ function loadJSON(callback) { xobj.send(null); } -loadJSON( +loadJSON(fileName[3], function JSONparse(response) { // Parse JSON string into object jsonObj = JSON.parse(response);