From 43cd49384b6dc637644050c859968f3a7f785e45 Mon Sep 17 00:00:00 2001 From: "1152958806@qq.com" <17683872107czx> Date: Tue, 15 Aug 2023 11:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E5=88=86?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/assets/js/heo.js | 6 ++- templates/assets/zhheo/blogex.js | 20 ++++++++- templates/modules/widgets/page.html | 66 +++++++++++++++++------------ 3 files changed, 61 insertions(+), 31 deletions(-) diff --git a/templates/assets/js/heo.js b/templates/assets/js/heo.js index ca79c3dc..66d06d02 100644 --- a/templates/assets/js/heo.js +++ b/templates/assets/js/heo.js @@ -487,7 +487,11 @@ var heo = { $htmlDom.toggle('hide-aside') $htmlDom.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on") }, - + toPage: function() { + var e, t = document.querySelectorAll(".page-number"), o = parseInt(t[t.length - 1].innerHTML), n = document.getElementById("toPageText"), a = parseInt(n.value); + !isNaN(a) && a > 0 && "0" !== ("" + a)[0] && a <= o && (e = 1 === a ? "/" : "/page/" + a, + document.getElementById("toPageButton").href = e) + }, changeSayHelloText: function() { const e = GLOBAL_CONFIG.helloText.length == 0 ? ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手", "🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"] : GLOBAL_CONFIG.helloText , t = document.getElementById("author-info__sayhi"); diff --git a/templates/assets/zhheo/blogex.js b/templates/assets/zhheo/blogex.js index f48ad999..a109822e 100644 --- a/templates/assets/zhheo/blogex.js +++ b/templates/assets/zhheo/blogex.js @@ -643,11 +643,27 @@ function setBodyDataType(){ att.value = GLOBAL_CONFIG.htmlType; body.setAttributeNode(att); } - +function listenToPageInputPress() { + var e = document.getElementById("toPageText") + , t = document.getElementById("toPageButton"); + e && (e.addEventListener("keydown", (e=>{ + 13 === e.keyCode && (heo.toPage(), + pjax.loadUrl(t.href)) + } + )), + e.addEventListener("input", (function() { + "" === e.value || "0" === e.value ? t.classList.remove("haveValue") : t.classList.add("haveValue"); + var o = document.querySelectorAll(".page-number") + , n = +o[o.length - 1].innerHTML; + +document.getElementById("toPageText").value > n && (e.value = n) + } + ))) +} function initBlog() { heo.initIndexEssay(), checkUrlAndAddHideBanner(), - setBodyDataType() + setBodyDataType(), + listenToPageInputPress() } // 如果当前页有评论就执行函数 diff --git a/templates/modules/widgets/page.html b/templates/modules/widgets/page.html index 26943bb5..2d844245 100644 --- a/templates/modules/widgets/page.html +++ b/templates/modules/widgets/page.html @@ -6,38 +6,48 @@ @param path '/path/page/n' 中的 `/path` 需要保留 `/` @param pageInfo Halo类型UrlContextListResult --> - \ No newline at end of file