var Parole = ""; let mmoQueries = 0; let infQueries = 0; let perQueries = 0; let lgQueries = 0; $(document).ready(function () { //####################################### populateOption(); var search_name = ""; var Label = ""; var object_Label = ""; var id_label = ""; var name_per = ""; var note_per = ""; var occupation_per = ""; var place_search = ""; var testo = ""; $('#ClipArt1').on("click", function () { $('#Man-Made_Object').text(""); $('#n_mmo').text("0"); $('#Information_Object').text(""); $('#n_io').text("0"); $('#Person').text(""); $('#n_ps').text("0"); $('#Place').text(""); $('#n_pl').text("0"); testo = $('input#TextArea1').val(); Parole = testo; //questo era il contenuto di results_retrieveData() mmoQueries = 0; infQueries = 0; perQueries = 0; lgQueries = 0; $("#mmoLoader").css("display", "block"); $("#infLoader").css("display", "block"); $("#perLoader").css("display", "block"); $("#lgLoader").css("display", "block"); $('#wb_Image1').text(""); $('.results').css("display", "none"); next_text = testo.split(" "); search_name = "\"'" + next_text[0] + "'"; if (next_text.length > 1) { for (var i=1; i', search_graph).replace('<{WORD}>', Label); var query2 = pref + (queryManager['queryMMO']['queryArte']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', Label); var query3 = pref + (queryManager['queryMMO']['queryIdentificatore']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', testo); var query4 = pref + (queryManager['queryINF']['queryContenuti1']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label); var query5 = pref + (queryManager['queryINF']['queryContenuti2']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label); var query6 = pref + (queryManager['queryINF']['queryContenuti3']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label); var query7 = pref + (queryManager['queryPER']['queryNome']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', name_per); var query8 = pref + (queryManager['queryPER']['queryNote']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', note_per); var query9 = pref + (queryManager['queryPER']['queryOccupazione']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', occupation_per); var query10 = pref + (queryManager['queryLG']['queryLuoghi']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', place_search); // la funzione doJsonQuery restituisce direttamente l'oggetto della chiamata ajax in json. // Una volta effettuata la chiamata, il risultato è passato alla funzione manage... doJsonQuery(query1).done(function(r) { manageMMO(r); }); doJsonQuery(query2).done(function(r) { manageMMO(r); }); doJsonQuery(query3).done(function(r) { manageMMO(r); }); doJsonQuery(query4).done(function(r) { manageINF(r); }); doJsonQuery(query5).done(function(r) { manageINF(r); }); doJsonQuery(query6).done(function(r) { manageINF(r); }); doJsonQuery(query7).done(function(r) { managePER(r); }); doJsonQuery(query8).done(function(r) { managePER(r); }); doJsonQuery(query9).done(function(r) { managePER(r); }); doJsonQuery(query10).done(function(r) { manageLG(r); }); }); $('input#TextArea1').keypress(function(e) { var key = e.which; if (key == 13) // the enter key code { $('#ClipArt1').click(); return false; } }); }); function checkEmpty() { if ($("#Man-Made_Object").is(':empty')) { var message = '

Nessun Oggetto Fisico trovato

'; $('#Man-Made_Object').append(message); } if ($("#Information_Object").is(':empty')) { var message = '

Nessun Oggetto Informativo trovato

'; $('#Information_Object').append(message); } if ($("#Person").is(':empty')) { var message = '

Nessuna Persona trovata

'; $('#Person').append(message); } if ($("#Place").is(':empty')) { var message = '

Nessun Luogo trovato

'; $('#Place').append(message); } } function rewrite_graph(graph) { var graph_name = "" if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") { graph_name = "Archivio di Stato di Prato - Fondo Datini"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") { graph_name = "Archivio di Stato di Prato - Fondo Marcolvaldi"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/actors") { graph_name = "Archivio di Stato di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/martini") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/datini") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/authors") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/ovi/datini") { graph_name = "Opera del Vocabolario Italiano"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/ovi/datini/trascr") { graph_name = "Opera del Vocabolario Italiano"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/places") { graph_name = "Luoghi"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/places") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/label/toponimi") { graph_name = "Toponimi Archivio di Stato di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica") { graph_name = "Archivio di Stato di Prato - Onomatica Datini"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli/newdataset") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica/gruppi") { graph_name = "Archivio di Stato di Prato - Onomastica Datini"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/autori") { graph_name = "Museo di Palazzo Pretorio"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica/datini") { graph_name = "Archivio di Stato di Prato - Onomastica Datini"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/onomastica/ospedale") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else {graph_name = graph; } return graph_name; } function MMO_handle_json(json) { // console.log(json); mmoQueries = mmoQueries+1; if(mmoQueries==3){ $('#mmoLoader').css("display", "none"); } $('#wb_Shape1').text(""); $(".results").css("display", "block"); var n_mmo = $('#n_mmo').text(); var b = parseInt(n_mmo); var i = 0; $.each( json['results']['bindings'], function (index, value) { var object = ""; /*Inserisci VALUE TIPOLOGIA*/ var graph = value['graph']['value']; var graph_name = rewrite_graph(graph); var mmoType = ""; var mmoId = ""; var object_button = ""; var object_type = ""; if (value.hasOwnProperty('type')) { mmoType = value['type']['value']; } if (value.hasOwnProperty('identifier')) { mmoId = value['identifier']['value']; } if (mmoType.includes("Opera d'Arte")) { object_type = "artwork"; object_button += ''; } else { object_type = "object"; object_button += ''; } object += /*INIZIO DIV*/ '
' + graph_name + '
' + '' + value['label']['value'] + '
' + '' + mmoType + ' ' + mmoId + '
' + '
' + object_button + '' + /*DA QUI HYPERLINK ->*/'' + /*DA QUI LOD ->*/'
'; i++; /*onclick=copy__Text("' + value['link']['value'] + '")*/ $('#Man-Made_Object').append(object); }); var n_oggetto = b + i; $('#n_mmo').text(""); $('#n_mmo').append(n_oggetto); if (n_oggetto == 0) { $('#Man-Made_Object').text(""); var message = '

Nessun Oggetto Fisico trovato

'; $('#Man-Made_Object').append(message); } else { $('#no_mmo').remove(""); } } function InfObj_handle_json(json) { // console.log(json); infQueries = infQueries+1; if(infQueries==3){ $('#infLoader').css("display", "none"); } var n_io = $('#n_io').text(); var b = parseInt(n_io); var i = 0; $.each( json['results']['bindings'], function (index, value) { var information = ""; /*Inserisci VALUE TIPOLOGIA*/ var graph = value['graph']['value']; var graph_name = rewrite_graph(graph); var tipo = ""; var id = ""; var infObject_button = ""; if (value['text']['type'] != 'uri') { var myString = value['text']['value']; var str = myString.replace(/<[^>]*>?/gm, ''); let string_text = str.toLowerCase(); let string_len = str.length; var word = Parole; let ind = string_text.indexOf(word); let length = word.length; var wl = ind + length; var resource_type = ""; var link_type = ""; /*var start = 0; var end = 0 var bb = pp - 50; var ee = pp + length + 150;*/ var pp = ind; before = str.substring(0, ind); after = str.substring(wl, string_len); let bb = before.lastIndexOf("."); let point = bb + pp; let ee = str.indexOf(".", point); if (bb < 0) { start = 0; } else { start = bb+1; } if (ee < 0) { end = string_len; } else { end = ee; } first_chunk = str.substring(start, ind); highlight = str.substring(ind, wl); second_chunk = str.substring(wl, end); var snippet = first_chunk + highlight + second_chunk ; //var snippet = first_chunk + "" + highlight + "" + second_chunk ; if (value.hasOwnProperty('types')) { tipo = value['types']['value']; } if (value.hasOwnProperty('id')) { id = " (" + value['id']['value'] + ")"; } if (tipo.includes("lettera")) { link_name = value['subject']['value']; resource_type = "lettera"; link_type = "lettera"; infObject_button += ''; } else { link_name = value['Physical_Object']['value']; resource_type = "object"; link_type = "object"; infObject_button += ''; } //'

' + graph_name + '
' + //'' + value['label']['value'] + '

' information += /*INIZIO DIV*/ '

'+ snippet+'

' + 'In: ' + graph_name + ';
' + '' + value['label']['value'] + id + ';
' + tipo + '
' + '
' + infObject_button + '' + /*DA QUI HYPERLINK ->*/'' + /*DA QUI LOD ->*/'
'; i++; /*onclick=copy__Text("' + value['link']['value'] + '")*/ $('#Information_Object').append(information); } }); var n_oggetto = b + i; $('#n_io').text(""); $('#n_io').append(n_oggetto); if (n_oggetto == 0) { $('#Information_Object').text(""); var message = '

Nessun Testo trovato

'; $('#Information_Object').append(message); } else { $('#no_io').remove(""); } } function Person_handle_json(json) { console.log(json); perQueries = perQueries+1; if(perQueries==3){ $('#perLoader').css("display", "none"); } var n_ps = $('#n_ps').text(); var b = parseInt(n_ps); var i = 0; $.each( json['results']['bindings'], function (index, value) { var person = ""; /*Inserisci VALUE TIPOLOGIA*/ var graph = value['graph']['value']; var graph_name = rewrite_graph(graph); person += /*INIZIO DIV*/ '

' + graph_name + '
' + '' + value['name']['value'] + '

' + '
' + '' + /*DA QUI HYPERLINK ->*/'' + /*DA QUI LOD ->*/'
'; i++; /*onclick=copy__Text("' + value['link']['value'] + '")*/ $('#Person').append(person); }); var n_oggetto = b + i; $('#n_ps').text(""); $('#n_ps').append(n_oggetto); if (n_oggetto == 0) { $('#Person').text(""); var message = '

Nessun Persona trovata

'; $('#Person').append(message); } else { $('#no_ps').remove(""); } } function Place_handle_json(json) { // console.log(json); lgQueries = lgQueries+1; if(lgQueries==1){ $('#lgLoader').css("display", "none"); } var n_pl = $('#n_pl').text(); var b = parseInt(n_pl); var i = 0; $.each( json['results']['bindings'], function (index, value) { var place = ""; /*Inserisci VALUE TIPOLOGIA*/ var graph = value['graph']['value']; var graph_name = rewrite_graph(graph); place += /*INIZIO DIV*/ '

' + graph_name + '
' + '' + value['label']['value'] + '

' + '
' + '' + /*DA QUI HYPERLINK ->*/'' + /*DA QUI LOD ->*/'
'; i++; /*onclick=copy__Text("' + value['link']['value'] + '")*/ $('#Place').append(place); }); var n_oggetto = b + i; $('#n_pl').text(""); $('#n_pl').append(n_oggetto); if (n_oggetto == 0) { $('#Place').text(""); var message = '

Nessun Luogo trovato

'; $('#Place').append(message); } else { $('#no_pl').remove(""); } } //onlick hyperlink button $(document).on("click", ".hyp", function (ev) { var baseurl = window.location.origin+window.location.pathname; let slash = baseurl.lastIndexOf("/"); var type = $(this).val() + '.html'; var link = this.id; var url = baseurl.substr(0, slash+1) + type + "?link="+link; var link = this.id; $("#myModal").empty(); $("#myModal").css("display", "block"); $('#myModal').append("