10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-26 14:23:42 +01:00
QUESTDB_website/static/js/indexDB.js

17 lines
599 B
JavaScript
Raw Normal View History

2020-09-20 17:53:58 +02:00
class indexDB {
static async loadAsync() {
if (window.indexDB) {
return window.indexDB
}
2020-09-20 17:53:58 +02:00
var db = new indexDB
const maxAge= (DebugMode.Enabled,0,600)
2020-11-25 01:52:53 +01:00
var site_url = "/"+window.location.pathname.split('/')[1];
const text = await getTextFromFileUrlAsync(site_url+"/data/index.yaml",{"Cache-Control":`max-age=${maxAge}`})
2020-09-20 17:53:58 +02:00
const myYaml = jsyaml.load(text);
db.sets = ((myYaml.sets === null) ? new Map() : new Map(Object.entries(myYaml.sets)));
db.others = ((myYaml.others === null) ? [] : Array.from(myYaml.others));
window.indexDB=db
2020-09-20 17:53:58 +02:00
return db
}
2020-11-25 01:52:53 +01:00
}