代码加一些注释
This commit is contained in:
parent
31c57ef67c
commit
fda2a942e6
|
@ -0,0 +1,2 @@
|
|||
/*! instant.page v5.1.1 - (C) 2019-2020 Alexandre Dieulot - https://instant.page/license */
|
||||
let t,e;const n=new Set,o=document.createElement("link"),i=o.relList&&o.relList.supports&&o.relList.supports("prefetch")&&window.IntersectionObserver&&"isIntersecting"in IntersectionObserverEntry.prototype,s="instantAllowQueryString"in document.body.dataset,a="instantAllowExternalLinks"in document.body.dataset,r="instantWhitelist"in document.body.dataset,c="instantMousedownShortcut"in document.body.dataset,d=1111;let l=65,u=!1,f=!1,m=!1;if("instantIntensity"in document.body.dataset){const t=document.body.dataset.instantIntensity;if("mousedown"==t.substr(0,"mousedown".length))u=!0,"mousedown-only"==t&&(f=!0);else if("viewport"==t.substr(0,"viewport".length))navigator.connection&&(navigator.connection.saveData||navigator.connection.effectiveType&&navigator.connection.effectiveType.includes("2g"))||("viewport"==t?document.documentElement.clientWidth*document.documentElement.clientHeight<45e4&&(m=!0):"viewport-all"==t&&(m=!0));else{const e=parseInt(t);isNaN(e)||(l=e)}}if(i){const n={capture:!0,passive:!0};if(f||document.addEventListener("touchstart",function(t){e=performance.now();const n=t.target.closest("a");if(!h(n))return;v(n.href)},n),u?c||document.addEventListener("mousedown",function(t){const e=t.target.closest("a");if(!h(e))return;v(e.href)},n):document.addEventListener("mouseover",function(n){if(performance.now()-e<d)return;if(!("closest"in n.target))return;const o=n.target.closest("a");if(!h(o))return;o.addEventListener("mouseout",p,{passive:!0}),t=setTimeout(()=>{v(o.href),t=void 0},l)},n),c&&document.addEventListener("mousedown",function(t){if(performance.now()-e<d)return;const n=t.target.closest("a");if(t.which>1||t.metaKey||t.ctrlKey)return;if(!n)return;n.addEventListener("click",function(t){1337!=t.detail&&t.preventDefault()},{capture:!0,passive:!1,once:!0});const o=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});n.dispatchEvent(o)},n),m){let t;(t=window.requestIdleCallback?t=>{requestIdleCallback(t,{timeout:1500})}:t=>{t()})(()=>{const t=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const n=e.target;t.unobserve(n),v(n.href)}})});document.querySelectorAll("a").forEach(e=>{h(e)&&t.observe(e)})})}}function p(e){e.relatedTarget&&e.target.closest("a")==e.relatedTarget.closest("a")||t&&(clearTimeout(t),t=void 0)}function h(t){if(t&&t.href&&(!r||"instant"in t.dataset)&&(a||t.origin==location.origin||"instant"in t.dataset)&&["http:","https:"].includes(t.protocol)&&("http:"!=t.protocol||"https:"!=location.protocol)&&(s||!t.search||"instant"in t.dataset)&&!(t.hash&&t.pathname+t.search==location.pathname+location.search||"noInstant"in t.dataset))return!0}function v(t){if(n.has(t))return;const e=document.createElement("link");e.rel="prefetch",e.href=t,document.head.appendChild(e),n.add(t)}
|
File diff suppressed because one or more lines are too long
|
@ -25,6 +25,7 @@
|
|||
rel="stylesheet"
|
||||
/>
|
||||
<!-- 全局配置 -->
|
||||
<!-- todo 不知是否可以移除,或者抽走 -->
|
||||
<script>var GLOBAL_CONFIG = {
|
||||
root: "/",
|
||||
localSearch: void 0,
|
||||
|
@ -169,10 +170,17 @@
|
|||
}
|
||||
})(window)</script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js"></script>
|
||||
<link href="https://at.alicdn.com/t/font_1891866_47sukspu18q.css" rel="stylesheet">
|
||||
|
||||
<!-- todo 不知道是否有用 https://remixicon.com/ -->
|
||||
<link href="https://cdn2.tianli0.top/npm/remixicon@2.5.0/fonts/remixicon.css" rel="stylesheet">
|
||||
|
||||
<!-- todo 应该是日志模块用的 https://blog.zhheo.com/p/a6947667.html -->
|
||||
<link href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/Swiper/8.0.6/swiper-bundle.min.css" rel="stylesheet">
|
||||
|
||||
<!-- 不知道是否可替代 -->
|
||||
<link rel="stylesheet" th:href="@{/assets/zhheo/commentBarrage.css}">
|
||||
|
||||
<!-- todo 动态加载条,换成可配置 -->
|
||||
<script data-pace-options='{ "restartOnRequestAfter":false,"eventLag":false}'
|
||||
src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/pace/1.2.4/pace.min.js"></script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:fragment="layout(content)">
|
||||
<html lang="en" th:fragment="layout(content)" xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<!-- head 中自定义的 -->
|
||||
<head th:replace="modules/head :: head(metas = null,links = null, scripts = null)"></head>
|
||||
|
@ -9,7 +9,7 @@
|
|||
<!-- loading 页面 -->
|
||||
<div th:replace="modules/loading-box :: loading-box"></div>
|
||||
|
||||
<!-- todo 还不知道干啥用的 -->
|
||||
<!-- todo 暂时不知道用处 -->
|
||||
<div id="web_bg"></div>
|
||||
|
||||
<!-- 控制台 -->
|
||||
|
@ -18,6 +18,7 @@
|
|||
<!-- 内容 -->
|
||||
<th:block th:replace="${content}"></th:block>
|
||||
|
||||
<!-- todo 暂时不知道用处 -->
|
||||
<div id="rightside">
|
||||
<div id="rightside-config-hide">
|
||||
<button id="translateLink" title="简繁转换" type="button">简</button>
|
||||
|
@ -36,93 +37,132 @@
|
|||
<script th:src="@{/assets/js/utils.js}"></script>
|
||||
<script th:src="@{/assets/js/main.js}"></script>
|
||||
<script charset="utf-8" data-pjax="" th:src="@{/assets/zhheo/blogex.js}"></script>
|
||||
<script src="https://cdn.zhheo.com/JS-Heo/translate/tw_cn.js"></script>
|
||||
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/instant.page/5.1.0/instantpage.min.js"
|
||||
type="module"></script>
|
||||
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vanilla-lazyload/17.3.1/lazyload.iife.min.js"></script>
|
||||
|
||||
<!-- 繁简翻译 js -->
|
||||
<!-- 改成可配置 -->
|
||||
<script th:src="@{/assets/translate/tw_cn.js}"></script>
|
||||
|
||||
<!-- https://instant.page/ 网站预加载, 放在 </body> 之前 -->
|
||||
<script th:src="@{/assets/instantpage/instantpage.min.js}" type="module"></script>
|
||||
|
||||
<!-- https://www.andreaverlicchi.eu/vanilla-lazyload/ 懒加载-->
|
||||
<!-- todo 图片懒加载,并且可自定义懒加载图片 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.3/dist/lazyload.min.js"></script>
|
||||
|
||||
<!-- 右下角通知 https://www.polonel.com/snackbar/ -->
|
||||
<!-- todo head 中有它的 css,应该可以写一块,并改成后台可配置的功能,代码中应该还有他的 js -->
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/node-snackbar/0.1.16/snackbar.min.js"></script>
|
||||
<script defer src="https://cdn.zhheo.com/public/algolia/algolia.js"></script>
|
||||
<script>var preloader = {
|
||||
endLoading: () => {
|
||||
//- document.body.style.overflow = 'auto';
|
||||
document.getElementById('loading-box').classList.add("loaded")
|
||||
},
|
||||
initLoading: () => {
|
||||
//- document.body.style.overflow = '';
|
||||
document.getElementById('loading-box').classList.remove("loaded")
|
||||
}
|
||||
}
|
||||
window.addEventListener('load', preloader.endLoading())
|
||||
setTimeout(function () {
|
||||
preloader.endLoading();
|
||||
}, 3000)</script>
|
||||
<div class="js-pjax"></div>
|
||||
<script>window.addEventListener('load', () => {
|
||||
const changeContent = (content) => {
|
||||
if (content === '') return content
|
||||
|
||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[图片]') // replace image link
|
||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url
|
||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[代码]') // replace code
|
||||
content = content.replace(/<[^>]+>/g, "") // remove html tag
|
||||
|
||||
if (content.length > 150) {
|
||||
content = content.substring(0, 150) + '...'
|
||||
<script>
|
||||
<!-- todo 暂时不知道用处 -->
|
||||
var preloader = {
|
||||
endLoading: () => {
|
||||
//- document.body.style.overflow = 'auto';
|
||||
document.getElementById('loading-box').classList.add("loaded")
|
||||
},
|
||||
initLoading: () => {
|
||||
//- document.body.style.overflow = '';
|
||||
document.getElementById('loading-box').classList.remove("loaded")
|
||||
}
|
||||
return content
|
||||
}
|
||||
window.addEventListener('load', preloader.endLoading())
|
||||
setTimeout(function () {
|
||||
preloader.endLoading();
|
||||
}, 3000)
|
||||
</script>
|
||||
|
||||
const generateHtml = array => {
|
||||
let result = ''
|
||||
<!-- todo 暂时不知道用处 -->
|
||||
<div class="js-pjax"></div>
|
||||
<script>
|
||||
// todo 暂时不知道用处
|
||||
// 看着像评论模块,如果是的话,则可以删除掉了,评论使用评论插件
|
||||
window.addEventListener('load', () => {
|
||||
const changeContent = (content) => {
|
||||
if (content === '') return content
|
||||
|
||||
if (array.length) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
result += '<div class=\'aside-list-item\'>'
|
||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[图片]') // replace image link
|
||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url
|
||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[代码]') // replace code
|
||||
content = content.replace(/<[^>]+>/g, "") // remove html tag
|
||||
|
||||
if (true) {
|
||||
const name = 'data-lazy-src'
|
||||
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'><div class='name'><span>${array[i].nick}</span></div></a>`
|
||||
}
|
||||
if (content.length > 150) {
|
||||
content = content.substring(0, 150) + '...'
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
result += `<div class='content'>
|
||||
const generateHtml = array => {
|
||||
let result = ''
|
||||
|
||||
if (array.length) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
result += '<div class=\'aside-list-item\'>'
|
||||
|
||||
if (true) {
|
||||
const name = 'data-lazy-src'
|
||||
result += `<a href='${array[i].url}' class='thumbnail'><img ${name}='${array[i].avatar}' alt='${array[i].nick}'><div class='name'><span>${array[i].nick}</span></div></a>`
|
||||
}
|
||||
|
||||
result += `<div class='content'>
|
||||
<a class='comment' href='${array[i].url}'>${array[i].content}</a>
|
||||
<time datetime="${array[i].date}">${btf.diffDate(array[i].date, true)}</time></div>
|
||||
</div>`
|
||||
}
|
||||
} else {
|
||||
result += '没有评论'
|
||||
}
|
||||
|
||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom.innerHTML = result
|
||||
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||
window.pjax && window.pjax.refresh($dom)
|
||||
}
|
||||
|
||||
const newestCommentInit = () => {
|
||||
if (document.querySelector('#card-newest-comments .aside-list')) {
|
||||
const data = saveToLocal.get('twikoo-newest-comments')
|
||||
if (data) {
|
||||
generateHtml(JSON.parse(data))
|
||||
}
|
||||
} else {
|
||||
getComment()
|
||||
result += '没有评论'
|
||||
}
|
||||
|
||||
let $dom = document.querySelector('#card-newest-comments .aside-list')
|
||||
$dom.innerHTML = result
|
||||
window.lazyLoadInstance && window.lazyLoadInstance.update()
|
||||
window.pjax && window.pjax.refresh($dom)
|
||||
}
|
||||
|
||||
const newestCommentInit = () => {
|
||||
if (document.querySelector('#card-newest-comments .aside-list')) {
|
||||
const data = saveToLocal.get('twikoo-newest-comments')
|
||||
if (data) {
|
||||
generateHtml(JSON.parse(data))
|
||||
} else {
|
||||
getComment()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newestCommentInit()
|
||||
document.addEventListener('pjax:complete', newestCommentInit)
|
||||
})</script>
|
||||
newestCommentInit()
|
||||
document.addEventListener('pjax:complete', newestCommentInit)
|
||||
})
|
||||
</script>
|
||||
|
||||
<!-- https://davidshimjs.github.io/qrcodejs/ 生成二维码 -->
|
||||
<!-- 应该是文章页分享使用 -->
|
||||
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/qrcodejs/1.0.0/qrcode.min.js"></script>
|
||||
|
||||
<!-- todo -->
|
||||
<script data-pjax=""
|
||||
src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/Swiper/6.6.2/swiper-bundle.min.js"></script>
|
||||
|
||||
<!-- todo 不知道是否可以抽到 right-menu.html 中,做到后台可配置 -->
|
||||
<script th:src="@{/assets/zhheo/rightmenu.js}"></script>
|
||||
|
||||
<!-- todo 随机跳转功能,应该是随机友链和随机文章,应该也可以抽走 -->
|
||||
<script th:src="@{/assets/zhheo/random.js}"></script>
|
||||
<script data-pjax th:src="@{/zhheo/commentBarrage.js}"></script>
|
||||
|
||||
<!-- https://raphamorim.io/waterfall.js/ 应该是这个 还有相关的 js 代码 是否可以调整-->
|
||||
<script src="https://cdn.zhheo.com/public/waterfall/waterfall.min.js"></script>
|
||||
|
||||
<!-- 无障碍功能 https://github.com/duheng/assist 无用就可以删除了 -->
|
||||
|
||||
<script src="https://cdn.zhheo.com/public/assist/assist-entry.min.js"></script>
|
||||
|
||||
<!-- 音乐播放器,应该还有相关 js 可以一并移除,或者抽出公共模块,最好是使用 halo2.0 插件 -->
|
||||
<script src="https://cdn.zhheo.com/public/aplayer/Meting2.min.js"></script>
|
||||
|
||||
<!-- 不知道对要不要 -->
|
||||
<script src="https://cdn.zhheo.com/public/pjax/pjax.min.js"></script>
|
||||
|
||||
<!-- 不知道干啥的 -->
|
||||
<script>let pjaxSelectors = [
|
||||
'title',
|
||||
'#config-diff',
|
||||
|
@ -194,6 +234,7 @@
|
|||
}
|
||||
})</script>
|
||||
</div>
|
||||
<!-- 不知道干啥的 -->
|
||||
<div class="js-pjax">
|
||||
<script>
|
||||
coverColor(),
|
||||
|
|
Loading…
Reference in New Issue