From 582849733f302be7815b97c9b6f61693d9be88c4 Mon Sep 17 00:00:00 2001 From: wizardforcel <562826179@qq.com> Date: Sun, 9 May 2021 00:24:53 +0800 Subject: [PATCH] 2021-05-09 00:24:53 --- asset/docsify-quick-page.css | 39 +++++++++++++++++++++++++++++++++ asset/docsify-quick-page.js | 42 ++++++++++++++++++++++++++++++++++++ asset/emoji-down.svg | 14 ++++++++++++ asset/emoji-up.svg | 16 ++++++++++++++ index.html | 2 ++ 5 files changed, 113 insertions(+) create mode 100644 asset/docsify-quick-page.css create mode 100644 asset/docsify-quick-page.js create mode 100644 asset/emoji-down.svg create mode 100644 asset/emoji-up.svg diff --git a/asset/docsify-quick-page.css b/asset/docsify-quick-page.css new file mode 100644 index 0000000..df2481f --- /dev/null +++ b/asset/docsify-quick-page.css @@ -0,0 +1,39 @@ +#prev-page-button { + position:fixed; + top:140px; + width: 35px; + height: 35px; + right: 15px; + background-color: transparent; + background-image: url(emoji-up.svg); + background-repeat: no-repeat; + background-size: cover; + border:0; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + outline:none; + cursor: pointer; + transform: rotate(-90deg); +} + +#next-page-button { + position:fixed; + top:180px; + width:35px; + height:35px; + right:15px; + background-color: transparent; + background-image: url(emoji-down.svg); + background-repeat: no-repeat; + background-size: cover; + border:0; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + outline:none; + cursor: pointer; + transform: rotate(-90deg); +} \ No newline at end of file diff --git a/asset/docsify-quick-page.js b/asset/docsify-quick-page.js new file mode 100644 index 0000000..d472eeb --- /dev/null +++ b/asset/docsify-quick-page.js @@ -0,0 +1,42 @@ +document.addEventListener('DOMContentLoaded', function() { + var prevBtn = document.createElement("div") + prevBtn.id = "prev-page-button" + document.body.appendChild(prevBtn) + var nextBtn = document.createElement("div"); + nextBtn.id = "next-page-button" + document.body.appendChild(nextBtn) + + var links = null + var linkMap = null + var getCurIdx = function() { + if (!links) { + links = Array + .from(document.querySelectorAll(".sidebar-nav a")) + .map(x => x.href) + linkMap = {} + links.forEach((x, i) => linkMap[x] = i) + } + + var elem = document.querySelector(".active a") + var curIdx = elem? linkMap[elem.href]: -1 + return curIdx + } + + prevBtn.addEventListener('click', function () { + if (!document.body.classList.contains('ready')) + return + var curIdx = getCurIdx() + location.href = curIdx == -1? + links[0]: + links[(curIdx - 1 + links.length) % links.length] + document.body.scrollIntoView() + }, false) + + nextBtn.addEventListener('click', function () { + if (!document.body.classList.contains('ready')) + return + var curIdx = getCurIdx() + location.href = links[(curIdx + 1) % links.length] + document.body.scrollIntoView() + }, false) +}) \ No newline at end of file diff --git a/asset/emoji-down.svg b/asset/emoji-down.svg new file mode 100644 index 0000000..a1bea40 --- /dev/null +++ b/asset/emoji-down.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/asset/emoji-up.svg b/asset/emoji-up.svg new file mode 100644 index 0000000..8701e78 --- /dev/null +++ b/asset/emoji-up.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/index.html b/index.html index a678b0d..f75de9c 100644 --- a/index.html +++ b/index.html @@ -54,5 +54,7 @@ + + \ No newline at end of file -- GitLab