mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-25 22:03:49 +01:00
Use Class.name for trueTypeOf
comparison and only constructor name
This commit is contained in:
parent
9cd212ab33
commit
923a9acb7f
@ -131,7 +131,7 @@ draft: false
|
|||||||
var td = $("<td/>", {
|
var td = $("<td/>", {
|
||||||
style: "white-space: nowrap;"
|
style: "white-space: nowrap;"
|
||||||
})
|
})
|
||||||
if (trueTypeOf(el) == "DOI") {
|
if (trueTypeOf(el) == DOI.name) {
|
||||||
var publi = doiCache.get(el.string)
|
var publi = doiCache.get(el.string)
|
||||||
$("<a/>", {
|
$("<a/>", {
|
||||||
href: el.url,
|
href: el.url,
|
||||||
@ -230,7 +230,7 @@ draft: false
|
|||||||
})
|
})
|
||||||
for (const el of tableels) {
|
for (const el of tableels) {
|
||||||
td=$(tdtemp).clone()
|
td=$(tdtemp).clone()
|
||||||
if (trueTypeOf(el) == "DOI") {
|
if (trueTypeOf(el) == DOI.name) {
|
||||||
var publi = doiCache.get(el.string)
|
var publi = doiCache.get(el.string)
|
||||||
$("<a/>", {
|
$("<a/>", {
|
||||||
href: el.url,
|
href: el.url,
|
||||||
|
@ -96,10 +96,10 @@ draft: false
|
|||||||
$(sec).empty()
|
$(sec).empty()
|
||||||
for (const element of md) {
|
for (const element of md) {
|
||||||
switch (trueTypeOf(element)) {
|
switch (trueTypeOf(element)) {
|
||||||
case "string":
|
case String.name:
|
||||||
$("<h2/>").text(element).appendTo(sec)
|
$("<h2/>").text(element).appendTo(sec)
|
||||||
break;
|
break;
|
||||||
case "DOI":
|
case DOI.name:
|
||||||
var publi = await Cite.async(element.string)
|
var publi = await Cite.async(element.string)
|
||||||
var output = publi.format('bibliography', {
|
var output = publi.format('bibliography', {
|
||||||
format: 'html',
|
format: 'html',
|
||||||
@ -111,14 +111,14 @@ draft: false
|
|||||||
target: "_blank"
|
target: "_blank"
|
||||||
}).html(output).appendTo(sec)
|
}).html(output).appendTo(sec)
|
||||||
break
|
break
|
||||||
case "websiteFile":
|
case websiteFile.name:
|
||||||
$("<a/>", {
|
$("<a/>", {
|
||||||
href: element.url,
|
href: element.url,
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
href: await element.getViewerURL()
|
href: await element.getViewerURL()
|
||||||
}).text("Go to file").appendTo(sec)
|
}).text("Go to file").appendTo(sec)
|
||||||
break
|
break
|
||||||
case "Array":
|
case Array.name:
|
||||||
k = element[0]
|
k = element[0]
|
||||||
v = element[1]
|
v = element[1]
|
||||||
k = k.charAt(0).toUpperCase() + k.slice(1)
|
k = k.charAt(0).toUpperCase() + k.slice(1)
|
||||||
|
@ -112,11 +112,11 @@ class dataFileBase {
|
|||||||
}
|
}
|
||||||
static async loadAsync(file) {
|
static async loadAsync(file) {
|
||||||
switch (trueTypeOf(file)) {
|
switch (trueTypeOf(file)) {
|
||||||
case "string":
|
case String.name:
|
||||||
file=getFullDataPath(file)
|
file=getFullDataPath(file)
|
||||||
var str=await getTextFromFileUrlAsync(file)
|
var str=await getTextFromFileUrlAsync(file)
|
||||||
break;
|
break;
|
||||||
case "File":
|
case File.name:
|
||||||
var str=await getTextFromUploadedFileAsync(file)
|
var str=await getTextFromUploadedFileAsync(file)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
function trueTypeOf(object){
|
function trueTypeOf(object){
|
||||||
result=typeof object
|
return object.constructor.name
|
||||||
if(result==typeof({})) {
|
|
||||||
result= object.constructor.name
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ class websiteFile{
|
|||||||
var params=new URLSearchParams()
|
var params=new URLSearchParams()
|
||||||
var urlbase="/view"
|
var urlbase="/view"
|
||||||
switch (trueTypeOf(this.file)) {
|
switch (trueTypeOf(this.file)) {
|
||||||
case "string":
|
case String.name:
|
||||||
params.append("file",this.file)
|
params.append("file",this.file)
|
||||||
break
|
break
|
||||||
case "File":
|
case File.name:
|
||||||
var base64=btoa(await getTextFromUploadedFileAsync(this.file))
|
var base64=btoa(await getTextFromUploadedFileAsync(this.file))
|
||||||
params.append("fileBase64",base64);
|
params.append("fileBase64",base64);
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user