search.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. $(document).ready(function () {
  2. //#######################################
  3. const graphArray = [
  4. ["ASPO - Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/datini"],
  5. ["ASPO - Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale"],
  6. ["ASPO - Marcovaldi", "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi"],
  7. ["ASPO - Gettatelli", "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli"],
  8. ["ASPO - Autori ASPO", "http://dev.restore.ovi.cnr.it:8890/aspo/actors"],
  9. ["MPP - Collezione Martini", "http://dev.restore.ovi.cnr.it:8890/mpp/martini"],
  10. ["MPP - Collezione Ospedale", "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale"],
  11. ["MPP - Collezione Datini", "http://dev.restore.ovi.cnr.it:8890/mpp/datini"],
  12. ["MPP - Autori MPP", "http://dev.restore.ovi.cnr.it:8890/mpp/authors"],
  13. ["OVI - Lettere", "http://dev.restore.ovi.cnr.it:8890/ovi/datini"],
  14. ["Luoghi", "http://dev.restore.ovi.cnr.it:8890/mpp/places"]
  15. ];
  16. var graph_selector = document.getElementById("graph_selector");
  17. let x = graphArray.length;
  18. for(var i=0; i<x; i++) {
  19. var opt = document.createElement("option");
  20. opt.value= graphArray[i][1];
  21. opt.innerHTML = graphArray[i][0]; // whatever property it has
  22. // then append it to the select element
  23. graph_selector.add(opt);
  24. }
  25. var search_name = "";
  26. var testo = "";
  27. function results_retrieveData() {
  28. search_name = testo;
  29. var g = document.getElementById("graph_selector");
  30. var graph = g.value;
  31. var search_graph = "?g";
  32. var gg = "?g";
  33. if (graph != "") {
  34. search_graph = '<' + graph + '>';
  35. gg = "";
  36. }
  37. //var query='SELECT DISTINCT ?nome WHERE { ?autore <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.cidoc-crm.org/cidoc-crm/E39_Actor> . ?autore <http://www.cidoc-crm.org/cidoc-crm/P1_is_identified_by> ?nomeid. ?nomeid <http://www.w3.org/2000/01/rdf-schema#label> ?nome . FILTER regex(?nome, "'+ search_name +'") }' ;
  38. prefixes = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \
  39. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
  40. PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>"
  41. queryMMO = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label ?object\
  42. WHERE {GRAPH "+ search_graph +" { ?subject ?property ?object }\
  43. ?subject rdf:type crm:E22_Man-Made_Object ;\
  44. rdfs:label ?label ;\
  45. ?property ?object .\
  46. ?object bif:contains \"\' "+ search_name + " \'\" .\
  47. }"
  48. queryInfObj = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph (SAMPLE(?type) AS ?typeName) ?subject ?label ?object \
  49. WHERE {GRAPH "+ search_graph +" { ?subject ?property ?object }\
  50. ?subject rdf:type crm:E73_Information_Object ;\
  51. rdfs:label ?label ;\
  52. ?property ?object .\
  53. ?object bif:contains \"\' "+ search_name + " \'\" .\
  54. OPTIONAL {?subject crm:P2_has_type ?entity_type . \
  55. ?entity_type rdfs:label ?type .}\
  56. } \
  57. GROUP BY ?subject ?object ?label "+ gg + ""
  58. queryPerson = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \
  59. WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\
  60. rdf:type crm:E21_Person .\
  61. ?label bif:contains \"\' "+ search_name + " \'\" .}\
  62. }"
  63. queryPlace = prefixes + " SELECT DISTINCT "+ search_graph +" AS ?graph ?subject ?label \
  64. WHERE {GRAPH "+ search_graph +" { ?subject rdfs:label ?label ;\
  65. rdf:type crm:E53_Place .\
  66. ?label bif:contains \"\' "+ search_name + " \'\" .}\
  67. }"
  68. //query = 'SELECT DISTINCT '+ search_graph +' AS ?graph ?link ?label ?entity ?object ?objLab WHERE { GRAPH '+ search_graph +' { ?link <http://www.w3.org/2000/01/rdf-schema#label> ?label ; <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> '+ search_entity +' . ?label bif:contains "\'' + search_name + '\'" .} '+ search_entity +' <http://www.w3.org/2000/01/rdf-schema#label> ?entity . FILTER (langMatches( lang(?entity), "en" )) OPTIONAL {?link <http://www.cidoc-crm.org/cidoc-crm/P2_has_type> ?object } OPTIONAL {?link <http://www.cidoc-crm.org/cidoc-crm/P2_has_type> ?link_object . ?link_object <http://www.w3.org/2000/01/rdf-schema#label> ?objLab }} limit 100';
  69. var ManMadeObject_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryMMO) + '&output=json';
  70. var InformationObject_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryInfObj) + '&output=json';
  71. var Persons_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryPerson) + '&output=json';
  72. var Places_url = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(queryPlace) + '&output=json';
  73. $.ajax({
  74. url: ManMadeObject_url + '&callback=?',
  75. dataType: "json",
  76. success: function (data) {
  77. MMO_handle_json(data);
  78. },
  79. error: function (e) {}
  80. });
  81. $.ajax({
  82. url: InformationObject_url + '&callback=?',
  83. dataType: "json",
  84. success: function (data) {
  85. InfObj_handle_json(data);
  86. },
  87. error: function (e) {}
  88. });
  89. $.ajax({
  90. url: Persons_url + '&callback=?',
  91. dataType: "json",
  92. success: function (data) {
  93. Person_handle_json(data);
  94. },
  95. error: function (e) {}
  96. });
  97. $.ajax({
  98. url: Places_url + '&callback=?',
  99. dataType: "json",
  100. success: function (data) {
  101. Place_handle_json(data);
  102. },
  103. error: function (e) {}
  104. });
  105. }
  106. function rewrite_graph(graph) {
  107. var graph_name = ""
  108. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") {
  109. graph_name = "Archivio di Stato di Prato";
  110. }
  111. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") {
  112. graph_name = "Archivio di Stato di Prato";
  113. }
  114. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") {
  115. graph_name = "Archivio di Stato di Prato";
  116. }
  117. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") {
  118. graph_name = "Archivio di Stato di Prato";
  119. }
  120. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/actors") {
  121. graph_name = "Archivio di Stato di Prato";
  122. }
  123. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/martini") {
  124. graph_name = "Museo di Palazzo Pretorio di Prato";
  125. }
  126. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale") {
  127. graph_name = "Museo di Palazzo Pretorio di Prato";
  128. }
  129. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/datini") {
  130. graph_name = "Museo di Palazzo Pretorio di Prato";
  131. }
  132. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/authors") {
  133. graph_name = "Museo di Palazzo Pretorio di Prato";
  134. }
  135. else if (graph == "http://dev.restore.ovi.cnr.it:8890/ovi/datini") {
  136. graph_name = "Opera del Vocabolario Italiano";
  137. }
  138. else if (graph == "http://dev.restore.ovi.cnr.it:8890/ovi/datini/trascr") {
  139. graph_name = "Opera del Vocabolario Italiano";
  140. }
  141. else if (graph == "http://dev.restore.ovi.cnr.it:8890/places") {
  142. graph_name = "Luoghi";
  143. }
  144. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/places") {
  145. graph_name = "Museo di Palazzo Pretorio di Prato";
  146. }
  147. else if (graph == "http://dev.restore.ovi.cnr.it:8890/label/toponimi") {
  148. graph_name = "Toponimi Archivio di Stato di Prato";
  149. }
  150. else {graph_name = graph;
  151. }
  152. return graph_name;
  153. }
  154. function MMO_handle_json(json) {
  155. console.log(json);
  156. $('#wb_Shape1').text("");
  157. $('#wb_Image1').text("");
  158. $('#Man-Made_Object').text("");
  159. $(".results").css("display", "block");
  160. $('#n_mmo').text("");
  161. var i = 0;
  162. $.each(
  163. json['results']['bindings'],
  164. function (index, value) {
  165. var object = ""; /*Inserisci VALUE TIPOLOGIA*/
  166. var graph = value['graph']['value'];
  167. var graph_name = rewrite_graph(graph);
  168. object += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
  169. '<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' +
  170. '<div class="col"></div>' +
  171. '<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
  172. /*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
  173. /*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  174. i++;
  175. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  176. $('#Man-Made_Object').append(object);
  177. });
  178. $('#n_mmo').append(i);
  179. if (i==0) {
  180. var message = '<p>Nessun Oggetto Fisico trovato</p>';
  181. $('#Man-Made_Object').append(message);
  182. }
  183. }
  184. function InfObj_handle_json(json) {
  185. console.log(json);
  186. $('#Information_Object').text("");
  187. $('#n_io').text("");
  188. var i = 0;
  189. $.each(
  190. json['results']['bindings'],
  191. function (index, value) {
  192. var information = ""; /*Inserisci VALUE TIPOLOGIA*/
  193. var graph = value['graph']['value'];
  194. var graph_name = rewrite_graph(graph);
  195. var tipo = "";
  196. var envelope_button = "";
  197. if (value.hasOwnProperty('typeName')) {
  198. tipo = value['typeName']['value'];
  199. }
  200. if (tipo == "lettera" || tipo == "Testo annotato OVI") {
  201. envelope_button += '<button type="button" id="' + value['subject']['value'] +
  202. '" class="lettera btn btn-default" alt="lettera" title="' + value['label']['value'] +
  203. '"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  204. }
  205. information += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
  206. '<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' +
  207. '<div class="col">' + envelope_button + '</div>' +
  208. '<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
  209. /*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
  210. /*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  211. i++;
  212. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  213. $('#Information_Object').append(information);
  214. });
  215. $('#n_io').append(i);
  216. if (i==0) {
  217. var message = '<p>Nessun Oggetto Informativo trovato</p>';
  218. $('#Information_Object').append(message);
  219. }
  220. }
  221. function Person_handle_json(json) {
  222. console.log(json);
  223. $('#Person').text("");
  224. $('#n_ps').text("");
  225. var i = 0;
  226. $.each(
  227. json['results']['bindings'],
  228. function (index, value) {
  229. var person = ""; /*Inserisci VALUE TIPOLOGIA*/
  230. var graph = value['graph']['value'];
  231. var graph_name = rewrite_graph(graph);
  232. person += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
  233. '<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' +
  234. '<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="persona btn btn-default" alt="persona" title="' +
  235. value['label']['value'] + '"><i class="fa fa-user"></i><p class="btn-text">Scheda Persona</p></button></div>' +
  236. '<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
  237. /*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
  238. /*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  239. i++;
  240. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  241. $('#Person').append(person);
  242. });
  243. $('#n_ps').append(i);
  244. if (i==0) {
  245. var message = '<p>Nessuna Persona trovata</p>';
  246. $('#Person').append(message);
  247. }
  248. }
  249. function Place_handle_json(json) {
  250. console.log(json);
  251. $('#Place').text("");
  252. $('#n_pl').text("");
  253. var i = 0;
  254. $.each(
  255. json['results']['bindings'],
  256. function (index, value) {
  257. var place = ""; /*Inserisci VALUE TIPOLOGIA*/
  258. var graph = value['graph']['value'];
  259. var graph_name = rewrite_graph(graph);
  260. place += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
  261. '<a href=' + value['subject']['value'] + '>' + value['label']['value'] + '</a></div>' +
  262. '<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="luogo btn btn-default" alt="luogo" title="' +
  263. value['label']['value'] + '"><i class="fa fa-map"></i><p class="btn-text">Scheda Luogo</p></button></div>' +
  264. '<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button></div>' +
  265. /*DA QUI HYPERLINK ->*/'<div class="col"><button type="button" id="' + value['subject']['value'] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button></div>' +
  266. /*DA QUI LOD ->*/'<div class="col"><a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" class="btn btn-default info" alt="LOD"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></div></div>';
  267. i++;
  268. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  269. $('#Place').append(place);
  270. });
  271. $('#n_pl').append(i);
  272. if (i==0) {
  273. var message = '<p>Nessun Luogo trovato</p>';
  274. $('#Place').append(message);
  275. }
  276. }
  277. $('#ClipArt1').click(function () {
  278. testo = $('input#TextArea1').val();
  279. results_retrieveData();
  280. search_name = "";
  281. });
  282. $('input#TextArea1').keypress(function(e) {
  283. var key = e.which;
  284. if (key == 13) // the enter key code
  285. {
  286. $('#ClipArt1').click();
  287. return false;
  288. }
  289. });
  290. //onlick hyperlink button
  291. $(document).on("click", ".hyp", function (ev) {
  292. var link = this.id;
  293. //alert(nome_autore);
  294. //$('#myModal').text("");
  295. $("#myModal").empty();
  296. $("#myModal").css("display", "block");
  297. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  298. link + "</div><button id='copy_btn' class='btn btn-primary btn-lg' onclick='myFunction()'>Copia</button>");
  299. });
  300. $(document).on("click", ".lettera", function (ev) {
  301. var link = this.id;
  302. //alert(nome_autore);
  303. //$('#myModal').text("");
  304. window.open("lettera.html?link="+this.id);
  305. });
  306. $(document).on("click", ".persona", function (ev) {
  307. var link = this.id;
  308. //alert(nome_autore);
  309. //$('#myModal').text("");
  310. window.open("Persona.html?link="+this.id);
  311. });
  312. $(document).on("click", ".luogo", function (ev) {
  313. var link = this.id;
  314. //alert(nome_autore);
  315. //$('#myModal').text("");
  316. window.open("Luogo.html?link="+this.id);
  317. });
  318. $(document).on("click", ".close", function (ev) {
  319. var link = this.id;
  320. //alert(nome_autore);
  321. //$('#myModal').text("");
  322. $("#myModal").css("display", "none");
  323. });
  324. $(document).on("click", ".back", function (ev) {
  325. $("#myTab").css("display", "none");
  326. });
  327. $(document).on("click", ".cit", function (ev) {
  328. var author ="RESTORE. smart access to digital heritage and memory"
  329. var year = new Date().getFullYear()
  330. var today = new Date();
  331. var dd = String(today.getDate()).padStart(2, '0');
  332. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  333. var yyyy = today.getFullYear();
  334. today = dd + '/' + mm + '/' + yyyy;
  335. var link = this.id;
  336. //alert(nome_autore);
  337. //$('#myModal').text("");
  338. $("#myModal").empty();
  339. $("#myModal").css("display", "block");
  340. $('#myModal').append("<div class='modal-content'><span class='close'>&times;</span><div id='myInput'>" +
  341. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + link + "&gt;</div><button id='copy_btn' class='btn btn-primary btn-lg' onclick='myFunction()'>Copia</button>");
  342. });
  343. $(document).on("click", ".scheda", function (ev) {
  344. var link = this.id;
  345. var title = this.title;
  346. //alert(nome_autore);
  347. $("#myTab").empty();
  348. $("#myTab").css("display", "block");
  349. $('#myTab').append("<div class='tab-content'><span class='back'>&lt; Indietro</span><br /><h2><a href='" + link + "' target='_blank'>" + title + "</a></h2><div id='tab_container'><h3>Relazioni dirette</h3><br /><table id='info_link' class='table table-hover'></table><br /><table id='info_ico' class='table table-hover'></table><br /><h3>Relazioni inverse</h3><br /><table id='info_obj' class='table table-hover'></table></div></div>");
  350. /*var query_a = 'SELECT DISTINCT ?label WHERE { {<' + link +
  351. '> ?p ?object. OPTIONAL {?object ?property ?label . FILTER(?property = <http://www.w3.org/2004/02/skos/core#prefLabel> || ?property = <http://www.w3.org/2000/01/rdf-schema#label>) FILTER (langMatches( lang(?label), "en" )) } } UNION {<'+ link +
  352. '> ?p ?object. OPTIONAL {?p <http://www.w3.org/2000/01/rdf-schema#label> ?propertyLabel .?object <http://www.w3.org/2000/01/rdf-schema#label> ?label } FILTER (?p != <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>) FILTER (langMatches( lang(?propertyLabel), "en" )) }}';
  353. */
  354. var query_a = 'SELECT DISTINCT ?propLab ?object ?label WHERE {{<' + link +
  355. '> ?property ?object. ?property <http://www.w3.org/2000/01/rdf-schema#label> ?propLab . OPTIONAL {?object <http://www.w3.org/2000/01/rdf-schema#label> ?label . } FILTER (?property != <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?property != <http://www.cidoc-crm.org/cidoc-crm/P62_depicts>) FILTER (langMatches( lang(?propLab), "en" ))} UNION {<' + link +
  356. '> ?property ?object. ?property <http://www.w3.org/2000/01/rdf-schema#label> ?propLab . OPTIONAL {?object <http://www.w3.org/2000/01/rdf-schema#label> ?label . } FILTER (?property != <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?property != <http://www.w3.org/2000/01/rdf-schema#label>) FILTER(!regex(?property, "cidoc"))}}';
  357. var object_url_a = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query_a) + '&output=json';
  358. var query_b = 'SELECT DISTINCT ?subject ?label ?property ?propertyLabel WHERE {?subject ?property <' + link +
  359. '> ; <http://www.w3.org/2000/01/rdf-schema#label> ?label . ?property <http://www.w3.org/2000/01/rdf-schema#label> ?propertyLabel . FILTER (langMatches( lang(?propertyLabel), "en" ))}';
  360. var object_url_b = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query_b) + '&output=json';
  361. var query_c = 'SELECT DISTINCT ?object ?label WHERE {{<' + link + '> <http://www.cidoc-crm.org/cidoc-crm/P62_depicts> ?object . ?object <http://www.w3.org/2000/01/rdf-schema#label> ?label .} UNION {<' + link +
  362. '> <http://www.cidoc-crm.org/cidoc-crm/P62_depicts> ?object . ?object <http://www.w3.org/2004/02/skos/core#prefLabel> ?label . FILTER (langMatches(lang(?label), "it" )) }}';
  363. var object_url_c = 'http://dev.restore.ovi.cnr.it:8890/sparql/?default-graph-uri=&query=' + encodeURIComponent(query_c) + '&output=json';
  364. $.ajax({//SOGGETTO
  365. url: object_url_a + '&callback=?',
  366. dataType: "json",
  367. success: function (data_a) {
  368. object_info_a(data_a);
  369. },
  370. error: function (e) {}
  371. });
  372. $.ajax({//OGGETTO
  373. url: object_url_b + '&callback=?',
  374. dataType: "json",
  375. success: function (data_b) {
  376. object_info_b(data_b);
  377. },
  378. error: function (e) {}
  379. });
  380. $.ajax({//ICONCLASS
  381. url: object_url_c + '&callback=?',
  382. dataType: "json",
  383. success: function (data_c) {
  384. object_info_c(data_c);
  385. },
  386. error: function (e) {}
  387. });
  388. });
  389. function object_info_a(json) {
  390. console.log(json);
  391. var j = 0;
  392. $('#info_link').text("");
  393. $.each(
  394. json['results']['bindings'],
  395. function (index, value) {
  396. var autore_a = "";
  397. var object = "";
  398. var object_type = value['object']['type'];
  399. if (object_type == "typed-literal" || object_type == "literal"){
  400. object = '<td>'+ value['object']['value'] + '</td>';
  401. }
  402. else{
  403. object = '<td style="width:60%;"><a href="'+ value['object']['value'] +'" target="_blank">'+ value['label']['value'] +'</a></td><td>' +
  404. '<button type="button" id="' + value['object']['value'] + '" class="scheda btn btn-default" alt="scheda" title="' + value['label']['value'] + '"><i class="fa fa-bars"></i><p class="btn-text">Scheda</p></button></td><td>' +
  405. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['object']['value'] + '" target="_blank"><button type="button" id="lod " class="btn btn-default info" alt="scheda" title="Info"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></td>';
  406. }
  407. autore_a += /*INIZIO DIV*/ '<tr><td style="width:25%;">' + value['propLab']['value'] + '</td>' + object + '</tr>';/*FINE DIV*/
  408. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  409. j++;
  410. $('#info_link').append(autore_a);
  411. });
  412. if (j==0) {
  413. var message_a = '<tr id="error"><td><p>Non sono presenti relazioni dirette per questa risorsa</p></td></tr>';
  414. $('#info_link').append(message_a);
  415. }
  416. }
  417. function object_info_b(json) {
  418. console.log(json);
  419. var k = 0;
  420. $('#info_obj').text("");
  421. $.each(
  422. json['results']['bindings'],
  423. function (index, value) {
  424. var autore_b = "";
  425. autore_b += /*INIZIO DIV*/ '<tr><td style="width:60%;"><a href="' + value['subject']['value'] + '" target="_blank">' + value['label']['value'] + '</a></td><td style="width:25%;">' + value['propertyLabel']['value'] + '</td><td>' +
  426. '<button type="button" id="' + value['subject']['value'] + '" class="scheda btn btn-default" alt="scheda" title="' + value['label']['value'] + '"><i class="fa fa-bars"></i><p class="btn-text">Scheda</p></button></td><td>' +
  427. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['subject']['value'] + '" target="_blank"><button type="button" id="lod " class="btn btn-default info" alt="scheda" title="Info"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></td></tr>';
  428. /*FINE DIV*/
  429. k++;
  430. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  431. $('#info_obj').append(autore_b);
  432. });
  433. if (k==0) {
  434. var message_b = '<tr id="error"><td><p>Non sono presenti relazioni inverse per questa risorsa</p></td></tr>';
  435. $('#info_obj').append(message_b);
  436. }
  437. }
  438. function object_info_c(json) {
  439. console.log(json);
  440. $('#info_ico').text("");
  441. $.each(
  442. json['results']['bindings'],
  443. function (index, value) {
  444. var autore_c = "";
  445. autore_c += /*INIZIO DIV*/ '<tr><td style="width:25%;">depicts</td><td style="width:60%;"><a href="' + value['object']['value'] + '">' + value['label']['value'] + '</a></td><td>' +
  446. '<button type="button" id="' + value['object']['value'] + '" class="scheda btn btn-default" alt="scheda" title="' + value['label']['value'] + '"><i class="fa fa-bars"></i><p class="btn-text">Scheda</p></button></td><td>' +
  447. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + value['object']['value'] + '" target="_blank"><button type="button" id="lod " class="btn btn-default info" alt="scheda" title="Info"><i class="fa fa-share-alt"></i><p class="btn-text">Lod</p></button></a></td></tr>';
  448. /*FINE DIV*/
  449. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  450. $('#info_ico').append(autore_c);
  451. });
  452. }
  453. //VISUALIZZAZIONI DATI DELL'AUTORE
  454. //FUNZIONE LETTURA LUNGHEZZA FILE JSON
  455. /*
  456. function objLength(obj){
  457. var i=0;
  458. for (var x in obj){
  459. if(obj.hasOwnProperty(x)){
  460. i++;
  461. }
  462. }
  463. return i;
  464. }
  465. */
  466. //#######################################
  467. });
  468. function copyToClipboard(text) {
  469. var sampleTextarea = document.createElement("textarea");
  470. document.body.appendChild(sampleTextarea);
  471. sampleTextarea.value = text; //save main text in it
  472. sampleTextarea.select(); //select textarea contenrs
  473. document.execCommand("copy");
  474. document.body.removeChild(sampleTextarea);
  475. }
  476. function myFunction(){
  477. var copy = document.getElementById("myInput");
  478. copyText = copy.textContent;
  479. copyToClipboard(copyText);
  480. //copyToClipboard(copyText.value);
  481. }