From 746fd1d775d56e95f0f48ca7593f8b47258c20d5 Mon Sep 17 00:00:00 2001 From: Celeter Date: Sun, 8 Mar 2020 20:48:47 +0800 Subject: [PATCH] up --- app/src/main/assets/web/bookshelf.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/assets/web/bookshelf.js b/app/src/main/assets/web/bookshelf.js index 02e90a6ab..7aa35df0f 100644 --- a/app/src/main/assets/web/bookshelf.js +++ b/app/src/main/assets/web/bookshelf.js @@ -7,6 +7,7 @@ ; var now_chapter = -1; +var sum_chapter = 0; var formatTime = value => { return new Date(value).toLocaleString('zh-CN', { @@ -64,7 +65,8 @@ var init = () => { }); $$('#books img').forEach(bookImg => bookImg.addEventListener("click", () => { - now_chapter = -1 + now_chapter = -1; + sum_chapter = 0; $('#allcontent').classList.add("read"); var book = books[bookImg.getAttribute("data-series-num")]; $("#info").innerHTML = ` @@ -97,6 +99,7 @@ var init = () => { ch.innerHTML = chapter.title.length > 15 ? chapter.title.substring(0, 14) + "..." : chapter.title; $("#chapter").appendChild(ch); }); + sum_chapter = data.data.length; $('#chapter').scrollTop = 0; $("#content").innerHTML = "章节列表加载完成!"; }); @@ -139,15 +142,24 @@ $('#up').addEventListener('click', e => { let clickEvent = document.createEvent('MouseEvents'); clickEvent.initEvent("click", true, false); $('[data-index="' + now_chapter + '"]').dispatchEvent(clickEvent); + } else if (now_chapter == 0) { + alert("已经是第一章了^_^!") + } else { + } }); $('#down').addEventListener('click', e => { if (now_chapter > -1) { - now_chapter++; - let clickEvent = document.createEvent('MouseEvents'); - clickEvent.initEvent("click", true, false); - $('[data-index="' + now_chapter + '"]').dispatchEvent(clickEvent); + if (now_chapter < sum_chapter - 1) { + now_chapter++; + let clickEvent = document.createEvent('MouseEvents'); + clickEvent.initEvent("click", true, false); + $('[data-index="' + now_chapter + '"]').dispatchEvent(clickEvent); + + } else { + alert("已经是最后一章了^_^!") + } } });