2018-06-13 20:07:24 +02:00
|
|
|
/**
|
|
|
|
* Function toggleHash toggles a specified location.hash value.
|
|
|
|
*
|
|
|
|
* @param {string} identifier ID to toggle.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
function toggleHash(identifier) {
|
|
|
|
if (window.location.hash == "#" + identifier) window.location.hash = "";
|
|
|
|
else window.location.hash = "#" + identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
|
|
|
|
let translations = {
|
|
|
|
"en" : {
|
2018-06-15 11:26:25 +02:00
|
|
|
"More" : "More",
|
|
|
|
"MoreAtMuseumDigital" : "museum-digital",
|
|
|
|
"ObjectAtMuseumDigital" : "Object entry at museum-digital",
|
2018-06-18 10:43:22 +02:00
|
|
|
"InstitutionAtMuseumDigital": "Institution at museum-digital",
|
|
|
|
"CollectionAtMuseumDigital" : "Collection at museum-digital",
|
|
|
|
"ExhibitionAtMuseumDigital" : "Exhibition at museum-digital",
|
|
|
|
"EventAtMuseumDigital" : "Event at museum-digital",
|
2018-06-15 11:26:25 +02:00
|
|
|
"Collection" : "Collection",
|
2018-06-18 10:43:22 +02:00
|
|
|
"Collections" : "Collections",
|
2018-06-15 11:26:25 +02:00
|
|
|
"object_material_technique" : "Material / Technique",
|
|
|
|
"object_dimensions" : "Dimensions",
|
|
|
|
"Metadata" : "Metadata",
|
|
|
|
"LastUpdated" : "Last Updated",
|
|
|
|
"Licence" : "Licence",
|
|
|
|
"Tags" : "Tags",
|
|
|
|
"People" : "People",
|
|
|
|
"Places" : "Places",
|
|
|
|
"Times" : "Times",
|
|
|
|
"Search" : "Search",
|
|
|
|
"SearchingFor" : "Searching for",
|
2018-06-15 13:31:31 +02:00
|
|
|
"Hits" : "Hits:",
|
|
|
|
"ResultsInPages" : "Results in texts",
|
2018-06-15 22:32:37 +02:00
|
|
|
"ResultsInObjects" : "Results in objects",
|
2018-06-15 11:26:25 +02:00
|
|
|
"... who" : "... who",
|
|
|
|
"... where" : "... where",
|
|
|
|
"... when" : "... when",
|
|
|
|
"eventType1" : "Created",
|
2018-06-13 20:07:24 +02:00
|
|
|
},
|
|
|
|
"de" : {
|
2018-06-15 11:26:25 +02:00
|
|
|
"More" : "Mehr",
|
|
|
|
"MoreAtMuseumDigital" : "museum-digital",
|
|
|
|
"ObjectAtMuseumDigital" : "Objekt bei museum-digital",
|
2018-06-18 10:43:22 +02:00
|
|
|
"InstitutionAtMuseumDigital": "Institution bei museum-digital",
|
|
|
|
"CollectionAtMuseumDigital" : "Sammlung bei museum-digital",
|
|
|
|
"ExhibitionAtMuseumDigital" : "Ausstellung bei museum-digital",
|
|
|
|
"EventAtMuseumDigital" : "Veranstaltung bei museum-digital",
|
2018-06-15 11:26:25 +02:00
|
|
|
"Collection" : "Sammlung",
|
2018-06-18 10:43:22 +02:00
|
|
|
"Collection" : "Sammlungen",
|
2018-06-15 11:26:25 +02:00
|
|
|
"object_material_technique" : "Material / Technik",
|
|
|
|
"object_dimensions" : "Ausmaße",
|
|
|
|
"Metadata" : "Metadaten",
|
|
|
|
"LastUpdated" : "Zuletzt geupdatet",
|
|
|
|
"Licence" : "Lizenz",
|
|
|
|
"Tags" : "Schlagworte",
|
|
|
|
"People" : "Personen",
|
|
|
|
"Places" : "Orte",
|
|
|
|
"Times" : "Zeiten",
|
|
|
|
"Search" : "Suche",
|
|
|
|
"SearchingFor" : "Suche nach",
|
2018-06-15 13:31:31 +02:00
|
|
|
"Hits" : "Treffer:",
|
|
|
|
"ResultsInPages" : "Treffer in Texten",
|
2018-06-15 22:32:37 +02:00
|
|
|
"ResultsInObjects" : "Treffer in Objekten",
|
2018-06-15 11:26:25 +02:00
|
|
|
"... who" : "... wer",
|
|
|
|
"... where" : "... wo",
|
|
|
|
"... when" : "... wann",
|
|
|
|
"eventType1" : "Hergestellt",
|
2018-06-13 20:07:24 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var debugging = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function queryPage queries a web page and runs the specified function over the output.
|
|
|
|
*
|
|
|
|
* @param string url URL to query.
|
|
|
|
* @param function func Callback function to run on the request after loading.
|
|
|
|
* @param boolean debug Enable / disable debug mode.
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
function queryPage (url, func, debug = false) {
|
|
|
|
|
|
|
|
let request = new XMLHttpRequest();
|
|
|
|
request.open('GET', url);
|
|
|
|
request.setRequestHeader("Cache-Control", "no-cache");
|
|
|
|
request.responseType = 'htm';
|
|
|
|
request.send();
|
|
|
|
request.onload = function() {
|
|
|
|
|
|
|
|
func(request, debug);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a requested translation from an array in the currently used language.
|
|
|
|
*
|
|
|
|
* @param mixed[] list Translation variable.
|
|
|
|
* @param string specifier Specifies which translation to get.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function getTranslation (list, specifier) {
|
|
|
|
|
|
|
|
let preferedLang = document.getElementsByTagName("html")[0].getAttribute("lang");
|
|
|
|
|
|
|
|
if (list[preferedLang] !== undefined && list[preferedLang][specifier] !== null) return list[preferedLang][specifier];
|
|
|
|
return list["en"][specifier];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to get all GET variables passed by user
|
|
|
|
* Based on gion_13's answer at https://stackoverflow.com/questions/12049620/how-to-get-get-variables-value-in-javascript
|
|
|
|
*
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
function getGETvars () {
|
|
|
|
|
|
|
|
var output = {};
|
|
|
|
if(document.location.toString().indexOf('?') !== -1) {
|
|
|
|
var query = document.location
|
|
|
|
.toString()
|
|
|
|
// get the query string
|
|
|
|
.replace(/^.*?\?/, '')
|
|
|
|
// and remove any existing hash string (thanks, @vrijdenker)
|
|
|
|
.replace(/#.*$/, '')
|
|
|
|
.split('&');
|
|
|
|
|
|
|
|
for(var i = 0, l = query.length; i < l; i++) {
|
|
|
|
var aux = decodeURIComponent(query[i]).split('=');
|
|
|
|
output[aux[0]] = aux[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (output);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the URL given in the href attribute of the element with the given ID.
|
|
|
|
*
|
|
|
|
* @param {string} identifier ID of the element with whose href to replace location.href
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
function replaceWindowById(identifier) {
|
|
|
|
|
|
|
|
var link = document.getElementById(identifier);
|
|
|
|
|
|
|
|
if (link != null) {
|
|
|
|
window.location.href = link.href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-15 23:41:25 +02:00
|
|
|
/**
|
|
|
|
* Set placeholder for all input element of type="search".
|
|
|
|
*/
|
|
|
|
(function() {
|
|
|
|
let toTranslate = document.getElementsByTagName("input");
|
|
|
|
for (let i = 0, max = toTranslate.length; i < max; i++) {
|
|
|
|
console.log(toTranslate[i].type);
|
|
|
|
if (toTranslate[i].type !== "search") continue;
|
|
|
|
toTranslate[i].placeholder = getTranslation(translations, "Search");
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2018-06-15 11:26:25 +02:00
|
|
|
(function() {
|
|
|
|
let toTranslate = document.getElementsByClassName("toTranslate");
|
|
|
|
for (let i = 0, max = toTranslate.length; i < max; i++) {
|
2018-06-15 23:41:25 +02:00
|
|
|
if (debugging === true) console.log(toTranslate[i].getAttribute("data-content"));
|
2018-06-15 11:26:25 +02:00
|
|
|
toTranslate[i].textContent = getTranslation(translations, toTranslate[i].getAttribute("data-content"));
|
|
|
|
}
|
|
|
|
})();
|
2018-06-13 20:07:24 +02:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|