加了上一章下一章按钮

pull/137/head
Celeter 5 years ago
parent 6d7d8f0659
commit 0f3580cfe3
  1. 3
      app/src/main/assets/web/bookshelf.html
  2. 20
      app/src/main/assets/web/bookshelf.js

@ -28,6 +28,9 @@
<div class="clear"></div>
<div id="chapter" class="chapter"></div>
<div id="content" class="content"></div>
<div id="page" class="button">
<center><button id='up'>上一章</button><button id='down'>下一章</button></center>
</div>
</div>
</div>
<script src="bookshelf.js"></script>

@ -130,6 +130,25 @@ $('#showchapter').addEventListener("click", () => {
window.location.hash = "#chapter";
});
var now_chapter = -1;
$('#up').addEventListener('click', e => {
if (now_chapter > 0) {
now_chapter--;
let clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent("click", true, false);
$('[data-index="' + now_chapter + '"]').dispatchEvent(clickEvent);
}
});
$('#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);
}
});
$('#chapter').addEventListener("click", (e) => {
if (e.target.tagName === "BUTTON") {
var url = e.target.getAttribute("data-url");
@ -141,6 +160,7 @@ $('#chapter').addEventListener("click", (e) => {
if (!index && (0 != index)) {
alert("未取得章节索引");
}
now_chapter = parseInt(index);
$("#content").innerHTML = "<p>" + name + " 加载中...</p>";
fetch(apiAddress("getBookContent", url, index), { mode: "cors" })
.then(res => res.json())

Loading…
Cancel
Save