script3.js 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  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. // Stop large processes
  13. stopFlag = true;
  14. // Update Preview Image
  15. $("#img-preview").attr("src", "img?id="+id+"&name="+name+"&type=preview&counter=0");
  16. // Hide other nav bars
  17. $('.nav-data').each(function(index) {
  18. id = "#nav"+$(this).text().replace ( /[^\d.]/g, '' );
  19. if ($(this).text() != current_nav) {
  20. $(id).collapse("hide");
  21. } else {
  22. console.log(current_nav, $(this).text());
  23. //$('[data-toggle=collapse]').prop('disabled',true);
  24. //$(id).collapse("show");
  25. }
  26. });
  27. $.ajax({
  28. url: 'update?index=' + index + '&name=' + name,
  29. type: 'GET',
  30. success: function (response) {
  31. console.log("Success.");
  32. console.log(response);
  33. $("td#size"+response.index).text(response.data_size + " GB");
  34. var html = "";
  35. for (i = 0; i < response["desc"].length; i++) {
  36. if (response["desc"][i]["type"] == "i") {
  37. tmp = "<i>" + response["desc"][i]["text"] + "</i>";
  38. } else if (response["desc"][i]["type"] == "p") {
  39. tmp = response["desc"][i]["text"];
  40. }
  41. html += tmp;
  42. }
  43. $("td#desc"+response.index).empty().append(html);
  44. $("#front-count-text").text(" (max: " + response.front_count + ")");
  45. $("#left-count-text").text(" (max: " + response.left_count + ")");
  46. $("#top-count-text").text(" (max: " + response.top_count + ")");
  47. $("#front-count").text(response.front_count);
  48. $("#left-count").text(response.left_count);
  49. $("#top-count").text(response.top_count);
  50. $("#slider-right").slider("option", "max" , response.front_count );
  51. $("#slider-left").slider("option", "max" , response.top_count );
  52. $("#slider-center").slider("option", "max" , response.left_count );
  53. var left_index = $( "#slider-left" ).slider( "option", "value" );
  54. var top_index = $( "#slider-center" ).slider( "option", "value" );
  55. var front_index = $( "#slider-right" ).slider( "option", "value" );
  56. // update images
  57. $("#placeholder-left").attr("src", "img?id="+index+"&name="+name+"&type=left-resized&counter="+(left_index-1));
  58. $("#img-top").attr("src", "img?id="+index+"&name="+name+"&type=top-resized&counter="+(top_index-1));
  59. $("#img-front").attr("src", "img?id="+index+"&name="+name+"&type=front-resized&counter="+(front_index-1));
  60. var imageUrlLeft = "img?id="+index+"&name="+name+"&type=left&counter="+(left_index-1);
  61. var imageUrlTop ="img?id="+index+"&name="+name+"&type=top&counter="+(top_index-1);
  62. var imageUrlFront = "img?id="+index+"&name="+name+"&type=front&counter="+(front_index-1);
  63. $("#placeholder-left-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlLeft + '")');
  64. $("#img-top-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlTop + '")');
  65. $("#img-front-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlFront + '")');
  66. $("#front-quality-text").text("Magnification: " + ($("#img-front").width() / parseInt($("#front-count").text())).toFixed(2).toString());
  67. $("#top-quality-text").text("Magnification: " + ($("#img-top").height() / parseInt($("#top-count").text())).toFixed(2).toString());
  68. $("#left-quality-text").text("Magnification: " + ($("#placeholder-left").height() / parseInt($("#left-count").text())).toFixed(2).toString());
  69. if (index in imgTopArray) {
  70. cur_value = parseInt( (imgTopArray[index].length/parseFloat(response.left_count))*100.0);
  71. //console.log(imgTopArray[index].length, response.top_count, response.left_count, response.front_count);
  72. $('#progress-top').css('width', cur_value+'%').attr('aria-valuenow', cur_value);
  73. } else {
  74. $('#progress-top').css('width', '0%').attr('aria-valuenow', 0);
  75. }
  76. if (index in imgLeftArray) {
  77. cur_value = parseInt( (imgLeftArray[index].length/parseFloat(response.top_count))*100.0);
  78. $('#progress-left').css('width', cur_value+'%').attr('aria-valuenow', cur_value);
  79. } else {
  80. $('#progress-left').css('width', '0%').attr('aria-valuenow', 0);
  81. }
  82. if (index in imgFrontArray) {
  83. cur_value = parseInt( (imgFrontArray[index].length/parseFloat(response.front_count))*100.0);
  84. $('#progress-front').css('width', cur_value+'%').attr('aria-valuenow', cur_value);
  85. } else {
  86. $('#progress-front').css('width', '0%').attr('aria-valuenow', 0);
  87. }
  88. },
  89. error: function () {
  90. console.log("Error.")
  91. }
  92. });
  93. });
  94. if (document.addEventListener)
  95. {
  96. document.addEventListener('webkitfullscreenchange', exitHandler, false);
  97. document.addEventListener('mozfullscreenchange', exitHandler, false);
  98. document.addEventListener('fullscreenchange', exitHandler, false);
  99. document.addEventListener('MSFullscreenChange', exitHandler, false);
  100. }
  101. function exitHandler() {
  102. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  103. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  104. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  105. $(glob_elem).css("width", "100%");
  106. $(glob_elem).css("height", "100%");
  107. $(glob_elem).css("background-color", "white");
  108. $(glob_elem).css("color", "#000");
  109. $("#front-quality-text").text("Size: 25%");
  110. $("#top-quality-text").text("Size: 25%");
  111. $("#left-quality-text").text("Size: 25%");
  112. $("#"+glob_id).width('100%');
  113. $("#"+glob_id).height("100%");
  114. } else {
  115. $("#front-quality-text").text("Size: 100%");
  116. $("#top-quality-text").text("Size: 100%");
  117. $("#left-quality-text").text("Size: 100%");
  118. }
  119. }
  120. }
  121. function toggleFullscreen(elem, _id) {
  122. elem = elem || document.documentElement;
  123. console.log("ID: "+_id);
  124. var ori_width = glob_width
  125. var ori_height = glob_height;
  126. var fs_scale;
  127. var myRatio;
  128. if (window.devicePixelRatio < 1) {
  129. myRatio = 1.0;
  130. } else {
  131. myRatio = 2.0;
  132. }
  133. $("#"+_id).css('width', 'auto')
  134. $("#"+_id).css('height', 'auto')
  135. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  136. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  137. if ((ori_height*1.2) > ori_width) {
  138. //newWidth = screen.width * (1/Math.ceil(window.devicePixelRatio));
  139. //newHeight = screen.width * (ori_height/ori_width) * (1/Math.ceil(window.devicePixelRatio));
  140. newWidth = screen.width * (1/ myRatio);
  141. newHeight = screen.width * (ori_height/ori_width) * (1/ myRatio);
  142. $("#"+_id).removeAttr('width');
  143. $("#"+_id).height("80%");
  144. } else {
  145. newHeight = screen.height * (1/myRatio);
  146. newWidth = screen.height * (ori_width/ori_height) * (1/myRatio);
  147. $("#"+_id).removeAttr('height');
  148. $("#"+_id).width("100%");
  149. //newHeight = screen.height * (1/Math.ceil(window.devicePixelRatio));
  150. //newWidth = screen.height * (ori_width/ori_height) * (1/Math.ceil(window.devicePixelRatio));
  151. }
  152. $(elem).css("height", (newHeight)+"px");
  153. $(elem).css("width", (newWidth)+"px");
  154. //$("#"+_id).removeAttr('width');
  155. //$("#"+_id).height("80%");
  156. //$(elem).css("width", "200px");
  157. $(elem).css("background-color", "black");
  158. $(elem).css("color", "#ccc");
  159. if (elem.requestFullscreen) {
  160. elem.requestFullscreen();
  161. } else if (elem.msRequestFullscreen) {
  162. elem.msRequestFullscreen();
  163. } else if (elem.mozRequestFullScreen) {
  164. elem.mozRequestFullScreen();
  165. } else if (elem.webkitRequestFullscreen) {
  166. elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  167. }
  168. } else {
  169. $("#"+_id).width('100%');
  170. $("#"+_id).height("100%");
  171. //$(elem).css("width", "100%");
  172. $(elem).css("background-color", "white");
  173. $(elem).css("color", "#000");
  174. if (document.exitFullscreen) {
  175. document.exitFullscreen();
  176. } else if (document.msExitFullscreen) {
  177. document.msExitFullscreen();
  178. } else if (document.mozCancelFullScreen) {
  179. document.mozCancelFullScreen();
  180. } else if (document.webkitExitFullscreen) {
  181. document.webkitExitFullscreen();
  182. }
  183. }
  184. }
  185. function IsImageOk(img) {
  186. // During the onload event, IE correctly identifies any images that
  187. // weren’t downloaded as not complete. Others should too. Gecko-based
  188. // browsers act like NS4 in that they report this incorrectly.
  189. if (!img.complete) {
  190. return false;
  191. }
  192. // However, they do have two very useful properties: naturalWidth and
  193. // naturalHeight. These give the true size of the image. If it failed
  194. // to load, either of these should be zero.
  195. if (typeof img.naturalWidth !== "undefined" && img.naturalWidth === 0) {
  196. return false;
  197. }
  198. // No other way of checking: assume it’s ok.
  199. return true;
  200. }
  201. var imgTopArray = {};
  202. var imgFrontArray = {};
  203. var imgLeftArray = {};
  204. $(function() {
  205. $(window).resize(function() {
  206. $("#front-quality-text").text("Magnification: " + ($("#img-front").width() / parseInt($("#front-count").text())).toFixed(2).toString() + "%");
  207. $("#top-quality-text").text("Magnification: " + ($("#img-top").height() / parseInt($("#top-count").text())).toFixed(2).toString() + "%");
  208. $("#left-quality-text").text("Magnification: " + ($("#placeholder-left").height() / parseInt($("#left-count").text())).toFixed(2).toString() + "%");
  209. });
  210. $( "#slider-left" ).slider({
  211. range: "max",
  212. min: 1,
  213. max: parseInt($("#left-count").text()),
  214. //max: 1500,
  215. value: 1,
  216. start: function(event, ui) {
  217. //if (leftFlag == false) {
  218. // leftFlag = true;
  219. //processLargeLeftArray( parseInt( $("#left-count").text()) );
  220. //}
  221. },
  222. stop: function(event, ui) {
  223. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+(ui.value-1));
  224. imageUrl = "img?id="+id+"&name="+name+"&type=left&counter="+(ui.value-1);
  225. var zoomConfig = {
  226. zoomWindowPosition: "abcd",
  227. zoomWindowHeight: "100%",
  228. zoomWindowWidth: "33.3%",
  229. borderSize: 0,
  230. easing:true,
  231. onShow: function () {
  232. $("#sidebar" ).css("opacity", "0");
  233. },
  234. onHide: function () {
  235. $("#sidebar" ).css("opacity", "1");
  236. }
  237. };
  238. var zoomImage = $('#placeholder-left');
  239. $('.zoomContainer').remove();
  240. zoomImage.attr('src', imageUrl);
  241. zoomImage.data('zoom-image', imageUrl);
  242. // Reinitialize EZ
  243. zoomImage.ezPlus(zoomConfig);
  244. },
  245. slide: function( event, ui ) {
  246. name = $( "#header_title" ).text().trim();
  247. id = name.replace ( /[^\d.]/g, '' );
  248. if (id in imgLeftArray) {
  249. if (IsImageOk(imgLeftArray[id][ui.value-1]) ) {
  250. console.log("Hellow");
  251. $("#img-left-container").empty().append(imgLeftArray[id][ui.value-1]);
  252. } else {
  253. console.log("RIP2");
  254. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+(ui.value-1));
  255. }
  256. } else {
  257. console.log("RIP");
  258. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+(ui.value-1));
  259. }
  260. $("#left-text").text(ui.value);
  261. }
  262. });
  263. $( "#slider-right" ).slider({
  264. range: "max",
  265. min: 1,
  266. max: parseInt($("#front-count").text()),
  267. value: 1,
  268. start: function(event, ui) {
  269. //processLargeFrontArray( parseInt( $("#front-count").text()) );
  270. },
  271. stop: function(event, ui) {
  272. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+(ui.value-1));
  273. imageUrl = "img?id="+id+"&name="+name+"&type=front&counter="+(ui.value-1);
  274. var zoomConfig = {
  275. zoomWindowPosition: "abcd",
  276. zoomWindowHeight: "100%",
  277. zoomWindowWidth: "33.3%",
  278. borderSize: 0,
  279. easing:true,
  280. onShow: function () {
  281. $("#sidebar" ).css("opacity", "0");
  282. },
  283. onHide: function () {
  284. $("#sidebar" ).css("opacity", "1");
  285. }
  286. };
  287. var zoomImage = $('#img-front');
  288. $('.zoomContainer').remove();
  289. zoomImage.attr('src', imageUrl);
  290. zoomImage.data('zoom-image', imageUrl);
  291. // Reinitialize EZ
  292. zoomImage.ezPlus(zoomConfig);
  293. },
  294. slide: function( event, ui ) {
  295. name = $( "#header_title" ).text().trim();
  296. id = name.replace ( /[^\d.]/g, '' );
  297. if (id in imgFrontArray) {
  298. if (IsImageOk(imgFrontArray[id][ui.value-1]) ) {
  299. console.log("Hellow");
  300. $("#img-front-container").empty().append(imgFrontArray[id][ui.value-1]);
  301. } else {
  302. console.log("RIP2");
  303. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+(ui.value-1));
  304. }
  305. } else {
  306. console.log("RIP");
  307. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+(ui.value-1));
  308. }
  309. $("#front-text").text(ui.value);
  310. }
  311. });
  312. $( "#slider-center" ).slider({
  313. range: "max",
  314. min: 1,
  315. max: parseInt($("#top-count").text()),
  316. //max: 1500,
  317. value: 1,
  318. start: function(event, ui) {
  319. //processLargeTopArray( parseInt( $("#top-count").text()) );
  320. },
  321. stop: function(event, ui) {
  322. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+(ui.value-1));
  323. imageUrl = "img?id="+id+"&name="+name+"&type=top&counter="+(ui.value-1);
  324. var zoomConfig = {
  325. zoomWindowPosition: "abcd",
  326. zoomWindowHeight: "100%",
  327. zoomWindowWidth: "33.3%",
  328. borderSize: 0,
  329. easing:true,
  330. onShow: function () {
  331. $("#sidebar" ).css("opacity", "0");
  332. },
  333. onHide: function () {
  334. $("#sidebar" ).css("opacity", "1");
  335. }
  336. };
  337. var zoomImage = $('#img-top');
  338. $('.zoomContainer').remove();
  339. zoomImage.attr('src', imageUrl);
  340. zoomImage.data('zoom-image', imageUrl);
  341. // Reinitialize EZ
  342. zoomImage.ezPlus(zoomConfig);
  343. },
  344. slide: function( event, ui ) {
  345. name = $( "#header_title" ).text().trim();
  346. id = name.replace ( /[^\d.]/g, '' );
  347. if (id in imgTopArray) {
  348. if (IsImageOk(imgTopArray[id][ui.value-1]) ) {
  349. console.log("Hellow");
  350. $("#img-top-container").empty().append(imgTopArray[id][ui.value-1]);
  351. } else {
  352. console.log("RIP2");
  353. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+(ui.value-1));
  354. }
  355. } else {
  356. console.log("RIP");
  357. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+(ui.value-1));
  358. }
  359. /*
  360. if (imgTopArray[name].length > (parseInt( $("#top-count").text())*0.7) ) {
  361. console.log("HELLO");
  362. if (IsImageOk(imgTopArray[name][ui.value-1])) {
  363. $("#img-top-container").empty().append(imgTopArray[name][ui.value-1]);
  364. }
  365. }
  366. } else {
  367. console.log("WUT", name, );
  368. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+(ui.value-1));
  369. }
  370. */
  371. $("#top-text").text(ui.value);
  372. }
  373. });
  374. $( "#download" ).click(function(e) {
  375. name = $( "#header_title" ).text().trim();
  376. id = name.replace ( /[^\d.]/g, '' );
  377. //var did = $( "select option:selected" ).text();
  378. e.preventDefault(); //stop the browser from following
  379. window.location.href = 'download?did=' + name;
  380. });
  381. $( "#bufferTop" ).click(function() {
  382. name = $( "#header_title" ).text().trim();
  383. total = parseInt( $("#top-count").text());
  384. id = name.replace ( /[^\d.]/g, '' );
  385. console.log(id, total, name);
  386. if ( !(id in imgTopArray) || (imgTopArray[id].length != total) ) {
  387. processLargeTopArray(name, total );
  388. }
  389. });
  390. $( "#bufferLeft" ).click(function() {
  391. name = $( "#header_title" ).text().trim();
  392. total = parseInt( $("#left-count").text());
  393. id = name.replace ( /[^\d.]/g, '' );
  394. if ( !(id in imgLeftArray) || (imgLeftArray[id].length != total) ) {
  395. processLargeLeftArray(name, total );
  396. }
  397. });
  398. $( "#bufferFront" ).click(function() {
  399. name = $( "#header_title" ).text().trim();
  400. total = parseInt( $("#front-count").text());
  401. id = name.replace ( /[^\d.]/g, '' );
  402. if ( !(id in imgFrontArray) || (imgFrontArray[id].length != total) ) {
  403. processLargeFrontArray(name, total );
  404. }
  405. });
  406. /*
  407. $('.target').change(function() {
  408. var name = $(this).find("option:selected").text();
  409. var index = $(this).find("option:selected").val();
  410. $.ajax({
  411. url: 'update?index=' + index + '&name=' + name,
  412. type: 'GET',
  413. success: function (response) {
  414. console.log("Success.");
  415. console.log(response);
  416. $("#size").text("("+response.data_size+" GB)");
  417. var html = "<span>Description</span>";
  418. for (i = 0; i < response["desc"].length; i++) {
  419. if (response["desc"][i]["type"] == "i") {
  420. tmp = "<i>" + response["desc"][i]["text"] + "</i>";
  421. } else if (response["desc"][i]["type"] == "p") {
  422. tmp = response["desc"][i]["text"];
  423. }
  424. html += tmp;
  425. }
  426. $("#description").empty().append(html);
  427. $("#front-count-text").text(" (max: " + response.front_count + ")");
  428. $("#left-count-text").text(" (max: " + response.left_count + ")");
  429. $("#top-count-text").text(" (max: " + response.top_count + ")");
  430. $("#front-count").text(response.front_count);
  431. $("#left-count").text(response.left_count);
  432. $("#top-count").text(response.top_count);
  433. $("#slider-right").slider("option", "max" , response.front_count );
  434. $("#slider-left").slider("option", "max" , response.left_count );
  435. $("#slider-center").slider("option", "max" , response.top_count );
  436. var left_index = $( "#slider-left" ).slider( "option", "value" );
  437. var top_index = $( "#slider-center" ).slider( "option", "value" );
  438. var front_index = $( "#slider-right" ).slider( "option", "value" );
  439. // update images
  440. $("#placeholder-left").attr("src", "img?id="+index+"&name="+name+"&type=left-resized&counter="+(left_index-1));
  441. $("#img-top").attr("src", "img?id="+index+"&name="+name+"&type=top-resized&counter="+(top_index-1));
  442. $("#img-front").attr("src", "img?id="+index+"&name="+name+"&type=front-resized&counter="+(front_index-1));
  443. var imageUrlLeft = "img?id="+index+"&name="+name+"&type=left&counter="+(left_index-1);
  444. var imageUrlTop ="img?id="+index+"&name="+name+"&type=top&counter="+(top_index-1);
  445. var imageUrlFront = "img?id="+index+"&name="+name+"&type=front&counter="+(front_index-1);
  446. $("#placeholder-left-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlLeft + '")');
  447. $("#img-top-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlTop + '")');
  448. $("#img-front-zoomContainer > .zoomWindowContainer > div").css('background-image', 'url("' + imageUrlFront + '")');
  449. $("#front-quality-text").text("Magnification: " + ($("#img-front").width() / parseInt($("#front-count").text())).toFixed(2).toString());
  450. $("#top-quality-text").text("Magnification: " + ($("#img-top").height() / parseInt($("#top-count").text())).toFixed(2).toString());
  451. $("#left-quality-text").text("Magnification: " + ($("#placeholder-left").height() / parseInt($("#left-count").text())).toFixed(2).toString());
  452. },
  453. error: function () {
  454. console.log("Error.")
  455. }
  456. });
  457. $("#img-preview").attr("src", "img?id="+index+"&name="+name+"&type=preview&counter=0");
  458. });
  459. */
  460. $("#front-left").click( function() {
  461. var index = parseInt($("#front-text").text());
  462. name = $( "#header_title" ).text().trim();
  463. id = name.replace ( /[^\d.]/g, '' );
  464. index -= 1;
  465. if (index < 1) {
  466. index = 1;
  467. }
  468. $("#front-text").text(index);
  469. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  470. /*
  471. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  472. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  473. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  474. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  475. } else {
  476. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  477. }
  478. } else {
  479. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  480. }
  481. */
  482. });
  483. $("#front-right").click( function() {
  484. var index = parseInt($("#front-text").text());
  485. var max_count = parseInt($("#front-count").text());
  486. name = $( "#header_title" ).text().trim();
  487. id = name.replace ( /[^\d.]/g, '' );
  488. //console.log(index, max_count);
  489. index += 1;
  490. if (index > max_count) {
  491. index = max_count;
  492. }
  493. $("#front-text").text(index);
  494. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  495. /*
  496. // update image src
  497. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  498. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  499. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  500. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  501. } else {
  502. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front&counter="+index.toString());
  503. }
  504. } else {
  505. $("#img-front").attr("src", "img?id="+id+"&name="+name+"&type=front-resized&counter="+index.toString());
  506. }
  507. */
  508. });
  509. $("#top-left").click( function() {
  510. var index = parseInt($("#top-text").text());
  511. name = $( "#header_title" ).text().trim();
  512. id = name.replace ( /[^\d.]/g, '' );
  513. index -= 1;
  514. if (index < 1) {
  515. index = 1;
  516. }
  517. $("#top-text").text(index);
  518. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  519. /*
  520. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  521. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  522. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  523. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  524. } else {
  525. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  526. }
  527. } else {
  528. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+index.toString());
  529. }
  530. */
  531. });
  532. $("#top-right").click( function() {
  533. var index = parseInt($("#top-text").text());
  534. var max_count = parseInt($("#top-count").text());
  535. name = $( "#header_title" ).text().trim();
  536. id = name.replace ( /[^\d.]/g, '' );
  537. //console.log(index, max_count);
  538. index += 1;
  539. if (index > max_count) {
  540. index = max_count;
  541. }
  542. $("#top-text").text(index);
  543. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  544. /*
  545. // update image src
  546. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  547. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  548. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  549. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+index.toString());
  550. } else {
  551. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top&counter="+index.toString());
  552. }
  553. } else {
  554. $("#img-top").attr("src", "img?id="+id+"&name="+name+"&type=top-resized&counter="+index.toString());
  555. }
  556. */
  557. });
  558. $("#left-left").click( function() {
  559. var index = parseInt($("#left-text").text());
  560. name = $( "#header_title" ).text().trim();
  561. id = name.replace ( /[^\d.]/g, '' );
  562. index -= 1;
  563. if (index < 1) {
  564. index = 1;
  565. }
  566. $("#left-text").text(index);
  567. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  568. /*
  569. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  570. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  571. } else {
  572. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  573. }
  574. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  575. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  576. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  577. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  578. } else {
  579. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  580. }
  581. } else {
  582. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  583. }
  584. */
  585. });
  586. $("#left-right").click( function() {
  587. var index = parseInt($("#left-text").text());
  588. var max_count = parseInt($("#left-count").text());
  589. name = $( "#header_title" ).text().trim();
  590. id = name.replace ( /[^\d.]/g, '' );
  591. //console.log(index, max_count);
  592. index += 1;
  593. if (index > max_count) {
  594. index = max_count;
  595. }
  596. $("#left-text").text(index);
  597. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  598. /*
  599. // update image src
  600. if (document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement !== null) {
  601. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  602. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  603. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  604. } else {
  605. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left&counter="+index.toString());
  606. }
  607. } else {
  608. $("#placeholder-left").attr("src", "img?id="+id+"&name="+name+"&type=left-resized&counter="+index.toString());
  609. }
  610. */
  611. });
  612. /*
  613. // FULLSCREEN
  614. document.getElementById("img-front").addEventListener("click", function() {
  615. var container = $("#photowrapper-front");
  616. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  617. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  618. glob_id = this.id;
  619. glob_width = $("#photowrapper-front > img").width();
  620. glob_height = $("#photowrapper-front > img").height();
  621. glob_elem = $("#photowrapper-front")[0];
  622. }
  623. toggleFullscreen(container[0], this.id);
  624. });
  625. document.getElementById('img-top').addEventListener('click', function() {
  626. var container = $("#photowrapper-top");
  627. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  628. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  629. glob_id = this.id;
  630. glob_width = $("#photowrapper-top > img").width();
  631. glob_height = $("#photowrapper-top > img").height();
  632. glob_elem = $("#photowrapper-top")[0];
  633. }
  634. toggleFullscreen(container[0], this.id);
  635. });
  636. document.getElementById('placeholder-left').addEventListener('click', function() {
  637. var container = $("#photowrapper-left");
  638. if (!document.fullscreenElement && !document.mozFullScreenElement &&
  639. !document.webkitFullscreenElement && !document.msFullscreenElement) {
  640. glob_id = this.id;
  641. glob_width = $("#photowrapper-left > img").width();
  642. glob_height = $("#photowrapper-left > img").height();
  643. glob_elem = $("#photowrapper-left")[0];
  644. }
  645. toggleFullscreen(container[0], this.id);
  646. });
  647. */
  648. /*
  649. $("#img-top").ezPlus({
  650. zoomWindowPosition: 1,
  651. scrollZoom: true,
  652. zoomLevel: 0.1,
  653. minZoomLevel: 0.1,
  654. zoomWindowWidth: 300,
  655. zoomWindowHeight: 300
  656. });
  657. */
  658. $("#img-top").ezPlus({
  659. ////zoomWindowPosition: 1,
  660. zoomWindowPosition: "abcd",
  661. //scrollZoom: true,
  662. zoomWindowHeight: "100%",
  663. zoomWindowWidth: "33.3%",
  664. borderSize: 0,
  665. easing:true,
  666. onShow: function () {
  667. $("#sidebar" ).css("opacity", "0");
  668. },
  669. onHide: function () {
  670. $("#sidebar" ).css("opacity", "1");
  671. }
  672. });
  673. $("#placeholder-left").ezPlus({
  674. zoomWindowPosition: "abcd",
  675. //zoomWindowPosition: 9,
  676. //scrollZoom: true,
  677. //zoomLevel: 0.1,
  678. //minZoomLevel: 0.1,
  679. zoomWindowHeight: "100%",
  680. zoomWindowWidth: "33.3%",
  681. borderSize: 0,
  682. easing:true,
  683. onShow: function () {
  684. $("#sidebar" ).css("opacity", "0");
  685. },
  686. onHide: function () {
  687. $("#sidebar" ).css("opacity", "1");
  688. }
  689. });
  690. $("#img-front").ezPlus({
  691. zoomWindowPosition: "abcd",
  692. zoomWindowHeight: "100%",
  693. zoomWindowWidth: "33.3%",
  694. borderSize: 0,
  695. easing:true,
  696. onShow: function () {
  697. $("#sidebar" ).css("opacity", "0");
  698. },
  699. onHide: function () {
  700. $("#sidebar" ).css("opacity", "1");
  701. }
  702. });
  703. /*
  704. * print folder, imLeft.size, imTop.size, imFront.size
  705. * NRM-PZ Ar65771 (1174, 2929) (1173, 2929) (1173, 1174)
  706. * NRM-PZ Ar65772 (1122, 3200) (1173, 3200) (1173, 1122)
  707. * NRM-PZ Ar65794 (1118, 3113) (1133, 3113) (1133, 1118)
  708. * NRM-PZ Ar65793 (1294, 3431) (1240, 3431) (1240, 1294)
  709. * NRM-PZ Ar65720 (1223, 3311) (1267, 3311) (1267, 1223)
  710. * NRM-PZ Ar65767 (1302, 2936) (1284, 2936) (1284, 1302)
  711. */
  712. $("#front-quality-text").text("Magnification: 0.34");
  713. $("#top-quality-text").text("Magnification: 0.13");
  714. $("#left-quality-text").text("Magnification: 0.13");
  715. /*
  716. console.log("FRONT QUALITY: " + $("#img-front").width() + " / " + $("#front-count").text() );
  717. console.log("TOP QUALITY: " + $("#img-top").height() + " / " + $("#top-count").text() );
  718. console.log("LEFT QUALITY: " + $("#placeholder-left").height() + " / " + $("#left-count").text() );
  719. */
  720. /*
  721. // PRELOAD Front Images
  722. for (i = 0; i < parseInt( $("#front-count").text() ); i++) {
  723. name = $( "#header_title" ).text();
  724. id = name.replace ( /[^\d.]/g, '' );
  725. var img = new Image();
  726. img.src = "img?id="+id+"&name="+name+"&type=front-resized&counter="+i;
  727. img.id = "img-front";
  728. img.style.width = 100 + '%';
  729. imgFrontArray[i] = img;
  730. }
  731. */
  732. function processLargeFrontArray(name, max_iter) {
  733. // set this to whatever number of items you can process at once
  734. // Can use FPS to find the balance between chunk size and timeout value
  735. var chunk = 10;
  736. var index = 0;
  737. var tmpArray = []
  738. name = $( "#header_title" ).text().trim();
  739. id = name.replace ( /[^\d.]/g, '' );
  740. function doChunk() {
  741. var cnt = chunk;
  742. while (cnt-- && index < max_iter) {
  743. var img = new Image();
  744. img.src = "img?id="+id+"&name="+name+"&type=front-resized&counter="+index;
  745. img.id = "img-front";
  746. img.style.width = 100 + '%';
  747. tmpArray[index] = img;
  748. if (stopFlag == true) {
  749. index = 999999;
  750. stopFlag = false;
  751. break;
  752. }
  753. // process array[index] here
  754. ++index;
  755. }
  756. if (index < max_iter) {
  757. // set Timeout for async iteration
  758. setTimeout(doChunk, 100);
  759. cur_value = parseInt( (tmpArray.length/parseFloat(max_iter))*100.0);
  760. //console.log(tmpArray.length, max_iter)
  761. $('#progress-front').css('width', cur_value+'%').attr('aria-valuenow', cur_value);
  762. } else {
  763. console.log(index);
  764. if (tmpArray.length > 100) {
  765. imgFrontArray[id] = tmpArray;
  766. $('#progress-front').css('width', '100%').attr('aria-valuenow', 100);
  767. }
  768. stopFlag = false;
  769. index = 0;
  770. tmpArray = [];
  771. }
  772. /*else {
  773. processLargeFrontArray( parseInt( $("#front-count").text()) );
  774. }*/
  775. }
  776. doChunk();
  777. }
  778. function processLargeLeftArray(name, max_iter) {
  779. // set this to whatever number of items you can process at once
  780. // Can use FPS to find the balance between chunk size and timeout value
  781. var chunk = 10;
  782. var index = 0;
  783. var tmpArray = []
  784. name = $( "#header_title" ).text().trim();
  785. id = name.replace ( /[^\d.]/g, '' );
  786. function doChunk() {
  787. var cnt = chunk;
  788. while (cnt-- && index < max_iter) {
  789. var img = new Image();
  790. img.src = "img?id="+id+"&name="+name+"&type=left-resized&counter="+index;
  791. img.id = "placeholder-left";
  792. img.style.width = 100 + '%';
  793. tmpArray[index] = img;
  794. if (stopFlag == true) {
  795. index = 999999;
  796. stopFlag = false;
  797. break;
  798. }
  799. // process array[index] here
  800. ++index;
  801. }
  802. if (index < max_iter) {
  803. // set Timeout for async iteration
  804. setTimeout(doChunk, 100);
  805. cur_value = parseInt( (tmpArray.length/parseFloat(max_iter))*100.0);
  806. //console.log(tmpArray.length, max_iter)
  807. $('#progress-left').css('width', cur_value+'%').attr('aria-valuenow', cur_value);
  808. } else {
  809. console.log(index);
  810. if (tmpArray.length > 100) {
  811. imgLeftArray[id] = tmpArray;
  812. $('#progress-left').css('width', '100%').attr('aria-valuenow', 100);
  813. }
  814. stopFlag = false;
  815. index = 0;
  816. tmpArray = [];
  817. }
  818. /*else {
  819. processLargeFrontArray( parseInt( $("#front-count").text()) );
  820. }*/
  821. }
  822. doChunk();
  823. }
  824. function processLargeTopArray(name, max_iter) {
  825. // set this to whatever number of items you can process at once
  826. // Can use FPS to find the balance between chunk size and timeout value
  827. var chunk = 10;
  828. var index = 0;
  829. var myVar;
  830. var tmpArray = []
  831. name = $( "#header_title" ).text().trim();
  832. id = name.replace ( /[^\d.]/g, '' );
  833. function doChunk() {
  834. var cnt = chunk;
  835. while (cnt-- && index < max_iter) {
  836. var img = new Image();
  837. img.src = "img?id="+id+"&name="+name+"&type=top-resized&counter="+index;
  838. img.id = "img-top";
  839. img.style.width = 100 + '%';
  840. tmpArray[index] = img;
  841. if (stopFlag == true) {
  842. //index = 999999;
  843. break;
  844. }
  845. // process array[index] here
  846. ++index;
  847. }
  848. if ( (index < max_iter) && (stopFlag == false)) {
  849. // set Timeout for async iteration
  850. myVar = setTimeout(doChunk, 100);
  851. cur_value = parseInt( (tmpArray.length/parseFloat(max_iter))*100.0);
  852. //console.log(tmpArray.length, max_iter)
  853. $('#progress-top').css('width', cur_value+'%').attr('aria-valuenow', cur_value);
  854. } else {
  855. console.log(index);
  856. clearTimeout(myVar);
  857. if (tmpArray.length > 100) {
  858. imgTopArray[id] = tmpArray;
  859. $('#progress-top').css('width', '100%').attr('aria-valuenow', 100);
  860. }
  861. stopFlag = false;
  862. index = 0;
  863. tmpArray = [];
  864. }
  865. /*else {
  866. processLargeFrontArray( parseInt( $("#front-count").text()) );
  867. }*/
  868. }
  869. doChunk();
  870. }
  871. /*
  872. // PRELOAD Top Images
  873. for (i = 0; i < parseInt( $("#top-count").text() ); i++) {
  874. name = $( "#header_title" ).text();
  875. id = name.replace ( /[^\d.]/g, '' );
  876. var img = new Image();
  877. img.src = "img?id="+id+"&name="+name+"&type=top-resized&counter="+i;
  878. img.id = "img-top";
  879. img.style.width = 100 + '%';
  880. imgTopArray[i] = img;
  881. }
  882. // PRELOAD Left Images
  883. for (i = 0; i < parseInt( $("#left-count").text() ); i++) {
  884. name = $( "#header_title" ).text();
  885. id = name.replace ( /[^\d.]/g, '' );
  886. var img = new Image();
  887. img.src = "img?id="+id+"&name="+name+"&type=left-resized&counter="+i;
  888. img.id = "placeholder-left";
  889. img.style.width = 100 + '%';
  890. imgLeftArray[i] = img;
  891. }
  892. */
  893. /*
  894. // WEB WORKER APPROACH
  895. var worker = new Worker('http://katrin.kit.edu/static/js/doWork.js');
  896. name = $( "#header_title" ).text();
  897. id = name.replace ( /[^\d.]/g, '' );
  898. //worker.postMessage(999999999);
  899. //
  900. //
  901. myArray = []
  902. for (i = 0; i < parseInt( $("#front-count").text() ); i++) {
  903. var img = new Image();
  904. myArray[i] = img;
  905. }
  906. worker.postMessage({'name': name, 'id': id, 'front_count': $("#front-count").text(), 'imgContainer': myArray });
  907. // array of images
  908. // var images = [];
  909. //worker.addEventListener('message', function(e) {
  910. // console.log(e.data);
  911. //}, false);
  912. worker.onmessage = function(e) {
  913. console.log(e.data);
  914. }
  915. */
  916. });