object.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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 provenienza = "";
  146. var uri_provenienza = "";
  147. var licenza = "";
  148. var provenienza_img = "";
  149. var licenza_img = "";
  150. var Images = "";
  151. let markImg = [];
  152. let imgMark = [];
  153. var tiles = [];
  154. $.each(
  155. json['results']['bindings'],
  156. function (index, value) {
  157. uri = value['uri']['value'];;
  158. contrassegno = value['contrassegno']['value'];
  159. immagine = value['image']['value'];
  160. uri_gettatello = value['uri_person']['value'];
  161. uri_provenienza = value['uri_istituto']['value'];
  162. licenza = value['license']['value'];
  163. provenienza = value['provenienza']['value'];
  164. gettatello = value['gettatello']['value'];
  165. graph = value['g']['value'];
  166. if (immagine != "") {
  167. $("#IMM").css("display", "flex");
  168. var cos_image = "http://restore.ovi.cnr.it/img/contrassegni/" + immagine;
  169. //let imgs = immagine.split("_");
  170. tiles.push({
  171. type: "image",
  172. url: cos_image
  173. });
  174. /*const suffix = ["_a", "_b", "_c", "_a_2", "_a1", "_a2"];
  175. for (var k=0; k<suffix.length; k++) {
  176. var image_url = "http://restore.ovi.cnr.it/img/contrassegni/" + imgs[0] + suffix[k] + ".jpg";
  177. markImg.push(image_url);
  178. }*/
  179. }
  180. });
  181. if ((gettatello != "") && (uri_gettatello != "")) {
  182. $("#GT").css("display", "flex");
  183. var gt_btn = '<button type="button" id="' + uri_gettatello +
  184. '" class="persona btn btn-default" alt="persona"><i class="fa fa-user"></i><p class="btn-text">Persona</p></button>';
  185. document.getElementById('pp_gettatello').innerHTML = gettatello;
  186. document.getElementById('btn_gt').innerHTML = gt_btn;
  187. }
  188. if (uri_provenienza != "") {
  189. $("#PRO_CARD").css("display", "flex");
  190. provenienza_img = '<a href="' + uri_provenienza + '">' + provenienza + '</a>';
  191. }
  192. if (licenza != "") {
  193. $("#CC_CARD").css("display", "flex");
  194. licenza_img = '<img src="' + licenza + '" width="100" height="auto" />';
  195. }
  196. if (contrassegno != "") {
  197. document.getElementById("nome_oggetto").innerHTML = contrassegno;
  198. }
  199. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  200. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  201. <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> \
  202. <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> \
  203. <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>';
  204. var dataset = get_graph_name(graph);
  205. runOpenseadragon(tiles);
  206. document.getElementById("grafo").innerHTML = dataset;
  207. document.getElementById("link_buttons").innerHTML = Buttons;
  208. document.getElementById("provenienza").innerHTML = provenienza_img;
  209. document.getElementById("license").innerHTML = licenza_img;
  210. }
  211. function organizeImages(images) {
  212. console.log(images);
  213. var tiles2 = [];
  214. for (var i=0; i<images.length; i++) {
  215. tiles2.push({
  216. type: "image",
  217. url: images[i]
  218. });
  219. }
  220. runOpenseadragon(tiles2);
  221. }
  222. function createImage(image) {
  223. checkIfImageExists(image, (exists) => {
  224. if (exists) {
  225. console.log(image);
  226. var tile = {
  227. type: "image",
  228. url: images[i]
  229. };
  230. viewer.add-item(tile);
  231. /*var Image = '<div class="singleImg"> \
  232. <img src="' + image + '" alt="contrassegno" style="width:100%" onclick="expandImg(this);"> \
  233. </div>';
  234. console.log(Image);
  235. $('#images').append(Image);*/
  236. } else {
  237. console.error('Image does not exists.')
  238. }
  239. });
  240. }
  241. function checkIfImageExists(url, callback) {
  242. const img = new Image();
  243. img.src = url;
  244. if (img.complete) {
  245. callback(true);
  246. } else {
  247. img.onload = () => {
  248. callback(true);
  249. };
  250. img.onerror = () => {
  251. callback(false);
  252. };
  253. }
  254. }
  255. function handle_objectInfo(json) {
  256. console.log(json['results']['bindings']);
  257. $.each(
  258. json['results']['bindings'],
  259. function (index, value) {
  260. var title = "";
  261. var type = "";
  262. var subject = "";
  263. if (value.hasOwnProperty('titolo')) {
  264. $("#titolo").css("display", "flex");
  265. title = value['titolo']['value'];
  266. }
  267. if (value.hasOwnProperty('tipo')) {
  268. $("#tipo").css("display", "flex");
  269. type = value['tipo']['value'];
  270. }
  271. if (value.hasOwnProperty('ref')) {
  272. if (value['ref']['value'] != "") {
  273. $("#argomento").css("display", "flex");
  274. subject = value['ref']['value'];
  275. }
  276. }
  277. document.getElementById("title").innerHTML = title;
  278. document.getElementById("type").innerHTML = type;
  279. document.getElementById("subject").innerHTML = subject;
  280. });
  281. }
  282. function handle_oviLetter(json) {
  283. console.log(json['results']['bindings']);
  284. $.each(
  285. json['results']['bindings'],
  286. function (index, value) {
  287. var other_id = "";
  288. var uri = "";
  289. var button_letter = "";
  290. if (value.hasOwnProperty('otherId')) {
  291. $("#IDbis").css("display", "flex");
  292. other_id = value['otherId']['value'];
  293. }
  294. if (value.hasOwnProperty('InfObj')) {
  295. uri = value['InfObj']['value'];
  296. }
  297. if (uri != "") {
  298. button_letter = '<button type="button" id="' + uri +
  299. '" class="lettera btn btn-default" alt="lettera"><i class="fa fa-envelope"></i><p class="btn-text">Scheda Lettera</p></button>';
  300. }
  301. document.getElementById("other_identifier").innerHTML = other_id;
  302. document.getElementById("btn_other_identifier").innerHTML = button_letter;
  303. });
  304. }
  305. function handle_citedPeople(json) {
  306. console.log(json);
  307. const people = [];
  308. $.each(
  309. json['results']['bindings'],
  310. function (index, value) {
  311. var uri = value['uri_person']['value'];
  312. var name = value['name']['value'];
  313. var tipo1 = "";
  314. var tipo2 = "";
  315. var nota = "";
  316. if (value.hasOwnProperty('types')) {
  317. if (value['types']['value'] != "") {
  318. tipo1 = value['types']['value'];
  319. }
  320. }
  321. if (value.hasOwnProperty('types2')) {
  322. if (value['types2']['value'] != "") {
  323. tipo2 = value['types2']['value'];
  324. }
  325. }
  326. if (value.hasOwnProperty('note')) {
  327. nota = value['note']['value'];
  328. }
  329. var tipo = "";
  330. if (tipo2 != "") {
  331. tipo = tipo2;
  332. } else {
  333. tipo = tipo1;
  334. }
  335. people.push([uri, name, tipo, nota]);
  336. });
  337. var Person = "";
  338. for (var i=0; i<people.length; i++) {
  339. var object = '<div class="col-8"><p><span id="' + people[i][0] + '" class="title_doc persona">'+ titleCase(people[i][1]) + '</span>';
  340. if (people[i][2] != "") {
  341. object = object + "<br />Ruoli documentati: " + people[i][2];
  342. }
  343. if (people[i][3] != "") {
  344. object = object + "<br />Nota: " + people[i][3];
  345. }
  346. object = object + '</p></div>';
  347. Person += '<div class="row res">' + object +
  348. '<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="' +
  349. people[i][1] + '"><i class="fa fa-user"></i><p class="btn-text">Persona</p></button>' +
  350. '<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>' +
  351. '<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>' +
  352. '<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>';
  353. }
  354. document.getElementById("n_pp").innerHTML = people.length;
  355. document.getElementById("cited_people").innerHTML = Person;
  356. if (people.length==0) {
  357. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  358. document.getElementById("cited_people").innerHTML = messaggio;
  359. }
  360. }
  361. function handle_treeview(json, uri_subject) {
  362. console.log(json);
  363. var upLevel = "";
  364. var uri_up = "";
  365. var tree_doc = "";
  366. $.each(
  367. json['results']['bindings'],
  368. function (index, value) {
  369. upLevel = value['label']['value'];
  370. uri_up = value['uri']['value'];
  371. var uri = value['uri_document']['value'];
  372. var document = value['document']['value'];
  373. tree_doc += '<li class="tree_el"><i class="fa fa-file-alt"></i><span id="' + uri + '" class="tree_seed link object">' + document + '</span><li>'
  374. });
  375. if (tree_doc != "") {
  376. var tree_list = '<li class="upLevelTree"><span style="cursor:pointer;" class="caret link"><i class="fa fa-folder-open"></i>' +
  377. '<w>' + upLevel + '</w></span><ul id="nested" style="display: none;">' + tree_doc + '</ul></li>';
  378. document.getElementById("treeView").innerHTML = tree_list;
  379. }
  380. }
  381. function handle_luoghiDocumento(json) {
  382. console.log(json);
  383. const places = [];
  384. $.each(
  385. json['results']['bindings'],
  386. function (index, value) {
  387. var uri = value['uri_place']['value'];
  388. var label = value['place']['value'];
  389. places.push([uri, label]);
  390. });
  391. var Luoghi = "";
  392. for (var i=0; i<places.length; i++) {
  393. var object = '<div class="col-8"><p><span id="' + places[i][0] + '" class="title_doc luogo">'+ places[i][1] + '</span></p></div>';
  394. var object_button = '<button type="button" id="' + places[i][0] +
  395. '" class="luogo btn btn-default" alt="oggetto" title="' + places[i][1] +
  396. '"><i class="fa fa-map"></i><p class="btn-text">luogo</p></button>';
  397. Luoghi += '<div class="row res">'+ object +
  398. '<div class="col d-flex align-items-start justify-content-end">' + object_button +
  399. '<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>' +
  400. '<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>' +
  401. '<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>';
  402. }
  403. document.getElementById("n_pl").innerHTML = places.length;
  404. document.getElementById("section_places").innerHTML = Luoghi;
  405. if (places.length==0) {
  406. var messaggio = "<p class='no-results'>Questa ricerca non ha prodotto risultati</p>";
  407. document.getElementById("section_places").innerHTML = messaggio;
  408. }
  409. }
  410. function createDivRelazione(type, id){
  411. htmlCode = '\
  412. <div class="row mb-2"> \
  413. <div class="col-sm-4"> \
  414. <span class="label"><RELATIONSHIP></span> \
  415. </div> \
  416. <div class="col record_box" id="<ID_RELATIONSHIP>"></div> \
  417. </div> \
  418. '.replace("<RELATIONSHIP>", type).replace("<ID_RELATIONSHIP>", id);
  419. return htmlCode;
  420. }
  421. function createColRelazione(text, link, tipo, fa, tab, decl) {
  422. htmlCode = '\
  423. <div class="row"> \
  424. <div class="col <CLASS>"><NAME></div> \
  425. <div class="col-auto"> \
  426. <button class="<TIPO> btn btn-default" type="button" id="<URI>">\
  427. <i class="<BUTTON>" aria-hidden="true">\
  428. <p class="btn-text"><TAB></p>\
  429. </i>\
  430. </button>\</div> \
  431. </div>\
  432. '.replace("<NAME>", text).replace("<URI>", link).replace("<TIPO>", tipo).replace("<BUTTON>", fa).replace("<TAB>", tab).replace("<CLASS>", decl);
  433. return htmlCode;
  434. }
  435. $(document).on("click", ".caret", function (ev) {
  436. $("#nested").toggle();
  437. //$("#nested").css("display", "block");
  438. });