$(document).ready(function () { //####################################### const graphArray = [ ["ASPO - Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/datini"], ["ASPO - Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale"], ["ASPO - Marcovaldi", "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi"], ["ASPO - Gettatelli", "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli"], ["ASPO - Autori ASPO", "http://dev.restore.ovi.cnr.it:8890/aspo/actors"], ["MPP - Collezione Martini", "http://dev.restore.ovi.cnr.it:8890/mpp/martini"], ["MPP - Collezione Ospedale", "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale"], ["MPP - Collezione Datini", "http://dev.restore.ovi.cnr.it:8890/mpp/datini"], ["MPP - Autori MPP", "http://dev.restore.ovi.cnr.it:8890/mpp/authors"], ["OVI - Lettere", "http://dev.restore.ovi.cnr.it:8890/ovi/datini"], ["Luoghi", "http://dev.restore.ovi.cnr.it:8890/mpp/places"] ]; var graph_selector = document.getElementById("graph_selector"); let x = graphArray.length; for(var i=0; i'; gg = ""; } //var query='SELECT DISTINCT ?nome WHERE { ?autore . ?autore ?nomeid. ?nomeid ?nome . FILTER regex(?nome, "'+ search_name +'") }' ; prefixes = "PREFIX rdfs: \ PREFIX rdf: \ PREFIX crm: " queryMMO = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label (group_concat(distinct ?type ;separator=', ') as ?types) \ WHERE {GRAPH "+ search_graph +" { ?subject ?property ?object } \ ?subject rdf:type crm:E22_Man-Made_Object ; \ rdfs:label ?label ; \ ?property ?object . \ OPTIONAL {?subject crm:P2_has_type ?type } \ ?object bif:contains \"\' "+ search_name + " \'\" . \ }" queryInfObj = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label ?id (group_concat(distinct ?type ;separator=', ') as ?types) ?object_type ?object_Label \ WHERE { \ GRAPH "+ search_graph +" {?subject rdf:type crm:E73_Information_Object ; \ rdfs:label ?label .} \ OPTIONAL {?subject crm:P1_is_identified_by ?id_subject . \ ?id_subject rdfs:label ?id ; \ rdf:type crm:E42_Identifier . } \ OPTIONAL {?subject crm:P2_has_type ?entity_type . \ ?entity_type rdfs:label ?type .} \ {?subject ?property ?object_Label . \ ?object_Label bif:contains \"\' "+ search_name + " \'\" . \ } UNION { \ ?subject ?property ?object . \ ?object rdfs:label ?object_Label ; \ rdf:type ?object_type . \ ?object_Label bif:contains \"\' "+ search_name + " \'\" . \ } \ FILTER NOT EXISTS { ?property rdfs:label 'label' } \ } ORDER BY ?id ?types" queryPerson = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \ WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\ rdf:type crm:E21_Person .\ ?label bif:contains \"\' "+ search_name + " \'\" .}\ }" queryPlace = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \ WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\ rdf:type crm:E53_Place .\ ?label bif:contains \"\' "+ search_name + " \'\" .}\ }" //query = 'SELECT DISTINCT '+ search_graph +' AS ?graph ?link ?label ?entity ?object ?objLab WHERE { GRAPH '+ search_graph +' { ?link ?label ; '+ search_entity +' . ?label bif:contains "\'' + search_name + '\'" .} '+ search_entity +' ?entity . FILTER (langMatches( lang(?entity), "en" )) OPTIONAL {?link ?object } OPTIONAL {?link ?link_object . ?link_object ?objLab }} limit 100'; var ManMadeObject_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryMMO) + '&output=json'; var InformationObject_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryInfObj) + '&output=json'; var Persons_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryPerson) + '&output=json'; var Places_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryPlace) + '&output=json'; $.ajax({ url: ManMadeObject_url + '&callback=?', dataType: "json", success: function (data) { MMO_handle_json(data); }, error: function (e) {} }); $.ajax({ url: InformationObject_url + '&callback=?', dataType: "json", success: function (data) { InfObj_handle_json(data); }, error: function (e) {} }); $.ajax({ url: Persons_url + '&callback=?', dataType: "json", success: function (data) { Person_handle_json(data); }, error: function (e) {} }); $.ajax({ url: Places_url + '&callback=?', dataType: "json", success: function (data) { Place_handle_json(data); }, error: function (e) {} }); } 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"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") { graph_name = "Archivio di Stato di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") { graph_name = "Archivio di Stato di Prato"; } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") { graph_name = "Archivio di Stato di Prato"; } 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 {graph_name = graph; } return graph_name; } function MMO_handle_json(json) { console.log(json); $('#wb_Shape1').text(""); $('#wb_Image1').text(""); $('#Man-Made_Object').text(""); $(".results").css("display", "block"); $('#n_mmo').text(""); 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 artwork_button = ""; if (value.hasOwnProperty('types')) { mmoType = value['types']['value']; } if (mmoType.includes("Opera d'Arte")) { artwork_button += ''; } object += /*INIZIO DIV*/ '
' + graph_name + '
' + '' + value['label']['value'] + '
' + '' + mmoType + '
' + '
' + artwork_button + '
' + '
' + /*DA QUI HYPERLINK ->*/'
' + /*DA QUI LOD ->*/'
'; i++; /*onclick=copy__Text("' + value['link']['value'] + '")*/ $('#Man-Made_Object').append(object); }); $('#n_mmo').append(i); if (i==0) { var message = '

Nessun Oggetto Fisico trovato

'; $('#Man-Made_Object').append(message); } } function InfObj_handle_json(json) { console.log(json); $('#Information_Object').text(""); $('#n_io').text(""); 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 envelope_button = ""; var myString = value['object_Label']['value']; var str = myString.replace(/<[^>]*>?/gm, ''); let string_text = str.toLowerCase(); let string_len = str.length; var word = testo; let ind = string_text.indexOf(word); let length = word.length; var wl = ind + length; /*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); console.log(bb, ee); if (bb < 0) { start = 0; } else { start = bb+1; } if (ee < 0) { end = string_len; } else { end = ee; } console.log(start, bb, end, ee); /*if (bb<=0) { start = 0; } else { start = bb; } if (ee>=string_len) { 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 ; console.log(snippet); if (value.hasOwnProperty('types')) { tipo = value['types']['value']; } if (value.hasOwnProperty('id')) { id = " (" + value['id']['value'] + ")"; } if (tipo.includes("Testo annotato OVI")) { envelope_button += ''; } information += /*INIZIO DIV*/ '

'+ snippet+'

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

Nessun Oggetto Informativo trovato

'; $('#Information_Object').append(message); } } function Person_handle_json(json) { console.log(json); $('#Person').text(""); $('#n_ps').text(""); 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['label']['value'] + '
' + '
' + '
' + /*DA QUI HYPERLINK ->*/'
' + /*DA QUI LOD ->*/'
'; i++; /*onclick=copy__Text("' + value['link']['value'] + '")*/ $('#Person').append(person); }); $('#n_ps').append(i); if (i==0) { var message = '

Nessuna Persona trovata

'; $('#Person').append(message); } } function Place_handle_json(json) { console.log(json); $('#Place').text(""); $('#n_pl').text(""); 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); }); $('#n_pl').append(i); if (i==0) { var message = '

Nessun Luogo trovato

'; $('#Place').append(message); } } $('#ClipArt1').click(function () { testo = $('input#TextArea1').val(); results_retrieveData(); search_name = ""; }); $('input#TextArea1').keypress(function(e) { var key = e.which; if (key == 13) // the enter key code { $('#ClipArt1').click(); return false; } }); //onlick hyperlink button $(document).on("click", ".hyp", function (ev) { var link = this.id; //alert(nome_autore); //$('#myModal').text(""); $("#myModal").empty(); $("#myModal").css("display", "block"); $('#myModal').append("