diff --git a/scholia/app/static/scholia.js b/scholia/app/static/scholia.js
index e8fccffbb..9d4d633ee 100644
--- a/scholia/app/static/scholia.js
+++ b/scholia/app/static/scholia.js
@@ -539,14 +539,13 @@ function sparqlToShortInchiKey(sparql, key, element, filename) {
sparqlToDataTable2(new_sparql, element, filename);
}
-};
-function workWithQ(q) {
+function workWithQ(q,urlstatic) {
var url = 'https://www.wikidata.org/w/api.php?action=wbgetentities&ids=' +
q +
'&format=json&callback=?';
-
+
$.getJSON(url, function (data) {
var item = data.entities[q];
if ('en' in item.labels) {
@@ -557,14 +556,14 @@ function workWithQ(q) {
var detailsList = Array();
try {
var orcid = item.claims.P496[0].mainsnak.datavalue.value;
- detailsList.push( ' ' +
+ `` +
+ ' https://orcid.org/' + escapeHTML( orcid ) + '');
}
catch(e) {}
- try {s
+ try {
var mastodonAccount = item.claims.P4033[0].mainsnak.datavalue.value;
var mastodonComponents = mastodonAccount.split("@");
if (mastodonComponents.length == 2) {
@@ -618,8 +617,8 @@ function workWithQ(q) {
"@type" : "Person" ,
"http://purl.org/dc/terms/conformsTo": { "@type": "CreativeWork", "@id": "https://bioschemas.org/profiles/Person/0.2-DRAFT-2019_07_19/" },
"description" : "A person" ,
- "identifier" : "{{ q }}" ,
- "mainEntityOfPage" : "http://www.wikidata.org/entity/{{ q }}"
+ "identifier" : q ,
+ "mainEntityOfPage" : "http://www.wikidata.org/entity/" + q
}
if ('en' in item.labels) {
bioschemasAnnotation.name = item.labels.en.value;
@@ -634,8 +633,8 @@ function workWithQ(q) {
"@context" : "https://schema.org",
"@type" : "ChemicalSubstance" ,
"http://purl.org/dc/terms/conformsTo": { "@type": "CreativeWork", "@id": "https://bioschemas.org/profiles/ChemicalSubstance/0.4-RELEASE/" },
- "identifier" : "{{ q }}" ,
- "url" : "http://www.wikidata.org/entity/{{ q }}"
+ "identifier" : q,
+ "url" : "http://www.wikidata.org/entity/" + q
}
if ('en' in item.labels) {
bioschemasAnnotation.name = item.labels.en.value;
@@ -650,7 +649,7 @@ function workWithQ(q) {
"@type" : "Taxon" ,
"http://purl.org/dc/terms/conformsTo": { "@type": "CreativeWork", "@id": "https://bioschemas.org/profiles/Taxon/0.6-RELEASE/" },
"name" : taxonName ,
- "url" : "http://www.wikidata.org/entity/{{ q }}"
+ "url" : "http://www.wikidata.org/entity/" + q
}
if (item.claims.P105) {
var taxonRank = item.claims.P105[0].mainsnak.datavalue.value.id;
@@ -670,9 +669,9 @@ function workWithQ(q) {
"@context" : "https://schema.org",
"@type" : "MolecularEntity" ,
"http://purl.org/dc/terms/conformsTo": { "@type": "CreativeWork", "@id": "https://bioschemas.org/profiles/MolecularEntity/0.5-RELEASE/" },
- "identifier" : "{{ q }}" ,
+ "identifier" : q,
"inChIKey" : inchiKey ,
- "url" : "http://www.wikidata.org/entity/{{ q }}"
+ "url" : "http://www.wikidata.org/entity/" + q
}
if ('en' in item.labels) {
bioschemasAnnotation.name = item.labels.en.value;
@@ -702,8 +701,8 @@ function workWithQ(q) {
"@context" : "https://schema.org",
"@type" : "Protein" ,
"http://purl.org/dc/terms/conformsTo": { "@type": "CreativeWork", "@id": "https://bioschemas.org/profiles/Protein/0.11-RELEASE/" },
- "identifier" : "{{ q }}" ,
- "url" : "http://www.wikidata.org/entity/{{ q }}" ,
+ "identifier" : q ,
+ "url" : "http://www.wikidata.org/entity/" + q ,
"sameAs": "https://www.uniprot.org/uniprot/" + uniprot
}
if ('en' in item.labels) {
@@ -718,8 +717,8 @@ function workWithQ(q) {
"@context" : "https://schema.org",
"@type" : "Gene" ,
"http://purl.org/dc/terms/conformsTo": { "@type": "CreativeWork", "@id": "https://bioschemas.org/profiles/Gene/0.7-RELEASE/" },
- "identifier" : "{{ q }}" ,
- "url" : "http://www.wikidata.org/entity/{{ q }}"
+ "identifier" : q ,
+ "url" : "http://www.wikidata.org/entity/" + q
}
if ('en' in item.labels) {
bioschemasAnnotation.name = item.labels.en.value;
@@ -882,9 +881,11 @@ function wembedder(q) {
}
-function searchTerm(placeholder) {
+function searchTerm(placeholder, urlfor) {
let search_text = ""
+
+
$('#searchterm').select2({
allowClear: true,
placeholder: placeholder,
@@ -907,7 +908,7 @@ function searchTerm(placeholder) {
var results = [{id: -1, text: "Advanced search"}];
$.each(data.search, function (index, item) {
results.push({
- id: "{{ url_for('app.index') }}" + item.title,
+ id: urlfor + item.title,
text: item.label + " - " + item.description
});
});
diff --git a/scholia/app/templates/base.html b/scholia/app/templates/base.html
index 8b286c466..6cd6ad540 100644
--- a/scholia/app/templates/base.html
+++ b/scholia/app/templates/base.html
@@ -95,7 +95,7 @@
{% if q %}
- workWithQ("{{ q }}")
+ workWithQ("{{ q }}", urlstatic="{{ url_for('static',filename='') }}")
{% if q2 %}
workWithQ2("{{ q2 }}")
@@ -119,7 +119,8 @@
$(document).ready(function () {
searchTerm(placeholder=`{{
"Scientist, paper, topic, DOI, etc." if request.path.endswith("search") else "Search ..."
- }}`)
+ }}`,
+ urlfor="{{ url_for('app.index') }}")
// Add anchor links to all headings
var headers = document.querySelectorAll('h2[id], h3[id]')