OA.js 30 KB

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