From 01f2e6734b1532b645bc51dd0ea576798c9d46d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Thu, 5 Sep 2019 11:31:38 +0200 Subject: [PATCH] Fix bugs introduced in the last two commit --- content/pages/index.html | 4 ++-- content/scripts/data.js | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/content/pages/index.html b/content/pages/index.html index 97d80c22..c850c4ef 100644 --- a/content/pages/index.html +++ b/content/pages/index.html @@ -17,7 +17,7 @@ var file=filename+'.dat'; var lnk_file=document.getElementById('lnk_file'); lnk_file.setAttribute('href',getFullDataPath(file)); - dat= await data.loadAsnyc(file); + dat= await data.loadAsync(file); await applyData(dat); } async function applyData(dat) { @@ -71,7 +71,7 @@

Go to file diff --git a/content/scripts/data.js b/content/scripts/data.js index 031f1d52..7416a3f8 100644 --- a/content/scripts/data.js +++ b/content/scripts/data.js @@ -70,21 +70,23 @@ class data { this.doi=null; this.excitations=[]; } - static async loadAsync(file) { - return new Promise(function (resolve, reject) { - var req = new XMLHttpRequest(); - req.open("GET",getFullDataPath(file), true); - req.onreadystatechange = function() { - if (req.readyState == 4 && req.status == 200) {//when a good response is given do this + static async loadAsync(file) { + return new Promise(function (resolve, reject) { + var req = new XMLHttpRequest(); + req.open("GET",getFullDataPath(file), true); + req.onreadystatechange = function() { + if (req.readyState == 4) { + if (req.status == 200) {//when a good response is given do this var text = req.responseText; - resolve(data.loadString(text)) + resolve(data.loadString(text)); } else { reject({ status: req.status, statusText: req.statusText }); } - }; + } + } req.send(); }); }