OA.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. scheda.replace(".jpg", "");
  289. schede.push(scheda);
  290. for (i in suffix) {
  291. ss = suffix[i];
  292. var image_scheda = "img/schedeStoriche/" + scheda + "/" + ss + ".jpg";
  293. createImage(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. if (schede.length = 0) {
  303. $("#btn_schedastorica").css("display", "none");
  304. }/* else {
  305. document.getElementById("image_scheda_min").innerHTML = schede;
  306. }*/
  307. }
  308. function createImage(image) {
  309. checkIfImageExists(image, (exists) => {
  310. if (exists) {
  311. console.log(image);
  312. var Image = '<div class="row"> \
  313. <img class="viewImage" src="' + image + '" onclick="expandImg(this);"> \
  314. </div>';
  315. console.log(Image);
  316. $('#image_scheda_min').append(Image);
  317. } else {
  318. console.error('Image does not exists.')
  319. }
  320. });
  321. }
  322. function checkIfImageExists(url, callback) {
  323. const img = new Image();
  324. img.src = url;
  325. if (img.complete) {
  326. callback(true);
  327. } else {
  328. img.onload = () => {
  329. callback(true);
  330. };
  331. img.onerror = () => {
  332. callback(false);
  333. };
  334. }
  335. }
  336. function show_OA(){
  337. document.getElementById("OA_info").style.display = "block";
  338. document.getElementById("catalogo_info").style.display = "none";
  339. document.getElementById("scheda_info").style.display = "none";
  340. document.getElementById("image_artwork_min").style.display = "block";
  341. document.getElementById("image_catalog_min").style.display = "none";
  342. document.getElementById("image_scheda_min").style.display = "none";
  343. document.getElementById("img_title").innerHTML = "Opera";
  344. document.getElementById("expandedImg").src = img_pic;
  345. }
  346. function show_CAT(){
  347. document.getElementById("OA_info").style.display = "none";
  348. document.getElementById("catalogo_info").style.display = "block";
  349. document.getElementById("scheda_info").style.display = "none";
  350. document.getElementById("image_artwork_min").style.display = "none";
  351. document.getElementById("image_catalog_min").style.display = "block";
  352. document.getElementById("image_scheda_min").style.display = "none";
  353. document.getElementById("img_title").innerHTML = "Catalogo";
  354. document.getElementById("expandedImg").src = img_cat;
  355. }
  356. function show_INV(){
  357. document.getElementById("OA_info").style.display = "none";
  358. document.getElementById("catalogo_info").style.display = "none";
  359. document.getElementById("scheda_info").style.display = "block";
  360. document.getElementById("image_artwork_min").style.display = "none";
  361. document.getElementById("image_catalog_min").style.display = "none";
  362. document.getElementById("image_scheda_min").style.display = "block";
  363. document.getElementById("img_title").innerHTML = "Scheda Storica";
  364. document.getElementById("expandedImg").src = img_sc;
  365. }
  366. var $loupe = $(".loupe"),
  367. loupeWidth = $loupe.width(),
  368. loupeHeight = $loupe.height();
  369. $(document).on("mouseenter", ".image", function (e) {
  370. var $currImage = $(this),
  371. $img = $('<img/>')
  372. .attr('src', $('img', this).attr("src"))
  373. .css({ 'width': $currImage.width() * 2, 'height': $currImage.height() * 2 });
  374. $loupe.html($img).fadeIn(100);
  375. $(document).on("mousemove",moveHandler);
  376. function moveHandler(e) {
  377. var imageOffset = $currImage.offset(),
  378. fx = imageOffset.left - loupeWidth / 2,
  379. fy = imageOffset.top - loupeHeight / 2,
  380. fh = imageOffset.top + $currImage.height() + loupeHeight / 2,
  381. fw = imageOffset.left + $currImage.width() + loupeWidth / 2;
  382. $loupe.css({
  383. 'left': e.pageX - 75,
  384. 'top': e.pageY - 75
  385. });
  386. var loupeOffset = $loupe.offset(),
  387. lx = loupeOffset.left,
  388. ly = loupeOffset.top,
  389. lw = lx + loupeWidth,
  390. lh = ly + loupeHeight,
  391. bigy = (ly - loupeHeight / 4 - fy) * 2,
  392. bigx = (lx - loupeWidth / 4 - fx) * 2;
  393. $img.css({ 'left': -bigx, 'top': -bigy });
  394. if (lx < fx || lh > fh || ly < fy || lw > fw) {
  395. $img.remove();
  396. $(document).off("mousemove",moveHandler);
  397. $loupe.fadeOut(100);
  398. }
  399. }
  400. });