10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-05 05:33:55 +01:00
QUESTDB_website/static/js/PubliData.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

class PubliData{
static async loadAsync(DOI){
const path = PubliData.GetPathForDOI(DOI)
var me = JSON.parse(await getTextFromFileUrlAsync(`${path}/metadata.json`))
Reflect.setPrototypeOf(me,PubliData.prototype)
return me
}
static async loadManyAsync(DOIs){
var data = []
for (const DOI of DOIs) {
if (DOI!=null) {
data.push(await PubliData.loadAsync(DOI))
}
}
return data
}
get Path(){
return PubliData.GetPathForDOI(this.DOI)
}
get PictureURL(){
return PubliData.GetPictureURLForDOI(this.DOI)
}
get AbstractURL(){
return PubliData.GetAbstractURLForDOI(this.DOI)
}
async getAbstractTextAsync(){
return await PubliData.getAbstractTexForDOIAsync(this.DOI)
}
static GetPathForDOI(DOI){
2020-11-25 01:59:56 +01:00
var site_url = "/"+window.location.pathname.split('/')[1];
2020-11-25 01:52:53 +01:00
return site_url + `/data/publis/${DOI.replaceAll(".","/")}`
}
static GetAbstractURLForDOI(DOI){
return `${PubliData.GetPathForDOI(DOI)}/abstract.html`
}
static GetPictureURLForDOI(DOI){
return `${PubliData.GetPathForDOI(DOI)}/picture.jpeg`
}
static async getAbstractTexForDOIAsync(DOI){
return await getTextFromFileUrlAsync(PubliData.GetAbstractURLForDOI(DOI))
}
2020-11-25 01:52:53 +01:00
}