2020-11-24 19:21:58 +01:00
|
|
|
class indexDB {
|
|
|
|
static async loadAsync() {
|
|
|
|
if (window.indexDB) {
|
|
|
|
return window.indexDB
|
|
|
|
}
|
|
|
|
var db = new indexDB
|
|
|
|
const maxAge= (DebugMode.Enabled,0,600)
|
2020-11-25 01:55:18 +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-11-24 19:21:58 +01:00
|
|
|
const myYaml = jsyaml.load(text);
|
2020-12-08 15:05:44 +01:00
|
|
|
db.sets = ((myYaml.sets == null) ? new Map() : new Map(Object.entries(myYaml.sets)));
|
|
|
|
db.others = ((myYaml.others == null) ? [] : Array.from(myYaml.others));
|
|
|
|
db.reviews = ((myYaml.reviews == null) ? [] : Array.from(myYaml.reviews));
|
2020-11-24 19:21:58 +01:00
|
|
|
window.indexDB=db
|
|
|
|
return db
|
|
|
|
}
|
2020-11-25 01:55:18 +01:00
|
|
|
}
|