|
@@ -1,120 +0,0 @@
|
|
|
-
|
|
|
-// Oggetto che raccoglie le info necessarie per la pagina
|
|
|
-pageInfo = {};
|
|
|
-
|
|
|
-// Inizializzazione della pagina
|
|
|
-initPage();
|
|
|
-
|
|
|
-
|
|
|
-// Def. funzione di inizializzazione
|
|
|
-async function initPage(){
|
|
|
- pageInfo = await getPageInfo();
|
|
|
- updatePage();
|
|
|
-}
|
|
|
-
|
|
|
-// Esegue le queries, restituisce un oggetto con tutte le info per completare la pagina
|
|
|
-async function getPageInfo(){
|
|
|
- var out = {};
|
|
|
-
|
|
|
- try{
|
|
|
- out.query1 = await doJsonQuery(query1, true);
|
|
|
- out.titolo = await doJsonQuery(queryTitolo, true);
|
|
|
- out.segnatura = await doJsonQuery(querySegnatura, true);
|
|
|
- out.areaLinguistica = await doJsonQuery(queryAreaLinguistica, true);
|
|
|
- out.descrizione = await doJsonQuery(queryDescrizione, true);
|
|
|
- out.testo = await doJsonQuery(queryTestoLemmatizzato, true);
|
|
|
- out.edizione = await doJsonQuery(queryEdizione, true);
|
|
|
- out.toponimi = await doJsonQuery(queryToponimi);
|
|
|
- out.antroponimi = await doJsonQuery(queryAntroponimi);
|
|
|
-
|
|
|
- // out.tipo = await doJsonQuery(queryTipo);
|
|
|
- // out.siglaOVI = await doJsonQuery(querySiglaOVI);
|
|
|
- // out.raccolta = await doJsonQuery(queryRaccolta);
|
|
|
- } catch(err){
|
|
|
- console.log(err);
|
|
|
- }
|
|
|
-
|
|
|
- console.log('out', out)
|
|
|
- return out;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// Aggiorna la pagina usando l'oggetto-info passato come parametro
|
|
|
-function updatePage(){
|
|
|
-
|
|
|
- if(pageInfo.titolo) document.getElementById("title").innerHTML = pageInfo.titolo.titolo.value;
|
|
|
- if(pageInfo.query1){
|
|
|
- document.getElementById("mittente_id").innerHTML = pageInfo.query1.mittente.value;
|
|
|
- document.getElementById("mittente_btn").innerHTML = createButton("fa fa-user", "Scheda persona", "schedaPersona('PERS')".replace("PERS", pageInfo.query1.mittente.value));
|
|
|
- }
|
|
|
- if(pageInfo.query1){
|
|
|
- document.getElementById("destinatario_id").innerHTML = pageInfo.query1.destinatario.value;
|
|
|
- document.getElementById("destinatario_btn").innerHTML = createButton("fa fa-user", "Scheda persona", "schedaPersona('PERS')".replace("PERS", pageInfo.query1.destinatario.value));
|
|
|
- }
|
|
|
- if(pageInfo.query1){
|
|
|
- document.getElementById("luogo_partenza_id").innerHTML = pageInfo.query1.luogo_partenza.value;
|
|
|
- document.getElementById("luogo_partenza_btn").innerHTML = createButton("fa fa-map", "Vedi mappa", "schedaMappa('LUOGO')".replace("LUOGO", pageInfo.query1.luogo_partenza.value));
|
|
|
- }
|
|
|
- if(pageInfo.query1){
|
|
|
- document.getElementById("luogo_arrivo_id").innerHTML = pageInfo.query1.luogo_arrivo.value;
|
|
|
- document.getElementById("luogo_arrivo_btn").innerHTML = createButton("fa fa-map", "Vedi mappa", "schedaMappa('LUOGO')".replace("LUOGO", pageInfo.query1.luogo_arrivo.value));
|
|
|
- }
|
|
|
- if(pageInfo.query1) document.getElementById("data_partenza_id").innerHTML = pageInfo.query1.data_partenza.value;
|
|
|
- if(pageInfo.query1) document.getElementById("data_arrivo_id").innerHTML = pageInfo.query1.data_arrivo.value;
|
|
|
- if(pageInfo.descrizione) document.getElementById("descrizione_id").innerHTML = pageInfo.descrizione.descrizione.value;
|
|
|
- if(pageInfo.areaLinguistica) document.getElementById("lingua_id").innerHTML = pageInfo.areaLinguistica.lingua.value;
|
|
|
- if(pageInfo.areaLinguistica) document.getElementById("area_linguistica_id").innerHTML = pageInfo.areaLinguistica.area_linguistica.value;
|
|
|
- if(pageInfo.segnatura){
|
|
|
- document.getElementById("segnatura_id").innerHTML = pageInfo.segnatura.segnatura_OVI.value;
|
|
|
- document.getElementById("segnatura_btn").innerHTML = createButton("fa fa-link", "Link ASPO", "schedaASPO('SEGN')".replace("SEGN", thisUrlParams.link));
|
|
|
- }
|
|
|
- if(pageInfo.edizione){
|
|
|
- document.getElementById("edizione_id").innerHTML = pageInfo.edizione.edizione.value;
|
|
|
- document.getElementById("edizione_btn").innerHTML = createButton("fa fa-comments", "Cita Edizione", "schedaEdizione('EDIZ')".replace("EDIZ", pageInfo.edizione.edizione.value));
|
|
|
- }
|
|
|
- if(pageInfo.testo) document.getElementById("trascrizione_id").innerHTML = pageInfo.testo.testo_lemmatizzato.value;
|
|
|
- //
|
|
|
- if(pageInfo.antroponimi && pageInfo.antroponimi.length){
|
|
|
- const listaAntroponimi = pageInfo.antroponimi.map(elem => elem.antroponimo.value);
|
|
|
- document.getElementById("antroponimi").innerHTML = formatListAsLi(listaAntroponimi);
|
|
|
- }
|
|
|
- if(pageInfo.toponimi && pageInfo.toponimi.length){
|
|
|
- const listaToponimi = pageInfo.toponimi.map(elem => elem.toponimo.value);
|
|
|
- document.getElementById("toponimi").innerHTML = formatListAsLi(listaToponimi);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// Mini-utility per formattare liste
|
|
|
-function formatListAsLi(thisList){
|
|
|
- toRet = "";
|
|
|
- thisList.forEach(value => toRet += "<li>" + value + "</li>");
|
|
|
- return toRet;
|
|
|
-}
|
|
|
-
|
|
|
-// Buttons
|
|
|
-function createButton(buttonClass, text, onClickFunction){
|
|
|
- htmlCode = '\
|
|
|
- <button class="btn btn-default" type="button" onclick="<FUNCTION>">\
|
|
|
- <i class="<CLASS>" aria-hidden="true">\
|
|
|
- <p class="btn-text"><TEXT></p>\
|
|
|
- </i>\
|
|
|
- </button>\
|
|
|
- '.replace("<CLASS>", buttonClass).replace("<TEXT>", text).replace("<FUNCTION>", onClickFunction);
|
|
|
- return htmlCode;
|
|
|
-}
|
|
|
-
|
|
|
-function schedaPersona(info){
|
|
|
- alert("Hi! I've been clicked.\n I've been passed: '" + info + "' as a paramater");
|
|
|
-}
|
|
|
-
|
|
|
-function schedaMappa(info){
|
|
|
- alert("Hi! I've been clicked.\n I've been passed: '" + info + "' as a paramater");
|
|
|
-}
|
|
|
-
|
|
|
-function schedaASPO(info){
|
|
|
- window.open(info);
|
|
|
-}
|
|
|
-
|
|
|
-function schedaEdizione(info){
|
|
|
- alert("Hi! I've been clicked.\n I've been passed: '" + info + "' as a paramater");
|
|
|
-}
|