优化js文件
This commit is contained in:
parent
11b2e9e1b5
commit
ecc228dab2
|
@ -18,22 +18,6 @@ var heo = {
|
|||
}
|
||||
},
|
||||
|
||||
// //bb添加时间
|
||||
// changeTimeInEssay: function () {
|
||||
// const relativeDate = function (selector) {
|
||||
// selector.forEach(item => {
|
||||
// const $this = item
|
||||
// const timeVal = $this.getAttribute('datetime')
|
||||
// $this.innerText = btf.diffDate(timeVal, true)
|
||||
// $this.style.display = 'inline'
|
||||
// })
|
||||
// }
|
||||
//
|
||||
// if (document.querySelector('#comment')) {
|
||||
// relativeDate(document.querySelectorAll('#comment time'))
|
||||
// }
|
||||
// },
|
||||
|
||||
// 首页bb
|
||||
initIndexEssay: function() {
|
||||
if (document.querySelector("#bber-talk"))
|
||||
|
@ -81,60 +65,6 @@ var heo = {
|
|||
$("#cookies-window").hide())
|
||||
},
|
||||
|
||||
// 标签页面
|
||||
//分类条
|
||||
// tagPageActive: function () {
|
||||
// var urlinfo = window.location.pathname;
|
||||
// urlinfo = decodeURIComponent(urlinfo)
|
||||
// // console.log(urlinfo);
|
||||
// // 验证是否是分类链接
|
||||
// var pattern = /\/tags\/.*?\//;
|
||||
// var patbool = pattern.test(urlinfo);
|
||||
// // console.log(patbool);
|
||||
// // 获取当前的分类
|
||||
// if (patbool) {
|
||||
// var valuegroup = urlinfo.split("/");
|
||||
// // console.log(valuegroup[2]);
|
||||
// // 获取当前分类
|
||||
// var nowCategorie = valuegroup[2];
|
||||
// if (document.querySelector('#tag-page-tags')) {
|
||||
// $('a').removeClass('select')
|
||||
// document.getElementById(nowCategorie).classList.add("select");
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
//分类条
|
||||
// categoriesBarActive: function () {
|
||||
// if (document.querySelector('#category-bar')) {
|
||||
// $(".category-bar-item").removeClass("select")
|
||||
// }
|
||||
// var urlinfo = window.location.pathname;
|
||||
// urlinfo = decodeURIComponent(urlinfo);
|
||||
// // console.log(urlinfo);
|
||||
// //判断是否是首页
|
||||
// if (urlinfo == '/') {
|
||||
// if (document.querySelector('#category-bar')) {
|
||||
// document.getElementById('category-bar-home').classList.add("select");
|
||||
// }
|
||||
// } else {
|
||||
// // 验证是否是分类链接
|
||||
// var pattern = /\/categories\/.*?\//;
|
||||
// var patbool = pattern.test(urlinfo);
|
||||
// // console.log(patbool);
|
||||
// // 获取当前的分类
|
||||
// if (patbool) {
|
||||
// var valuegroup = urlinfo.split("/");
|
||||
// // console.log(valuegroup[2]);
|
||||
// // 获取当前分类
|
||||
// var nowCategorie = valuegroup[2];
|
||||
// if (document.querySelector('#category-bar')) {
|
||||
// document.getElementById(nowCategorie).classList.add("select");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
// 页脚友链
|
||||
addFriendLinksInFooter: function () {
|
||||
const linksUrl = GLOBAL_CONFIG.source.links.linksUrl
|
||||
|
@ -201,18 +131,6 @@ var heo = {
|
|||
|
||||
},
|
||||
|
||||
// 添加标签
|
||||
addTag: function () {
|
||||
//添加new标签
|
||||
if (document.querySelector('.heo-tag-new')) {
|
||||
$(".heo-tag-new").append(`<sup class="heo-tag heo-tag-new-view">N</sup>`)
|
||||
}
|
||||
//添加hot标签
|
||||
if (document.querySelector('.heo-tag-hot')) {
|
||||
$(".heo-tag-hot").append(`<sup class="heo-tag heo-tag-hot-view">H</sup>`)
|
||||
}
|
||||
},
|
||||
|
||||
// 二维码
|
||||
qrcodeCreate: function () {
|
||||
if (document.getElementById('qrcode')) {
|
||||
|
@ -232,7 +150,7 @@ var heo = {
|
|||
reflashEssayWaterFall: function() {
|
||||
document.querySelector("#waterfall") && setTimeout((function() {
|
||||
waterfall("#waterfall"),
|
||||
document.getElementById("waterfall").classList.add("show")
|
||||
document.getElementById("waterfall") && document.getElementById("waterfall").classList.add("show")
|
||||
}
|
||||
), 500)
|
||||
},
|
||||
|
|
|
@ -124,7 +124,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
// }
|
||||
|
||||
/**
|
||||
* fancybox和 mediumZoom
|
||||
* fancybox
|
||||
*/
|
||||
const addFancybox = function (ele) {
|
||||
const runFancybox = (ele) => {
|
||||
|
@ -161,16 +161,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
}
|
||||
}
|
||||
|
||||
const addMediumZoom = () => {
|
||||
const zoom = mediumZoom(document.querySelectorAll('#article-container :not(a)>img'))
|
||||
zoom.on('open', e => {
|
||||
const photoBg = document.documentElement.getAttribute('data-theme') === 'dark' ? '#121212' : '#fff'
|
||||
zoom.update({
|
||||
background: photoBg
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const jqLoadAndRun = () => {
|
||||
const $fancyboxEle = GLOBAL_CONFIG.lightbox === 'fancybox'
|
||||
? document.querySelectorAll('#article-container :not(a):not(.gallery-group):not(.site-card-avatar):not(.flink-item-info):not(.rss-plan-info-group) > img, #article-container > img,.bber-container-img > img')
|
||||
|
@ -265,234 +255,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toc
|
||||
*/
|
||||
const tocFn = function () {
|
||||
const $cardTocLayout = document.getElementById('card-toc')
|
||||
const $cardToc = $cardTocLayout.getElementsByClassName('toc-content')[0]
|
||||
const $tocLink = $cardToc.querySelectorAll('.toc-link')
|
||||
const $article = document.getElementById('article-container')
|
||||
|
||||
// main of scroll
|
||||
window.tocScrollFn = function () {
|
||||
return btf.throttle(function () {
|
||||
const currentTop = window.scrollY || document.documentElement.scrollTop
|
||||
scrollPercent(currentTop)
|
||||
findHeadPosition(currentTop)
|
||||
}, 100)()
|
||||
}
|
||||
window.addEventListener('scroll', tocScrollFn)
|
||||
|
||||
const scrollPercent = function (currentTop) {
|
||||
const docHeight = $article.clientHeight
|
||||
const winHeight = document.documentElement.clientHeight
|
||||
const headerHeight = $article.offsetTop
|
||||
const contentMath = (docHeight > winHeight) ? (docHeight - winHeight) : (document.documentElement.scrollHeight - winHeight)
|
||||
const scrollPercent = (currentTop - headerHeight) / (contentMath)
|
||||
const scrollPercentRounded = Math.round(scrollPercent * 100)
|
||||
const percentage = (scrollPercentRounded > 100) ? 100 : (scrollPercentRounded <= 0) ? 0 : scrollPercentRounded
|
||||
$cardToc.setAttribute('progress-percentage', percentage)
|
||||
}
|
||||
|
||||
// anchor
|
||||
const isAnchor = GLOBAL_CONFIG.isanchor
|
||||
const updateAnchor = function (anchor) {
|
||||
if (window.history.replaceState && anchor !== window.location.hash) {
|
||||
if (!anchor) anchor = location.pathname
|
||||
const title = GLOBAL_CONFIG_SITE.title
|
||||
window.history.replaceState({
|
||||
url: location.href,
|
||||
title: title
|
||||
}, title, anchor)
|
||||
}
|
||||
}
|
||||
|
||||
const mobileToc = {
|
||||
open: () => {
|
||||
$cardTocLayout.style.cssText = 'animation: toc-open .3s; opacity: 1; right: 45px'
|
||||
},
|
||||
|
||||
close: () => {
|
||||
$cardTocLayout.style.animation = 'toc-close .2s'
|
||||
setTimeout(() => {
|
||||
$cardTocLayout.style.cssText = "opacity:''; animation: ''; right: ''"
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('mobile-toc-button').addEventListener('click', () => {
|
||||
if (window.getComputedStyle($cardTocLayout).getPropertyValue('opacity') === '0') mobileToc.open()
|
||||
else mobileToc.close()
|
||||
})
|
||||
|
||||
// toc元素點擊
|
||||
$cardToc.addEventListener('click', (e) => {
|
||||
e.preventDefault()
|
||||
const $target = e.target.classList.contains('toc-link')
|
||||
? e.target
|
||||
: e.target.parentElement
|
||||
btf.scrollToDest(btf.getEleTop(document.getElementById(decodeURI($target.getAttribute('href')).replace('#', ''))), 300)
|
||||
if (window.innerWidth < 900) {
|
||||
mobileToc.close()
|
||||
}
|
||||
})
|
||||
|
||||
const autoScrollToc = function (item) {
|
||||
const activePosition = item.getBoundingClientRect().top
|
||||
const sidebarScrollTop = $cardToc.scrollTop
|
||||
if (activePosition > (document.documentElement.clientHeight - 100)) {
|
||||
$cardToc.scrollTop = sidebarScrollTop + 150
|
||||
}
|
||||
if (activePosition < 100) {
|
||||
$cardToc.scrollTop = sidebarScrollTop - 150
|
||||
}
|
||||
}
|
||||
|
||||
// find head position & add active class
|
||||
const list = $article.querySelectorAll('h1,h2,h3,h4,h5,h6')
|
||||
let detectItem = ''
|
||||
const findHeadPosition = function (top) {
|
||||
if ($tocLink.length === 0 || top === 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
let currentId = ''
|
||||
let currentIndex = ''
|
||||
|
||||
list.forEach(function (ele, index) {
|
||||
if (top > btf.getEleTop(ele) - 80) {
|
||||
currentId = '#' + encodeURI(ele.getAttribute('id'))
|
||||
currentIndex = index
|
||||
}
|
||||
})
|
||||
|
||||
if (detectItem === currentIndex) return
|
||||
|
||||
if (isAnchor) updateAnchor(currentId)
|
||||
|
||||
if (currentId === '') {
|
||||
$cardToc.querySelectorAll('.active').forEach(i => { i.classList.remove('active') })
|
||||
detectItem = currentIndex
|
||||
return
|
||||
}
|
||||
|
||||
detectItem = currentIndex
|
||||
|
||||
$cardToc.querySelectorAll('.active').forEach(item => { item.classList.remove('active') })
|
||||
const currentActive = $tocLink[currentIndex]
|
||||
currentActive.classList.add('active')
|
||||
|
||||
setTimeout(() => {
|
||||
autoScrollToc(currentActive)
|
||||
}, 0)
|
||||
|
||||
let parent = currentActive.parentNode
|
||||
|
||||
for (; !parent.matches('.toc'); parent = parent.parentNode) {
|
||||
if (parent.matches('li')) parent.classList.add('active')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rightside
|
||||
*/
|
||||
// const rightSideFn = {
|
||||
// switchReadMode: () => { // read-mode
|
||||
// const $body = document.body
|
||||
// $body.classList.add('read-mode')
|
||||
// const newEle = document.createElement('button')
|
||||
// newEle.type = 'button'
|
||||
// newEle.className = 'fas fa-sign-out-alt exit-readmode'
|
||||
// $body.appendChild(newEle)
|
||||
//
|
||||
// function clickFn() {
|
||||
// $body.classList.remove('read-mode')
|
||||
// newEle.remove()
|
||||
// newEle.removeEventListener('click', clickFn)
|
||||
// }
|
||||
//
|
||||
// newEle.addEventListener('click', clickFn)
|
||||
// },
|
||||
// switchDarkMode: () => { // Switch Between Light And Dark Mode
|
||||
// const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
||||
// if (nowMode === 'light') {
|
||||
// activateDarkMode()
|
||||
// saveToLocal.set('theme', 'dark', 2);
|
||||
// GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night, false, 2000);
|
||||
// } else {
|
||||
// activateLightMode();
|
||||
// saveToLocal.set('theme', 'light', 2);
|
||||
// GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day, false, 2000);
|
||||
// }
|
||||
// // handle some cases
|
||||
// typeof utterancesTheme === 'function' && utterancesTheme()
|
||||
// typeof FB === 'object' && window.loadFBComment()
|
||||
// window.DISQUS && document.getElementById('disqus_thread').children.length && setTimeout(() => window.disqusReset(), 200)
|
||||
// },
|
||||
// showOrHideBtn: () => { // rightside 點擊設置 按鈕 展開
|
||||
// document.getElementById('rightside-config-hide').classList.toggle('show')
|
||||
// },
|
||||
// scrollToTop: () => { // Back to top
|
||||
// btf.scrollToDest(0, 500)
|
||||
// },
|
||||
// hideAsideBtn: () => { // Hide aside
|
||||
// const $htmlDom = document.documentElement.classList
|
||||
// $htmlDom.contains('hide-aside')
|
||||
// ? saveToLocal.set('aside-status', 'show', 2)
|
||||
// : saveToLocal.set('aside-status', 'hide', 2)
|
||||
// $htmlDom.toggle('hide-aside')
|
||||
// },
|
||||
//
|
||||
// adjustFontSize: (plus) => {
|
||||
// const fontSizeVal = parseInt(window.getComputedStyle(document.documentElement).getPropertyValue('--global-font-size'))
|
||||
// let newValue = ''
|
||||
// if (plus) {
|
||||
// if (fontSizeVal >= 20) return
|
||||
// newValue = fontSizeVal + 1
|
||||
// document.documentElement.style.setProperty('--global-font-size', newValue + 'px')
|
||||
// !document.getElementById('nav').classList.contains('hide-menu') && adjustMenu(true)
|
||||
// } else {
|
||||
// if (fontSizeVal <= 10) return
|
||||
// newValue = fontSizeVal - 1
|
||||
// document.documentElement.style.setProperty('--global-font-size', newValue + 'px')
|
||||
// document.getElementById('nav').classList.contains('hide-menu') && adjustMenu(true)
|
||||
// }
|
||||
//
|
||||
// saveToLocal.set('global-font-size', newValue, 2)
|
||||
// // document.getElementById('font-text').innerText = newValue
|
||||
// }
|
||||
// }
|
||||
|
||||
// document.getElementById('rightside').addEventListener('click', function (e) {
|
||||
// const $target = e.target.id || e.target.parentNode.id
|
||||
// switch ($target) {
|
||||
// case 'go-up':
|
||||
// rightSideFn.scrollToTop()
|
||||
// break
|
||||
// case 'rightside_config':
|
||||
// rightSideFn.showOrHideBtn()
|
||||
// break
|
||||
// case 'readmode':
|
||||
// rightSideFn.switchReadMode()
|
||||
// break
|
||||
// case 'darkmode':
|
||||
// rightSideFn.switchDarkMode()
|
||||
// break
|
||||
// case 'hide-aside-btn':
|
||||
// rightSideFn.hideAsideBtn()
|
||||
// break
|
||||
// case 'font-plus':
|
||||
// rightSideFn.adjustFontSize(true)
|
||||
// break
|
||||
// case 'font-minus':
|
||||
// rightSideFn.adjustFontSize()
|
||||
// break
|
||||
// default:
|
||||
// break
|
||||
// }
|
||||
// })
|
||||
|
||||
/**
|
||||
* menu
|
||||
|
@ -661,26 +423,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
}
|
||||
}
|
||||
|
||||
// const switchComments = function () {
|
||||
// let switchDone = false
|
||||
// const $switchBtn = document.querySelector('#comment-switch > .switch-btn')
|
||||
// $switchBtn && $switchBtn.addEventListener('click', function () {
|
||||
// this.classList.toggle('move')
|
||||
// document.querySelectorAll('#post-comment > .comment-wrap > div').forEach(function (item) {
|
||||
// if (btf.isHidden(item)) {
|
||||
// item.style.cssText = 'display: block;animation: tabshow .5s'
|
||||
// } else {
|
||||
// item.style.cssText = "display: none;animation: ''"
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// if (!switchDone && typeof loadOtherComment === 'function') {
|
||||
// switchDone = true
|
||||
// loadOtherComment()
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
const addPostOutdateNotice = function () {
|
||||
const data = GLOBAL_CONFIG.noticeOutdate
|
||||
const diffDay = btf.diffDate(GLOBAL_CONFIG_SITE.postUpdate)
|
||||
|
@ -732,13 +474,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
|
||||
GLOBAL_CONFIG.lazyload.enable && lazyloadImg()
|
||||
if (GLOBAL_CONFIG.isPost) {
|
||||
// GLOBAL_CONFIG.isToc && tocFn()
|
||||
addRuntime();
|
||||
// GLOBAL_CONFIG.noticeOutdate !== undefined && addPostOutdateNotice()
|
||||
// GLOBAL_CONFIG.relativeDate.post && relativeDate(document.querySelectorAll('#post-meta time'))
|
||||
} else {
|
||||
// GLOBAL_CONFIG.relativeDate.homepage && relativeDate(document.querySelectorAll('#recent-posts time'))
|
||||
// GLOBAL_CONFIG.runtime && addRuntime()
|
||||
addLastPushDate()
|
||||
toggleCardCategory()
|
||||
addRuntime()
|
||||
|
@ -746,16 +483,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
|
||||
sidebarFn()
|
||||
GLOBAL_CONFIG.isHome && scrollDownInIndex()
|
||||
// addHighlightTool()
|
||||
//GLOBAL_CONFIG.isPhotoFigcaption && addPhotoFigcaption()
|
||||
scrollFn()
|
||||
addTableWrap()
|
||||
clickFnOfTagHide()
|
||||
tabsFn.clickFnOfTabs()
|
||||
tabsFn.backToTop()
|
||||
jqLoadAndRun()
|
||||
//initGallery()
|
||||
// switchComments()
|
||||
}
|
||||
|
||||
refreshFn()
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
"use strict";function _objectSpread(a){for(var b=1;b<arguments.length;b++){var c=null==arguments[b]?{}:arguments[b],d=Object.keys(c);"function"==typeof Object.getOwnPropertySymbols&&(d=d.concat(Object.getOwnPropertySymbols(c).filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable}))),d.forEach(function(b){_defineProperty(a,b,c[b])})}return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}class MetingJSElement extends HTMLElement{connectedCallback(){window.APlayer&&window.fetch&&(this._init(),this._parse())}disconnectedCallback(){this.lock||this.aplayer.destroy()}_camelize(a){return a.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(a,b)=>b.toUpperCase())}_init(){let a={};for(let b=0;b<this.attributes.length;b+=1)a[this._camelize(this.attributes[b].name)]=this.attributes[b].value;let b=["server","type","id","api","auth","auto","lock","name","title","artist","author","url","cover","pic","lyric","lrc"];this.meta={};for(var c=0;c<b.length;c++){let d=b[c];this.meta[d]=a[d],delete a[d]}this.config=a,this.api=this.meta.api||window.meting_api||"https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r",this.meta.auto&&this._parse_link()}_parse_link(){let a=[["music.163.com.*song.*id=(\\d+)","netease","song"],["music.163.com.*album.*id=(\\d+)","netease","album"],["music.163.com.*artist.*id=(\\d+)","netease","artist"],["music.163.com.*playlist.*id=(\\d+)","netease","playlist"],["music.163.com.*discover/toplist.*id=(\\d+)","netease","playlist"],["y.qq.com.*song/(\\w+).html","tencent","song"],["y.qq.com.*album/(\\w+).html","tencent","album"],["y.qq.com.*singer/(\\w+).html","tencent","artist"],["y.qq.com.*playsquare/(\\w+).html","tencent","playlist"],["y.qq.com.*playlist/(\\w+).html","tencent","playlist"],["xiami.com.*song/(\\w+)","xiami","song"],["xiami.com.*album/(\\w+)","xiami","album"],["xiami.com.*artist/(\\w+)","xiami","artist"],["xiami.com.*collect/(\\w+)","xiami","playlist"]];for(var b=0;b<a.length;b++){let c=a[b],d=new RegExp(c[0]),e=d.exec(this.meta.auto);if(null!==e)return this.meta.server=c[1],this.meta.type=c[2],void(this.meta.id=e[1])}}_parse(){if(this.meta.url){let a={name:this.meta.name||this.meta.title||"Audio name",artist:this.meta.artist||this.meta.author||"Audio artist",url:this.meta.url,cover:this.meta.cover||this.meta.pic,lrc:this.meta.lrc||this.meta.lyric||"",type:this.meta.type||"auto"};return a.lrc||(this.meta.lrcType=0),this.innerText&&(a.lrc=this.innerText,this.meta.lrcType=2),void this._loadPlayer([a])}let a=this.api.replace(":server",this.meta.server).replace(":type",this.meta.type).replace(":id",this.meta.id).replace(":auth",this.meta.auth).replace(":r",Math.random());fetch(a).then(a=>a.json()).then(a=>this._loadPlayer(a))}_loadPlayer(a){let b={audio:a,mutex:!0,lrcType:this.meta.lrcType||3,storageName:"metingjs"};if(a.length){let a=_objectSpread({},b,this.config);for(let b in a)("true"===a[b]||"false"===a[b])&&(a[b]="true"===a[b]);let c=document.createElement("div");a.container=c,this.appendChild(c),this.aplayer=new APlayer(a)}}}console.log("\n %c MetingJS v2.0.1 %c https://github.com/metowolf/MetingJS \n","color: #fadfa3; background: #030307; padding:5px 0;","background: #fadfa3; padding:5px 0;"),window.customElements&&!window.customElements.get("meting-js")&&(window.MetingJSElement=MetingJSElement,window.customElements.define("meting-js",MetingJSElement));
|
||||
"use strict";function _objectSpread(a){for(var b=1;b<arguments.length;b++){var c=null==arguments[b]?{}:arguments[b],d=Object.keys(c);"function"==typeof Object.getOwnPropertySymbols&&(d=d.concat(Object.getOwnPropertySymbols(c).filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable}))),d.forEach(function(b){_defineProperty(a,b,c[b])})}return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}class MetingJSElement extends HTMLElement{connectedCallback(){window.APlayer&&window.fetch&&(this._init(),this._parse())}disconnectedCallback(){this.lock||this.aplayer.destroy()}_camelize(a){return a.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(a,b)=>b.toUpperCase())}_init(){let a={};for(let b=0;b<this.attributes.length;b+=1)a[this._camelize(this.attributes[b].name)]=this.attributes[b].value;let b=["server","type","id","api","auth","auto","lock","name","title","artist","author","url","cover","pic","lyric","lrc"];this.meta={};for(var c=0;c<b.length;c++){let d=b[c];this.meta[d]=a[d],delete a[d]}this.config=a,this.api=this.meta.api||window.meting_api||"https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r",this.meta.auto&&this._parse_link()}_parse_link(){let a=[["music.163.com.*song.*id=(\\d+)","netease","song"],["music.163.com.*album.*id=(\\d+)","netease","album"],["music.163.com.*artist.*id=(\\d+)","netease","artist"],["music.163.com.*playlist.*id=(\\d+)","netease","playlist"],["music.163.com.*discover/toplist.*id=(\\d+)","netease","playlist"],["y.qq.com.*song/(\\w+).html","tencent","song"],["y.qq.com.*album/(\\w+).html","tencent","album"],["y.qq.com.*singer/(\\w+).html","tencent","artist"],["y.qq.com.*playsquare/(\\w+).html","tencent","playlist"],["y.qq.com.*playlist/(\\w+).html","tencent","playlist"],["xiami.com.*song/(\\w+)","xiami","song"],["xiami.com.*album/(\\w+)","xiami","album"],["xiami.com.*artist/(\\w+)","xiami","artist"],["xiami.com.*collect/(\\w+)","xiami","playlist"]];for(var b=0;b<a.length;b++){let c=a[b],d=new RegExp(c[0]),e=d.exec(this.meta.auto);if(null!==e)return this.meta.server=c[1],this.meta.type=c[2],void(this.meta.id=e[1])}}_parse(){if(this.meta.url){let a={name:this.meta.name||this.meta.title||"Audio name",artist:this.meta.artist||this.meta.author||"Audio artist",url:this.meta.url,cover:this.meta.cover||this.meta.pic,lrc:this.meta.lrc||this.meta.lyric||"",type:this.meta.type||"auto"};return a.lrc||(this.meta.lrcType=0),this.innerText&&(a.lrc=this.innerText,this.meta.lrcType=2),void this._loadPlayer([a])}let a=this.api.replace(":server",this.meta.server).replace(":type",this.meta.type).replace(":id",this.meta.id).replace(":auth",this.meta.auth).replace(":r",Math.random());fetch(a).then(a=>a.json()).then(a=>this._loadPlayer(a))}_loadPlayer(a){let b={audio:a,mutex:!0,lrcType:this.meta.lrcType||3,storageName:"metingjs"};if(a.length){let a=_objectSpread({},b,this.config);for(let b in a)("true"===a[b]||"false"===a[b])&&(a[b]="true"===a[b]);let c=document.createElement("div");a.container=c,this.appendChild(c),this.aplayer=new APlayer(a)}}}window.customElements&&!window.customElements.get("meting-js")&&(window.MetingJSElement=MetingJSElement,window.customElements.define("meting-js",MetingJSElement));
|
|
@ -1 +1 @@
|
|||
!function(a,b){"function"==typeof define&&define.amd?define("waterfall",function(){return b}):"object"==typeof module&&module.exports?module.exports=b:a.waterfall=b}(this,function(a){function b(a){return window.getComputedStyle(a)}function c(a,c){return parseFloat(b(c)["margin"+a])||0}function d(a){return parseFloat(a)+"px"}function e(a){return parseFloat(a.style.top)}function f(a){return parseFloat(a.style.left)}function g(a){return parseFloat(b(a).width)}function h(a){return parseFloat(b(a).height)}function i(a){return e(a)+h(a)+c("Bottom",a)}function j(a){return f(a)+g(a)+c("Right",a)}function k(a){a=a.sort(function(a,b){var c=i(b)-i(a);return c||f(b)-f(a)})}function l(a){var b=a;k(b),this.add=function(a){b.push(a),k(b),b.pop()},this.min=function(){return b[b.length-1]},this.max=function(){return b[0]}}function m(a,b,c){a.style.position="absolute",a.style.top=d(b),a.style.left=d(c)}function n(a){m(a,0,c("Left",a))}function o(a,b){m(b,a.style.top,j(a)+c("Left",b))}function p(a,b){m(b,i(a)+c("Top",b),f(a))}function q(a,b){a.style.position="relative",a.style.height=d(i(b)+c("Bottom",b))}function r(b,c){return j(b[c-1])+g(b[c])<=g(a)}"string"==typeof a&&(a=document.querySelector(a));var s=a.children;s.length&&n(s[0]);for(var t=1;t<s.length&&r(s,t);t++)o(s[t-1],s[t]);for(var u=[].slice.call(s,0,t),v=new l(u);t<s.length;t++)p(v.min(),s[t]),v.add(s[t]);q(a,v.max())});
|
||||
!function(a,b){"function"==typeof define&&define.amd?define("waterfall",(function(){return b})):"object"==typeof module&&module.exports?module.exports=b:a.waterfall=b}(this,(function(a){function b(a){return window.getComputedStyle(a)}function c(a,c){return parseFloat(b(c)["margin"+a])||0}function d(a){return parseFloat(a)+"px"}function f(a){return parseFloat(a.style.left)}function g(a){return parseFloat(b(a).width)}function i(a){return function(a){return parseFloat(a.style.top)}(a)+function(a){return parseFloat(b(a).height)}(a)+c("Bottom",a)}function j(a){return f(a)+g(a)+c("Right",a)}function k(a){a=a.sort((function(a,b){return i(b)-i(a)||f(b)-f(a)}))}function m(a,b,c){a.style.position="absolute",a.style.top=d(b),a.style.left=d(c)}function o(a,b){m(b,a.style.top,j(a)+c("Left",b))}function p(a,b){m(b,i(a)+c("Top",b),f(a))}function r(b,c){return j(b[c-1])+g(b[c])<=g(a)}if("string"==typeof a&&(a=document.querySelector(a)),null!=a){var s=a.children;s.length&&function(a){m(a,0,c("Left",a))}(s[0]);for(var t=1;t<s.length&&r(s,t);t++)o(s[t-1],s[t]);for(var v=new function(a){var b=a;k(b),this.add=function(a){b.push(a),k(b),b.pop()},this.min=function(){return b[b.length-1]},this.max=function(){return b[0]}}([].slice.call(s,0,t));t<s.length;t++)p(v.min(),s[t]),v.add(s[t]);!function(a,b){a.style.position="relative",a.style.height=d(i(b)+c("Bottom",b))}(a,v.max())}}));
|
|
@ -617,7 +617,7 @@ function percent() {
|
|||
, o = Math.round(e / t * 100)
|
||||
, n = document.querySelector("#percent");
|
||||
var a = window.scrollY + document.documentElement.clientHeight
|
||||
, i = document.getElementById("post-tools") || document.getElementById("footer");
|
||||
, i = document.getElementById("post-comment") || document.getElementById("footer");
|
||||
i.offsetTop + i.offsetHeight / 2 < a || o > 90 ? (document.querySelector("#nav-totop").classList.add("long"),
|
||||
n.innerHTML = "返回顶部") : (document.querySelector("#nav-totop").classList.remove("long"),
|
||||
o >= 0 && (n.innerHTML = o)),
|
||||
|
@ -660,10 +660,28 @@ function listenToPageInputPress() {
|
|||
)))
|
||||
}
|
||||
function initBlog() {
|
||||
// 图片主色
|
||||
GLOBAL_CONFIG.source.post.dynamicBackground && coverColor(),
|
||||
navTitle(),
|
||||
percent(),
|
||||
heo.topCategoriesBarScroll(),
|
||||
heo.initIndexEssay(),
|
||||
checkUrlAndAddHideBanner(),
|
||||
setBodyDataType(),
|
||||
listenToPageInputPress()
|
||||
listenToPageInputPress(),
|
||||
heo.topPostScroll(),
|
||||
heo.sayhi(),
|
||||
heo.qrcodeCreate(),
|
||||
//右下角 snackbar 弹窗
|
||||
GLOBAL_CONFIG.source.tool.switch && heo.hidecookie(),
|
||||
heo.stopImgRightDrag(),
|
||||
heo.onlyHome(),
|
||||
heo.addNavBackgroundInit(),
|
||||
heo.darkModeStatus(),
|
||||
heo.initThemeColor(),
|
||||
//隐藏加载动画
|
||||
GLOBAL_CONFIG.loadingBox && heo.hideLoading(),
|
||||
checkUrlAndAddHideBanner()
|
||||
|
||||
}
|
||||
|
||||
// 如果当前页有评论就执行函数
|
||||
|
@ -862,34 +880,9 @@ document.addEventListener('pjax:send', function () {
|
|||
})
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// coverColor()
|
||||
navTitle()
|
||||
percent()
|
||||
heo.topPostScroll()
|
||||
heo.topCategoriesBarScroll()
|
||||
heo.sayhi()
|
||||
heo.addTag()
|
||||
heo.stopImgRightDrag()
|
||||
//页脚友联
|
||||
if(GLOBAL_CONFIG.isFriendLinksInFooter){
|
||||
heo.addFriendLinksInFooter()
|
||||
}
|
||||
heo.qrcodeCreate()
|
||||
heo.onlyHome()
|
||||
|
||||
heo.addNavBackgroundInit()
|
||||
// heo.changeTimeInEssay()
|
||||
heo.reflashEssayWaterFall()
|
||||
//heo.addMediumInEssay()
|
||||
heo.darkModeStatus()
|
||||
// heo.categoriesBarActive()
|
||||
heo.initThemeColor()
|
||||
//隐藏加载动画
|
||||
if(GLOBAL_CONFIG.loadingBox){
|
||||
heo.hideLoading()
|
||||
}
|
||||
// heo.tagPageActive()
|
||||
})
|
||||
window.onscroll = function () {
|
||||
percent();
|
||||
};
|
||||
|
|
|
@ -8028,16 +8028,6 @@ span.fund_name {
|
|||
line-height: 19px;
|
||||
}
|
||||
|
||||
.heo-tag-new-view {
|
||||
color: var(--heo-white);
|
||||
background: var(--heo-green);
|
||||
}
|
||||
|
||||
.heo-tag-hot-view {
|
||||
color: var(--heo-white);
|
||||
background: var(--heo-red);
|
||||
}
|
||||
|
||||
|
||||
/* 主页导航栏让位偏移 */
|
||||
/* .layout_page .recent-posts{
|
||||
|
|
|
@ -236,6 +236,12 @@
|
|||
locationLng: [[${theme.config.sidebar.welcome.locationLng}]],
|
||||
locationLat: [[${theme.config.sidebar.welcome.locationLat}]],
|
||||
},
|
||||
post:{
|
||||
dynamicBackground: [[${ theme.config.post.dynamicBackground }]]
|
||||
},
|
||||
tool:{
|
||||
switch: [[${ theme.config.tool.snackbar.switch }]]
|
||||
}
|
||||
},
|
||||
date_suffix: {
|
||||
just: '刚刚',
|
||||
|
@ -264,6 +270,7 @@
|
|||
enable_height_limit: [[${theme.config.code.enable_height_limit}]]
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
// 根据htmlType设置页面title
|
||||
|
|
|
@ -210,50 +210,24 @@
|
|||
|
||||
<script data-pjax="">
|
||||
|
||||
|
||||
if ([[${ theme.config.post.dynamicBackground }]]) {
|
||||
// 图片主色
|
||||
coverColor();
|
||||
}
|
||||
|
||||
if ([[${ theme.config.other.loadingBoxs.loadingBoxEnable }]]) {
|
||||
// 移除加载动画
|
||||
removeLoading();
|
||||
}
|
||||
navTitle();
|
||||
heo.topPostScroll();
|
||||
heo.topCategoriesBarScroll();
|
||||
heo.sayhi();
|
||||
heo.addTag();
|
||||
heo.stopImgRightDrag();
|
||||
heo.qrcodeCreate();
|
||||
heo.onlyHome();
|
||||
heo.addNavBackgroundInit();
|
||||
//heo.addMediumInEssay();
|
||||
heo.darkModeStatus();
|
||||
// heo.categoriesBarActive();
|
||||
heo.initThemeColor();
|
||||
//页脚友联
|
||||
if(GLOBAL_CONFIG.isFriendLinksInFooter){
|
||||
heo.addFriendLinksInFooter()
|
||||
}
|
||||
|
||||
//右下角 snackbar 弹窗
|
||||
if ([[${ theme.config.tool.snackbar.switch }]]) {
|
||||
heo.hidecookie()
|
||||
}
|
||||
|
||||
//音乐页面切换歌曲调用
|
||||
if(GLOBAL_CONFIG.isMusic){
|
||||
heo.changeMusicBg(false);
|
||||
}
|
||||
|
||||
//代码块
|
||||
if(GLOBAL_CONFIG.prism.enable){
|
||||
halo.addPrismTool()
|
||||
halo.dataCodeTheme()
|
||||
}
|
||||
|
||||
if(document.querySelector('#danmu') &&
|
||||
document.body.clientWidth > 768 &&
|
||||
[[${theme.config.envelope_comment.enable_danmu}]]){
|
||||
|
@ -261,9 +235,6 @@
|
|||
halo.addScript("Danmaku", "[[${assets_link + '/libs/twikoo/easy-Danmaku.js'}]]", halo.danmu("[(${theme.config.comments.twikoos.envId})]","[(${theme.config.comments.twikoos.accessToken})]",[[${theme.config.envelope_comment.maxBarrage}]]))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
Loading…
Reference in New Issue