OA.js 18 KB

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