search.js 25 KB

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