object.js 19 KB

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