OA.js 30 KB

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