From 3505984d12b7a4d7113b6486eaca652fbe9833cb Mon Sep 17 00:00:00 2001 From: ReznoRMichael Date: Sat, 22 Aug 2020 17:41:39 +0200 Subject: [PATCH] initial commit --- .gitignore | 1 + HKCheckCompletion.js | 29 ++++++++++++++++++++++ index.html | 57 ++++++++++++++++++++++++++++++++++++++++++++ loadJson.js | 39 ++++++++++++++++++++++++++++++ style.css | 37 ++++++++++++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 .gitignore create mode 100644 HKCheckCompletion.js create mode 100644 index.html create mode 100644 loadJson.js create mode 100644 style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48ff423 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plain.json \ No newline at end of file diff --git a/HKCheckCompletion.js b/HKCheckCompletion.js new file mode 100644 index 0000000..242d500 --- /dev/null +++ b/HKCheckCompletion.js @@ -0,0 +1,29 @@ +function HKCheckCompletion(jsonObject) { + console.log("Script Run"); + + let HKPlayerData = jsonObject.playerData; + let symbolTrue = "✅"; + let symbolFalse = "❌"; + + let divStart = [ + "
" + ].join("\n"); + + let divEnd = [ + "
" + ].join("\n"); + + for(i in HKPlayerData) { + let completedCheck = symbolFalse; + + if(i === "completionPercentage") { + if(HKPlayerData.completionPercentage >= 112) completedCheck = symbolTrue; + document.getElementById("hk-intro").innerHTML += divStart + completedCheck + " Hollow Knight Completion: " + HKPlayerData.completionPercentage + " %" + divEnd; + } + + if(i === "mawlekDefeated") { + if(HKPlayerData.mawlekDefeated === true) completedCheck = symbolTrue; + document.getElementById("hk-bosses").innerHTML += divStart + completedCheck + " Brooding Mawlek: " + HKPlayerData.mawlekDefeated + divEnd; + } + } +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..7c72720 --- /dev/null +++ b/index.html @@ -0,0 +1,57 @@ + + + + + + + + Hollow Knight Completion % + + + + + + + + + + + + + + + + + + + + + + + + +

Hollow Knight Completion %

+ +

Check what you have left for completion.

+ +
+ + + +
+ +
+
+ +
+
Bosses:
+
+ + + \ No newline at end of file diff --git a/loadJson.js b/loadJson.js new file mode 100644 index 0000000..6feb078 --- /dev/null +++ b/loadJson.js @@ -0,0 +1,39 @@ +var jsonObj; + +/** + * Reads the .json file and parses it to a JS object (jsonObj). + * @param callback Asynchronous function. + */ +function loadJSON( 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" ); + + // 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', 'plain.json', true ); // Path to the file + + // Defines a function to be called when the readyState property changes + xobj.onreadystatechange = function GetResponseText() { + if( xobj.readyState == 4 && xobj.status == "200" ) { + // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode + // Returns the response data as a string + callback( xobj.responseText ); + } + }; + // Sends the request to the server - Used for GET requests + xobj.send( null ); +} + +loadJSON( + function JSONparse( response ) { + // Parse JSON string into object + jsonObj = JSON.parse( response ); + console.log( jsonObj ); + } +); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..2b82fcd --- /dev/null +++ b/style.css @@ -0,0 +1,37 @@ +body { + font-family: Arial, Helvetica, sans-serif; + font-size: 15px; +} +p { + margin-top: 10px; + margin-bottom: 10px; +} +.horizontal-line { + padding-bottom: 1px; + background: linear-gradient(90deg, #e9e9e9 0%, #FFFFFF 75%); +} +.smalltext { + font-size: 0.75em; +} +.entryNo { + color: #d1d1d1; +} +.changelog { + margin-top: 0px; + padding-inline-start: 30px; +} +.date { + font-size: 0.75em; + color: #737373; + margin-left: 1em; +} +a, +a:active, +a:visited { + color: black; + font-weight: bold; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} \ No newline at end of file