search.js 27 KB

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