catch read save area errors

This commit is contained in:
ReznoRMichael 2021-01-31 01:15:14 +01:00
parent 301e0ac32e
commit f38501acb7
6 changed files with 18 additions and 12 deletions

File diff suppressed because one or more lines are too long

View file

@ -76,7 +76,7 @@
<div class="input-buttons">
<!-- <button id="save-area-file" class="button" onclick="">Load Save</button> -->
<!-- <input id="save-area-file" class="" type="file" name="file" accept=".dat,.bak*" onchange="LoadSaveFile(this)"> -->
<button id="save-area-read" class="button" onclick="HKReadTextArea();">Analyze Text</button>
<button id="save-area-read" class="button" onclick="HKReadTextArea('save-area');">Analyze Text</button>
</div>
<div class="checkboxes">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View file

@ -76,7 +76,7 @@
<div class="input-buttons">
<!-- <button id="save-area-file" class="button" onclick="">Load Save</button> -->
<!-- <input id="save-area-file" class="" type="file" name="file" accept=".dat,.bak*" onchange="LoadSaveFile(this)"> -->
<button id="save-area-read" class="button" onclick="HKReadTextArea();">Analyze Text</button>
<button id="save-area-read" class="button" onclick="HKReadTextArea('save-area');">Analyze Text</button>
</div>
<div class="checkboxes">

View file

@ -826,18 +826,24 @@ function CheckHintsTrue(divId, dataObject, playerData, worldData) {
/**
* Pre-Cleans HTML. Reads contents inside text area and parses it to a JavaScript object. If not empty, runs HKCheckCompletion() to check data.
*/
function HKReadTextArea() {
function HKReadTextArea(textAreaId = "") {
// refresh and prepare document for filling with data from the save
InitialHTMLPopulate(HK.DIV_ID);
let textAreaId = "save-area";
let contents = document.getElementById(textAreaId).value;
if (contents.length) {
let jsonObject = JSON.parse(contents);
// console.log(jsonObject);
if (jsonObject.hasOwnProperty("playerData")) HKCheckCompletion(jsonObject);
// console.log(jsonObject);
try {
let jsonObject = JSON.parse(contents);
// console.log(jsonObject);
if (jsonObject.hasOwnProperty("playerData")) HKCheckCompletion(jsonObject);
// console.log(jsonObject);
} catch (error) {
alert(`This seems like not a valid Hollow Knight save. ${error}`);
console.info(`This seems like not a valid Hollow Knight save. ${error}`);
}
}
}

View file

@ -97,7 +97,7 @@ function ProcessFileObject() {
console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin);
// after pasting the decoded string, launch the main analyzing function immediately
HKReadTextArea();
HKReadTextArea("save-area");
// finish total and show benchmark
benchTotal = new Date();