catch read save area errors
This commit is contained in:
parent
301e0ac32e
commit
f38501acb7
6 changed files with 18 additions and 12 deletions
File diff suppressed because one or more lines are too long
|
|
@ -76,7 +76,7 @@
|
||||||
<div class="input-buttons">
|
<div class="input-buttons">
|
||||||
<!-- <button id="save-area-file" class="button" onclick="">Load Save</button> -->
|
<!-- <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)"> -->
|
<!-- <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>
|
||||||
|
|
||||||
<div class="checkboxes">
|
<div class="checkboxes">
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 6.1 KiB |
|
|
@ -76,7 +76,7 @@
|
||||||
<div class="input-buttons">
|
<div class="input-buttons">
|
||||||
<!-- <button id="save-area-file" class="button" onclick="">Load Save</button> -->
|
<!-- <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)"> -->
|
<!-- <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>
|
||||||
|
|
||||||
<div class="checkboxes">
|
<div class="checkboxes">
|
||||||
|
|
|
||||||
|
|
@ -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.
|
* 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);
|
InitialHTMLPopulate(HK.DIV_ID);
|
||||||
|
|
||||||
let textAreaId = "save-area";
|
|
||||||
let contents = document.getElementById(textAreaId).value;
|
let contents = document.getElementById(textAreaId).value;
|
||||||
|
|
||||||
if (contents.length) {
|
if (contents.length) {
|
||||||
|
|
||||||
|
try {
|
||||||
let jsonObject = JSON.parse(contents);
|
let jsonObject = JSON.parse(contents);
|
||||||
// console.log(jsonObject);
|
// console.log(jsonObject);
|
||||||
if (jsonObject.hasOwnProperty("playerData")) HKCheckCompletion(jsonObject);
|
if (jsonObject.hasOwnProperty("playerData")) HKCheckCompletion(jsonObject);
|
||||||
// console.log(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}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ function ProcessFileObject() {
|
||||||
console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin);
|
console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin);
|
||||||
|
|
||||||
// after pasting the decoded string, launch the main analyzing function immediately
|
// after pasting the decoded string, launch the main analyzing function immediately
|
||||||
HKReadTextArea();
|
HKReadTextArea("save-area");
|
||||||
|
|
||||||
// finish total and show benchmark
|
// finish total and show benchmark
|
||||||
benchTotal = new Date();
|
benchTotal = new Date();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue