object.js 19 KB

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