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-07 11:08:18 +01:00
|
|
|
db.sets = ((myYaml.sets === undefined) ? new Map() : new Map(Object.entries(myYaml.sets)));
|
|
|
|
db.others = ((myYaml.others === undefined) ? [] : Array.from(myYaml.others));
|
2020-12-07 11:12:16 +01:00
|
|
|
db.reviews = ((myYaml.reviews === undefined) ? [] : 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
|
|
|
}
|