script3.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. var glob_width;
  2. var glob_height;
  3. var glob_elem;
  4. var glob_id;
  5. var stopFlag = false;
  6. $('.nav-data').click( function(e) {
  7. var current_nav = $(this).text();
  8. $("#header_title").text(current_nav);
  9. name = current_nav.trim();
  10. id = name.replace ( /[^\d.]/g, '' );
  11. index = id;
  12. //<img id="img-preview" width="100%" src="img?id={{ index }}&name={{ name }}&type=preview&counter=0"/>
  13. stopFlag = true;
  14. $("#img-preview").attr("src", "img?id="+id+"&name="+name+"&type=preview&counter=0");
  15. //stopFlag = true;
  16. $('.nav-data').each(function(index) {
  17. id = "#nav"+$(this).text().replace ( /[^\d.]/g, '' );
  18. if ($(this).text() != current_nav) {
  19. $(id).collapse("hide");
  20. } else {
  21. console.log(current_nav, $(this).text());
  22. //$('[data-toggle=collapse]').prop('disabled',true);
  23. //$(id).collapse("show");
  24. }
  25. });
  26. $.ajax({
  27. url: 'update?index=' + index + '&name=' + name,
  28. type: 'GET',
  29. success: function (response) {
  30. console.log("Success.");
  31. console.log(response);
  32. $("td#size"+response.index).text(response.data_size + " GB");
  33. /*
  34. $("#size").text("("+response.data_size+" GB)");
  35. var html = "<span>Description</span>";
  36. for (i = 0; i < response["desc"].length; i++) {
  37. if (response["desc"][i]["type"] == "i") {
  38. tmp = "<i>" + response["desc"][i]["text"] + "</i>";
  39. } else if (response["desc"][i]["type"] == "p") {
  40. tmp = response["desc"][i]["text"];
  41. }
  42. html += tmp;
  43. }
  44. $("#description").empty().append(html);
  45. $("#front-count-text").text(" (max: " + response.front_count + ")");
  46. $("#left-count-text").text(" (max: " + response.left_count + ")");
  47. $("#top-count-text").text(" (max: " + response.top_count + ")");
  48. $("#front-count").text(response.front_count);
  49. $("#left-count").text(response.left_count);
  50. $("#top-count").text(response.top_count);
  51. $("#slider-right").slider("option", "max" , response.front_count );
  52. $("#slider-left").slider("option", "max" , response.left_count );
  53. $("#slider-center").slider("option", "max" , response.top_count );
  54. var left_index = $( "#slider-left" ).slider( "option", "value" );
  55. var top_index = $( "#slider-center" ).slider( "option", "value" );
  56. var front_index = $( "#slider-right" ).slider( "option", "value" );
  57. // update images
  58. $("#placeholder-left").attr("src", "img?id="+index+"&name="+name+"&type=left-resized&counter="+(left_index-1));
  59. $("#img-top").attr("src", "img?id="+index+"&name="+name+"&type=top-resized&counter="+(top_index-1));
  60. $("#img-front").attr("src", "img?id="+index+"&name="+name+"&type=front-resized&counter="+(front_index-1));
  61. var imageUrlLeft = "img?id="+index+"&name="+name+"&type=left&counter="+(left_index-1);
  62. var imageUrlTop ="img?id="+index+"&name="+name+"&type=top&counter="+(top_index-1);
  63. var imageUrlFront = "img?id="+index+"&name="+name+"&type=front&counter="+(front_index-1);
  64. $("#placeholder-left-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlLeft + '")');
  65. $("#img-top-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlTop + '")');
  66. $("#img-front-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlFront + '")');
  67. $("#front-quality-text").text("Magnification: " + ($("#img-front").width() / parseInt($("#front-count").text())).toFixed(2).toString());
  68. $("#top-quality-text").text("Magnification: " + ($("#img-top").height() / parseInt($("#top-count").text())).toFixed(2).toString());
  69. $("#left-quality-text").text("Magnification: " + ($("#placeholder-left").height() / parseInt($("#left-count").text())).toFixed(2).toString());
  70. */
  71. },
  72. error: function () {
  73. console.log("Error.")
  74. }
  75. });
  76. });
  77. if (document.addEventListener)
  78. {
  79. document.addEventListener('webkitfullscreenchange', exitHandler, false);
  80. document.addEventListener('mozfullscreenchange', exitHandler, false);
  81. document.addEventListener('fullscreenchange', exitHandler, false);
  82. document.addEventListener('MSFullscreenChange', exitHandler, false);
  83. }
  84. function exitHandler() {
  85. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  86. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  87. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  88. $(glob_elem).css("width", "100%");
  89. $(glob_elem).css("height", "100%");
  90. $(glob_elem).css("background-color", "white");
  91. $(glob_elem).css("color", "#000");
  92. $("#front-quality-text").text("Size: 25%");
  93. $("#top-quality-text").text("Size: 25%");
  94. $("#left-quality-text").text("Size: 25%");
  95. $("#"+glob_id).width('100%');
  96. $("#"+glob_id).height("100%");
  97. } else {
  98. $("#front-quality-text").text("Size: 100%");
  99. $("#top-quality-text").text("Size: 100%");
  100. $("#left-quality-text").text("Size: 100%");
  101. }
  102. }
  103. }
  104. function toggleFullscreen(elem, _id) {
  105. elem = elem || document.documentElement;
  106. console.log("ID: "+_id);
  107. var ori_width = glob_width
  108. var ori_height = glob_height;
  109. var fs_scale;
  110. var myRatio;
  111. if (window.devicePixelRatio < 1) {
  112. myRatio = 1.0;
  113. } else {
  114. myRatio = 2.0;
  115. }
  116. $("#"+_id).css('width', 'auto')
  117. $("#"+_id).css('height', 'auto')
  118. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  119. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  120. if ((ori_height*1.2) > ori_width) {
  121. //newWidth = screen.width * (1/Math.ceil(window.devicePixelRatio));
  122. //newHeight = screen.width * (ori_height/ori_width) * (1/Math.ceil(window.devicePixelRatio));
  123. newWidth = screen.width * (1/ myRatio);
  124. newHeight = screen.width * (ori_height/ori_width) * (1/ myRatio);
  125. $("#"+_id).removeAttr('width');
  126. $("#"+_id).height("80%");
  127. } else {
  128. newHeight = screen.height * (1/myRatio);
  129. newWidth = screen.height * (ori_width/ori_height) * (1/myRatio);
  130. $("#"+_id).removeAttr('height');
  131. $("#"+_id).width("100%");
  132. //newHeight = screen.height * (1/Math.ceil(window.devicePixelRatio));
  133. //newWidth = screen.height * (ori_width/ori_height) * (1/Math.ceil(window.devicePixelRatio));
  134. }
  135. $(elem).css("height", (newHeight)+"px");
  136. $(elem).css("width", (newWidth)+"px");
  137. //$("#"+_id).removeAttr('width');
  138. //$("#"+_id).height("80%");
  139. //$(elem).css("width", "200px");
  140. $(elem).css("background-color", "black");
  141. $(elem).css("color", "#ccc");
  142. if (elem.requestFullscreen) {
  143. elem.requestFullscreen();
  144. } else if (elem.msRequestFullscreen) {
  145. elem.msRequestFullscreen();
  146. } else if (elem.mozRequestFullScreen) {
  147. elem.mozRequestFullScreen();
  148. } else if (elem.webkitRequestFullscreen) {
  149. elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  150. }
  151. } else {
  152. $("#"+_id).width('100%');
  153. $("#"+_id).height("100%");
  154. //$(elem).css("width", "100%");
  155. $(elem).css("background-color", "white");
  156. $(elem).css("color", "#000");
  157. if (document.exitFullscreen) {
  158. document.exitFullscreen();
  159. } else if (document.msExitFullscreen) {
  160. document.msExitFullscreen();
  161. } else if (document.mozCancelFullScreen) {
  162. document.mozCancelFullScreen();
  163. } else if (document.webkitExitFullscreen) {
  164. document.webkitExitFullscreen();
  165. }
  166. }
  167. }
  168. function IsImageOk(img) {
  169. // During the onload event, IE correctly identifies any images that
  170. // weren’t downloaded as not complete. Others should too. Gecko-based
  171. // browsers act like NS4 in that they report this incorrectly.
  172. if (!img.complete) {
  173. return false;
  174. }
  175. // However, they do have two very useful properties: naturalWidth and
  176. // naturalHeight. These give the true size of the image. If it failed
  177. // to load, either of these should be zero.
  178. if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
  179. return false;
  180. }
  181. // No other way of checking: assume it’s ok.
  182. return true;
  183. }
  184. var imgTopArray = [];
  185. var imgFrontArray = [];
  186. var imgLeftArray = [];
  187. $(function() {
  188. $(window).resize(function() {
  189. $("#front-quality-text").text("Magnification: " + ($("#img-front").width() / parseInt($("#front-count").text())).toFixed(2).toString() + "%");
  190. $("#top-quality-text").text("Magnification: " + ($("#img-top").height() / parseInt($("#top-count").text())).toFixed(2).toString() + "%");
  191. $("#left-quality-text").text("Magnification: " + ($("#placeholder-left").height() / parseInt($("#left-count").text())).toFixed(2).toString() + "%");
  192. });
  193. var name;
  194. var id;
  195. $( "#slider-left" ).slider({
  196. range: "max",
  197. min: 1,
  198. max: parseInt($("#left-count").text()),
  199. //max: 1500,
  200. value: 1,
  201. stop: function(event, ui) {
  202. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+(ui.value-1));
  203. },
  204. slide: function( event, ui ) {
  205. name = $( "#header_title" ).text();
  206. id = name.replace ( /[^\d.]/g, '' );
  207. if (ui.value > imgFrontArray.length) {
  208. $("#img-left-container").empty();
  209. } else {
  210. if (IsImageOk(imgLeftArray[ui.value-1]) ) {
  211. $("#img-left-container").empty().append(imgLeftArray[ui.value-1]);
  212. } else {
  213. //$("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+(ui.value-1));
  214. }
  215. }
  216. $("#left-text").text(ui.value);
  217. }
  218. });
  219. $( "#slider-right" ).slider({
  220. range: "max",
  221. min: 1,
  222. max: parseInt($("#front-count").text()),
  223. value: 1,
  224. start: function(event, ui) {
  225. processLargeFrontArray( parseInt( $("#front-count").text()) );
  226. },
  227. stop: function(event, ui) {
  228. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+(ui.value-1));
  229. },
  230. slide: function( event, ui ) {
  231. name = $( "#header_title" ).text();
  232. id = name.replace ( /[^\d.]/g, '' );
  233. if (ui.value > imgFrontArray.length) {
  234. $("#img-front-container").empty();
  235. } else {
  236. if (IsImageOk(imgFrontArray[ui.value-1]) ) {
  237. $("#img-front-container").empty().append(imgFrontArray[ui.value-1]);
  238. } else {
  239. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+(ui.value-1));
  240. }
  241. }
  242. $("#front-text").text(ui.value);
  243. }
  244. });
  245. $( "#slider-center" ).slider({
  246. range: "max",
  247. min: 1,
  248. max: parseInt($("#top-count").text()),
  249. //max: 1500,
  250. value: 1,
  251. stop: function(event, ui) {
  252. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+(ui.value-1));
  253. },
  254. slide: function( event, ui ) {
  255. name = $( "#header_title" ).text();
  256. id = name.replace ( /[^\d.]/g, '' );
  257. if (ui.value > imgTopArray.length) {
  258. $("#img-top-container").empty();
  259. } else {
  260. if (IsImageOk(imgTopArray[ui.value-1]) ) {
  261. $("#img-top-container").empty().append(imgTopArray[ui.value-1]);
  262. } else {
  263. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+(ui.value-1));
  264. }
  265. }
  266. $("#top-text").text(ui.value);
  267. }
  268. });
  269. $( "#download" ).click(function(e) {
  270. var did = $( "select option:selected" ).text();
  271. e.preventDefault(); //stop the browser from following
  272. window.location.href = 'download?did=' + did;
  273. });
  274. /*
  275. $('.target').change(function() {
  276. var name = $(this).find("option:selected").text();
  277. var index = $(this).find("option:selected").val();
  278. $.ajax({
  279. url: 'update?index=' + index + '&name=' + name,
  280. type: 'GET',
  281. success: function (response) {
  282. console.log("Success.");
  283. console.log(response);
  284. $("#size").text("("+response.data_size+" GB)");
  285. var html = "<span>Description</span>";
  286. for (i = 0; i < response["desc"].length; i++) {
  287. if (response["desc"][i]["type"] == "i") {
  288. tmp = "<i>" + response["desc"][i]["text"] + "</i>";
  289. } else if (response["desc"][i]["type"] == "p") {
  290. tmp = response["desc"][i]["text"];
  291. }
  292. html += tmp;
  293. }
  294. $("#description").empty().append(html);
  295. $("#front-count-text").text(" (max: " + response.front_count + ")");
  296. $("#left-count-text").text(" (max: " + response.left_count + ")");
  297. $("#top-count-text").text(" (max: " + response.top_count + ")");
  298. $("#front-count").text(response.front_count);
  299. $("#left-count").text(response.left_count);
  300. $("#top-count").text(response.top_count);
  301. $("#slider-right").slider("option", "max" , response.front_count );
  302. $("#slider-left").slider("option", "max" , response.left_count );
  303. $("#slider-center").slider("option", "max" , response.top_count );
  304. var left_index = $( "#slider-left" ).slider( "option", "value" );
  305. var top_index = $( "#slider-center" ).slider( "option", "value" );
  306. var front_index = $( "#slider-right" ).slider( "option", "value" );
  307. // update images
  308. $("#placeholder-left").attr("src", "img?id="+index+"&name="+name+"&type=left-resized&counter="+(left_index-1));
  309. $("#img-top").attr("src", "img?id="+index+"&name="+name+"&type=top-resized&counter="+(top_index-1));
  310. $("#img-front").attr("src", "img?id="+index+"&name="+name+"&type=front-resized&counter="+(front_index-1));
  311. var imageUrlLeft = "img?id="+index+"&name="+name+"&type=left&counter="+(left_index-1);
  312. var imageUrlTop ="img?id="+index+"&name="+name+"&type=top&counter="+(top_index-1);
  313. var imageUrlFront = "img?id="+index+"&name="+name+"&type=front&counter="+(front_index-1);
  314. $("#placeholder-left-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlLeft + '")');
  315. $("#img-top-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlTop + '")');
  316. $("#img-front-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlFront + '")');
  317. $("#front-quality-text").text("Magnification: " + ($("#img-front").width() / parseInt($("#front-count").text())).toFixed(2).toString());
  318. $("#top-quality-text").text("Magnification: " + ($("#img-top").height() / parseInt($("#top-count").text())).toFixed(2).toString());
  319. $("#left-quality-text").text("Magnification: " + ($("#placeholder-left").height() / parseInt($("#left-count").text())).toFixed(2).toString());
  320. },
  321. error: function () {
  322. console.log("Error.")
  323. }
  324. });
  325. $("#img-preview").attr("src", "img?id="+index+"&name="+name+"&type=preview&counter=0");
  326. });
  327. */
  328. $("#front-left").click( function() {
  329. var index = parseInt($("#front-text").text());
  330. name = $( "#header_title" ).text();
  331. id = name.replace ( /[^\d.]/g, '' );
  332. index -= 1;
  333. if (index < 1) {
  334. index = 1;
  335. }
  336. $("#front-text").text(index);
  337. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  338. /*
  339. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  340. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  341. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  342. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  343. } else {
  344. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  345. }
  346. } else {
  347. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  348. }
  349. */
  350. });
  351. $("#front-right").click( function() {
  352. var index = parseInt($("#front-text").text());
  353. var max_count = parseInt($("#front-count").text());
  354. name = $( "#header_title" ).text();
  355. id = name.replace ( /[^\d.]/g, '' );
  356. //console.log(index, max_count);
  357. index += 1;
  358. if (index > max_count) {
  359. index = max_count;
  360. }
  361. $("#front-text").text(index);
  362. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  363. /*
  364. // update image src
  365. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  366. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  367. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  368. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  369. } else {
  370. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  371. }
  372. } else {
  373. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  374. }
  375. */
  376. });
  377. $("#top-left").click( function() {
  378. var index = parseInt($("#top-text").text());
  379. name = $( "#header_title" ).text();
  380. id = name.replace ( /[^\d.]/g, '' );
  381. index -= 1;
  382. if (index < 1) {
  383. index = 1;
  384. }
  385. $("#top-text").text(index);
  386. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  387. /*
  388. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  389. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  390. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  391. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  392. } else {
  393. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  394. }
  395. } else {
  396. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+index.toString());
  397. }
  398. */
  399. });
  400. $("#top-right").click( function() {
  401. var index = parseInt($("#top-text").text());
  402. var max_count = parseInt($("#top-count").text());
  403. name = $( "#header_title" ).text();
  404. id = name.replace ( /[^\d.]/g, '' );
  405. //console.log(index, max_count);
  406. index += 1;
  407. if (index > max_count) {
  408. index = max_count;
  409. }
  410. $("#top-text").text(index);
  411. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  412. /*
  413. // update image src
  414. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  415. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  416. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  417. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+index.toString());
  418. } else {
  419. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  420. }
  421. } else {
  422. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+index.toString());
  423. }
  424. */
  425. });
  426. $("#left-left").click( function() {
  427. var index = parseInt($("#left-text").text());
  428. name = $( "#header_title" ).text();
  429. id = name.replace ( /[^\d.]/g, '' );
  430. index -= 1;
  431. if (index < 1) {
  432. index = 1;
  433. }
  434. $("#left-text").text(index);
  435. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  436. /*
  437. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  438. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  439. } else {
  440. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  441. }
  442. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  443. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  444. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  445. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  446. } else {
  447. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  448. }
  449. } else {
  450. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  451. }
  452. */
  453. });
  454. $("#left-right").click( function() {
  455. var index = parseInt($("#left-text").text());
  456. var max_count = parseInt($("#left-count").text());
  457. name = $( "#header_title" ).text();
  458. id = name.replace ( /[^\d.]/g, '' );
  459. //console.log(index, max_count);
  460. index += 1;
  461. if (index > max_count) {
  462. index = max_count;
  463. }
  464. $("#left-text").text(index);
  465. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  466. /*
  467. // update image src
  468. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  469. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  470. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  471. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  472. } else {
  473. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  474. }
  475. } else {
  476. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  477. }
  478. */
  479. });
  480. /*
  481. // FULLSCREEN
  482. document.getElementById("img-front").addEventListener("click", function() {
  483. var container = $("#photowrapper-front");
  484. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  485. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  486. glob_id = this.id;
  487. glob_width = $("#photowrapper-front > img").width();
  488. glob_height = $("#photowrapper-front > img").height();
  489. glob_elem = $("#photowrapper-front")[0];
  490. }
  491. toggleFullscreen(container[0], this.id);
  492. });
  493. document.getElementById('img-top').addEventListener('click', function() {
  494. var container = $("#photowrapper-top");
  495. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  496. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  497. glob_id = this.id;
  498. glob_width = $("#photowrapper-top > img").width();
  499. glob_height = $("#photowrapper-top > img").height();
  500. glob_elem = $("#photowrapper-top")[0];
  501. }
  502. toggleFullscreen(container[0], this.id);
  503. });
  504. document.getElementById('placeholder-left').addEventListener('click', function() {
  505. var container = $("#photowrapper-left");
  506. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  507. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  508. glob_id = this.id;
  509. glob_width = $("#photowrapper-left > img").width();
  510. glob_height = $("#photowrapper-left > img").height();
  511. glob_elem = $("#photowrapper-left")[0];
  512. }
  513. toggleFullscreen(container[0], this.id);
  514. });
  515. */
  516. /*
  517. $("#img-top").ezPlus({
  518. zoomWindowPosition: 1,
  519. scrollZoom: true,
  520. zoomLevel: 0.1,
  521. minZoomLevel: 0.1,
  522. zoomWindowWidth: 300,
  523. zoomWindowHeight: 300
  524. });
  525. $("#placeholder-left").ezPlus({
  526. zoomWindowPosition: 9,
  527. scrollZoom: true,
  528. zoomLevel: 0.1,
  529. minZoomLevel: 0.1,
  530. zoomWindowWidth: 300,
  531. zoomWindowHeight: 300
  532. });
  533. $("#img-front").ezPlus({
  534. zoomWindowPosition: 11,
  535. scrollZoom: true,
  536. zoomLevel: 0.1,
  537. minZoomLevel: 0.1,
  538. zoomWindowWidth: 300,
  539. zoomWindowHeight: 300
  540. });
  541. */
  542. /*
  543. * print folder, imLeft.size, imTop.size, imFront.size
  544. * NRM-PZ Ar65771 (1174, 2929) (1173, 2929) (1173, 1174)
  545. * NRM-PZ Ar65772 (1122, 3200) (1173, 3200) (1173, 1122)
  546. * NRM-PZ Ar65794 (1118, 3113) (1133, 3113) (1133, 1118)
  547. * NRM-PZ Ar65793 (1294, 3431) (1240, 3431) (1240, 1294)
  548. * NRM-PZ Ar65720 (1223, 3311) (1267, 3311) (1267, 1223)
  549. * NRM-PZ Ar65767 (1302, 2936) (1284, 2936) (1284, 1302)
  550. */
  551. $("#front-quality-text").text("Magnification: 0.34");
  552. $("#top-quality-text").text("Magnification: 0.13");
  553. $("#left-quality-text").text("Magnification: 0.13");
  554. /*
  555. console.log("FRONT QUALITY: " + $("#img-front").width() + " / " + $("#front-count").text() );
  556. console.log("TOP QUALITY: " + $("#img-top").height() + " / " + $("#top-count").text() );
  557. console.log("LEFT QUALITY: " + $("#placeholder-left").height() + " / " + $("#left-count").text() );
  558. */
  559. /*
  560. // PRELOAD Front Images
  561. for (i = 0; i < parseInt( $("#front-count").text() ); i++) {
  562. name = $( "#header_title" ).text();
  563. id = name.replace ( /[^\d.]/g, '' );
  564. var img = new Image();
  565. img.src = "img?id="+id+"&name="+name+"&type=front-resized&counter="+i;
  566. img.id = "img-front";
  567. img.style.width = 100 + '%';
  568. imgFrontArray[i] = img;
  569. }
  570. */
  571. function processLargeFrontArray(max_iter) {
  572. // set this to whatever number of items you can process at once
  573. var chunk = 10;
  574. var index = 0;
  575. name = $( "#header_title" ).text();
  576. id = name.replace ( /[^\d.]/g, '' );
  577. function doChunk() {
  578. var cnt = chunk;
  579. while (cnt-- && index < max_iter) {
  580. var img = new Image();
  581. img.src = "img?id="+id+"&name="+name+"&type=front-resized&counter="+index;
  582. img.id = "img-front";
  583. img.style.width = 100 + '%';
  584. imgFrontArray[index] = img;
  585. if (stopFlag == true) {
  586. max_iter = 999999;
  587. imgFrontArray = [];
  588. stopFlag = false;
  589. break;
  590. }
  591. // process array[index] here
  592. ++index;
  593. }
  594. if (index < max_iter && index < 1500) {
  595. // set Timeout for async iteration
  596. setTimeout(doChunk, 100);
  597. }
  598. /*else {
  599. processLargeFrontArray( parseInt( $("#front-count").text()) );
  600. }*/
  601. }
  602. doChunk();
  603. }
  604. //processLargeFrontArray( parseInt( $("#front-count").text()) );
  605. /*
  606. // PRELOAD Top Images
  607. for (i = 0; i < parseInt( $("#top-count").text() ); i++) {
  608. name = $( "#header_title" ).text();
  609. id = name.replace ( /[^\d.]/g, '' );
  610. var img = new Image();
  611. img.src = "img?id="+id+"&name="+name+"&type=top-resized&counter="+i;
  612. img.id = "img-top";
  613. img.style.width = 100 + '%';
  614. imgTopArray[i] = img;
  615. }
  616. // PRELOAD Left Images
  617. for (i = 0; i < parseInt( $("#left-count").text() ); i++) {
  618. name = $( "#header_title" ).text();
  619. id = name.replace ( /[^\d.]/g, '' );
  620. var img = new Image();
  621. img.src = "img?id="+id+"&name="+name+"&type=left-resized&counter="+i;
  622. img.id = "placeholder-left";
  623. img.style.width = 100 + '%';
  624. imgLeftArray[i] = img;
  625. }
  626. */
  627. /*
  628. // WEB WORKER APPROACH
  629. var worker = new Worker('http://katrin.kit.edu/static/js/doWork.js');
  630. name = $( "#header_title" ).text();
  631. id = name.replace ( /[^\d.]/g, '' );
  632. //worker.postMessage(999999999);
  633. //
  634. //
  635. myArray = []
  636. for (i = 0; i < parseInt( $("#front-count").text() ); i++) {
  637. var img = new Image();
  638. myArray[i] = img;
  639. }
  640. worker.postMessage({'name': name, 'id': id, 'front_count': $("#front-count").text(), 'imgContainer': myArray });
  641. // array of images
  642. // var images = [];
  643. //worker.addEventListener('message', function(e) {
  644. // console.log(e.data);
  645. //}, false);
  646. worker.onmessage = function(e) {
  647. console.log(e.data);
  648. }
  649. */
  650. });