10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-26 06:14:38 +01:00
QUESTDB_website/static/js/indexDB.js
mveril 563726c954
Proposition of a new references page (#5)
* Fix broken link

* Fix bug in indexDB

* Proposition of a new references page

Co-authored-by: Mickaël Véril <mveril@irsamc.ups-tlse.fr>
2020-12-07 11:11:09 +01:00

18 lines
694 B
JavaScript

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