OA.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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. var img_g1858 = [];
  19. var img_g1888 = [];
  20. var img_p1912 = [];
  21. var img_m1956 = [];
  22. function handle_OAdata(json) {
  23. console.log(json['results']['bindings']);
  24. $.each(
  25. json['results']['bindings'],
  26. function (index, value) {
  27. var graph = value['graph']['value'];
  28. var label = value['label']['value'];
  29. var uri = value['uri']['value'];
  30. var title = "";
  31. var type = "";
  32. var current_owner = "";
  33. var current_location = "";
  34. var subject = "";
  35. var dimensions = "";
  36. var materials = "";
  37. var condition = "";
  38. var note = "";
  39. var identifier = "";
  40. var unit = "";
  41. var inscription = "";
  42. var conn_subject = "";
  43. var src_picture = "";
  44. var picture = "";
  45. var dataset = get_dataset_name(graph);
  46. if (value.hasOwnProperty('title')) {
  47. $("#SGTT").css("display", "flex");
  48. title = value['title']['value'];
  49. }
  50. if (value.hasOwnProperty('identifier')) {
  51. $("#NCT").css("display", "flex");
  52. identifier = value['identifier']['value'];
  53. }
  54. if (value.hasOwnProperty('type')) {
  55. $("#OGTD").css("display", "flex");
  56. type = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriType']['value'] + "'>" +
  57. value['type']['value'] + "</a></div></div>";
  58. }
  59. if (value.hasOwnProperty('current_owner')) {
  60. $("#LDCN").css("display", "flex");
  61. current_owner = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriOwner']['value'] + "'>" +
  62. value['current_owner']['value'] + "</a></div></div>";
  63. }
  64. if (value.hasOwnProperty('current_location')) {
  65. $("#LDCS").css("display", "flex");
  66. current_location = value['current_location']['value'];
  67. }
  68. if (value.hasOwnProperty('unit')) {
  69. unit = value['unit']['value'];
  70. }
  71. if (value.hasOwnProperty('subject')) {
  72. $("#SGTI").css("display", "flex");
  73. subject = value['subject']['value'];
  74. }
  75. if (value.hasOwnProperty('dimensions')) {
  76. if (value['dimensions']['value'] != "") {
  77. $("#MIS").css("display", "flex");
  78. dimensions = value['dimensions']['value'];
  79. }
  80. }
  81. if (value.hasOwnProperty('condition')) {
  82. $("#STCC").css("display", "flex");
  83. condition = value['condition']['value'];
  84. }
  85. if (value.hasOwnProperty('note')) {
  86. $("#NSC").css("display", "flex");
  87. note = value['note']['value'];
  88. }
  89. if (value.hasOwnProperty('iscrizione')) {
  90. $("#ISCR").css("display", "flex");
  91. inscription = value['iscrizione']['value'];
  92. }
  93. if (value.hasOwnProperty('uriSubjectPer')) {
  94. $("#SGTI_C").css("display", "flex");
  95. var givenName = value['personName']['value'];
  96. var surname = value['personSurname']['value'];
  97. var patronymic = value['personPatronymic']['value'];
  98. var name = givenName + " " + patronymic + " " + titleCase(surname);
  99. conn_subject = "<div class='d-flex'><div class='mr-3'><a href='" + value['uriSubjectPer']['value'] + "'>" +
  100. name + "</a></div><div class='d-flex ml-auto'><div class='persona btn-icon' style='cursor:pointer' id='" +
  101. value['uriSubjectPer']['value'] + "'><i class='fa fa-user'></i><p class='btn-text'>PERSONA</p></div></div></div></div>";
  102. }
  103. if (value.hasOwnProperty('Materials')) {
  104. if (value['Materials']['value'] != "") {
  105. $("#MTC").css("display", "flex");
  106. mm = value['Materials']['value'];
  107. mat = mm.split("<br />");
  108. for (i in mat) {
  109. slice = mat[i].split("; ");
  110. /*materials += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";*/
  111. materials += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  112. slice[1] + "</a></div>";
  113. }
  114. }
  115. }
  116. var subjects = document.getElementsByClassName("subject");
  117. for (i in subjects) {
  118. subjects[i].innerHTML = subject;
  119. }
  120. var Buttons = '<button title="Apri risorsa originale" class="btn btn-default" type="button" onclick="schedaASPO(\'' + uri + '\')"> \
  121. <i class="fas fa-external-link-alt" aria-hidden="true"></i></button> \
  122. <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> \
  123. <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> \
  124. <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>';
  125. document.getElementById("grafo").innerHTML = dataset;
  126. document.getElementById("nome_oggetto").innerHTML = label;
  127. document.getElementById("identifier").innerHTML = identifier;
  128. document.getElementById("type").innerHTML = type;
  129. document.getElementById("owner").innerHTML = current_owner;
  130. document.getElementById("connected_subject").innerHTML = conn_subject;
  131. document.getElementById("dimensions").innerHTML = dimensions + unit;
  132. document.getElementById("materials").innerHTML = materials;
  133. document.getElementById("condition").innerHTML = condition;
  134. document.getElementById("description").innerHTML = note;
  135. document.getElementById("inscription").innerHTML = inscription;
  136. document.getElementById("link_buttons").innerHTML = Buttons;
  137. });
  138. }
  139. function handle_Picture(json) {
  140. console.log(json['results']['bindings']);
  141. var picture = "";
  142. const tavole = [];
  143. var tiles2 = [];
  144. $.each(
  145. json['results']['bindings'],
  146. function (index, value) {
  147. var src_picture = value['picture']['value'];
  148. var tipo = "";
  149. if (value.hasOwnProperty('type')) {
  150. tipo = value['type']['value'];
  151. }
  152. let tv = [src_picture, tipo];
  153. tavole.push(tv);
  154. src_picture = value['picture']['value'];
  155. //picture += '<div class="row"> \
  156. // <img class="minImage viewImage" src="img/mpp_img/' + src_picture + '" onclick="expandImg(this);" /> \
  157. // </div>';
  158. img_pic.push({
  159. type: "image",
  160. url: "http://restore.ovi.cnr.it/beta/img/mpp_img/" + src_picture
  161. });
  162. });
  163. runOpenseadragon(img_pic);
  164. /*var front_pic = "";
  165. if (tavole.length > 1) {
  166. for (i in tavole) {
  167. if (tavole[i][1] == "Tavola d'insieme") {
  168. front_pic = tavole[i][0];
  169. }
  170. }
  171. } else {
  172. front_pic = tavole[0][0];
  173. }
  174. img_pic = "img/mpp_img/" + front_pic;*/
  175. //document.getElementById("image_artwork_min").innerHTML = picture;
  176. //document.getElementById("expandedImg").src = "img/mpp_img/" + front_pic;
  177. }
  178. function get_dataset_name(graph) {
  179. var string = "Scheda Opera d'Arte";
  180. if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/martini") {
  181. string = string + " / Collezione Martini";
  182. }
  183. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale") {
  184. string = string + " / Collezione Ospedale";
  185. }
  186. else if (graph == "http://dev.restore.ovi.cnr.it:8890/mpp/datini") {
  187. string = string + " / Collezione Datini";
  188. }
  189. else {
  190. string = string;
  191. }
  192. return (string);
  193. }
  194. function handle_Production(json) {
  195. console.log(json['results']['bindings']);
  196. $.each(
  197. json['results']['bindings'],
  198. function (index, value) {
  199. var partecipants = "";
  200. var teche = "";
  201. var time = "";
  202. var client = "";
  203. var artist = "";
  204. var artist_name = "";
  205. if (value.hasOwnProperty('techniques')) {
  206. if (value['techniques']['value'] != "") {
  207. $("#MTC").css("display", "flex");
  208. tt = value['techniques']['value'];
  209. tec = tt.split("<br />");
  210. for (i in tec) {
  211. slice = tec[i].split("; ");
  212. /*teche += "<a href='" + slice[0] + "'>" + slice[1] + "</a><br />";*/
  213. teche += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  214. slice[1] + "</a></div>";
  215. }
  216. }
  217. }
  218. if (value.hasOwnProperty('Partecipants')) {
  219. pp = value['Partecipants']['value'];
  220. people = pp.split("<br />");
  221. for (i in people) {
  222. slice = people[i].split("; ");
  223. if (slice[2] == "Committente") {
  224. $("#CMM").css("display", "flex");
  225. client += slice[1];
  226. } else {
  227. $("#AUT").css("display", "flex");
  228. artist_name += slice[1];
  229. artist += "<div class='d-flex'><div class='mr-3'><a href='" + slice[0] + "'>" +
  230. slice[1] + "</a></div><div class='d-flex ml-auto'><div class='persona btn-icon' style='cursor:pointer' id='" +
  231. slice[0] + "'><i class='fa fa-user'></i><p class='btn-text'>PERSONA</p></div></div></div></div>";
  232. }
  233. }
  234. }
  235. if (value.hasOwnProperty('time') && (value['time']['value'] != "")) {
  236. $("#DT").css("display", "flex");
  237. time = value['time']['value'];
  238. }
  239. var authors = document.getElementsByClassName("author");
  240. for (i in authors) {
  241. authors[i].innerHTML = artist;
  242. }
  243. var dates = document.getElementsByClassName("date");
  244. for (i in dates) {
  245. dates[i].innerHTML = time;
  246. }
  247. document.getElementById("technique").innerHTML = teche;
  248. document.getElementById("client").innerHTML = client;
  249. });
  250. }
  251. function handle_Bibliography(json) {
  252. console.log(json['results']['bindings']);
  253. var Biblio = "";
  254. var bibCit = "";
  255. var g1858Cit = "";
  256. var g1888Cit = "";
  257. var p1912Cit = "";
  258. const bibArray = [];
  259. var catImg = "";
  260. var g1858Img = "";
  261. var g1888Img = "";
  262. var p1912Img = "";
  263. var n_cat = 0;
  264. var n_g1858 = 0;
  265. var n_g1888 = 0;
  266. var n_p1912 = 0;
  267. $.each(
  268. json['results']['bindings'],
  269. function (index, value) {
  270. var bib = value['bibliography']['value'];
  271. var pages = "";
  272. if (value.hasOwnProperty('pages')) {
  273. pages = value['pages']['value'];
  274. }
  275. if (value.hasOwnProperty('catalog')) {
  276. var type = "";
  277. if (value.hasOwnProperty('type')) {
  278. type = value['type']['value'];
  279. }
  280. if (type == "Guida Marchini 1958") {
  281. bibCit = value['bibliography']['value'] + " " + pages;
  282. cc = value['catalog']['value'];
  283. cat = cc.split(", ");
  284. for (i in cat) {
  285. n_cat+=1;
  286. var marchini = cat[i].replace(".jpg", " (1).jpg");
  287. var img_catalogo = "img/MPP_marchini_stampa/" + marchini;
  288. img_cat.push({
  289. type: "image",
  290. url: "http://restore.ovi.cnr.it/beta/" + img_catalogo
  291. });
  292. }
  293. }
  294. if (type == "Guida Guasti 1858") {
  295. g1858Cit = value['bibliography']['value'] + " " + pages;
  296. cc1858 = value['catalog']['value'];
  297. cat1858 = cc1858.split(", ");
  298. for (i in cat1858) {
  299. n_g1858+=1;
  300. var guasti1858 = cat1858[i];
  301. var img_guasti1858 = "img/MPP_Guasti_1858/" + guasti1858;
  302. img_g1858.push({
  303. type: "image",
  304. url: "http://restore.ovi.cnr.it/beta/" + img_guasti1858
  305. });
  306. }
  307. }
  308. if (type == "Guida Guasti 1888") {
  309. g1888Cit = value['bibliography']['value'] + " " + pages;
  310. cc1888 = value['catalog']['value'];
  311. cat1888 = cc1888.split(", ");
  312. for (i in cat1888) {
  313. n_g1888+=1;
  314. var guasti1888 = cat1888[i];
  315. var img_guasti1888 = "img/MPP_Guasti_1888/" + guasti1888;
  316. img_g1888.push({
  317. type: "image",
  318. url: "http://restore.ovi.cnr.it/beta/" + img_guasti1888
  319. });
  320. }
  321. }
  322. if (type == "Catalogo Papini 1912") {
  323. p1912Cit = value['bibliography']['value'] + " " + pages;
  324. cc1912 = value['catalog']['value'];
  325. cat1912 = cc1912.split(", ");
  326. for (i in cat1912) {
  327. n_p1912+=1;
  328. var papini1912 = cat1912[i];
  329. img_papini1912 = "img/MPP_Papini_1912/" + papini1912;
  330. img_p1912.push({
  331. type: "image",
  332. url: "http://restore.ovi.cnr.it/beta/" + img_papini1912
  333. });
  334. }
  335. }
  336. }
  337. var book = bib + " " + pages;
  338. bibArray.push(book);
  339. });
  340. console.log(catImg);
  341. bibArray.sort();
  342. for (k in bibArray) {
  343. Biblio += '<li>' + bibArray[k] + '</li>';
  344. }
  345. document.getElementById("bibliography").innerHTML = Biblio;
  346. document.getElementById("catalog_description").innerHTML = bibCit;
  347. document.getElementById("guasti1858_description").innerHTML = g1858Cit;
  348. document.getElementById("guasti1888_description").innerHTML = g1888Cit;
  349. document.getElementById("papini1912_description").innerHTML = p1912Cit;
  350. if (n_cat == 0) {
  351. $("#btn_catalogo").css("display", "none");
  352. }
  353. if (n_g1858 == 0) {
  354. $("#btn_guasti1858").css("display", "none");
  355. }
  356. if (n_g1888 == 0) {
  357. $("#btn_guasti1888").css("display", "none");
  358. }
  359. if (n_p1912 == 0) {
  360. $("#btn_papini1912").css("display", "none");
  361. }
  362. }
  363. function handle_Iconclass(json) {
  364. console.log(json['results']['bindings']);
  365. var Icon = "";
  366. $.each(
  367. json['results']['bindings'],
  368. function (index, value) {
  369. var uri_icon = value['uri_iconclass']['value'];
  370. var sigla_icon = value['iconclass']['value'];
  371. Icon += '<a href="' + uri_icon + '">' + sigla_icon + '</a><br />';
  372. });
  373. document.getElementById("iconclass").innerHTML = Icon;
  374. if (Icon != "") {
  375. $("#ICON").css("display", "flex");
  376. }
  377. }
  378. function handle_SchedeStoriche(json) {
  379. console.log(json['results']['bindings']);
  380. const schede = [];
  381. var m1956Img = "";
  382. var n_m1956 = 0;
  383. let suffix = ["0", "1", "2", "3", "4", "5"];
  384. $.each(
  385. json['results']['bindings'],
  386. function (index, value) {
  387. var type = value['type']['value'];
  388. var scheda = value['scheda']['value'];
  389. console.log([type, scheda]);
  390. if (type == "Scheda Storica") {
  391. var sc = scheda.replace(".jpg", "");
  392. schede.push(scheda);
  393. //img_sc = "img/schedeStoriche/" + sc + "/0.jpg";;
  394. for (i in suffix) {
  395. ss = suffix[i];
  396. var image_scheda = "img/schedeStoriche/" + sc + "/" + ss + ".jpg";
  397. createScheda(image_scheda);
  398. }
  399. }
  400. /* img_sc = "img/mpp_img/" + scheda;
  401. schede += '<div class="row"> \
  402. <img class="viewImage" src="img/mpp_img/' + scheda + '" onclick="expandImg(this);" /> \
  403. </div>';
  404. var dir = "img/schedeStoriche/" + scheda + "/";
  405. console.log(files);*/
  406. if (type == "Marchini 1956") {
  407. cc1956 = scheda;
  408. cat1956 = cc1956.split(", ");
  409. for (i in cat1956) {
  410. n_m1956 = n_m1956 + 1;
  411. var marchini1956 = cat1956[i];
  412. var img_marchini1956 = "img/MPP_Marchini_1956/" + marchini1956;
  413. img_m1956.push({
  414. type: "image",
  415. url: "http://restore.ovi.cnr.it/beta/" + img_marchini1956
  416. });
  417. }
  418. }
  419. });
  420. if (schede.length = 0) {
  421. $("#btn_schedastorica").css("display", "none");
  422. }
  423. console.log(n_m1956);
  424. if (n_m1956 == 0) {
  425. $("#btn_marchini1956").css("display", "none");
  426. }
  427. }
  428. function createScheda(image) {
  429. checkIfSchedaExists(image, (exists) => {
  430. if (exists) {
  431. var ImageScheda = '<div class="row"> \
  432. <img class="minImage viewImage" src="' + image + '" onclick="expandImg(this);"> \
  433. </div>';
  434. img_sc.push({
  435. type: "image",
  436. url: "http://restore.ovi.cnr.it/beta/" + image
  437. });
  438. } else {
  439. console.error('Image does not exists.')
  440. }
  441. });
  442. }
  443. function checkIfSchedaExists(url, callback) {
  444. const img = new Image();
  445. img.src = url;
  446. if (img.complete) {
  447. callback(true);
  448. } else {
  449. img.onload = () => {
  450. callback(true);
  451. };
  452. img.onerror = () => {
  453. callback(false);
  454. };
  455. }
  456. }
  457. function show_OA(){
  458. document.getElementById("OA_info").style.display = "block";
  459. document.getElementById("catalogo_info").style.display = "none";
  460. document.getElementById("scheda_info").style.display = "none";
  461. document.getElementById("guasti1858_info").style.display = "none";
  462. document.getElementById("guasti1888_info").style.display = "none";
  463. document.getElementById("papini1912_info").style.display = "none";
  464. document.getElementById("marchini1956_info").style.display = "none";
  465. document.getElementById("img_title").innerHTML = "Opera";
  466. clearViewer();
  467. runOpenseadragon(img_pic);
  468. }
  469. function show_CAT(){
  470. document.getElementById("OA_info").style.display = "none";
  471. document.getElementById("catalogo_info").style.display = "block";
  472. document.getElementById("scheda_info").style.display = "none";
  473. document.getElementById("guasti1858_info").style.display = "none";
  474. document.getElementById("guasti1888_info").style.display = "none";
  475. document.getElementById("papini1912_info").style.display = "none";
  476. document.getElementById("marchini1956_info").style.display = "none";
  477. document.getElementById("img_title").innerHTML = "Guida Marchini 1958";
  478. clearViewer();
  479. runOpenseadragon(img_cat);
  480. }
  481. function show_INV(){
  482. document.getElementById("OA_info").style.display = "none";
  483. document.getElementById("catalogo_info").style.display = "none";
  484. document.getElementById("scheda_info").style.display = "block";
  485. document.getElementById("guasti1858_info").style.display = "none";
  486. document.getElementById("guasti1888_info").style.display = "none";
  487. document.getElementById("papini1912_info").style.display = "none";
  488. document.getElementById("marchini1956_info").style.display = "none";
  489. document.getElementById("img_title").innerHTML = "Scheda Storica";
  490. clearViewer();
  491. runOpenseadragon(img_sc);
  492. }
  493. function show_G1858(){
  494. document.getElementById("OA_info").style.display = "none";
  495. document.getElementById("catalogo_info").style.display = "none";
  496. document.getElementById("scheda_info").style.display = "none";
  497. document.getElementById("guasti1858_info").style.display = "block";
  498. document.getElementById("guasti1888_info").style.display = "none";
  499. document.getElementById("papini1912_info").style.display = "none";
  500. document.getElementById("marchini1956_info").style.display = "none";
  501. document.getElementById("img_title").innerHTML = "Guida Guasti 1858";
  502. clearViewer();
  503. runOpenseadragon(img_g1858);
  504. }
  505. function show_G1888(){
  506. document.getElementById("OA_info").style.display = "none";
  507. document.getElementById("catalogo_info").style.display = "none";
  508. document.getElementById("scheda_info").style.display = "none";
  509. document.getElementById("guasti1858_info").style.display = "none";
  510. document.getElementById("guasti1888_info").style.display = "block";
  511. document.getElementById("papini1912_info").style.display = "none";
  512. document.getElementById("marchini1956_info").style.display = "none";
  513. document.getElementById("img_title").innerHTML = "Guida Guasti 1888";
  514. clearViewer();
  515. runOpenseadragon(img_g1888);
  516. }
  517. function show_P1912(){
  518. document.getElementById("OA_info").style.display = "none";
  519. document.getElementById("catalogo_info").style.display = "none";
  520. document.getElementById("scheda_info").style.display = "none";
  521. document.getElementById("guasti1858_info").style.display = "none";
  522. document.getElementById("guasti1888_info").style.display = "none";
  523. document.getElementById("papini1912_info").style.display = "block";
  524. document.getElementById("marchini1956_info").style.display = "none";
  525. document.getElementById("img_title").innerHTML = "Catalogo Papini 1912";
  526. clearViewer();
  527. runOpenseadragon(img_p1912);
  528. }
  529. function show_M1956(){
  530. document.getElementById("OA_info").style.display = "none";
  531. document.getElementById("catalogo_info").style.display = "none";
  532. document.getElementById("scheda_info").style.display = "none";
  533. document.getElementById("guasti1858_info").style.display = "none";
  534. document.getElementById("guasti1888_info").style.display = "none";
  535. document.getElementById("papini1912_info").style.display = "none";
  536. document.getElementById("marchini1956_info").style.display = "block";
  537. document.getElementById("img_title").innerHTML = "Marchini 1956";
  538. clearViewer();
  539. runOpenseadragon(img_m1956);
  540. //document.getElementById("expandedImg").src = img_m1956;
  541. }
  542. let magnifierInterval;
  543. function createMagnifier(imgID, zoom){
  544. magnify(imgID, zoom);
  545. let glass = document.getElementById('glass');
  546. let img = document.getElementById(imgID);
  547. magnifierInterval = setInterval(
  548. function(){
  549. // console.log('LOOP in corso');
  550. glass.style.backgroundImage = "url('" + img.src + "')";
  551. },
  552. 500
  553. )
  554. }
  555. function destroyMagnifier(){
  556. clearInterval(magnifierInterval);
  557. const element = document.getElementById('glass');
  558. element.remove();
  559. }
  560. function magnify(imgID, zoom) {
  561. var img, glass, w, h, bw;
  562. img = document.getElementById(imgID);
  563. /*create magnifier glass:*/
  564. glass = document.createElement("DIV");
  565. glass.setAttribute("class", "img-magnifier-glass");
  566. glass.setAttribute("id", "glass");
  567. /*insert magnifier glass:*/
  568. img.parentElement.insertBefore(glass, img);
  569. /*set background properties for the magnifier glass:*/
  570. glass.style.backgroundImage = "url('" + img.src + "')";
  571. glass.style.backgroundRepeat = "no-repeat";
  572. glass.style.backgroundSize = (img.width * zoom) + "px " + (img.height * zoom) + "px";
  573. bw = 3;
  574. w = glass.offsetWidth / 2;
  575. h = glass.offsetHeight / 2;
  576. /*execute a function when someone moves the magnifier glass over the image:*/
  577. glass.addEventListener("mousemove", moveMagnifier);
  578. img.addEventListener("mousemove", moveMagnifier);
  579. /*and also for touch screens:*/
  580. glass.addEventListener("touchmove", moveMagnifier);
  581. img.addEventListener("touchmove", moveMagnifier);
  582. function moveMagnifier(e) {
  583. var pos, x, y;
  584. /*prevent any other actions that may occur when moving over the image*/
  585. e.preventDefault();
  586. /*get the cursor's x and y positions:*/
  587. pos = getCursorPos(e);
  588. x = pos.x;
  589. y = pos.y;
  590. /*prevent the magnifier glass from being positioned outside the image:*/
  591. if (x > img.width - (w / zoom)) {x = img.width - (w / zoom);}
  592. if (x < w / zoom) {x = w / zoom;}
  593. if (y > img.height - (h / zoom)) {y = img.height - (h / zoom);}
  594. if (y < h / zoom) {y = h / zoom;}
  595. /*set the position of the magnifier glass:*/
  596. glass.style.left = (x - w) + "px";
  597. glass.style.top = (y - h) + "px";
  598. /*display what the magnifier glass "sees":*/
  599. glass.style.backgroundPosition = "-" + ((x * zoom) - w + bw) + "px -" + ((y * zoom) - h + bw) + "px";
  600. }
  601. function getCursorPos(e) {
  602. var a, x = 0, y = 0;
  603. e = e || window.event;
  604. /*get the x and y positions of the image:*/
  605. a = img.getBoundingClientRect();
  606. /*calculate the cursor's x and y coordinates, relative to the image:*/
  607. x = e.pageX - a.left;
  608. y = e.pageY - a.top;
  609. /*consider any page scrolling:*/
  610. x = x - window.pageXOffset;
  611. y = y - window.pageYOffset;
  612. return {x : x, y : y};
  613. }
  614. }
  615. function clearViewer() {
  616. var div = document.getElementById("contentDiv");
  617. while(div.firstChild) {
  618. div.removeChild(div.firstChild);
  619. }
  620. }