search.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. var Parole = "";
  2. let mmoQueries = 0;
  3. let infQueries = 0;
  4. let perQueries = 0;
  5. let lgQueries = 0;
  6. $(document).ready(function () {
  7. //#######################################
  8. populateOption();
  9. var search_name = "";
  10. var Label = "";
  11. var object_Label = "";
  12. var id_label = "";
  13. var name_per = "";
  14. var note_per = "";
  15. var occupation_per = "";
  16. var place_search = "";
  17. var testo = "";
  18. $('#ClipArt1').on("click", function () {
  19. $('#Man-Made_Object').text("");
  20. $('#n_mmo').text("0");
  21. $('#Information_Object').text("");
  22. $('#n_io').text("0");
  23. $('#Person').text("");
  24. $('#n_ps').text("0");
  25. $('#Place').text("");
  26. $('#n_pl').text("0");
  27. testo = $('input#TextArea1').val();
  28. Parole = testo;
  29. //questo era il contenuto di results_retrieveData()
  30. mmoQueries = 0;
  31. infQueries = 0;
  32. perQueries = 0;
  33. lgQueries = 0;
  34. $("#mmoLoader").css("display", "block");
  35. $("#infLoader").css("display", "block");
  36. $("#perLoader").css("display", "block");
  37. $("#lgLoader").css("display", "block");
  38. $('#wb_Image1').text("");
  39. $('.results').css("display", "none");
  40. next_text = testo.split(" ");
  41. search_name = "\"'" + next_text[0] + "'";
  42. if (next_text.length > 1) {
  43. for (var i=1; i<next_text.length; i++) {
  44. search_name = search_name + " AND '" + next_text[i] + "'";
  45. }
  46. }
  47. search_name = search_name + "\"";
  48. if (testo != "") {
  49. Label = " ?label bif:contains "+ search_name + " . ";
  50. object_Label = " ?object_Label bif:contains "+ search_name + " . ";
  51. id_label = " ?id bif:contains "+ search_name + " . ";
  52. name_per = "?name bif:contains "+ search_name + " . ";
  53. note_per = " ?note bif:contains " + search_name + " . ";
  54. occupation_per = " ?occupation bif:contains " + search_name + " . ";
  55. place_search = " ?label bif:contains" + search_name + " . ";
  56. }
  57. else {
  58. Label = "";
  59. object_Label = "";
  60. id_label = "";
  61. name_per = "";
  62. note_per = " ?note bif:contains 'NNNNNN' . ";;
  63. place_search = "";
  64. occupation_per = " ?occupation bif:contains 'NNNNN' . ";;
  65. }
  66. var g = document.getElementById("graph_selector");
  67. var g2 = document.getElementById("graph_selector2");
  68. var graph1 = g.value;
  69. var graph2 = g2.value;
  70. if (graph1 == 'MPP') {
  71. object_Label = " ?object_Label bif:contains 'NNNNNNNN' . ";
  72. }
  73. var search_graph = getGraph(graph1, graph2);
  74. var pref = queryManager['prefixes']['all'];
  75. var query1 = pref + (queryManager['queryMMO']['queryLabel']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', Label);
  76. var query2 = pref + (queryManager['queryMMO']['queryArte']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', Label);
  77. var query3 = pref + (queryManager['queryMMO']['queryIdentificatore']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', testo);
  78. var query4 = pref + (queryManager['queryINF']['queryContenuti1']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label);
  79. var query5 = pref + (queryManager['queryINF']['queryContenuti2']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label);
  80. var query6 = pref + (queryManager['queryINF']['queryContenuti3']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', object_Label);
  81. var query7 = pref + (queryManager['queryPER']['queryNome']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', name_per);
  82. var query8 = pref + (queryManager['queryPER']['queryNote']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', note_per);
  83. var query9 = pref + (queryManager['queryPER']['queryOccupazione']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', occupation_per);
  84. var query10 = pref + (queryManager['queryLG']['queryLuoghi']).replace('<{GRAPH}>', search_graph).replace('<{WORD}>', place_search);
  85. // la funzione doJsonQuery restituisce direttamente l'oggetto della chiamata ajax in json.
  86. // Una volta effettuata la chiamata, il risultato è passato alla funzione manage...
  87. doJsonQuery(query1).done(function(r) { manageMMO(r); });
  88. doJsonQuery(query2).done(function(r) { manageMMO(r); });
  89. doJsonQuery(query3).done(function(r) { manageMMO(r); });
  90. doJsonQuery(query4).done(function(r) { manageINF(r); });
  91. doJsonQuery(query5).done(function(r) { manageINF(r); });
  92. doJsonQuery(query6).done(function(r) { manageINF(r); });
  93. doJsonQuery(query7).done(function(r) { managePER(r); });
  94. doJsonQuery(query8).done(function(r) { managePER(r); });
  95. doJsonQuery(query9).done(function(r) { managePER(r); });
  96. doJsonQuery(query10).done(function(r) { manageLG(r); });
  97. });
  98. $('input#TextArea1').keypress(function(e) {
  99. var key = e.which;
  100. if (key == 13) // the enter key code
  101. {
  102. $('#ClipArt1').click();
  103. return false;
  104. }
  105. });
  106. });
  107. function checkEmpty() {
  108. if ($("#Man-Made_Object").is(':empty')) {
  109. var message = '<p class="no-results">Nessun <span>Oggetto Fisico</span> trovato</p>';
  110. $('#Man-Made_Object').append(message);
  111. }
  112. if ($("#Information_Object").is(':empty')) {
  113. var message = '<p class="no-results">Nessun <span>Oggetto Informativo</span> trovato</p>';
  114. $('#Information_Object').append(message);
  115. }
  116. if ($("#Person").is(':empty')) {
  117. var message = '<p class="no-results">Nessuna <span>Persona</span> trovata</p>';
  118. $('#Person').append(message);
  119. }
  120. if ($("#Place").is(':empty')) {
  121. var message = '<p class="no-results">Nessun <span>Luogo</span> trovato</p>';
  122. $('#Place').append(message);
  123. }
  124. }
  125. function rewrite_graph(graph) {
  126. var graph_name = ""
  127. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") {
  128. graph_name = "Archivio di Stato di Prato - Fondo Datini";
  129. }
  130. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") {
  131. graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce";
  132. }
  133. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") {
  134. graph_name = "Archivio di Stato di Prato - Fondo Marcolvaldi";
  135. }
  136. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") {
  137. graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce";
  138. }
  139. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/actors") {
  140. graph_name = "Archivio di Stato di Prato";
  141. }
  142. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/martini") {
  143. graph_name = "Museo di Palazzo Pretorio di Prato";
  144. }
  145. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale") {
  146. graph_name = "Museo di Palazzo Pretorio di Prato";
  147. }
  148. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/datini") {
  149. graph_name = "Museo di Palazzo Pretorio di Prato";
  150. }
  151. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/authors") {
  152. graph_name = "Museo di Palazzo Pretorio di Prato";
  153. }
  154. else if (graph == "http://dev.restore.ovi.cnr.it:8890/ovi/datini") {
  155. graph_name = "Opera del Vocabolario Italiano";
  156. }
  157. else if (graph == "http://dev.restore.ovi.cnr.it:8890/ovi/datini/trascr") {
  158. graph_name = "Opera del Vocabolario Italiano";
  159. }
  160. else if (graph == "http://dev.restore.ovi.cnr.it:8890/places") {
  161. graph_name = "Luoghi";
  162. }
  163. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/places") {
  164. graph_name = "Museo di Palazzo Pretorio di Prato";
  165. }
  166. else if (graph == "http://dev.restore.ovi.cnr.it:8890/label/toponimi") {
  167. graph_name = "Toponimi Archivio di Stato di Prato";
  168. }
  169. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica") {
  170. graph_name = "Archivio di Stato di Prato - Onomatica Datini";
  171. }
  172. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli/newdataset") {
  173. graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce";
  174. }
  175. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica/gruppi") {
  176. graph_name = "Archivio di Stato di Prato - Onomastica Datini";
  177. }
  178. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/autori") {
  179. graph_name = "Museo di Palazzo Pretorio";
  180. }
  181. else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica/datini") {
  182. graph_name = "Archivio di Stato di Prato - Onomastica Datini";
  183. }
  184. else if (graph == "http://dev.restore.ovi.cnr.it:8890/onomastica/ospedale") {
  185. graph_name = "Archivio di Stato di Prato - Fondo Ospedale Misericordia e Dolce";
  186. }
  187. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/ulan/viaf") {
  188. graph_name = "Persone";
  189. }
  190. else if (graph == "http://dev.restore.ovi.cnr.it:8890/places/microtoponimi") {
  191. graph_name = "Luoghi";
  192. }
  193. else {graph_name = graph;
  194. }
  195. return graph_name;
  196. }
  197. function MMO_handle_json(json) {
  198. // console.log(json);
  199. mmoQueries = mmoQueries+1;
  200. if(mmoQueries==3){
  201. $('#mmoLoader').css("display", "none");
  202. }
  203. $('#wb_Shape1').text("");
  204. $(".results").css("display", "block");
  205. var n_mmo = $('#n_mmo').text();
  206. var b = parseInt(n_mmo);
  207. var i = 0;
  208. $.each(
  209. json['results']['bindings'],
  210. function (index, value) {
  211. var object = ""; /*Inserisci VALUE TIPOLOGIA*/
  212. var graph = value['graph']['value'];
  213. var graph_name = rewrite_graph(graph);
  214. var mmoType = "";
  215. var mmoId = "";
  216. var object_button = "";
  217. var object_type = "";
  218. if (value.hasOwnProperty('type')) {
  219. mmoType = value['type']['value'];
  220. }
  221. if (value.hasOwnProperty('identifier')) {
  222. mmoId = value['identifier']['value'];
  223. }
  224. if (mmoType.includes("Opera d'Arte")) {
  225. object_type = "artwork";
  226. object_button += '<button type="button" id="' + value['subject']['value'] +
  227. '" class="artwork btn btn-default" alt="opera d\'arte" title="' + value['label']['value'] +
  228. '"><i class="fas fa-paint-brush"></i><p class="btn-text">Scheda Opera d\'Arte</p></button>';
  229. } else {
  230. object_type = "object";
  231. object_button += '<button type="button" id="' + value['subject']['value'] +
  232. '" class="object btn btn-default" alt="oggetto" title="' + value['label']['value'] +
  233. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  234. }
  235. object += /*INIZIO DIV*/ '<div class="row res"><div class="col-8">' + graph_name + '<br />' +
  236. '<span id="' + value['subject']['value'] + '" class="title_doc ' + object_type +'">' + value['label']['value'] + '</span><br />' +
  237. '<i>' + mmoType + ' ' + mmoId + '</i></div>' +
  238. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  239. '<button type="button" value="' + object_type + '" 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>' +
  240. /*DA QUI HYPERLINK ->*/'<button type="button" value="' + object_type + '" 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>' +
  241. /*DA QUI LOD ->*/'<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>';
  242. i++;
  243. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  244. $('#Man-Made_Object').append(object);
  245. });
  246. var n_oggetto = b + i;
  247. $('#n_mmo').text("");
  248. $('#n_mmo').append(n_oggetto);
  249. if (n_oggetto == 0) {
  250. $('#Man-Made_Object').text("");
  251. var message = '<p id="no_mmo" class="no-results">Nessun <span>Oggetto Fisico</span> trovato</p>';
  252. $('#Man-Made_Object').append(message);
  253. } else {
  254. $('#no_mmo').remove("");
  255. }
  256. }
  257. function InfObj_handle_json(json) {
  258. // console.log(json);
  259. infQueries = infQueries+1;
  260. if(infQueries==3){
  261. $('#infLoader').css("display", "none");
  262. }
  263. var n_io = $('#n_io').text();
  264. var b = parseInt(n_io);
  265. var i = 0;
  266. $.each(
  267. json['results']['bindings'],
  268. function (index, value) {
  269. var information = ""; /*Inserisci VALUE TIPOLOGIA*/
  270. var graph = value['graph']['value'];
  271. var graph_name = rewrite_graph(graph);
  272. var tipo = "";
  273. var id = "";
  274. var infObject_button = "";
  275. if (value['text']['type'] != 'uri') {
  276. var myString = value['text']['value'];
  277. var str = myString.replace(/<[^>]*>?/gm, '');
  278. let string_text = str.toLowerCase();
  279. let string_len = str.length;
  280. var word = Parole;
  281. let ind = string_text.indexOf(word);
  282. let length = word.length;
  283. var wl = ind + length;
  284. var resource_type = "";
  285. var link_type = "";
  286. /*var start = 0;
  287. var end = 0
  288. var bb = pp - 50;
  289. var ee = pp + length + 150;*/
  290. var pp = ind;
  291. before = str.substring(0, ind);
  292. after = str.substring(wl, string_len);
  293. let bb = before.lastIndexOf(".");
  294. let point = bb + pp;
  295. let ee = str.indexOf(".", point);
  296. if (bb < 0) {
  297. start = 0;
  298. } else {
  299. start = bb+1;
  300. }
  301. if (ee < 0) {
  302. end = string_len;
  303. } else {
  304. end = ee;
  305. }
  306. first_chunk = str.substring(start, ind);
  307. highlight = str.substring(ind, wl);
  308. second_chunk = str.substring(wl, end);
  309. var snippet = first_chunk + highlight + second_chunk ;
  310. //var snippet = first_chunk + "<span class='sharp'>" + highlight + "</span>" + second_chunk ;
  311. if (value.hasOwnProperty('types')) {
  312. tipo = value['types']['value'];
  313. }
  314. if (value.hasOwnProperty('id')) {
  315. id = " (" + value['id']['value'] + ")";
  316. }
  317. if (tipo.includes("lettera")) {
  318. link_name = value['subject']['value'];
  319. resource_type = "lettera";
  320. link_type = "lettera";
  321. infObject_button += '<button type="button" id="' + value['subject']['value'] +
  322. '" class="lettera btn btn-default" alt="lettera" title="' + value['label']['value'] +
  323. '"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  324. } else {
  325. link_name = value['Physical_Object']['value'];
  326. resource_type = "object";
  327. link_type = "object";
  328. infObject_button += '<button type="button" id="' + value['Physical_Object']['value'] +
  329. '" class="object btn btn-default" alt="oggetto" title="' + value['label']['value'] +
  330. '"><i class="fa fa-book"></i><p class="btn-text">Scheda Oggetto</p></button>';
  331. }
  332. //'<div class="row res"><div class="col-8"><p>' + graph_name + '<br />' +
  333. //'<span id="' + value['subject']['value'] + '" class="title_doc luogo">' + value['label']['value'] + '</span></p></div>'
  334. information += /*INIZIO DIV*/ '<div class="row res"><div class="col-8"><p>'+ snippet+'</p>' +
  335. 'In: ' + graph_name + ';<br />' +
  336. '<span id="' + link_name + '" class="title_doc ' + link_type + '">' + value['label']['value'] + id +
  337. '</span>;<br /><i>' + tipo + '</i><br /></div>' +
  338. '<div class="col d-flex align-items-start justify-content-end">' + infObject_button +
  339. '<button type="button" value="' + resource_type + '" 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>' +
  340. /*DA QUI HYPERLINK ->*/'<button type="button" value="' + resource_type + '" 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>' +
  341. /*DA QUI LOD ->*/'<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>';
  342. i++;
  343. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  344. $('#Information_Object').append(information);
  345. }
  346. });
  347. var n_oggetto = b + i;
  348. $('#n_io').text("");
  349. $('#n_io').append(n_oggetto);
  350. if (n_oggetto == 0) {
  351. $('#Information_Object').text("");
  352. var message = '<p id="no_io" class="no-results">Nessun <span>Testo</span> trovato</p>';
  353. $('#Information_Object').append(message);
  354. } else {
  355. $('#no_io').remove("");
  356. }
  357. }
  358. function Person_handle_json(json) {
  359. console.log(json);
  360. perQueries = perQueries+1;
  361. if(perQueries==3){
  362. $('#perLoader').css("display", "none");
  363. }
  364. var n_ps = $('#n_ps').text();
  365. var b = parseInt(n_ps);
  366. var i = 0;
  367. $.each(
  368. json['results']['bindings'],
  369. function (index, value) {
  370. var person = ""; /*Inserisci VALUE TIPOLOGIA*/
  371. var graph = value['graph']['value'];
  372. var graph_name = rewrite_graph(graph);
  373. person += /*INIZIO DIV*/ '<div class="row res"><div class="col-8"><p>' + graph_name + '<br />' +
  374. '<span id="' + value['subject']['value'] + '" class="title_doc persona">' + value['name']['value'] + '</span></p></div>' +
  375. '<div class="col d-flex align-items-start justify-content-end"><button type="button" id="' + value['subject']['value'] + '" class="persona btn btn-default" alt="persona" title="' +
  376. value['name']['value'] + '"><i class="fa fa-user"></i><p class="btn-text">Scheda Persona</p></button>' +
  377. '<button type="button" value="Persona" 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>' +
  378. /*DA QUI HYPERLINK ->*/'<button type="button" value="Persona" 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>' +
  379. /*DA QUI LOD ->*/'<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>';
  380. i++;
  381. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  382. $('#Person').append(person);
  383. });
  384. var n_oggetto = b + i;
  385. $('#n_ps').text("");
  386. $('#n_ps').append(n_oggetto);
  387. if (n_oggetto == 0) {
  388. $('#Person').text("");
  389. var message = '<p id="no_ps" class="no-results">Nessun <span>Persona</span> trovata</p>';
  390. $('#Person').append(message);
  391. } else {
  392. $('#no_ps').remove("");
  393. }
  394. }
  395. function Place_handle_json(json) {
  396. // console.log(json);
  397. lgQueries = lgQueries+1;
  398. if(lgQueries==1){
  399. $('#lgLoader').css("display", "none");
  400. }
  401. var n_pl = $('#n_pl').text();
  402. var b = parseInt(n_pl);
  403. var i = 0;
  404. $.each(
  405. json['results']['bindings'],
  406. function (index, value) {
  407. var place = ""; /*Inserisci VALUE TIPOLOGIA*/
  408. var graph = value['graph']['value'];
  409. var graph_name = rewrite_graph(graph);
  410. place += /*INIZIO DIV*/ '<div class="row res"><div class="col-8"><p>' + graph_name + '<br />' +
  411. '<span id="' + value['subject']['value'] + '" class="title_doc luogo">' + value['label']['value'] + '</span></p></div>' +
  412. '<div class="col d-flex align-items-start justify-content-end"><button type="button" id="' + value['subject']['value'] + '" class="luogo btn btn-default" alt="luogo" title="' +
  413. value['label']['value'] + '"><i class="fa fa-map"></i><p class="btn-text">Scheda Luogo</p></button>' +
  414. '<button type="button" value="Luogo" 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>' +
  415. /*DA QUI HYPERLINK ->*/'<button type="button" value="Luogo" 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>' +
  416. /*DA QUI LOD ->*/'<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>';
  417. i++;
  418. /*onclick=copy__Text("' + value['link']['value'] + '")*/
  419. $('#Place').append(place);
  420. });
  421. var n_oggetto = b + i;
  422. $('#n_pl').text("");
  423. $('#n_pl').append(n_oggetto);
  424. if (n_oggetto == 0) {
  425. $('#Place').text("");
  426. var message = '<p id="no_pl" class="no-results">Nessun <span>Luogo</span> trovato</p>';
  427. $('#Place').append(message);
  428. } else {
  429. $('#no_pl').remove("");
  430. }
  431. }
  432. //onlick hyperlink button
  433. $(document).on("click", ".hyp", function (ev) {
  434. var baseurl = window.location.origin+window.location.pathname;
  435. let slash = baseurl.lastIndexOf("/");
  436. var type = $(this).val() + '.html';
  437. var link = this.id;
  438. var url = baseurl.substr(0, slash+1) + type + "?link="+link;
  439. var link = this.id;
  440. $("#myModal").empty();
  441. $("#myModal").css("display", "block");
  442. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  443. url + "</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  444. });
  445. $(document).on("click", ".lettera", function (ev) {
  446. var link = this.id;
  447. //alert(nome_autore);
  448. //$('#myModal').text("");
  449. window.open("lettera.html?link="+this.id);
  450. });
  451. $(document).on("click", ".object", function (ev) {
  452. var link = this.id;
  453. //alert(nome_autore);
  454. //$('#myModal').text("");
  455. window.open("object.html?link="+this.id);
  456. });
  457. $(document).on("click", ".artwork", function (ev) {
  458. var link = this.id;
  459. //alert(nome_autore);
  460. //$('#myModal').text("");
  461. window.open("OA.html?link="+this.id);
  462. });
  463. $(document).on("click", ".persona", function (ev) {
  464. var link = this.id;
  465. //alert(nome_autore);
  466. //$('#myModal').text("");
  467. window.open("Persona.html?link="+this.id);
  468. });
  469. $(document).on("click", ".luogo", function (ev) {
  470. var link = this.id;
  471. //alert(nome_autore);
  472. //$('#myModal').text("");
  473. window.open("Luogo.html?link="+this.id);
  474. });
  475. $(document).on("click", ".close", function (ev) {
  476. var link = this.id;
  477. //alert(nome_autore);
  478. //$('#myModal').text("");
  479. $("#myModal").css("display", "none");
  480. });
  481. $(document).on("click", ".back", function (ev) {
  482. $("#myTab").css("display", "none");
  483. });
  484. $(document).on("click", ".cit", function (ev) {
  485. var author ="RESTORE. smart access to digital heritage and memory"
  486. var year = new Date().getFullYear()
  487. var today = new Date();
  488. var dd = String(today.getDate()).padStart(2, '0');
  489. var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
  490. var yyyy = today.getFullYear();
  491. today = dd + '/' + mm + '/' + yyyy;
  492. var baseurl = window.location.origin+window.location.pathname;
  493. let slash = baseurl.lastIndexOf("/");
  494. var type = $(this).val() + '.html';
  495. var link = this.id;
  496. var url = baseurl.substr(0, slash+1) + type + "?link="+link;
  497. //alert(nome_autore);
  498. //$('#myModal').text("");
  499. $("#myModal").empty();
  500. $("#myModal").css("display", "block");
  501. $('#myModal').append("<div class='modal-content'><div class='modal-close'><span class='close'>&times;</span></div><div id='myInput'>" +
  502. author + " " + year + ", accesso effettuato: " + today + ", &lt;" + url + "&gt;</div><button id='copy_btn' class='btn btn-theme-primary btn-md' onclick='myFunction()'>Copia</button>");
  503. });
  504. //#######################################
  505. function prepareQueryURL(query){
  506. sparqlEndpoint = 'http://dev.restore.ovi.cnr.it:8890/sparql/';
  507. sparqlUrlParams = '?default-graph-uri=&query=' + encodeURIComponent(query) + '&output=json&callback=?';
  508. return sparqlEndpoint + sparqlUrlParams;
  509. }
  510. // Esegue una query sull'endpoint SPARQL il cui testo completo deve essere fornito nel parametro-stringa 'query'
  511. // Restituisce una lista di oggetti json nel formato di Virtuoso
  512. // Il parametro opzionale 'isUnique', se messo a 'true' controlla che ci sia un unico risultato (un array di
  513. // lunghezza 1) e se non è così restituisce un errore.
  514. //restituisce direttamente l'oggetto della chiamata ajax
  515. function doJsonQuery(query) {
  516. queryURL = prepareQueryURL(query);
  517. return $.ajax({
  518. url: queryURL,
  519. dataType: "json",
  520. type: 'GET'
  521. });
  522. }
  523. //funzione che prende il risultato della chiamata ajax e fa tutto quello che serve dopo
  524. function manageMMO(result){
  525. // console.log(result);
  526. MMO_handle_json(result);
  527. }
  528. function manageINF(result){
  529. // console.log(result);
  530. InfObj_handle_json(result);
  531. }
  532. function managePER(result){
  533. // console.log(result);
  534. Person_handle_json(result);
  535. }
  536. function manageLG(result){
  537. // console.log(result);
  538. Place_handle_json(result);
  539. }
  540. function populateOption() {
  541. const graph_selector = document.getElementById("graph_selector");
  542. const graph_selector2 = document.getElementById("graph_selector2");
  543. const createOption = (graph_selector, text, value) => {
  544. const opt = document.createElement('option');
  545. opt.value = value;
  546. opt.text = text;
  547. graph_selector.options.add(opt);
  548. }
  549. const configureDropDownLists = (graph_selector, graph_selector2) => {
  550. const ASPO = [
  551. ['Tutti Fondi', ''],
  552. ['Fondo Datini', 'aspo_datini'],
  553. ['Fondo Ospedale Misericordia e Dolce', 'aspo_ospedale'],
  554. ['Fondo Marcovaldi', 'aspo_marcovaldi'],
  555. ['Fondo Gettatelli', 'aspo_gettatelli']
  556. ];
  557. const MPP = [
  558. ['Tutte', ''],
  559. ['Galleria Martini', 'mpp_martini'],
  560. ['Opere provenienti dall’Ospedale', 'mpp_ospedale'],
  561. ['Iconografia Datini', 'mpp_datini']
  562. ];
  563. const OVI = [
  564. ['Tutte le risorse', ''],
  565. ['Lettere', 'ovi_lettere']
  566. ];
  567. graph_selector2.options.length = 0
  568. switch (graph_selector.value) {
  569. case 'ASPO':
  570. for (const c of ASPO) {
  571. createOption(graph_selector2, c[0], c[1]);
  572. }
  573. break;
  574. case 'MPP':
  575. for (const s of MPP) {
  576. createOption(graph_selector2, s[0], s[1]);
  577. }
  578. break;
  579. case 'OVI':
  580. for (const n of OVI) {
  581. createOption(graph_selector2, n[0], n[1]);
  582. }
  583. break;
  584. default:
  585. break;
  586. }
  587. }
  588. graph_selector.addEventListener('change', () => {
  589. $("#graph_selector2").css("display", "block");
  590. configureDropDownLists(graph_selector, graph_selector2)
  591. });
  592. }
  593. function getGraph(graph1, graph2) {
  594. var search_graph = "";
  595. if ((graph1 == '') && (graph2 == '')) {
  596. search_graph = "";
  597. }
  598. else if ((graph1 != '') && (graph2 == '')) {
  599. if (graph1 == "ASPO") {
  600. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/aspo/datini> \
  601. <http://dev.restore.ovi.cnr.it:8890/aspo/ospedale> \
  602. <http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi> \
  603. <http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli>}";
  604. }
  605. if (graph1 == "MPP") {
  606. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/mpp/martini> \
  607. <http://dev.restore.ovi.cnr.it:8890/mpp/ospedale> \
  608. <http://dev.restore.ovi.cnr.it:8890/mpp/datini> \
  609. <http://dev.restore.ovi.cnr.it:8890/mpp/autori> }";
  610. }
  611. if (graph1 == "OVI") {
  612. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/ovi/datini>}";
  613. }
  614. }
  615. else if (graph2 != '') {
  616. if (graph2 == "aspo_datini") {
  617. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/aspo/datini>}";
  618. }
  619. if (graph2 == "aspo_ospedale") {
  620. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/aspo/ospedale>}";
  621. }
  622. if (graph2 == "aspo_marcovaldi") {
  623. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi>}";
  624. }
  625. if (graph2 == "aspo_gettatelli") {
  626. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli>}";
  627. }
  628. if (graph2 == "mpp_martini") {
  629. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/mpp/martini>}";
  630. }
  631. if (graph2 == "mpp_ospedale") {
  632. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/mpp/ospedale>}";
  633. }
  634. if (graph2 == "mpp_datini") {
  635. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/mpp/datini>}";
  636. }
  637. if (graph2 == "ovi_lettere") {
  638. search_graph = "VALUES ?g {<http://dev.restore.ovi.cnr.it:8890/ovi/datini>}";
  639. }
  640. } else {
  641. search_graph = "";
  642. }
  643. return search_graph;
  644. }
  645. function copyToClipboard(text) {
  646. var sampleTextarea = document.createElement("textarea");
  647. document.body.appendChild(sampleTextarea);
  648. sampleTextarea.value = text; //save main text in it
  649. sampleTextarea.select(); //select textarea contenrs
  650. document.execCommand("copy");
  651. document.body.removeChild(sampleTextarea);
  652. }
  653. function myFunction(){
  654. var copy = document.getElementById("myInput");
  655. copyText = copy.textContent;
  656. copyToClipboard(copyText);
  657. //copyToClipboard(copyText.value);
  658. }