OA.js 30 KB

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