mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-25 13:53:48 +01:00
Simplified code
This commit is contained in:
parent
8961e3e06a
commit
a77774882e
@ -1,30 +1,15 @@
|
|||||||
var fileCache = function () {
|
var fileCache = function () {
|
||||||
var json_url = "/data/database.json";
|
var json_url = "/data/database.json";
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
req.open("GET",json_url, true);
|
req.open("GET",json_url, false);
|
||||||
req.responseType = 'json';
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
req.onreadystatechange = function() {
|
|
||||||
if (req.readyState == 4) {
|
|
||||||
if (req.status == 200 || req.status==304) {//when a good response is given do this
|
|
||||||
resolve(req.response);
|
|
||||||
} else {
|
|
||||||
reject({
|
|
||||||
status: req.status,
|
|
||||||
statusText: req.statusText
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
req.send();
|
req.send();
|
||||||
});
|
return JSON.parse(req.responseText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_cache = fileCache();
|
_cache = fileCache();
|
||||||
async function getTextFromFileUrl(url,header={}) {
|
function getTextFromFileUrl(url,header={}) {
|
||||||
var cache = await _cache;
|
return _cache[url];
|
||||||
return cache[url];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user