OA.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. var link = thisUrlParams.link;
  2. prefixes = queryManager['prefixes']['all'];
  3. queryURL = prefixes + (queryManager['querySchedaOpera']['queryInfo']).replace('{URI}', link);
  4. doJsonQuery(queryURL).done(function(data) { handle_OAdata(data); });
  5. queryPro = prefixes + (queryManager['querySchedaOpera']['queryProduction']).replace('{URI}', link);
  6. doJsonQuery(queryPro).done(function(data) { handle_Production(data); });
  7. queryBib = prefixes + (queryManager['querySchedaOpera']['queryBibliography']).replace('{URI}', link);
  8. doJsonQuery(queryBib).done(function(data) { handle_Bibliography(data); });
  9. queryPic = prefixes + (queryManager['querySchedaOpera']['queryPicture']).replace('{URI}', link);
  10. doJsonQuery(queryPic).done(function(data) { handle_Picture(data); });
  11. querySc = prefixes + (queryManager['querySchedaOpera']['querySchedeStoriche']).replace('{URI}', link);
  12. doJsonQuery(querySc).done(function(data) { handle_SchedeStoriche(data); });
  13. queryIcon = prefixes + (queryManager['querySchedaOpera']['queryIconclass']).replace('{URI}', link);
  14. doJsonQuery(queryIcon).done(function(data) { handle_Iconclass(data); });
  15. var img_pic = "";
  16. var img_cat = "";
  17. var img_sc = "";
  18. function handle_OAdata(json) {
  19. console.log(json['results']['bindings']);
  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 title = "";
  27. var type = "";
  28. var current_owner = "";
  29. var current_location = "";
  30. var subject = "";
  31. var dimensions = "";
  32. var materials = "";
  33. var condition = "";
  34. var note = "";
  35. var identifier = "";
  36. var unit = "";
  37. var inscription = "";
  38. var conn_subject = "";
  39. var src_picture = "";
  40. var picture = "";
  41. var dataset = get_dataset_name(graph);
  42. if (value.hasOwnProperty('title')) {
  43. $("#SGTT").css("display", "flex");
  44. title = value['title']['value'];
  45. }
  46. if (value.hasOwnProperty('identifier')) {
  47. $("#NCT").css("display", "flex");
  48. identifier = value['identifier']['value'];
  49. }
  50. if (value.hasOwnProperty('type')) {
  51. $("#OGTD").css("display", "flex");
  52. type = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriType']['value'] + "'>" +
  53. value['type']['value'] + "</a></div></div>";
  54. }
  55. if (value.hasOwnProperty('current_owner')) {
  56. $("#LDCN").css("display", "flex");
  57. current_owner = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriOwner']['value'] + "'>" +
  58. value['current_owner']['value'] + "</a></div></div>";
  59. }
  60. if (value.hasOwnProperty('current_location')) {
  61. $("#LDCS").css("display", "flex");
  62. current_location = value['current_location']['value'];
  63. }
  64. if (value.hasOwnProperty('unit')) {
  65. unit = value['unit']['value'];
  66. }
  67. if (value.hasOwnProperty('subject')) {
  68. $("#SGTI").css("display", "flex");
  69. subject = value['subject']['value'];
  70. }
  71. if (value.hasOwnProperty('dimensions')) {
  72. if (value['dimensions']['value'] != "") {
  73. $("#MIS").css("display", "flex");
  74. dimensions = value['dimensions']['value'];
  75. }
  76. }
  77. if (value.hasOwnProperty('condition')) {
  78. $("#STCC").css("display", "flex");
  79. condition = value['condition']['value'];
  80. }
  81. if (value.hasOwnProperty('note')) {
  82. $("#NSC").css("display", "flex");
  83. note = value['note']['value'];
  84. }
  85. if (value.hasOwnProperty('iscrizione')) {
  86. $("#ISCR").css("display", "flex");
  87. inscription = value['iscrizione']['value'];
  88. }
  89. if (value.hasOwnProperty('uriSubjectPer')) {
  90. $("#SGTI_C").css("display", "flex");
  91. var givenName = value['personName']['value'];
  92. var surname = value['personSurname']['value'];
  93. var patronymic = value['personPatronymic']['value'];
  94. var name = givenName + " " + patronymic + " " + titleCase(surname);
  95. conn_subject = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriSubjectPer']['value'] + "'>" +
  96. name + "</a></div><div class='d-flex ml-auto'><div class='persona btn-icon' style='cursor:pointer' id='" +
  97. value['uriSubjectPer']['value'] + "'><i class='fa fa-user'></i><p class='btn-text'>PERSONA</p></div></div></div></div>";
  98. }
  99. if (value.hasOwnProperty('Materials')) {
  100. if (value['Materials']['value'] != "") {
  101. $("#MTC").css("display", "flex");
  102. mm = value['Materials']['value'];
  103. mat = mm.split("<br />");
  104. for (i in mat) {
  105. slice = mat[i].split("; ");
  106. /*materials += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";*/
  107. materials += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  108. slice[1] + "</a></div>";
  109. }
  110. }
  111. }
  112. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  113. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  114. <button title="Citazione" type="button" value="artwork" id="' + uri + '" class="cit btn btn-default" alt="scheda" title="Citazione"><i class="fa fa-quote-right"></i></button> \
  115. <button title="Permalink" type="button" value="artwork" id="' + uri + '" class="hyp btn btn-default" alt="scheda" title="Hyperlink"><i class="fa fa-link"></i></button> \
  116. <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>';
  117. document.getElementById("grafo").innerHTML = dataset;
  118. document.getElementById("nome_oggetto").innerHTML = label;
  119. document.getElementById("identifier").innerHTML = identifier;
  120. document.getElementById("type").innerHTML = type;
  121. document.getElementById("owner").innerHTML = current_owner;
  122. document.getElementById("subject").innerHTML = subject;
  123. document.getElementById("connected_subject").innerHTML = conn_subject;
  124. document.getElementById("dimensions").innerHTML = dimensions + unit;
  125. document.getElementById("materials").innerHTML = materials;
  126. document.getElementById("condition").innerHTML = condition;
  127. document.getElementById("description").innerHTML = note;
  128. document.getElementById("inscription").innerHTML = inscription;
  129. document.getElementById("link_buttons").innerHTML = Buttons;
  130. });
  131. }
  132. function handle_Picture(json) {
  133. console.log(json['results']['bindings']);
  134. var picture = "";
  135. const tavole = [];
  136. $.each(
  137. json['results']['bindings'],
  138. function (index, value) {
  139. var src_picture = value['picture']['value'];
  140. var tipo = "";
  141. if (value.hasOwnProperty('type')) {
  142. tipo = value['type']['value'];
  143. }
  144. let tv = [src_picture, tipo];
  145. tavole.push(tv);
  146. src_picture = value['picture']['value'];
  147. picture += '<div class="row"> \
  148. <img class="viewImage" src="img/mpp_img/' + src_picture + '" onclick="expandImg(this);" /> \
  149. </div>';
  150. });
  151. var front_pic = "";
  152. if (tavole.length > 1) {
  153. for (i in tavole) {
  154. if (tavole[i][1] == "Tavola d'insieme") {
  155. front_pic = tavole[i][0];
  156. }
  157. }
  158. } else {
  159. front_pic = tavole[0][0];
  160. }
  161. img_pic = "img/mpp_img/" + front_pic;
  162. document.getElementById("image_artwork_min").innerHTML = picture;
  163. document.getElementById("expandedImg").src = "img/mpp_img/" + front_pic;
  164. }
  165. function get_dataset_name(graph) {
  166. var string = "Scheda Opera d'Arte";
  167. if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/martini") {
  168. string = string + " / Collezione Martini";
  169. }
  170. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale") {
  171. string = string + " / Collezione Ospedale";
  172. }
  173. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/datini") {
  174. string = string + " / Collezione Datini";
  175. }
  176. else {
  177. string = string;
  178. }
  179. return (string);
  180. }
  181. function handle_Production(json) {
  182. console.log(json['results']['bindings']);
  183. $.each(
  184. json['results']['bindings'],
  185. function (index, value) {
  186. var partecipants = "";
  187. var teche = "";
  188. var time = "";
  189. var client = "";
  190. var artist = "";
  191. var artist_name = "";
  192. if (value.hasOwnProperty('techniques')) {
  193. if (value['techniques']['value'] != "") {
  194. $("#MTC").css("display", "flex");
  195. tt = value['techniques']['value'];
  196. tec = tt.split("<br />");
  197. for (i in tec) {
  198. slice = tec[i].split("; ");
  199. /*teche += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";*/
  200. teche += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  201. slice[1] + "</a></div>";
  202. }
  203. }
  204. }
  205. if (value.hasOwnProperty('Partecipants')) {
  206. pp = value['Partecipants']['value'];
  207. people = pp.split("<br />");
  208. for (i in people) {
  209. slice = people[i].split("; ");
  210. if (slice[2] == "Committente") {
  211. $("#CMM").css("display", "flex");
  212. client += slice[1];
  213. } else {
  214. $("#AUT").css("display", "flex");
  215. artist_name += slice[1];
  216. artist += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  217. slice[1] + "</a></div><div class='d-flex ml-auto'><div class='persona btn-icon' style='cursor:pointer' id='" +
  218. slice[0] + "'><i class='fa fa-user'></i><p class='btn-text'>PERSONA</p></div></div></div></div>";
  219. }
  220. }
  221. }
  222. if (value.hasOwnProperty('time') && (value['time']['value'] != "")) {
  223. $("#DT").css("display", "flex");
  224. time = value['time']['value'];
  225. }
  226. var authors = document.getElementsByClassName("author");
  227. for (i in authors) {
  228. authors[i].innerHTML = artist;
  229. }
  230. var dates = document.getElementsByClassName("date");
  231. for (i in dates) {
  232. dates[i].innerHTML = time;
  233. }
  234. document.getElementById("technique").innerHTML = teche;
  235. document.getElementById("client").innerHTML = client;
  236. });
  237. }
  238. function handle_Bibliography(json) {
  239. console.log(json['results']['bindings']);
  240. var Biblio = "";
  241. var bibCit = "";
  242. const bibArray = [];
  243. var catImg = "";
  244. $.each(
  245. json['results']['bindings'],
  246. function (index, value) {
  247. var bib = value['bibliography']['value'];
  248. var pages = "";
  249. if (value.hasOwnProperty('pages')) {
  250. pages = value['pages']['value'];
  251. }
  252. if (value.hasOwnProperty('catalog')) {
  253. if (value['catalog']['value'] != "") {
  254. bibCit = value['bibliography']['value'] + " " + pages;
  255. cc = value['catalog']['value'];
  256. cat = cc.split(", ");
  257. for (i in cat) {
  258. var marchini = cat[i].replace(".jpg", " (1).jpg");
  259. img_cat = "img/MPP_marchini_stampa/" + marchini;
  260. catImg += '<div class="row"> \
  261. <img class="viewImage" src="img/MPP_marchini_stampa/' + marchini + '" onclick="expandImg(this);" /> \
  262. </div>';
  263. }
  264. }
  265. }
  266. var book = bib + " " + pages;
  267. bibArray.push(book);
  268. });
  269. console.log(catImg);
  270. bibArray.sort();
  271. for (k in bibArray) {
  272. Biblio += '<li>' + bibArray[k] + '</li>';
  273. }
  274. document.getElementById("bibliography").innerHTML = Biblio;
  275. document.getElementById("catalog_description").innerHTML = bibCit;
  276. if (catImg == "") {
  277. $("#btn_catalogo").css("display", "none");
  278. } else {
  279. document.getElementById("image_catalog_min").innerHTML = catImg;
  280. }
  281. }
  282. function handle_Iconclass(json) {
  283. console.log(json['results']['bindings']);
  284. var Icon = "";
  285. $.each(
  286. json['results']['bindings'],
  287. function (index, value) {
  288. var uri_icon = value['scheda']['value'];
  289. var sigla_icon = scheda.replace(".jpg", "");
  290. Icon += '<a href="' + uri_icon + '">' + sigla_icon + '</a>';
  291. });
  292. document.getElementById("iconclass").innerHTML = Icon;
  293. if (Icon != "") {
  294. $("#ICON").css("display", "flex");
  295. } else {
  296. $("#ICON").css("display", "none");
  297. }
  298. }
  299. function handle_SchedeStoriche(json) {
  300. console.log(json['results']['bindings']);
  301. const schede = [];
  302. let suffix = ["0", "1", "2", "3", "4", "5"];
  303. $.each(
  304. json['results']['bindings'],
  305. function (index, value) {
  306. var scheda = value['scheda']['value'];
  307. var sc = scheda.replace(".jpg", "");
  308. schede.push(scheda);
  309. img_sc = "img/schedeStoriche/" + sc + "/0.jpg";;
  310. for (i in suffix) {
  311. ss = suffix[i];
  312. var image_scheda = "img/schedeStoriche/" + sc + "/" + ss + ".jpg";
  313. createScheda(image_scheda);
  314. }
  315. /* img_sc = "img/mpp_img/" + scheda;
  316. schede += '<div class="row"> \
  317. <img class="viewImage" src="img/mpp_img/' + scheda + '" onclick="expandImg(this);" /> \
  318. </div>';
  319. var dir = "img/schedeStoriche/" + scheda + "/";
  320. console.log(files);*/
  321. });
  322. console.log(schede);
  323. if (schede.length == 0) {
  324. $("#btn_schedastorica").css("display", "none");
  325. }/* else {
  326. document.getElementById("image_scheda_min").innerHTML = schede;
  327. }*/
  328. }
  329. function createScheda(image) {
  330. checkIfSchedaExists(image, (exists) => {
  331. if (exists) {
  332. console.log(image);
  333. var ImageScheda = '<div class="row"> \
  334. <img class="viewImage" src="' + image + '" onclick="expandImg(this);"> \
  335. </div>';
  336. console.log(ImageScheda);
  337. $('#image_scheda_min').append(ImageScheda);
  338. } else {
  339. console.error('Image does not exists.')
  340. }
  341. });
  342. }
  343. function checkIfSchedaExists(url, callback) {
  344. const img = new Image();
  345. img.src = url;
  346. if (img.complete) {
  347. callback(true);
  348. } else {
  349. img.onload = () => {
  350. callback(true);
  351. };
  352. img.onerror = () => {
  353. callback(false);
  354. };
  355. }
  356. }
  357. function show_OA(){
  358. document.getElementById("OA_info").style.display = "block";
  359. document.getElementById("catalogo_info").style.display = "none";
  360. document.getElementById("scheda_info").style.display = "none";
  361. document.getElementById("image_artwork_min").style.display = "block";
  362. document.getElementById("image_catalog_min").style.display = "none";
  363. document.getElementById("image_scheda_min").style.display = "none";
  364. document.getElementById("img_title").innerHTML = "Opera";
  365. document.getElementById("expandedImg").src = img_pic;
  366. }
  367. function show_CAT(){
  368. document.getElementById("OA_info").style.display = "none";
  369. document.getElementById("catalogo_info").style.display = "block";
  370. document.getElementById("scheda_info").style.display = "none";
  371. document.getElementById("image_artwork_min").style.display = "none";
  372. document.getElementById("image_catalog_min").style.display = "block";
  373. document.getElementById("image_scheda_min").style.display = "none";
  374. document.getElementById("img_title").innerHTML = "Catalogo";
  375. document.getElementById("expandedImg").src = img_cat;
  376. }
  377. function show_INV(){
  378. document.getElementById("OA_info").style.display = "none";
  379. document.getElementById("catalogo_info").style.display = "none";
  380. document.getElementById("scheda_info").style.display = "block";
  381. document.getElementById("image_artwork_min").style.display = "none";
  382. document.getElementById("image_catalog_min").style.display = "none";
  383. document.getElementById("image_scheda_min").style.display = "block";
  384. document.getElementById("img_title").innerHTML = "Scheda Storica";
  385. document.getElementById("expandedImg").src = img_sc;
  386. }
  387. function magnify(imgID, zoom) {
  388. var img, glass, w, h, bw;
  389. img = document.getElementById(imgID);
  390. /*create magnifier glass:*/
  391. glass = document.createElement("DIV");
  392. glass.setAttribute("class", "img-magnifier-glass");
  393. glass.setAttribute("id", "glass");
  394. /*insert magnifier glass:*/
  395. img.parentElement.insertBefore(glass, img);
  396. /*set background properties for the magnifier glass:*/
  397. glass.style.backgroundImage = "url('" + img.src + "')";
  398. glass.style.backgroundRepeat = "no-repeat";
  399. glass.style.backgroundSize = (img.width * zoom) + "px " + (img.height * zoom) + "px";
  400. bw = 3;
  401. w = glass.offsetWidth / 2;
  402. h = glass.offsetHeight / 2;
  403. /*execute a function when someone moves the magnifier glass over the image:*/
  404. glass.addEventListener("mousemove", moveMagnifier);
  405. img.addEventListener("mousemove", moveMagnifier);
  406. /*and also for touch screens:*/
  407. glass.addEventListener("touchmove", moveMagnifier);
  408. img.addEventListener("touchmove", moveMagnifier);
  409. function moveMagnifier(e) {
  410. var pos, x, y;
  411. /*prevent any other actions that may occur when moving over the image*/
  412. e.preventDefault();
  413. /*get the cursor's x and y positions:*/
  414. pos = getCursorPos(e);
  415. x = pos.x;
  416. y = pos.y;
  417. /*prevent the magnifier glass from being positioned outside the image:*/
  418. if (x > img.width - (w / zoom)) {x = img.width - (w / zoom);}
  419. if (x < w / zoom) {x = w / zoom;}
  420. if (y > img.height - (h / zoom)) {y = img.height - (h / zoom);}
  421. if (y < h / zoom) {y = h / zoom;}
  422. /*set the position of the magnifier glass:*/
  423. glass.style.left = (x - w) + "px";
  424. glass.style.top = (y - h) + "px";
  425. /*display what the magnifier glass "sees":*/
  426. glass.style.backgroundPosition = "-" + ((x * zoom) - w + bw) + "px -" + ((y * zoom) - h + bw) + "px";
  427. }
  428. function getCursorPos(e) {
  429. var a, x = 0, y = 0;
  430. e = e || window.event;
  431. /*get the x and y positions of the image:*/
  432. a = img.getBoundingClientRect();
  433. /*calculate the cursor's x and y coordinates, relative to the image:*/
  434. x = e.pageX - a.left;
  435. y = e.pageY - a.top;
  436. /*consider any page scrolling:*/
  437. x = x - window.pageXOffset;
  438. y = y - window.pageYOffset;
  439. return {x : x, y : y};
  440. }
  441. }
  442. magnify("expandedImg", 3);