OA.js 29 KB

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