global variables

This commit is contained in:
ReznoRMichael 2021-01-25 04:01:08 +01:00
parent e854f85962
commit b7f4e90139
5 changed files with 23 additions and 28 deletions

File diff suppressed because one or more lines are too long

View file

@ -49,7 +49,7 @@
<div class="buttons centered">
<div class="input-buttons">
<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);">
</div>
</div>

View file

@ -49,7 +49,7 @@
<div class="buttons centered">
<div class="input-buttons">
<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);">
</div>
</div>

View file

@ -1,4 +1,3 @@
/* global bench */
/* eslint-disable no-unused-vars */
/* eslint-disable no-prototype-builtins */
@ -35,6 +34,8 @@ let divEnd = [
let pSpan = "<span class='p-left-small'></span>";
let benchHKCCBegin, benchHKCCEnd;
// ---------------- Hollow Knight Data Constant Objects ----------------- //
const DIV_ID = {
@ -469,7 +470,7 @@ const HK_STATISTICS = {
function HKCheckCompletion(jsonObject) {
// start benchmark
bench.begin.HKCC = new Date();
benchHKCCBegin = new Date();
let HKPlayerData;
let HKWorldItems;
@ -659,8 +660,8 @@ function HKCheckCompletion(jsonObject) {
CompletionHTML(DIV_ID);
// finish and show benchmark
bench.end.HKCC = new Date();
console.info("HKCheckCompletion() time (ms) =", bench.end.HKCC - bench.begin.HKCC);
benchHKCCEnd = new Date();
console.info("HKCheckCompletion() time (ms) =", benchHKCCEnd - benchHKCCBegin);
return true;
}
@ -1200,7 +1201,7 @@ 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() {
window.HKReadTextArea = function HKReadTextArea() {
InitialHTMLPopulate(DIV_ID);
let textAreaId = "save-area";
@ -1378,4 +1379,6 @@ function ResetCompletion(jsObj) {
}
}
document.addEventListener("DOMContentLoaded", InitialHTMLPopulate(DIV_ID));
document.addEventListener("DOMContentLoaded", InitialHTMLPopulate(DIV_ID));
// document.getElementById("save-area-read").addEventListener("onclick", HKReadTextArea());

View file

@ -19,17 +19,7 @@ const ECB_STREAM_CIPHER = new aesjs.ModeOfOperation.ecb(AES_KEY); // create a ne
// ---------------- Variables ----------------- //
let bench = {
begin: {
LSF: 0,
HKCC: 0,
},
end: {
LSF: 0,
HKCC: 0,
total: 0,
}
};
let benchLSFBegin, benchLSFEnd, benchTotal;
// ---------------- Functions ----------------- //
@ -39,14 +29,14 @@ let bench = {
* @param {FileList} input FileList object containing a list of File objects. The FileList behaves like an array, so you can check its length property to get the number of selected files.
*/
// eslint-disable-next-line no-unused-vars
function LoadSaveFile(input, startTime = new Date()) {
window.LoadSaveFile = function LoadSaveFile(input, startTime = new Date()) {
// console.info("Input length: " + input.files.length)
// Cease further processing if user canceled the file input dialog
if (input.files.length < 1) return false;
// start benchmark
bench.begin.LSF = startTime;
benchLSFBegin = startTime;
// Prepares a File object from the first file of the input files for reading as an Array Buffer
let inputFileObject = input.files[0];
@ -102,15 +92,15 @@ function ProcessFileObject() {
document.getElementById("save-area").value = decodedString;
// finish and show benchmark
bench.end.LSF = new Date();
console.info("LoadSaveFile() time (ms) =", bench.end.LSF - bench.begin.LSF);
benchLSFEnd = new Date();
console.info("LoadSaveFile() time (ms) =", benchLSFEnd - benchLSFBegin);
// after pasting the decoded string, launch the main analyzing function immediately
HKReadTextArea();
// finish total and show benchmark
bench.end.total = new Date();
console.info("Total time (ms) =", bench.end.total - bench.begin.LSF);
benchTotal = new Date();
console.info("Total time (ms) =", benchTotal - benchLSFBegin);
// alert(`Decoded String: ${decodedString}`);
// alert(`Array Buffer: ${inputArrayBuffer}`);
@ -191,4 +181,6 @@ function Base64Decode(buffer) {
function AESDecryption(buffer, cipherObject = ECB_STREAM_CIPHER) {
let output = cipherObject.decrypt(buffer);
return output.subarray(0, -output[output.length - 1]);
}
}
// document.getElementById("save-area-file").addEventListener("onchange", LoadSaveFile(this));