diff --git a/lib/templates/bangumi.ejs b/lib/templates/bangumi.ejs
index 9c9740b..a6c32de 100644
--- a/lib/templates/bangumi.ejs
+++ b/lib/templates/bangumi.ejs
@@ -39,6 +39,6 @@
diff --git a/lib/templates/index.js b/lib/templates/index.js
index e89f015..44863aa 100644
--- a/lib/templates/index.js
+++ b/lib/templates/index.js
@@ -1,2 +1,2 @@
-"use strict";Element.prototype.siblings=function(){for(var a=[],b=this.parentNode.children,c=0;c 0) {
- currNum--
+ function previousBtn() {
+ const sibs = this.parentNode.siblings()
+ let currNum = this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText
+ currNum = currNum.substr(0, currNum.indexOf('/') - 1)
+ currNum = parseInt(currNum, 10) - 1
+ if (currNum > 0) {
+ currNum--
+ }
+ displayPage(sibs, currNum)
+ this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText = makePageNum(currNum, sibs)
}
- displayPage(sibs, currNum)
- this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText = makePageNum(currNum, sibs)
-}
-function nextBtn () {
- var sibs = this.parentNode.siblings()
- var currNum = this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText
- currNum = currNum.substr(0, currNum.indexOf('/') - 1)
- currNum = parseInt(currNum, 10) - 1
- if (currNum < Math.ceil(sibs.length / 10) - 1) {
- currNum++
+ function nextBtn() {
+ const sibs = this.parentNode.siblings()
+ let currNum = this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText
+ currNum = currNum.substr(0, currNum.indexOf('/') - 1)
+ currNum = parseInt(currNum, 10) - 1
+ if (currNum < Math.ceil(sibs.length / 10) - 1) {
+ currNum++
+ }
+ displayPage(sibs, currNum)
+ this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText = makePageNum(currNum, sibs)
}
- displayPage(sibs, currNum)
- this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText = makePageNum(currNum, sibs)
-}
-function lastBtn () {
- var sibs = this.parentNode.siblings()
- displayPage(sibs, Math.ceil(sibs.length / 10) - 1)
- this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText = makePageNum(Math.ceil(sibs.length / 10) - 1 === -1 ? 0 : Math.ceil(sibs.length / 10) - 1, sibs)
-}
+ function lastBtn() {
+ const sibs = this.parentNode.siblings()
+ displayPage(sibs, Math.ceil(sibs.length / 10) - 1)
+ this.parentNode.getElementsByClassName('bangumi-pagenum')[0].innerText = makePageNum(Math.ceil(sibs.length / 10) - 1 === -1 ? 0 : Math.ceil(sibs.length / 10) - 1, sibs)
+ }
-function displayPage (arr, num) {
- for (var i = 0; i < arr.length; i++) {
- if (Math.floor(i / 10) === num) {
- arr[i].classList.remove('bangumi-hide')
- var img = arr[i].getElementsByTagName('img')[0]
- img.src = img.getAttribute('data-src')
- } else {
- arr[i].classList.add('bangumi-hide')
+ function displayPage(arr, num) {
+ for (let i = 0; i < arr.length; i++) {
+ if (Math.floor(i / 10) === num) {
+ arr[i].classList.remove('bangumi-hide')
+ const img = arr[i].getElementsByTagName('img')[0]
+ img.src = img.getAttribute('data-src')
+ } else {
+ arr[i].classList.add('bangumi-hide')
+ }
}
}
-}
-for (var i = 0; i < firstpages.length; i++) {
- // add listener
- firstpages[i].onclick = firstBtn
- previouspages[i].onclick = previousBtn
- nextpages[i].onclick = nextBtn
- lastpages[i].onclick = lastBtn
+ for (let i = 0; i < firstpages.length; i++) {
+ // add listener
+ firstpages[i].onclick = firstBtn
+ previouspages[i].onclick = previousBtn
+ nextpages[i].onclick = nextBtn
+ lastpages[i].onclick = lastBtn
- // set page num
- var size = pagenums[i].parentNode.siblings().length
- pagenums[i].innerText = '1 / ' + (Math.ceil(size / 10) === 0 ? 1 : Math.ceil(size / 10))
- firstpages[i].click()
-}
+ // set page num
+ const size = pagenums[i].parentNode.siblings().length
+ pagenums[i].innerText = '1 / ' + (Math.ceil(size / 10) === 0 ? 1 : Math.ceil(size / 10))
+ firstpages[i].click()
+ }
+})()