object.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. var link = thisUrlParams.link;
  2. prefixes = queryManager['prefixes']['all'];
  3. queryURL = prefixes + (queryManager['querySchedaOggetto']['queryInfo']).replace('{URI}', link);
  4. console.log(queryURL);
  5. doJsonQuery(queryURL).done(function(data) { handle_objectData(data); });
  6. queryINF = prefixes + (queryManager['querySchedaOggetto']['queryContent']).replace('{URI}', link);
  7. doJsonQuery(queryINF).done(function(data) { handle_objectInfo(data); });
  8. queryGT = prefixes + (queryManager['querySchedaOggetto']['queryContrassegni']).replace('{URI}', link);
  9. doJsonQuery(queryGT).done(function(data) { handle_contrassegni(data); });
  10. queryOVI = prefixes + (queryManager['querySchedaOggetto']['queryOviLetter']).replace('{URI}', link);
  11. doJsonQuery(queryOVI).done(function(data) { handle_oviLetter(data); });
  12. queryPERS = prefixes + (queryManager['querySchedaOggetto']['queryPersone']).replace('{URI}', link);
  13. doJsonQuery(queryPERS).done(function(data) { handle_citedPeople(data); });
  14. queryLG = prefixes + (queryManager['querySchedaOggetto']['queryLuoghiGT']).replace('{URI}', link);
  15. doJsonQuery(queryLG).done(function(data) { handle_luoghiDocumento(data); });
  16. queryTR = prefixes + (queryManager['querySchedaOggetto']['queryTree']).replace('{URI}', link);
  17. doJsonQuery(queryTR).done(function(data) { handle_treeview(data, link); });
  18. function handle_objectData(json) {
  19. console.log(json);
  20. $.each(
  21. json['results']['bindings'],
  22. function (index, value) {
  23. var graph = value['graph']['value'];
  24. var label = value['label']['value'];
  25. var uri = value['uri']['value'];
  26. var siglaRegistro = "";
  27. var identifier = "";
  28. var dimensions = "";
  29. var consistence = "";
  30. var materials = "";
  31. var description = "";
  32. var button_ext = "";
  33. var button_owner = "";
  34. var current_owner = "";
  35. var uri_owner = "";
  36. var dates = "";
  37. var uri_composed = "";
  38. var composed = "";
  39. var button_doc = "";
  40. var treeList = "";
  41. var dataset = get_graph_name(graph);
  42. if (value.hasOwnProperty('id')) {
  43. $("#ID").css("display", "flex");
  44. identifier = value['id']['value'];
  45. }
  46. if (value.hasOwnProperty('dimension')) {
  47. $("#dimensione").css("display", "flex");
  48. dimensions = value['dimensions']['value'];
  49. }
  50. if (value.hasOwnProperty('consistency')) {
  51. $("#consistenza").css("display", "flex");
  52. consistence = value['consistency']['value'];
  53. }
  54. if (value.hasOwnProperty('sigla_registro')) {
  55. $("#IDreg").css("display", "flex");
  56. siglaRegistro = value['sigla_registro']['value'];
  57. }
  58. if (value.hasOwnProperty('condition')) {
  59. $("#STCC").css("display", "flex");
  60. condition = value['condition']['value'];
  61. }
  62. if (value.hasOwnProperty('material')) {
  63. $("#materia").css("display", "flex");
  64. materials = value['material']['value'];
  65. }
  66. if (value.hasOwnProperty('uri_owner')) {
  67. $("#current_owner").css("display", "flex");
  68. current_owner = value['owner']['value'];
  69. uri_owner = value['uri_owner']['value'];
  70. }
  71. if (value.hasOwnProperty('time_span')) {
  72. if (value['time_span']['value'] != ""){
  73. $("#time_span_object").css("display", "flex");
  74. dates = value['time_span']['value'];
  75. }
  76. }
  77. if (value.hasOwnProperty('note')) {
  78. $("#notes").css("display", "flex");
  79. description = value['note']['value'];
  80. }
  81. if (value.hasOwnProperty('uri_document')) {
  82. uri_composed = value['uri_document']['value'];
  83. }
  84. if (value.hasOwnProperty('document')) {
  85. //$("#composed").css("display", "flex");
  86. composed = value['document']['value'];
  87. }
  88. if (identifier != "") {
  89. button_ext = '<a title="Apri risorsa originale" href= "' + uri + '">' + identifier + '</a>';
  90. }
  91. if (uri_composed != "") {
  92. /*button_doc = '<button title="Apri risorsa di livello superiore" id="' + uri_composed + '" class="object btn btn-default" type="button" > \
  93. <i class="fa fa-book" aria-hidden="true"> <p class="btn-text">Livello superiore</p></i></button>';
  94. */
  95. treeList = '<li class="upLevel"><span id="' + uri_composed + '" class="object"><i class="fa fa-folder-open"></i>' +
  96. '<w class="link">' + composed + '</w></span><ul><li><span class="tree_label"><i class="fa fa-file-alt"></i>' + label + '<li></span><ul></li>'
  97. }
  98. if (owner != "") {
  99. button_owner = '<a title="Vai al sito dell\'Istituto" href= "' + uri_owner + '">' + current_owner + '</a>';
  100. }
  101. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  102. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  103. <button title="Citazione" type="button" value="object" id="' + uri + '" class="cit btn btn-default" alt="scheda" title="Citazione"><i class="fa fa-quote-right"></i></button> \
  104. <button title="Permalink" type="button" value="object" id="' + uri + '" class="hyp btn btn-default" alt="scheda" title="Hyperlink"><i class="fa fa-link"></i></button> \
  105. <a href="http://dev.restore.ovi.cnr.it/lodlive/?' + uri + '" target="_blank"><button type="button" title="Naviga il grafo" class="btn btn-default info" alt="LOD" title="LodLive"><i class="fa fa-share-alt"></i></button></a></div></div>';
  106. document.getElementById("grafo").innerHTML = dataset;
  107. document.getElementById("nome_oggetto").innerHTML = label;
  108. document.getElementById("identifier").innerHTML = button_ext;
  109. document.getElementById("nota").innerHTML = description;
  110. document.getElementById("sigla_registro").innerHTML = siglaRegistro;
  111. document.getElementById("dimensions").innerHTML = dimensions;
  112. document.getElementById("materials").innerHTML = materials;
  113. document.getElementById("consistence").innerHTML = consistence;
  114. document.getElementById("owner").innerHTML = button_owner;
  115. document.getElementById("timeSpan").innerHTML = dates;
  116. document.getElementById("superDoc").innerHTML = composed;
  117. //document.getElementById("btn_superDoc").innerHTML = button_doc;
  118. document.getElementById("link_buttons").innerHTML = Buttons;
  119. document.getElementById("tree").innerHTML = treeList;
  120. });
  121. }
  122. function get_graph_name(graph) {
  123. var dataset = "Scheda Oggetto";
  124. if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale") {
  125. dataset = dataset + " / Ospedale";
  126. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/datini") {
  127. dataset = dataset + " / Datini";
  128. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi") {
  129. dataset = dataset + " / Marcovaldi";
  130. } else if (graph == "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli") {
  131. dataset = dataset + " / Gettatelli";
  132. } else {
  133. dataset = dataset;
  134. }
  135. return dataset;
  136. }
  137. function handle_contrassegni(json) {
  138. console.log(json);
  139. var uri = "";
  140. var graph = "";
  141. var contrassegno = "";
  142. var immagine = "";
  143. var uri_gettatello = "";
  144. var gettatello = "";
  145. var Images = "";
  146. let markImg = [];
  147. let imgMark = [];
  148. var tiles = [];
  149. $.each(
  150. json['results']['bindings'],
  151. function (index, value) {
  152. uri = value['uri']['value'];;
  153. contrassegno = value['contrassegno']['value'];
  154. immagine = value['image']['value'];
  155. uri_gettatello = value['uri_person']['value'];
  156. gettatello = value['gettatello']['value'];
  157. graph = value['g']['value'];
  158. if (immagine != "") {
  159. $("#IMM").css("display", "flex");
  160. var cos_image = "http://restore.ovi.cnr.it/img/contrassegni/" + immagine;
  161. //let imgs = immagine.split("_");
  162. tiles.push({
  163. type: "image",
  164. url: cos_image
  165. });
  166. /*const suffix = ["_a", "_b", "_c", "_a_2", "_a1", "_a2"];
  167. for (var k=0; k<suffix.length; k++) {
  168. var image_url = "http://restore.ovi.cnr.it/img/contrassegni/" + imgs[0] + suffix[k] + ".jpg";
  169. markImg.push(image_url);
  170. }*/
  171. }
  172. });
  173. if ((gettatello != "") && (uri_gettatello != "")) {
  174. $("#GT").css("display", "flex");
  175. var gt_btn = '<button type="button" id="' + uri_gettatello +
  176. '" class="persona btn btn-default" alt="persona"><i class="fa fa-user"></i><p class="btn-text">Persona</p></button>';
  177. document.getElementById('pp_gettatello').innerHTML = gettatello;
  178. document.getElementById('btn_gt').innerHTML = gt_btn;
  179. }
  180. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  181. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  182. <button title="Citazione" type="button" value="object" id="' + uri + '" class="cit btn btn-default" alt="scheda" title="Citazione"><i class="fa fa-quote-right"></i></button> \
  183. <button title="Permalink" type="button" value="object" id="' + uri + '" class="hyp btn btn-default" alt="scheda" title="Hyperlink"><i class="fa fa-link"></i></button> \
  184. <a href="http://dev.restore.ovi.cnr.it/lodlive/?' + uri + '" target="_blank"><button type="button" title="Naviga il grafo" class="btn btn-default info" alt="LOD" title="LodLive"><i class="fa fa-share-alt"></i></button></a></div></div>';
  185. var dataset = get_graph_name(graph);
  186. runOpenseadragon(tiles);
  187. document.getElementById("nome_oggetto").innerHTML = contrassegno;
  188. document.getElementById("grafo").innerHTML = dataset;
  189. document.getElementById("link_buttons").innerHTML = Buttons;
  190. }
  191. function organizeImages(images) {
  192. console.log(images);
  193. var tiles2 = [];
  194. for (var i=0; i<images.length; i++) {
  195. tiles2.push({
  196. type: "image",
  197. url: images[i]
  198. });
  199. }
  200. runOpenseadragon(tiles2);
  201. }
  202. function createImage(image) {
  203. checkIfImageExists(image, (exists) => {
  204. if (exists) {
  205. console.log(image);
  206. var tile = {
  207. type: "image",
  208. url: images[i]
  209. };
  210. viewer.add-item(tile);
  211. /*var Image = '<div class="singleImg"> \
  212. <img src="' + image + '" alt="contrassegno" style="width:100%" onclick="expandImg(this);"> \
  213. </div>';
  214. console.log(Image);
  215. $('#images').append(Image);*/
  216. } else {
  217. console.error('Image does not exists.')
  218. }
  219. });
  220. }
  221. function checkIfImageExists(url, callback) {
  222. const img = new Image();
  223. img.src = url;
  224. if (img.complete) {
  225. callback(true);
  226. } else {
  227. img.onload = () => {
  228. callback(true);
  229. };
  230. img.onerror = () => {
  231. callback(false);
  232. };
  233. }
  234. }
  235. function handle_objectInfo(json) {
  236. console.log(json['results']['bindings']);
  237. $.each(
  238. json['results']['bindings'],
  239. function (index, value) {
  240. var title = "";
  241. var type = "";
  242. var subject = "";
  243. if (value.hasOwnProperty('titolo')) {
  244. $("#titolo").css("display", "flex");
  245. title = value['titolo']['value'];
  246. }
  247. if (value.hasOwnProperty('tipo')) {
  248. $("#tipo").css("display", "flex");
  249. type = value['tipo']['value'];
  250. }
  251. if (value.hasOwnProperty('ref')) {
  252. if (value['ref']['value'] != "") {
  253. $("#argomento").css("display", "flex");
  254. subject = value['ref']['value'];
  255. }
  256. }
  257. document.getElementById("title").innerHTML = title;
  258. document.getElementById("type").innerHTML = type;
  259. document.getElementById("subject").innerHTML = subject;
  260. });
  261. }
  262. function handle_oviLetter(json) {
  263. console.log(json['results']['bindings']);
  264. $.each(
  265. json['results']['bindings'],
  266. function (index, value) {
  267. var other_id = "";
  268. var uri = "";
  269. var button_letter = "";
  270. if (value.hasOwnProperty('otherId')) {
  271. $("#IDbis").css("display", "flex");
  272. other_id = value['otherId']['value'];
  273. }
  274. if (value.hasOwnProperty('InfObj')) {
  275. uri = value['InfObj']['value'];
  276. }
  277. if (uri != "") {
  278. button_letter = '<button type="button" id="' + uri +
  279. '" class="lettera btn btn-default" alt="lettera"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  280. }
  281. document.getElementById("other_identifier").innerHTML = other_id;
  282. document.getElementById("btn_other_identifier").innerHTML = button_letter;
  283. });
  284. }
  285. function handle_citedPeople(json) {
  286. console.log(json);
  287. const people = [];
  288. $.each(
  289. json['results']['bindings'],
  290. function (index, value) {
  291. var uri = value['uri_person']['value'];
  292. var name = value['name']['value'];
  293. var tipo1 = "";
  294. var tipo2 = "";
  295. var nota = "";
  296. if (value.hasOwnProperty('types')) {
  297. if (value['types']['value'] != "") {
  298. tipo1 = value['types']['value'];
  299. }
  300. }
  301. if (value.hasOwnProperty('types2')) {
  302. if (value['types2']['value'] != "") {
  303. tipo2 = value['types2']['value'];
  304. }
  305. }
  306. if (value.hasOwnProperty('note')) {
  307. nota = value['note']['value'];
  308. }
  309. var tipo = "";
  310. if (tipo2 != "") {
  311. tipo = tipo2;
  312. } else {
  313. tipo = tipo1;
  314. }
  315. people.push([uri, name, tipo, nota]);
  316. });
  317. var Person = "";
  318. for (var i=0; i<people.length; i++) {
  319. var object = '<div class="col-8"><p><span id="' + people[i][0] + '" class="title_doc persona">'+ titleCase(people[i][1]) + '</span>';
  320. if (people[i][2] != "") {
  321. object = object + "<br />Ruoli documentati: " + people[i][2];
  322. }
  323. if (people[i][3] != "") {
  324. object = object + "<br />Nota: " + people[i][3];
  325. }
  326. object = object + '</p></div>';
  327. Person += '<div class="row res">' + object +
  328. '<div class="col d-flex align-items-start justify-content-end"><button type="button" id="' + people[i][0] + '" class="persona btn btn-default" alt="persona" title="' +
  329. people[i][1] + '"><i class="fa fa-user"></i><p class="btn-text">Persona</p></button>' +
  330. '<button type="button" value="Persona" id="' + people[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  331. '<button value="Persona" type="button" id="' + people[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  332. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + people[i][0] + '" 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>';
  333. }
  334. document.getElementById("n_pp").innerHTML = people.length;
  335. document.getElementById("cited_people").innerHTML = Person;
  336. if (people.length==0) {
  337. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  338. document.getElementById("cited_people").innerHTML = messaggio;
  339. }
  340. }
  341. function handle_treeview(json, uri_subject) {
  342. console.log(json);
  343. var upLevel = "";
  344. var uri_up = "";
  345. var tree_doc = "";
  346. $.each(
  347. json['results']['bindings'],
  348. function (index, value) {
  349. upLevel = value['label']['value'];
  350. uri_up = value['uri']['value'];
  351. var uri = value['uri_document']['value'];
  352. var document = value['document']['value'];
  353. tree_doc += '<li class="tree_el"><i class="fa fa-file-alt"></i><span id="' + uri + '" class="tree_seed link object">' + document + '</span><li>'
  354. });
  355. if (tree_doc != "") {
  356. var tree_list = '<li class="upLevelTree"><span style="cursor:pointer;" class="caret link"><i class="fa fa-folder-open"></i>' +
  357. '<w>' + upLevel + '</w></span><ul id="nested" style="display: none;">' + tree_doc + '</ul></li>';
  358. document.getElementById("treeView").innerHTML = tree_list;
  359. }
  360. }
  361. function handle_luoghiDocumento(json) {
  362. console.log(json);
  363. const places = [];
  364. $.each(
  365. json['results']['bindings'],
  366. function (index, value) {
  367. var uri = value['uri_place']['value'];
  368. var label = value['place']['value'];
  369. places.push([uri, label]);
  370. });
  371. var Luoghi = "";
  372. for (var i=0; i<places.length; i++) {
  373. var object = '<div class="col-8"><p><span id="' + places[i][0] + '" class="title_doc luogo">'+ places[i][1] + '</span></p></div>';
  374. var object_button = '<button type="button" id="' + places[i][0] +
  375. '" class="luogo btn btn-default" alt="oggetto" title="' + places[i][1] +
  376. '"><i class="fa fa-map"></i><p class="btn-text">luogo</p></button>';
  377. Luoghi += '<div class="row res">'+ object +
  378. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  379. '<button type="button" value="luogo" id="' + places[i][0] + '" class="cit btn btn-default" alt="scheda" title="Info"><i class="fa fa-quote-right"></i><p class="btn-text">Citazione</p></button>' +
  380. '<button type="button" value="luogo" id="' + places[i][0] + '" class="hyp btn btn-default" alt="scheda" title="Info"><i class="fa fa-link"></i><p class="btn-text">Hyperlink</p></button>' +
  381. '<a href="http://dev.restore.ovi.cnr.it/lodlive/?' + places[i][0] + '" 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>';
  382. }
  383. document.getElementById("n_pl").innerHTML = places.length;
  384. document.getElementById("section_places").innerHTML = Luoghi;
  385. if (places.length==0) {
  386. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  387. document.getElementById("section_places").innerHTML = messaggio;
  388. }
  389. }
  390. function createDivRelazione(type, id){
  391. htmlCode = '\
  392. <div class="row mb-2"> \
  393. <div class="col-sm-4"> \
  394. <span class="label"><RELATIONSHIP></span> \
  395. </div> \
  396. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  397. </div> \
  398. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  399. return htmlCode;
  400. }
  401. function createColRelazione(text, link, tipo, fa, tab, decl) {
  402. htmlCode = '\
  403. <div class="row"> \
  404. <div class="col <CLASS>"><NAME></div> \
  405. <div class="col-auto"> \
  406. <button class="<TIPO> btn btn-default" type="button" id="<URI>">\
  407. <i class="<BUTTON>" aria-hidden="true">\
  408. <p class="btn-text"><TAB></p>\
  409. </i>\
  410. </button>\</div> \
  411. </div>\
  412. '.replace("<NAME>", text).replace("<URI>", link).replace("<TIPO>", tipo).replace("<BUTTON>", fa).replace("<TAB>", tab).replace("<CLASS>", decl);
  413. return htmlCode;
  414. }
  415. $(document).on("click", ".caret", function (ev) {
  416. $("#nested").toggle();
  417. //$("#nested").css("display", "block");
  418. });