viewComic.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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%;
  71. height:50%;
  72. display:block;
  73. z-index:998;
  74. background:transparent;" onClick="">
  75. </div>
  76. <!-- Setting Config DIV -->
  77. <div id="SettingInterface" style="
  78. position:fixed;
  79. top:0; bottom:0; left:0; right:0;
  80. width:100%;
  81. height:100%;
  82. display:block;
  83. z-index:1501;
  84. display:none;" onClick="">
  85. <div id="settingMenu" class="ts very narrow container" style="top:15%;z-index:1502;">
  86. <div class="ts container" style="color:white;">
  87. <div class="ts inverted segment" style="background:rgba(61,61,61,0.8);">
  88. <p style="font-size:120%;"><i class='setting icon'></i>Settings</p>
  89. <div class="ts toggle checkbox">
  90. <input type="checkbox" id="lefthand">
  91. <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>
  92. </div><br><br>
  93. <div class="ts toggle checkbox">
  94. <input type="checkbox" id="progress">
  95. <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>
  96. </div><br><br>
  97. <div class="ts toggle checkbox">
  98. <input type="checkbox" id="pcm">
  99. <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>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <!-- Page Info DIV-->
  106. <div align="right" style="position: fixed;bottom: 0;right: 0;background:rgba(0,0,0,0.5);color:white;z-index:1000;">
  107. <div id="PageInfo" class="ts fluid text container">
  108. Loading Page Data...
  109. </div>
  110. </div>
  111. <!-- Next Chapter Message-->
  112. <div class="ts inverted message" onclick="NextChapter();" style="cursor: pointer;">
  113. <div class="header"><i class="bookmark icon"></i>You have finished this chapter.</div>
  114. <p id="reminder">Click this box to proceed to next chapter.</p>
  115. </div>
  116. <!-- Start of Chapter Selector-->
  117. <div id="ChapterSelector" class="ts inverted message" style="color:white;display:none;">
  118. <div class="ts grid" id="chapterlist">
  119. </div>
  120. </div>
  121. <!-- END of Chapter Selector-->
  122. <div align="center" style="width:100%">
  123. <div class="ts buttons" >
  124. <button class="ts basic button" onClick="window.location.href='index.html'" style="color:white;"><i class="chevron left icon"></i>Back</button>
  125. <button class="ts basic button" onClick="ToggleChapters();" style="color:white;"><i class="book icon"></i>Chapters</button>
  126. </div>
  127. </div>
  128. <br>
  129. <br>
  130. <script type="text/javascript">
  131. var pages = [];
  132. var titles = "";
  133. var chapterPaths = [];
  134. var nextChapterID = 0;
  135. var maxChapterID = 0;
  136. var pagesNum = pages.length; //This page number is the number of files in the directory, not the actual page number
  137. var positions = [];
  138. var currentPage = 0;
  139. var chapterShown = false;
  140. var lastpage = 0;
  141. var floatWindow = !(!parent.isFunctionBar); //Updated support on floatWindow System
  142. //Auto save and left hand mode
  143. var autoSave = false;
  144. var leftHandMode = false;
  145. var isMobile = false; //initiate as false
  146. // device detection
  147. 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)
  148. || /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))) {
  149. isMobile = true;
  150. }
  151. var preRenderComplete = false;
  152. var pcm = false; //PC Mode
  153. //Screen Width and height data
  154. var screenWidth = $(window).width();
  155. var screenHeight = $(window).height();
  156. //Debug Interface
  157. console.log("This Chapter ID: ",nextChapterID);
  158. console.log("Max Chapter ID: ",maxChapterID);
  159. console.log("Chapter Paths: ",chapterPaths);
  160. if(floatWindow){
  161. $("#PageInfo").parent().css("bottom","0px");
  162. $("body").css("padding-bottom","20px");
  163. }
  164. //Load the content of this manga chapter
  165. var mangaFolder = window.location.hash.substr(1);
  166. ao_module_agirun("Manga Cafe/backend/getMangaInfo.js", {folder: mangaFolder}, function(data){
  167. console.log(data);
  168. pages = data.pages;
  169. titles = data.title,
  170. chapterPaths = data.otherChapterDir;
  171. nextChapterID = 0;
  172. maxChapterID = chapterPaths.length;
  173. //Render manga to ui
  174. $("#MangaList").html("");
  175. data.pages.forEach(page => {
  176. $("#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>`)
  177. });
  178. //Render next chapter button
  179. $("#chapterlist").html("");
  180. var counter = 0;
  181. var nextOneIsPreRender = false;
  182. var prerender = "";
  183. data.otherChapterDir.forEach(chapter => {
  184. var chapterName = chapter.split("/").pop();
  185. var chapterWide = "four";
  186. if (isMobile){
  187. chapterWide = "sixteen";
  188. }
  189. if (chapterName == data.title[1]){
  190. $("#chapterlist").append(`<div class="${chapterWide} wide column" style="color:white;"><a class="ts fluid basic disabled button" style="color:white;">${chapterName}</a></div>`);
  191. nextChapterID = counter;
  192. nextOneIsPreRender = true;
  193. }else{
  194. if (nextOneIsPreRender){
  195. nextOneIsPreRender = false;
  196. prerender = chapter;
  197. }
  198. $("#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>`);
  199. }
  200. counter++;
  201. });
  202. //Start waiting for all images to load
  203. var imagesLoaded = 0;
  204. var totalImages = $('img').length;
  205. $('img').on('load', function(event) {
  206. imagesLoaded++;
  207. if (imagesLoaded == totalImages) {
  208. init();
  209. if (nextOneIsPreRender == true){
  210. //There is no next chapter
  211. preRenderComplete = true;
  212. }else{
  213. //Start next chapter pre-render
  214. ao_module_agirun("Manga Cafe/backend/getMangaInfo.js",{folder: prerender}, function(data){
  215. //Pre-render complete
  216. console.log("Next chapter pre-render completed")
  217. preRenderComplete = true;
  218. });
  219. }
  220. }
  221. });
  222. });
  223. //Window onload replace document.ready due to the measurement of each div have to be done after the page loaded
  224. function init(){
  225. $('#loading').hide();
  226. enableScroll();
  227. positions = [];
  228. var count = 0;
  229. $('.item').each(function(i, obj) {
  230. var offsets = $(this).offset();
  231. var top = offsets.top;
  232. //console.log(top);
  233. positions.push(top);
  234. count += 1;
  235. });
  236. if (nextChapterID + 1 > maxChapterID - 1){
  237. $('#reminder').html('There is no more chapters.');
  238. }
  239. //alert(count);
  240. //Check if PCB Mode
  241. if (localStorage.pcm !== null){
  242. pcm = (localStorage.pcm == 'true');
  243. console.log('PC Mode: ' + pcm);
  244. $('#pcm').prop("checked",pcm);
  245. }
  246. if (pcm){
  247. //If PC mode is enabled, re-allign all image
  248. setTimeout(function(){ PCMode(0); }, 100);
  249. }
  250. //AutoSave Function
  251. if (localStorage.autoSave !== null){
  252. autoSave = (localStorage.autoSave == 'true');
  253. console.log('AutoSave: ' + autoSave);
  254. $('#progress').prop("checked",autoSave);
  255. if (localStorage.getItem(titles[0] + "-" + titles[1]) !== null && autoSave){
  256. var page = localStorage.getItem(titles[0] + "-" + titles[1]);
  257. console.log('Loading progress: ' + page);
  258. if (page != count){
  259. //Not yet finished
  260. console.log(count,page)
  261. setTimeout(function(){ GoToPage(page); },100);
  262. }
  263. }
  264. }
  265. if(localStorage.getItem(titles[0] + "-" + titles[1]) !== null && (localStorage.autoSave === null || localStorage.autoSave == 'false')){
  266. localStorage.removeItem(titles[0] + "-" + titles[1]);
  267. console.log("Old autosave record removed.");
  268. }
  269. //Left hand Mode function
  270. if (localStorage.leftHandMode !== null){
  271. leftHandMode = (localStorage.leftHandMode == 'true');
  272. console.log('Left Hand Mode: ' + leftHandMode);
  273. $('#lefthand').prop("checked",leftHandMode);
  274. }
  275. UpdatePageInfo();
  276. }
  277. //Check if settings changed
  278. $('#lefthand').change(function(){
  279. if($(this).is(':checked')){
  280. localStorage.leftHandMode = true;
  281. leftHandMode = true;
  282. console.log('Left Hand Mode Changed to ' + leftHandMode);
  283. } else {
  284. localStorage.leftHandMode = false;
  285. leftHandMode = false;
  286. console.log('Left Hand Mode Changed to ' + leftHandMode);
  287. }
  288. });
  289. $('#progress').change(function(){
  290. if($(this).is(':checked')){
  291. localStorage.autoSave = true;
  292. autoSave = true;
  293. console.log('Auto Save Changed to ' + autoSave);
  294. localStorage.setItem(titles[0] + "-" + titles[1], currentPage);
  295. } else {
  296. localStorage.autoSave = false;
  297. autoSave = false;
  298. console.log('Auto Save Changed to ' + autoSave);
  299. }
  300. });
  301. $('#pcm').change(function(){
  302. if($(this).is(':checked')){
  303. localStorage.pcm = true;
  304. pcm = true;
  305. console.log('PC Mode Changed to ' + pcm);
  306. PCMode();
  307. } else {
  308. localStorage.pcm = false;
  309. pcm = false;
  310. console.log('PC Mode Changed to ' + pcm);
  311. MobileMode();
  312. }
  313. });
  314. //End of setting change section
  315. //Recalculate page number accodring to new image position
  316. window.onresize = function() {
  317. positions = [];
  318. $('.item').each(function(i, obj) {
  319. var offsets = $(this).offset();
  320. var top = offsets.top;
  321. //console.log(top);
  322. positions.push(top);
  323. if (nextChapterID + 1 > maxChapterID - 1){
  324. $('#reminder').html('There is no more chapters.');
  325. }
  326. screenWidth = $(window).width();
  327. screenHeight = $(window).height();
  328. });
  329. }
  330. //Click Page Scroll functions
  331. var ControlPanel = document.getElementById('clickInterface');
  332. ControlPanel.addEventListener("click", AutoPageScroll, false);
  333. function AutoPageScroll(e){
  334. var clickX = e.clientX;
  335. var clickY = e.clientY;
  336. var split = screenWidth / 2;
  337. if (leftHandMode == true){
  338. //Left side is next page, right side is previous page
  339. if (clickX < split){
  340. //left
  341. scrollDown();
  342. }else{
  343. //right
  344. scrollUp();
  345. }
  346. }else{
  347. if (clickX > split){
  348. //right
  349. scrollDown();
  350. }else{
  351. //left
  352. scrollUp();
  353. }
  354. }
  355. }
  356. function scrollDown(){
  357. $("html, body").animate({ scrollTop: $(window).scrollTop() + screenHeight * 0.8 }, 1000);
  358. }
  359. function scrollUp(){
  360. $("html, body").animate({ scrollTop: $(window).scrollTop() - screenHeight * 0.8 }, 1000);
  361. }
  362. //End of auto scrolling
  363. //Resize all image to PC mode
  364. function PCMode(mode){
  365. var tmpPage = currentPage;
  366. $('.item').each(function(i, obj) {
  367. $(this).css("width","50%");
  368. });
  369. $('#MangaList').css("width","100%");
  370. $('#MangaList').prop("align","center");
  371. setTimeout(function(){ CalculatePageOffsets(); }, 1000);
  372. if (mode != 0){
  373. setTimeout(function(){ GoToPage(tmpPage); }, 100);
  374. }
  375. }
  376. function MobileMode(){
  377. var tmpPage = currentPage;
  378. $('.item').each(function(i, obj) {
  379. $(this).css("width","100%");
  380. });
  381. $('#MangaList').css("width","");
  382. $('#MangaList').prop("align","");
  383. setTimeout(function(){ CalculatePageOffsets(); }, 1000);
  384. setTimeout(function(){ GoToPage(tmpPage); }, 100);
  385. }
  386. function CalculatePageOffsets(){
  387. console.log('Calculating Page Offsets');
  388. positions = [];
  389. $('.item').each(function(i, obj) {
  390. var offsets = $(this).offset();
  391. var top = offsets.top;
  392. //console.log(top);
  393. positions.push(top);
  394. if (nextChapterID + 1 > maxChapterID - 1){
  395. $('#reminder').html('There is no more chapters.');
  396. }
  397. });
  398. UpdatePageInfo();
  399. }
  400. //Update page info on window scroll
  401. $( window ).scroll(function() {
  402. //console.log($(window).scrollTop());
  403. currentPage = getPageNum($(window).scrollTop(),positions);
  404. if (autoSave == true && currentPage != 0 && lastpage != currentPage){
  405. //Save Page number as: "title-chapter:page"
  406. localStorage.setItem(titles[0] + "-" + titles[1], currentPage);
  407. lastpage = currentPage;
  408. console.log(localStorage.getItem(titles[0] + "-" + titles[1]));
  409. }
  410. var shortentitle = titles[1];
  411. //console.log(currentPage);
  412. if (shortentitle.length > 12){
  413. shortentitle = shortentitle.substring(0, 12) + "...";
  414. }
  415. var prerenderFinishIcon = "<i class='loading spinner icon'></i>";
  416. if (preRenderComplete){
  417. prerenderFinishIcon = "<i class='checkmark icon' style='color: green;'></i>"
  418. }
  419. $('#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] + "  ");
  420. //if the page reached the end, hide the auto scroll div
  421. if($(window).scrollTop() + $(window).height() == $(document).height()) {
  422. $('#clickInterface').hide();
  423. }else if ( $('#clickInterface').is(':visible') !== true && chapterShown !== true){
  424. $('#clickInterface').show();
  425. }
  426. });
  427. //Update Page Info (same as window.scroll function)
  428. function UpdatePageInfo(){
  429. currentPage = getPageNum($(window).scrollTop(),positions);
  430. if (autoSave == true && currentPage != 0){
  431. //Save Page number as: "title-chapter:page"
  432. localStorage.setItem(titles[0] + "-" + titles[1], currentPage);
  433. }
  434. //console.log(currentPage);
  435. var shortentitle = titles[1];
  436. //console.log(currentPage);
  437. if (shortentitle.length > 12){
  438. shortentitle = shortentitle.substring(0, 12) + "...";
  439. }
  440. var prerenderFinishIcon = "";
  441. if (preRenderComplete){
  442. prerenderFinishIcon = "<i class='checkmark icon'></i>"
  443. }
  444. $('#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] + "  ");
  445. }
  446. function back(){
  447. window.location.href='index.html';
  448. }
  449. //Setting Interface controlling
  450. function ShowSetting(){
  451. $('#SettingInterface').fadeIn('slow');
  452. }
  453. var ExitPanel = document.getElementById('SettingInterface');
  454. ExitPanel.addEventListener("click", HideSetting, false);
  455. function HideSetting(e){
  456. //console.log(e.clientX);
  457. //console.log(e.clientY);
  458. pleft = $('#settingMenu').offset().left;
  459. pright = pleft + $('#settingMenu').width();
  460. ptop = $('#settingMenu').offset().top;
  461. pbottom = ptop + $('#settingMenu').height();
  462. //console.log(e.clientX,e.clientY,pleft,pright,ptop,pbottom);
  463. if (e.clientX < pleft || e.clientX > pright || e.clientY + $(window).scrollTop() < ptop || e.clientY + $(window).scrollTop()> pbottom){
  464. $('#SettingInterface').fadeOut('slow');
  465. }
  466. }
  467. //Next chapter controlling algorithm
  468. function NextChapter(){
  469. var id = nextChapterID + 1;
  470. if (id > maxChapterID - 1){
  471. }else{
  472. ChapterRedirect(chapterPaths[id]);
  473. }
  474. }
  475. function ChapterRedirect(path){
  476. window.location.href= "viewComic.html#" + path;
  477. window.location.reload();
  478. }
  479. //Show all chapters of this manga
  480. function ToggleChapters(){
  481. if (chapterShown == true){
  482. $('#ChapterSelector').fadeOut('slow');
  483. //$("html, body").animate({ scrollTop: $("#ChapterSelector").offset().top }, 1000);
  484. $("html, body").animate({ scrollTop: $(document).height() }, 1000);
  485. chapterShown = false;
  486. $('#clickInterface').show();
  487. }else{
  488. $('#ChapterSelector').fadeIn('slow');
  489. $("html, body").animate({ scrollTop: $("#ChapterSelector").offset().top }, 1000);
  490. //$("html, body").animate({ scrollTop: $(document).height() }, 1000);
  491. chapterShown = true;
  492. $('#clickInterface').hide();
  493. }
  494. }
  495. //Convert current view top to page number
  496. function getPageNum (num, arr) {
  497. for (var i = 0;i<arr.length;i++){
  498. if (arr[i] > num){
  499. return i;
  500. }
  501. }
  502. return arr.length;
  503. }
  504. function GoToPage(num){
  505. //console.log('Going to page: ' + num);
  506. CalculatePageOffsets();
  507. console.log("Going to page number:" + num);
  508. var targetTop = positions[num - 1];
  509. $('html, body').animate({scrollTop: targetTop + 5}, 1000);
  510. }
  511. </script>
  512. </body>
  513. </html>