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"); $('#licenza').css("display", "block"); 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 = '

No Physical object found

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

No Text found

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

No Person found

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

No Place found

'; $('#Place').append(message); } } function rewrite_graph(graph) { var graph_name = "" if (graph == "" + uri_base + "/aspo/datini") { graph_name = "Archivio di Stato di Prato - Fondo Datini"; } else if (graph == "" + uri_base + "/aspo/ospedale") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else if (graph == "" + uri_base + "/aspo/marcovaldi") { graph_name = "Archivio di Stato di Prato - Fondo Marcolvaldi"; } else if (graph == "" + uri_base + "/aspo/gettatelli") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else if (graph == "" + uri_base + "/aspo/actors") { graph_name = "Archivio di Stato di Prato"; } else if (graph == "" + uri_base + "/mpp/martini") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "" + uri_base + "/mpp/ospedale") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "" + uri_base + "/mpp/datini") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "" + uri_base + "/mpp/authors") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "" + uri_base + "/ovi/datini") { graph_name = "Opera del Vocabolario Italiano"; } else if (graph == "" + uri_base + "/ovi/datini/trascr") { graph_name = "Opera del Vocabolario Italiano"; } else if (graph == "" + uri_base + "/places") { graph_name = "Luoghi"; } else if (graph == "" + uri_base + "/mpp/places") { graph_name = "Museo di Palazzo Pretorio di Prato"; } else if (graph == "" + uri_base + "/label/toponimi") { graph_name = "Toponimi Archivio di Stato di Prato"; } else if (graph == "" + uri_base + "/aspo/onomastica") { graph_name = "Archivio di Stato di Prato - Onomatica Datini"; } else if (graph == "" + uri_base + "/aspo/gettatelli/newdataset") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else if (graph == "" + uri_base + "/aspo/onomastica/gruppi") { graph_name = "Archivio di Stato di Prato - Onomastica Datini"; } else if (graph == "" + uri_base + "/mpp/autori") { graph_name = "Museo di Palazzo Pretorio"; } else if (graph == "" + uri_base + "/aspo/onomastica/datini") { graph_name = "Archivio di Stato di Prato - Onomastica Datini"; } else if (graph == "" + uri_base + "/onomastica/ospedale") { graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce"; } else if (graph == "" + uri_base + "/mpp/ulan/viaf") { graph_name = "Persone"; } else if (graph == "" + uri_base + "/places/microtoponimi") { graph_name = "Luoghi"; } 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 = '

No Physical object found

'; $('#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 = '

No Text found

'; $('#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 = '

No oPlace found

'; $('#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("