viewComic.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <!DOCTYPE html>
  2. <meta name="apple-mobile-web-app-capable" content="yes" />
  3. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  4. <html>
  5. <head>
  6. <meta charset="UTF-8">
  7. <script src="../script/jquery.min.js"></script>
  8. <link rel="stylesheet" href="../script/tocas/tocas.css">
  9. <script type='text/javascript' src="../script/tocas/tocas.js"></script>
  10. <script type='text/javascript' src="../script/ao_module.js"></script>
  11. <style>
  12. body, html {
  13. height: 100%;
  14. margin: 0;
  15. background-color:#2b2b2b;
  16. }
  17. </style>
  18. <script>
  19. //Scrolling Controller
  20. var keys = {37: 1, 38: 1, 39: 1, 40: 1};
  21. function preventDefault(e) {
  22. e = e || window.event;
  23. if (e.preventDefault)
  24. e.preventDefault();
  25. e.returnValue = false;
  26. }
  27. function preventDefaultForScrollKeys(e) {
  28. if (keys[e.keyCode]) {
  29. preventDefault(e);
  30. return false;
  31. }
  32. }
  33. function disableScroll() {
  34. if (window.addEventListener) // older FF
  35. window.addEventListener('DOMMouseScroll', preventDefault, false);
  36. window.onwheel = preventDefault; // modern standard
  37. window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
  38. window.ontouchmove = preventDefault; // mobile
  39. document.onkeydown = preventDefaultForScrollKeys;
  40. }
  41. function enableScroll() {
  42. if (window.removeEventListener)
  43. window.removeEventListener('DOMMouseScroll', preventDefault, false);
  44. window.onmousewheel = document.onmousewheel = null;
  45. window.onwheel = null;
  46. window.ontouchmove = null;
  47. document.onkeydown = null;
  48. }
  49. disableScroll();
  50. </script>
  51. </head>
  52. <body>
  53. <div id="loading" style="position: fixed;top: 0;left: 0;background:rgba(0,0,0,0.5);color:white;width:100%;height:100%;z-index:100">
  54. <div class="ts active dimmer">
  55. <div class="ts text loader">Loading</div>
  56. </div>
  57. </div>
  58. <div class="ts attached inverted message" onClick="ToggleChapters();">
  59. <div class="header"><i class="bookmark icon"></i>You are already reached the top of this manga.</div>
  60. <p>Click here to select more chapters.</p>
  61. </div>
  62. <div id="MangaList" class="ts list">
  63. <div class="item" style="width: 100%;display: flex;align-items: flex-start;"><img src="" style="width: 100%;height: auto;"></img></div>
  64. </div>
  65. <!-- Click Detect DIV -->
  66. <div id="clickInterface" style="opacity:0;
  67. filter: alpha(opacity = 0);
  68. position:fixed;
  69. top:25%; bottom:25%; left:0; right:0;
  70. width:100%;height:50%
  71. display:block;
  72. z-index:998;
  73. background:transparent;" onClick="">
  74. </div>
  75. <!-- Setting Config DIV -->
  76. <div id="SettingInterface" style="
  77. position:fixed;
  78. top:0; bottom:0; left:0; right:0;
  79. width:100%;height:100%
  80. display:block;
  81. z-index:1501;
  82. display:none;" onClick="">
  83. <div id="settingMenu" class="ts very narrow container" style="top:15%;z-index:1502;">
  84. <div class="ts container" style="color:white;">
  85. <div class="ts inverted segment" style="background:rgba(61,61,61,0.8);">
  86. <p style="font-size:120%;"><i class='setting icon'></i>Settings</p>
  87. <div class="ts toggle checkbox">
  88. <input type="checkbox" id="lefthand">
  89. <label for="lefthand" style="color:white;"><i class="hand paper icon" style="transform: scaleX(-1);-moz-transform: scaleX(-1);-webkit-transform: scaleX(-1);-ms-transform: scaleX(-1);"></i>Left hand mode <br> Click the left section of the view for downward auto scrolling instead of right section.</label>
  90. </div><br><br>
  91. <div class="ts toggle checkbox">
  92. <input type="checkbox" id="progress">
  93. <label for="progress" style="color:white;"><i class="save icon"></i>Save progress <br> Save the current progress and return to that page automatically in the future.</label>
  94. </div><br><br>
  95. <div class="ts toggle checkbox">
  96. <input type="checkbox" id="pcm">
  97. <label for="pcm" style="color:white;"><i class="save icon"></i>PC Mode <br> Scale down the manga a bit to make you feel better on a big PC screen.</label>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <!-- Page Info DIV-->
  104. <div align="right" style="position: fixed;bottom: 0;right: 0;background:rgba(0,0,0,0.5);color:white;z-index:1000;">
  105. <div id="PageInfo" class="ts fluid text container">
  106. Loading Page Data...
  107. </div>
  108. </div>
  109. <!-- Next Chapter Message-->
  110. <div class="ts inverted message" onclick="NextChapter();" style="cursor: pointer;">
  111. <div class="header"><i class="bookmark icon"></i>You have finished this chapter.</div>
  112. <p id="reminder">Click this box to proceed to next chapter.</p>
  113. </div>
  114. <!-- Start of Chapter Selector-->
  115. <div id="ChapterSelector" class="ts inverted message" style="color:white;display:none;">
  116. <div class="ts grid" id="chapterlist">
  117. </div>
  118. </div>
  119. <!-- END of Chapter Selector-->
  120. <div align="center" style="width:100%">
  121. <div class="ts buttons" >
  122. <button class="ts basic button" onClick="window.location.href='index.html'" style="color:white;"><i class="chevron left icon"></i>Back</button>
  123. <button class="ts basic button" onClick="ToggleChapters();" style="color:white;"><i class="book icon"></i>Chapters</button>
  124. </div>
  125. </div>
  126. <br>
  127. <br>
  128. <script type="text/javascript">
  129. var pages = [];
  130. var titles = "";
  131. var chapterPaths = [];
  132. var nextChapterID = 0;
  133. var maxChapterID = 0;
  134. var pagesNum = pages.length; //This page number is the number of files in the directory, not the actual page number
  135. var positions = [];
  136. var currentPage = 0;
  137. var chapterShown = false;
  138. var lastpage = 0;
  139. var floatWindow = !(!parent.isFunctionBar); //Updated support on floatWindow System
  140. //Auto save and left hand mode
  141. var autoSave = false;
  142. var leftHandMode = false;
  143. var isMobile = false; //initiate as false
  144. // device detection
  145. if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
  146. || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) {
  147. isMobile = true;
  148. }
  149. var preRenderComplete = false;
  150. var pcm = false; //PC Mode
  151. //Screen Width and height data
  152. var screenWidth = $(window).width();
  153. var screenHeight = $(window).height();
  154. //Debug Interface
  155. console.log("This Chapter ID: ",nextChapterID);
  156. console.log("Max Chapter ID: ",maxChapterID);
  157. console.log("Chapter Paths: ",chapterPaths);
  158. if(floatWindow){
  159. $("#PageInfo").parent().css("bottom","0px");
  160. $("body").css("padding-bottom","20px");
  161. }
  162. //Load the content of this manga chapter
  163. var mangaFolder = window.location.hash.substr(1);
  164. ao_module_agirun("Manga Cafe/backend/getMangaInfo.js", {folder: mangaFolder}, function(data){
  165. console.log(data);
  166. pages = data.pages;
  167. titles = data.title,
  168. chapterPaths = data.otherChapterDir;
  169. nextChapterID = 0;
  170. maxChapterID = chapterPaths.length;
  171. //Render manga to ui
  172. $("#MangaList").html("");
  173. data.pages.forEach(page => {
  174. $("#MangaList").append(`<div class="item" style="width: 100%;display: flex;align-items: flex-start;"><img src="../media?file=${page}" style="width: 100%;height: auto;"></img></div>`)
  175. });
  176. //Render next chapter button
  177. $("#chapterlist").html("");
  178. var counter = 0;
  179. var nextOneIsPreRender = false;
  180. var prerender = "";
  181. data.otherChapterDir.forEach(chapter => {
  182. var chapterName = chapter.split("/").pop();
  183. var chapterWide = "four";
  184. if (isMobile){
  185. chapterWide = "sixteen";
  186. }
  187. if (chapterName == data.title[1]){
  188. $("#chapterlist").append(`<div class="${chapterWide} wide column" style="color:white;"><a class="ts fluid basic disabled button" style="color:white;">${chapterName}</a></div>`);
  189. nextChapterID = counter;
  190. nextOneIsPreRender = true;
  191. }else{
  192. if (nextOneIsPreRender){
  193. nextOneIsPreRender = false;
  194. prerender = chapter;
  195. }
  196. $("#chapterlist").append(`<div class="${chapterWide} wide column" style="color:white;"><a class="ts fluid basic button" style="color:white;" onClick="ChapterRedirect('${chapter}');">${chapterName}</a></div>`);
  197. }
  198. counter++;
  199. });
  200. //Start waiting for all images to load
  201. var imagesLoaded = 0;
  202. var totalImages = $('img').length;
  203. $('img').on('load', function(event) {
  204. imagesLoaded++;
  205. if (imagesLoaded == totalImages) {
  206. init();
  207. if (nextOneIsPreRender == true){
  208. //There is no next chapter
  209. preRenderComplete = true;
  210. }else{
  211. //Start next chapter pre-render
  212. ao_module_agirun("Manga Cafe/backend/getMangaInfo.js",{folder: prerender}, function(data){
  213. //Pre-render complete
  214. console.log("Next chapter pre-render completed")
  215. preRenderComplete = true;
  216. });
  217. }
  218. }
  219. });
  220. });
  221. //Window onload replace document.ready due to the measurement of each div have to be done after the page loaded
  222. function init(){
  223. $('#loading').hide();
  224. enableScroll();
  225. positions = [];
  226. var count = 0;
  227. $('.item').each(function(i, obj) {
  228. var offsets = $(this).offset();
  229. var top = offsets.top;
  230. //console.log(top);
  231. positions.push(top);
  232. count += 1;
  233. });
  234. if (nextChapterID + 1 > maxChapterID - 1){
  235. $('#reminder').html('There is no more chapters.');
  236. }
  237. //alert(count);
  238. //Check if PCB Mode
  239. if (localStorage.pcm !== null){
  240. pcm = (localStorage.pcm == 'true');
  241. console.log('PC Mode: ' + pcm);
  242. $('#pcm').prop("checked",pcm);
  243. }
  244. if (pcm){
  245. //If PC mode is enabled, re-allign all image
  246. setTimeout(function(){ PCMode(0); }, 100);
  247. }
  248. //AutoSave Function
  249. if (localStorage.autoSave !== null){
  250. autoSave = (localStorage.autoSave == 'true');
  251. console.log('AutoSave: ' + autoSave);
  252. $('#progress').prop("checked",autoSave);
  253. if (localStorage.getItem(titles[0] + "-" + titles[1]) !== null && autoSave){
  254. var page = localStorage.getItem(titles[0] + "-" + titles[1]);
  255. console.log('Loading progress: ' + page);
  256. if (page != count){
  257. //Not yet finished
  258. console.log(count,page)
  259. setTimeout(function(){ GoToPage(page); },100);
  260. }
  261. }
  262. }
  263. if(localStorage.getItem(titles[0] + "-" + titles[1]) !== null && (localStorage.autoSave === null || localStorage.autoSave == 'false')){
  264. localStorage.removeItem(titles[0] + "-" + titles[1]);
  265. console.log("Old autosave record removed.");
  266. }
  267. //Left hand Mode function
  268. if (localStorage.leftHandMode !== null){
  269. leftHandMode = (localStorage.leftHandMode == 'true');
  270. console.log('Left Hand Mode: ' + leftHandMode);
  271. $('#lefthand').prop("checked",leftHandMode);
  272. }
  273. UpdatePageInfo();
  274. }
  275. //Check if settings changed
  276. $('#lefthand').change(function(){
  277. if($(this).is(':checked')){
  278. localStorage.leftHandMode = true;
  279. leftHandMode = true;
  280. console.log('Left Hand Mode Changed to ' + leftHandMode);
  281. } else {
  282. localStorage.leftHandMode = false;
  283. leftHandMode = false;
  284. console.log('Left Hand Mode Changed to ' + leftHandMode);
  285. }
  286. });
  287. $('#progress').change(function(){
  288. if($(this).is(':checked')){
  289. localStorage.autoSave = true;
  290. autoSave = true;
  291. console.log('Auto Save Changed to ' + autoSave);
  292. localStorage.setItem(titles[0] + "-" + titles[1], currentPage);
  293. } else {
  294. localStorage.autoSave = false;
  295. autoSave = false;
  296. console.log('Auto Save Changed to ' + autoSave);
  297. }
  298. });
  299. $('#pcm').change(function(){
  300. if($(this).is(':checked')){
  301. localStorage.pcm = true;
  302. pcm = true;
  303. console.log('PC Mode Changed to ' + pcm);
  304. PCMode();
  305. } else {
  306. localStorage.pcm = false;
  307. pcm = false;
  308. console.log('PC Mode Changed to ' + pcm);
  309. MobileMode();
  310. }
  311. });
  312. //End of setting change section
  313. //Recalculate page number accodring to new image position
  314. window.onresize = function() {
  315. positions = [];
  316. $('.item').each(function(i, obj) {
  317. var offsets = $(this).offset();
  318. var top = offsets.top;
  319. //console.log(top);
  320. positions.push(top);
  321. if (nextChapterID + 1 > maxChapterID - 1){
  322. $('#reminder').html('There is no more chapters.');
  323. }
  324. screenWidth = $(window).width();
  325. screenHeight = $(window).height();
  326. });
  327. }
  328. //Click Page Scroll functions
  329. var ControlPanel = document.getElementById('clickInterface');
  330. ControlPanel.addEventListener("click", AutoPageScroll, false);
  331. function AutoPageScroll(e){
  332. var clickX = e.clientX;
  333. var clickY = e.clientY;
  334. var split = screenWidth / 2;
  335. if (leftHandMode == true){
  336. //Left side is next page, right side is previous page
  337. if (clickX < split){
  338. //left
  339. scrollDown();
  340. }else{
  341. //right
  342. scrollUp();
  343. }
  344. }else{
  345. if (clickX > split){
  346. //right
  347. scrollDown();
  348. }else{
  349. //left
  350. scrollUp();
  351. }
  352. }
  353. }
  354. function scrollDown(){
  355. $("html, body").animate({ scrollTop: $(window).scrollTop() + screenHeight * 0.8 }, 1000);
  356. }
  357. function scrollUp(){
  358. $("html, body").animate({ scrollTop: $(window).scrollTop() - screenHeight * 0.8 }, 1000);
  359. }
  360. //End of auto scrolling
  361. //Resize all image to PC mode
  362. function PCMode(mode){
  363. var tmpPage = currentPage;
  364. $('.item').each(function(i, obj) {
  365. $(this).css("width","50%");
  366. });
  367. $('#MangaList').css("width","100%");
  368. $('#MangaList').prop("align","center");
  369. setTimeout(function(){ CalculatePageOffsets(); }, 1000);
  370. if (mode != 0){
  371. setTimeout(function(){ GoToPage(tmpPage); }, 100);
  372. }
  373. }
  374. function MobileMode(){
  375. var tmpPage = currentPage;
  376. $('.item').each(function(i, obj) {
  377. $(this).css("width","100%");
  378. });
  379. $('#MangaList').css("width","");
  380. $('#MangaList').prop("align","");
  381. setTimeout(function(){ CalculatePageOffsets(); }, 1000);
  382. setTimeout(function(){ GoToPage(tmpPage); }, 100);
  383. }
  384. function CalculatePageOffsets(){
  385. console.log('Calculating Page Offsets');
  386. positions = [];
  387. $('.item').each(function(i, obj) {
  388. var offsets = $(this).offset();
  389. var top = offsets.top;
  390. //console.log(top);
  391. positions.push(top);
  392. if (nextChapterID + 1 > maxChapterID - 1){
  393. $('#reminder').html('There is no more chapters.');
  394. }
  395. });
  396. UpdatePageInfo();
  397. }
  398. //Update page info on window scroll
  399. $( window ).scroll(function() {
  400. //console.log($(window).scrollTop());
  401. currentPage = getPageNum($(window).scrollTop(),positions);
  402. if (autoSave == true && currentPage != 0 && lastpage != currentPage){
  403. //Save Page number as: "title-chapter:page"
  404. localStorage.setItem(titles[0] + "-" + titles[1], currentPage);
  405. lastpage = currentPage;
  406. console.log(localStorage.getItem(titles[0] + "-" + titles[1]));
  407. }
  408. var shortentitle = titles[1];
  409. //console.log(currentPage);
  410. if (shortentitle.length > 12){
  411. shortentitle = shortentitle.substring(0, 12) + "...";
  412. }
  413. var prerenderFinishIcon = "<i class='loading spinner icon'></i>";
  414. if (preRenderComplete){
  415. prerenderFinishIcon = "<i class='checkmark icon' style='color: green;'></i>"
  416. }
  417. $('#PageInfo').html("  <i class='chevron left icon' onClick='back();'></i>  <i class='setting icon' onClick='ShowSetting();'></i>" + shortentitle + " " + prerenderFinishIcon + " " + currentPage.toString() + "/" + positions.length.toString() + "    " + titles[0] + "  ");
  418. //if the page reached the end, hide the auto scroll div
  419. if($(window).scrollTop() + $(window).height() == $(document).height()) {
  420. $('#clickInterface').hide();
  421. }else if ( $('#clickInterface').is(':visible') !== true && chapterShown !== true){
  422. $('#clickInterface').show();
  423. }
  424. });
  425. //Update Page Info (same as window.scroll function)
  426. function UpdatePageInfo(){
  427. currentPage = getPageNum($(window).scrollTop(),positions);
  428. if (autoSave == true && currentPage != 0){
  429. //Save Page number as: "title-chapter:page"
  430. localStorage.setItem(titles[0] + "-" + titles[1], currentPage);
  431. }
  432. //console.log(currentPage);
  433. var shortentitle = titles[1];
  434. //console.log(currentPage);
  435. if (shortentitle.length > 12){
  436. shortentitle = shortentitle.substring(0, 12) + "...";
  437. }
  438. var prerenderFinishIcon = "";
  439. if (preRenderComplete){
  440. prerenderFinishIcon = "<i class='checkmark icon'></i>"
  441. }
  442. $('#PageInfo').html("  <i class='chevron left icon' onClick='back();'></i>  <i class='setting icon' onClick='ShowSetting();'></i>" + shortentitle + " " + prerenderFinishIcon + " " + currentPage.toString() + "/" + positions.length.toString() + "    " + titles[0] + "  ");
  443. }
  444. function back(){
  445. window.location.href='index.html';
  446. }
  447. //Setting Interface controlling
  448. function ShowSetting(){
  449. $('#SettingInterface').fadeIn('slow');
  450. }
  451. var ExitPanel = document.getElementById('SettingInterface');
  452. ExitPanel.addEventListener("click", HideSetting, false);
  453. function HideSetting(e){
  454. //console.log(e.clientX);
  455. //console.log(e.clientY);
  456. pleft = $('#settingMenu').offset().left;
  457. pright = pleft + $('#settingMenu').width();
  458. ptop = $('#settingMenu').offset().top;
  459. pbottom = ptop + $('#settingMenu').height();
  460. //console.log(e.clientX,e.clientY,pleft,pright,ptop,pbottom);
  461. if (e.clientX < pleft || e.clientX > pright || e.clientY + $(window).scrollTop() < ptop || e.clientY + $(window).scrollTop()> pbottom){
  462. $('#SettingInterface').fadeOut('slow');
  463. }
  464. }
  465. //Next chapter controlling algorithm
  466. function NextChapter(){
  467. var id = nextChapterID + 1;
  468. if (id > maxChapterID - 1){
  469. }else{
  470. ChapterRedirect(chapterPaths[id]);
  471. }
  472. }
  473. function ChapterRedirect(path){
  474. window.location.href= "viewComic.html#" + path;
  475. window.location.reload();
  476. }
  477. //Show all chapters of this manga
  478. function ToggleChapters(){
  479. if (chapterShown == true){
  480. $('#ChapterSelector').fadeOut('slow');
  481. //$("html, body").animate({ scrollTop: $("#ChapterSelector").offset().top }, 1000);
  482. $("html, body").animate({ scrollTop: $(document).height() }, 1000);
  483. chapterShown = false;
  484. $('#clickInterface').show();
  485. }else{
  486. $('#ChapterSelector').fadeIn('slow');
  487. $("html, body").animate({ scrollTop: $("#ChapterSelector").offset().top }, 1000);
  488. //$("html, body").animate({ scrollTop: $(document).height() }, 1000);
  489. chapterShown = true;
  490. $('#clickInterface').hide();
  491. }
  492. }
  493. //Convert current view top to page number
  494. function getPageNum (num, arr) {
  495. for (var i = 0;i<arr.length;i++){
  496. if (arr[i] > num){
  497. return i;
  498. }
  499. }
  500. return arr.length;
  501. }
  502. function GoToPage(num){
  503. //console.log('Going to page: ' + num);
  504. CalculatePageOffsets();
  505. console.log("Going to page number:" + num);
  506. var targetTop = positions[num - 1];
  507. $('html, body').animate({scrollTop: targetTop + 5}, 1000);
  508. }
  509. </script>
  510. </body>
  511. </html>