Site updated: 2024-11-15 12:55:55

This commit is contained in:
qinglong committed 2024-11-15 12:55:59 +08:00
1 parent 9868dfdb4d
commit d7edb8f3c3
233 files changed
+235 -1077

No files matched your search

+2 -2
View File
@@ -1,2 +1,2 @@
var e={version:"0.0.0",hostname:"https://hitoli.com",root:"/",statics:"/",favicon:{normal:"images/favicon.ico",hidden:"images/failure.ico"},darkmode:false,auto_scroll:true,js:{valine:"gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js",chart:"npm/frappe-charts@1.5.0/dist/frappe-charts.min.iife.min.js",copy_tex:"npm/katex@0.12.0/dist/contrib/copy-tex.min.js",fancybox:"combine/npm/jquery@3.5.1/dist/jquery.min.js,npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js,npm/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js"},css:{valine:"css/comment.css",katex:"npm/katex@0.12.0/dist/katex.min.css",mermaid:"css/mermaid.css",fancybox:"combine/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css,npm/justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css"},loader:{start:true,"switch":true},search:{appID:"2NU6BAFQUF",apiKey:"47a93cc6d8d1e77bd82d36e8365788dc",indexName:"blog",hits:{per_page:10}},valine:{appId:"pFJTr97i45HCNkAPfurKR0rS-gzGzoHsz",appKey:"9LsEPqi4hHCtghqzc7qDLyNV",placeholder:"ヽ(○´∀`)ノ♪欢迎畅所欲言",avatar:"mp",pageSize:10,lang:"zh-CN",visitor:true,NoRecordIP:false,serverURLs:null,powerMode:true,tagMeta:{visitor:"新朋友",master:"博主",friend:"小伙伴",investor:"金主粑粑"},tagColor:{master:"var(--color-orange)",friend:"var(--color-aqua)",investor:"var(--color-pink)"},tagMember:{master:["d2d281bfc950fb3d79ff50c5e2c7bd89"],friend:null,investor:null}},quicklink:{timeout:3e3,priority:true},audio:[{title:"博主喜欢",list:["https://nas.hitoli.com:18019/share/iX6Sgdkluz#/"]},{title:"网易云音乐",list:["https://music.163.com/#/playlist?id=5172410111","https://music.163.com/#/discover/toplist?id=19723756"]}],fireworks:["rgba(255,182,185,.9)","rgba(250,227,217,.9)","rgba(187,222,214,.9)","rgba(138,198,209,.9)"]};const t=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};const a=function(){return u("main > .inner").offsetHeight};const n=function(e,t,a){if(a){t()}else{var n=document.createElement("script");n.onload=n.onreadystatechange=function(e,a){if(a||!n.readyState||/loaded|complete/.test(n.readyState)){n.onload=n.onreadystatechange=null;n=undefined;if(!a&&t)setTimeout(t,0)}};n.src=e;document.head.appendChild(n)}};const i=function(t,a){var n=e[t][a];if(n.indexOf("npm")>-1||n.indexOf("gh")>-1||n.indexOf("combine")>-1)return"//cdn.jsdelivr.net/"+n;if(n.indexOf("http")>-1)return n;return m+n};const r=function(e,t,a){if(LOCAL[e]){n(i("js",e),t||function(){window[e]=true},a||window[e])}};const s=function(e,t){if(window["css"+e])return;if(LOCAL[e]){document.head.createChild("link",{rel:"stylesheet",href:i("css",e)});window["css"+e]=true}};const o=function(e){var t=e.text||e.textContent||e.innerHTML||"";var a=e.parentNode;a.removeChild(e);var n=document.createElement("script");if(e.id){n.id=e.id}if(e.className){n.className=e.className}if(e.type){n.type=e.type}if(e.src){n.src=e.src;n.async=false}if(e.dataset.pjax!==undefined){n.dataset.pjax=""}if(t!==""){n.appendChild(document.createTextNode(t))}a.appendChild(n)};const c=function(e,t,a){var n={targets:typeof t=="number"?e.parentNode:document.scrollingElement,duration:500,easing:"easeInOutQuad",scrollTop:t||(typeof e=="number"?e:e?e.top()+document.documentElement.scrollTop-_:0),complete:function(){a&&a()}};anime(n)};const l=function(e,t,a){var n={};var i="none";switch(t){case 0:n={opacity:[1,0]};break;case 1:n={opacity:[0,1]};i="block";break;case"bounceUpIn":n={begin:function(t){e.display("block")},translateY:[{value:-60,duration:200},{value:10,duration:200},{value:-5,duration:200},{value:0,duration:200}],opacity:[0,1]};i="block";break;case"shrinkIn":n={begin:function(t){e.display("block")},scale:[{value:1.1,duration:300},{value:1,duration:200}],opacity:1};i="block";break;case"slideRightIn":n={begin:function(t){e.display("block")},translateX:[100,0],opacity:[0,1]};i="block";break;case"slideRightOut":n={translateX:[0,100],opacity:[1,0]};break;default:n=t;i=t.display;break}anime(Object.assign({targets:e,duration:200,easing:"linear"},n)).finished.then(function(){e.display(i);a&&a()})};const d={get:function(e){return localStorage.getItem(e)},set:function(e,t){localStorage.setItem(e,t);return t},del:function(e){localStorage.removeItem(e)}};const u=function(e,t){t=t||document;if(e.indexOf("#")===0){return t.getElementById(e.replace("#",""))}return t.querySelector(e)};u.all=function(e,t){t=t||document;return t.querySelectorAll(e)};u.each=function(e,t,a){return u.all(e,a).forEach(t)};Object.assign(HTMLElement.prototype,{createChild:function(e,t,a){var n=document.createElement(e);Object.assign(n,t);switch(a){case"after":this.insertAfter(n);break;case"replace":this.innerHTML="";default:this.appendChild(n)}return n},wrap:function(e){var t=document.createElement("div");Object.assign(t,e);this.parentNode.insertBefore(t,this);this.parentNode.removeChild(this);t.appendChild(this)},height:function(e){if(e){this.style.height=typeof e=="number"?e+"rem":e}return this.getBoundingClientRect().height},width:function(e){if(Line truncated
i.addEventListener("click",function(t){var a=t.currentTarget;if(e.hasClass("breakline")){e.removeClass("breakline");a.child(".ic").className="ic i-align-left"}else{e.addClass("breakline");a.child(".ic").className="ic i-align-justify"}});var r=e.child(".fullscreen-btn");var s=function(){e.removeClass("fullscreen");e.scrollTop=0;w.removeClass("fullscreen");r.child(".ic").className="ic i-expand"};var o=function(t){var a=t.currentTarget;if(e.hasClass("fullscreen")){s();u&&u();c(e)}else{e.addClass("fullscreen");w.addClass("fullscreen");r.child(".ic").className="ic i-compress";d&&d()}};r.addEventListener("click",o);a&&a.addEventListener("click",o);if(t&&t.find("tr").length>15){t.style.maxHeight="300px";t.insertAdjacentHTML("beforeend",'<div class="show-btn"><i class="ic i-angle-down"></i></div>');var l=t.child(".show-btn");var d=function(){t.style.maxHeight="";l.addClass("open")};var u=function(){t.style.maxHeight="300px";l.removeClass("open")};l.addEventListener("click",function(e){if(l.hasClass("open")){s();u();c(t)}else{d()}})}});u.each("pre.mermaid > svg",function(e){e.style.maxWidth=""});u.each(".reward button",function(e){e.addEventListener("click",function(e){e.preventDefault();var t=u("#qr");if(t.display()==="inline-flex"){l(t,0)}else{l(t,1,function(){t.display("inline-flex")})}})});u.each(".quiz > ul.options li",function(e){e.addEventListener("click",function(t){if(e.hasClass("correct")){e.toggleClass("right");e.parentNode.parentNode.addClass("show")}else{e.toggleClass("wrong")}})});u.each(".quiz > p",function(e){e.addEventListener("click",function(t){e.parentNode.toggleClass("show")})});u.each(".quiz > p:first-child",function(e){var t=e.parentNode;var a="choice";if(t.hasClass("true")||t.hasClass("false"))a="true_false";if(t.hasClass("multi"))a="multiple";if(t.hasClass("fill"))a="gap_fill";if(t.hasClass("essay"))a="essay";e.attr("data-type",LOCAL.quiz[a])});u.each(".quiz .mistake",function(e){e.attr("data-type",LOCAL.quiz.mistake)});u.each("div.tags a",function(e){e.className=["primary","success","info","warning","danger"][Math.floor(Math.random()*5)]});u.each(".md div.player",function(e){p(e,{type:e.attr("data-type"),mode:"order",btns:[]}).player.load(JSON.parse(e.attr("data-src"))).fetch()})};const he=function(){var e;u.each("div.tab",function(t,a){if(t.attr("data-ready"))return;var n=t.attr("data-id");var i=t.attr("data-title");var r=u("#"+n);if(!r){r=document.createElement("div");r.className="tabs";r.id=n;r.innerHTML='<div class="show-btn"></div>';var s=r.child(".show-btn");s.addEventListener("click",function(e){c(r)});t.parentNode.insertBefore(r,t);e=true}else{e=false}var o=r.child(".nav ul");if(!o){o=r.createChild("div",{className:"nav",innerHTML:"<ul></ul>"}).child("ul")}var l=o.createChild("li",{innerHTML:i});if(e){l.addClass("active");t.addClass("active")}l.addEventListener("click",function(e){var a=e.currentTarget;r.find(".active").forEach(function(e){e.removeClass("active")});t.addClass("active");a.addClass("active")});r.appendChild(t);t.attr("data-ready",true)})};const pe=function(){var e=u("#comments");if(!e){A.display("none");return}else{A.display("")}if(!window.IntersectionObserver){s("valine")}else{var t=new IntersectionObserver(function(e,t){var a=e[0];s("valine");if(a.isIntersecting||a.intersectionRatio>0){l(u("#comments"),"bounceUpIn");t.disconnect()}});t.observe(e)}};const me=function(t){if(e.search===null)return;if(!q){q=w.createChild("div",{id:"search",innerHTML:'<div class="inner"><div class="header"><span class="icon"><i class="ic i-search"></i></span><div class="search-input-container"></div><span class="close-btn"><i class="ic i-times-circle"></i></span></div><div class="results"><div class="inner"><div id="search-stats"></div><div id="search-hits"></div><div id="search-pagination"></div></div></div></div>'})}var a=instantsearch({indexName:e.search.indexName,searchClient:algoliasearch(e.search.appID,e.search.apiKey),searchFunction:function(e){var t=u(".search-input");if(t.value){e.search()}}});a.on("render",function(){t.refresh(u("#search-hits"))});a.addWidgets([instantsearch.widgets.configure({hitsPerPage:e.search.hits.per_page||10}),instantsearch.widgets.searchBox({container:".search-input-container",placeholder:LOCAL.search.placeholder,showReset:false,showSubmit:false,showLoadingIndicator:false,cssClasses:{input:"search-input"}}),instantsearch.widgets.stats({container:"#search-stats",templates:{text:function(e){var t=LOCAL.search.stats.replace(/\$\{hits}/,e.nbHits).replace(/\$\{time}/,e.processingTimeMS);return t+'<span class="algolia-powered"></span><hr>'}}}),instantsearch.widgets.hits({container:"#search-hits",templates:{item:function(t){var a=t.categories?"<span>"+t.categories.join('<i class="ic i-angle-right"></i>')+"</span>":"";return'<a href="'+e.root+t.path+'">'+a+t._highlightResult.title.value+"</a>"},empty:function(e){return'<div id="hits-empty">'+LOCAL.search.empty.replace(/\$\{query}/,e.query)+"</div>"}},cssClasses:{item:"item"}}),instantsearch.widgets.pagination(Line truncated
var e={version:"0.0.0",hostname:"https://hitoli.com",root:"/",statics:"/",favicon:{normal:"images/favicon.ico",hidden:"images/failure.ico"},darkmode:false,auto_scroll:true,js:{valine:"gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js",chart:"npm/frappe-charts@1.5.0/dist/frappe-charts.min.iife.min.js",copy_tex:"npm/katex@0.12.0/dist/contrib/copy-tex.min.js",fancybox:"combine/npm/jquery@3.5.1/dist/jquery.min.js,npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js,npm/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js"},css:{valine:"css/comment.css",katex:"npm/katex@0.12.0/dist/katex.min.css",mermaid:"css/mermaid.css",fancybox:"combine/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css,npm/justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css"},loader:{start:true,"switch":true},search:{appID:"2NU6BAFQUF",apiKey:"47a93cc6d8d1e77bd82d36e8365788dc",indexName:"blog",hits:{per_page:10}},valine:{appId:"pFJTr97i45HCNkAPfurKR0rS-gzGzoHsz",appKey:"9LsEPqi4hHCtghqzc7qDLyNV",placeholder:"ヽ(○´∀`)ノ♪欢迎畅所欲言",avatar:"mp",pageSize:10,lang:"zh-CN",visitor:true,NoRecordIP:false,serverURLs:null,powerMode:true,tagMeta:{visitor:"新朋友",master:"博主",friend:"小伙伴",investor:"金主粑粑"},tagColor:{master:"var(--color-orange)",friend:"var(--color-aqua)",investor:"var(--color-pink)"},tagMember:{master:["d2d281bfc950fb3d79ff50c5e2c7bd89"],friend:null,investor:null}},quicklink:{timeout:3e3,priority:true},audio:[{title:"博主喜欢",list:["https://nas.hitoli.com:18021/nas-dispatcher/common/listMusic?playlistName=我的最爱"]},{title:"网易云音乐",list:["https://music.163.com/#/playlist?id=5172410111","https://music.163.com/#/discover/toplist?id=19723756"]}],fireworks:["rgba(255,182,185,.9)","rgba(250,227,217,.9)","rgba(187,222,214,.9)","rgba(138,198,209,.9)"]};const t=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};const a=function(){return u("main > .inner").offsetHeight};const n=function(e,t,a){if(a){t()}else{var n=document.createElement("script");n.onload=n.onreadystatechange=function(e,a){if(a||!n.readyState||/loaded|complete/.test(n.readyState)){n.onload=n.onreadystatechange=null;n=undefined;if(!a&&t)setTimeout(t,0)}};n.src=e;document.head.appendChild(n)}};const i=function(t,a){var n=e[t][a];if(n.indexOf("npm")>-1||n.indexOf("gh")>-1||n.indexOf("combine")>-1)return"//cdn.jsdelivr.net/"+n;if(n.indexOf("http")>-1)return n;return m+n};const r=function(e,t,a){if(LOCAL[e]){n(i("js",e),t||function(){window[e]=true},a||window[e])}};const s=function(e,t){if(window["css"+e])return;if(LOCAL[e]){document.head.createChild("link",{rel:"stylesheet",href:i("css",e)});window["css"+e]=true}};const o=function(e){var t=e.text||e.textContent||e.innerHTML||"";var a=e.parentNode;a.removeChild(e);var n=document.createElement("script");if(e.id){n.id=e.id}if(e.className){n.className=e.className}if(e.type){n.type=e.type}if(e.src){n.src=e.src;n.async=false}if(e.dataset.pjax!==undefined){n.dataset.pjax=""}if(t!==""){n.appendChild(document.createTextNode(t))}a.appendChild(n)};const c=function(e,t,a){var n={targets:typeof t=="number"?e.parentNode:document.scrollingElement,duration:500,easing:"easeInOutQuad",scrollTop:t||(typeof e=="number"?e:e?e.top()+document.documentElement.scrollTop-R:0),complete:function(){a&&a()}};anime(n)};const l=function(e,t,a){var n={};var i="none";switch(t){case 0:n={opacity:[1,0]};break;case 1:n={opacity:[0,1]};i="block";break;case"bounceUpIn":n={begin:function(t){e.display("block")},translateY:[{value:-60,duration:200},{value:10,duration:200},{value:-5,duration:200},{value:0,duration:200}],opacity:[0,1]};i="block";break;case"shrinkIn":n={begin:function(t){e.display("block")},scale:[{value:1.1,duration:300},{value:1,duration:200}],opacity:1};i="block";break;case"slideRightIn":n={begin:function(t){e.display("block")},translateX:[100,0],opacity:[0,1]};i="block";break;case"slideRightOut":n={translateX:[0,100],opacity:[1,0]};break;default:n=t;i=t.display;break}anime(Object.assign({targets:e,duration:200,easing:"linear"},n)).finished.then(function(){e.display(i);a&&a()})};const d={get:function(e){return localStorage.getItem(e)},set:function(e,t){localStorage.setItem(e,t);return t},del:function(e){localStorage.removeItem(e)}};const u=function(e,t){t=t||document;if(e.indexOf("#")===0){return t.getElementById(e.replace("#",""))}return t.querySelector(e)};u.all=function(e,t){t=t||document;return t.querySelectorAll(e)};u.each=function(e,t,a){return u.all(e,a).forEach(t)};Object.assign(HTMLElement.prototype,{createChild:function(e,t,a){var n=document.createElement(e);Object.assign(n,t);switch(a){case"after":this.insertAfter(n);break;case"replace":this.innerHTML="";default:this.appendChild(n)}return n},wrap:function(e){var t=document.createElement("div");Object.assign(t,e);this.parentNode.insertBefore(t,this);this.parentNode.removeChild(this);t.appendChild(this)},height:function(e){if(e){this.style.height=typeof e=="number"?e+"rem":e}return this.getBoundingCliLine truncated
}});var r=e.child(".fullscreen-btn");var s=function(){e.removeClass("fullscreen");e.scrollTop=0;w.removeClass("fullscreen");r.child(".ic").className="ic i-expand"};var o=function(t){var a=t.currentTarget;if(e.hasClass("fullscreen")){s();u&&u();c(e)}else{e.addClass("fullscreen");w.addClass("fullscreen");r.child(".ic").className="ic i-compress";d&&d()}};r.addEventListener("click",o);a&&a.addEventListener("click",o);if(t&&t.find("tr").length>15){t.style.maxHeight="300px";t.insertAdjacentHTML("beforeend",'<div class="show-btn"><i class="ic i-angle-down"></i></div>');var l=t.child(".show-btn");var d=function(){t.style.maxHeight="";l.addClass("open")};var u=function(){t.style.maxHeight="300px";l.removeClass("open")};l.addEventListener("click",function(e){if(l.hasClass("open")){s();u();c(t)}else{d()}})}});u.each("pre.mermaid > svg",function(e){e.style.maxWidth=""});u.each(".reward button",function(e){e.addEventListener("click",function(e){e.preventDefault();var t=u("#qr");if(t.display()==="inline-flex"){l(t,0)}else{l(t,1,function(){t.display("inline-flex")})}})});u.each(".quiz > ul.options li",function(e){e.addEventListener("click",function(t){if(e.hasClass("correct")){e.toggleClass("right");e.parentNode.parentNode.addClass("show")}else{e.toggleClass("wrong")}})});u.each(".quiz > p",function(e){e.addEventListener("click",function(t){e.parentNode.toggleClass("show")})});u.each(".quiz > p:first-child",function(e){var t=e.parentNode;var a="choice";if(t.hasClass("true")||t.hasClass("false"))a="true_false";if(t.hasClass("multi"))a="multiple";if(t.hasClass("fill"))a="gap_fill";if(t.hasClass("essay"))a="essay";e.attr("data-type",LOCAL.quiz[a])});u.each(".quiz .mistake",function(e){e.attr("data-type",LOCAL.quiz.mistake)});u.each("div.tags a",function(e){e.className=["primary","success","info","warning","danger"][Math.floor(Math.random()*5)]});u.each(".md div.player",function(e){p(e,{type:e.attr("data-type"),mode:"order",btns:[]}).player.load(JSON.parse(e.attr("data-src"))).fetch()})};const he=function(){var e;u.each("div.tab",function(t,a){if(t.attr("data-ready"))return;var n=t.attr("data-id");var i=t.attr("data-title");var r=u("#"+n);if(!r){r=document.createElement("div");r.className="tabs";r.id=n;r.innerHTML='<div class="show-btn"></div>';var s=r.child(".show-btn");s.addEventListener("click",function(e){c(r)});t.parentNode.insertBefore(r,t);e=true}else{e=false}var o=r.child(".nav ul");if(!o){o=r.createChild("div",{className:"nav",innerHTML:"<ul></ul>"}).child("ul")}var l=o.createChild("li",{innerHTML:i});if(e){l.addClass("active");t.addClass("active")}l.addEventListener("click",function(e){var a=e.currentTarget;r.find(".active").forEach(function(e){e.removeClass("active")});t.addClass("active");a.addClass("active")});r.appendChild(t);t.attr("data-ready",true)})};const pe=function(){var e=u("#comments");if(!e){A.display("none");return}else{A.display("")}if(!window.IntersectionObserver){s("valine")}else{var t=new IntersectionObserver(function(e,t){var a=e[0];s("valine");if(a.isIntersecting||a.intersectionRatio>0){l(u("#comments"),"bounceUpIn");t.disconnect()}});t.observe(e)}};const me=function(t){if(e.search===null)return;if(!S){S=w.createChild("div",{id:"search",innerHTML:'<div class="inner"><div class="header"><span class="icon"><i class="ic i-search"></i></span><div class="search-input-container"></div><span class="close-btn"><i class="ic i-times-circle"></i></span></div><div class="results"><div class="inner"><div id="search-stats"></div><div id="search-hits"></div><div id="search-pagination"></div></div></div></div>'})}var a=instantsearch({indexName:e.search.indexName,searchClient:algoliasearch(e.search.appID,e.search.apiKey),searchFunction:function(e){var t=u(".search-input");if(t.value){e.search()}}});a.on("render",function(){t.refresh(u("#search-hits"))});a.addWidgets([instantsearch.widgets.configure({hitsPerPage:e.search.hits.per_page||10}),instantsearch.widgets.searchBox({container:".search-input-container",placeholder:LOCAL.search.placeholder,showReset:false,showSubmit:false,showLoadingIndicator:false,cssClasses:{input:"search-input"}}),instantsearch.widgets.stats({container:"#search-stats",templates:{text:function(e){var t=LOCAL.search.stats.replace(/\$\{hits}/,e.nbHits).replace(/\$\{time}/,e.processingTimeMS);return t+'<span class="algolia-powered"></span><hr>'}}}),instantsearch.widgets.hits({container:"#search-hits",templates:{item:function(t){var a=t.categories?"<span>"+t.categories.join('<i class="ic i-angle-right"></i>')+"</span>":"";return'<a href="'+e.root+t.path+'">'+a+t._highlightResult.title.value+"</a>"},empty:function(e){return'<div id="hits-empty">'+LOCAL.search.empty.replace(/\$\{query}/,e.query)+"</div>"}},cssClasses:{item:"item"}}),instantsearch.widgets.pagination({container:"#search-pagination",scrollTo:false,showFirst:false,showLast:false,templates:{first:'<i class="ic i-angle-double-left"></i>',last:'<i class="ic i-angle-double-right"></i>',previous:'<i class="ic i-angle-left"></i>',next:'<Line truncated
-842
View File
@@ -1,842 +0,0 @@
var NOWPLAYING = null
const isMobile = /mobile/i.test(window.navigator.userAgent);
const mediaPlayer = function(t, config) {
var option = {
type: 'audio',
mode: 'random',
btns: ['play-pause', 'music'],
controls: ['mode', 'backward', 'play-pause', 'forward', 'volume'],
events: {
"play-pause": function(event) {
if(source.paused) {
t.player.play()
} else {
t.player.pause()
}
},
"music": function(event) {
if(info.el.hasClass('show')) {
info.hide()
} else {
info.el.addClass('show');
playlist.scroll().title()
}
}
}
}, utils = {
random: function(len) {
return Math.floor((Math.random()*len))
},
parse: function(link) {
var result = [];
[
['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'],
].forEach(function(rule) {
var patt = new RegExp(rule[0])
var res = patt.exec(link)
if (res !== null) {
result = [rule[1], rule[2], res[1]]
}
})
return result
},
fetch: function(source) {
var list = []
return new Promise(function(resolve, reject) {
source.forEach(function(raw) {
var meta = utils.parse(raw)
if(meta[0]) {
var skey = JSON.stringify(meta)
var playlist = store.get(skey)
if(playlist) {
//自己修改-start
var audioInfos = JSON.parse(playlist);
var neteaseStartUrl = "https://music.163.com/song/media/outer/url?id=";
//如果api.i-meto.com接口不正常并且是网易音乐就自己构建url
if (!t.player.meto && meta[0] == "netease" && audioInfos && audioInfos.length>0 &&
!audioInfos[0].url.startsWith(neteaseStartUrl)) {
audioInfos.forEach(function(audioInfo) {
var id = audioInfo.url.substring(audioInfo.url.indexOf("id=")+3, audioInfo.url.indexOf("&auth="));
audioInfo.url = neteaseStartUrl + id;
audioInfo.pic = "https://p3.music.126.net/Vji3PQJAZ2C7gS_6X51NFQ==/109951164723650033.jpg?param=200y200";
})
} else {
list.push.apply(list, audioInfos);
resolve(list);
}
//自己修改-end
} else {
fetch('https://api.i-meto.com/meting/api?server='+meta[0]+'&type='+meta[1]+'&id='+meta[2]+'&r='+ Math.random())
.then(function(response) {
return response.json()
}).then(function(json) {
store.set(skey, JSON.stringify(json))
list.push.apply(list, json);
resolve(list);
}).catch(function(ex) {})
}
} else {
list.push(raw);
resolve(list);
}
})
})
},
secondToTime: function(second) {
var add0 = function(num) {
return isNaN(num) ? '00' : (num < 10 ? '0' + num : '' + num)
};
var hour = Math.floor(second / 3600);
var min = Math.floor((second - hour * 3600) / 60);
var sec = Math.floor(second - hour * 3600 - min * 60);
return (hour > 0 ? [hour, min, sec] : [min, sec]).map(add0).join(':');
},
nameMap: {
dragStart: isMobile ? 'touchstart' : 'mousedown',
dragMove: isMobile ? 'touchmove' : 'mousemove',
dragEnd: isMobile ? 'touchend' : 'mouseup',
}
}, source = null;
t.player = {
_id: utils.random(999999),
group: true,
// 加载播放列表
load: function(newList) {
var d = ""
var that = this
if(newList && newList.length > 0) {
if(this.options.rawList !== newList) {
this.options.rawList = newList;
playlist.clear()
// 获取新列表
//this.fetch()
}
} else {
// 没有列表时,隐藏按钮
d = "none"
this.pause()
}
for(var el in buttons.el) {
buttons.el[el].display(d)
}
return this
},
fetch: function () {
var that = this;
return new Promise(function(resolve, reject) {
if(playlist.data.length > 0) {
resolve()
} else {
if(that.options.rawList) {
var promises = [];
that.options.rawList.forEach(function(raw, index) {
promises.push(new Promise(function(resolve, reject) {
var group = index
var source
if(!raw.list) {
group = 0
that.group = false
source = [raw]
} else {
that.group = true
source = raw.list
}
utils.fetch(source).then(function(list) {
playlist.add(group, list)
resolve()
})
}))
})
Promise.all(promises).then(function() {
resolve(true)
})
}
}
}).then(function(c) {
if(c) {
playlist.create()
controller.create()
that.mode()
}
})
},
// 根据模式切换当前曲目index
mode: function() {
var total = playlist.data.length;
if(!total || playlist.errnum == total)
return;
var step = controller.step == 'next' ? 1 : -1
var next = function() {
var index = playlist.index + step
if(index > total || index < 0) {
index = controller.step == 'next' ? 0 : total-1;
}
playlist.index = index;
}
var random = function() {
var p = utils.random(total)
if(playlist.index !== p) {
playlist.index = p
} else {
next()
}
}
switch (this.options.mode) {
case 'random':
random()
break;
case 'order':
next()
break;
case 'loop':
if(controller.step)
next()
if(playlist.index == -1)
random()
break;
}
this.init()
},
// 直接设置当前曲目index
switch: function(index) {
if(typeof index == 'number'
&& index != playlist.index
&& playlist.current()
&& !playlist.current().error) {
playlist.index = index;
this.init()
}
},
// 更新source为当前曲目index
init: function() {
var item = playlist.current()
if(!item || item['error']) {
this.mode();
return;
}
var playing = false;
if(!source.paused) {
playing = true
this.stop()
}
source.attr('src', item.url);
source.attr('title', item.name + ' - ' + item.artist);
this.volume(store.get('_PlayerVolume') || '0.7')
this.muted(store.get('_PlayerMuted'))
progress.create()
if(this.options.type == 'audio')
preview.create()
if(playing == true) {
this.play()
}
},
play: function() {
NOWPLAYING && NOWPLAYING.player.pause()
if(playlist.current().error) {
this.mode();
return;
}
var that = this
source.play().then(function() {
playlist.scroll()
}).catch(function(e) {});
},
pause: function() {
source.pause()
document.title = originTitle
},
stop: function() {
source.pause();
source.currentTime = 0;
document.title = originTitle;
},
seek: function(time) {
time = Math.max(time, 0)
time = Math.min(time, source.duration)
if (isNaN(time)) {
time = 0;
}
source.currentTime = time;
progress.update(time / source.duration)
},
muted: function(status) {
if(status == 'muted') {
source.muted = status
store.set('_PlayerMuted', status)
controller.update(0)
} else {
store.del('_PlayerMuted')
source.muted = false
controller.update(source.volume)
}
},
volume: function(percentage) {
if (!isNaN(percentage)) {
controller.update(percentage)
store.set('_PlayerVolume', percentage)
source.volume = percentage
}
},
mini: function() {
info.hide()
}
};
var info = {
el: null,
create: function() {
if(this.el)
return;
this.el = t.createChild('div', {
className: 'player-info',
innerHTML: (t.player.options.type == 'audio' ? '<div class="preview"></div>' : '') + '<div class="controller"></div><div class="playlist"></div>'
}, 'after');
preview.el = this.el.child(".preview");
playlist.el = this.el.child(".playlist");
controller.el = this.el.child(".controller");
},
hide: function() {
var el = this.el
el.addClass('hide');
window.setTimeout(function() {
el.removeClass('show hide')
}, 300);
}
}
var playlist = {
el: null,
data: [],
index: -1,
errnum: 0,
add: function(group, list) {
var that = this
list.forEach(function(item, i) {
item.group = group;
item.name = item.name || item.title || 'Meida name';
item.artist = item.artist || item.author || 'Anonymous';
item.cover = item.cover || item.pic;
item.type = item.type || 'normal';
that.data.push(item);
});
},
clear: function() {
this.data = []
this.el.innerHTML = ""
if(this.index !== -1) {
this.index = -1
t.player.fetch()
}
},
create: function() {
var el = this.el
this.data.map(function(item, index) {
if(item.el)
return
var id = 'list-' + t.player._id + '-'+item.group
var tab = $('#' + id)
if(!tab) {
tab = el.createChild('div', {
id: id,
className: t.player.group ?'tab':'',
innerHTML: '<ol></ol>',
})
if(t.player.group) {
tab.attr('data-title', t.player.options.rawList[item.group]['title'])
.attr('data-id', t.player._id)
}
}
item.el = tab.child('ol').createChild('li', {
title: item.name + ' - ' + item.artist,
innerHTML: '<span class="info"><span>'+item.name+'</span><span>'+item.artist+'</span></span>',
onclick: function(event) {
var current = event.currentTarget;
if(playlist.index === index && progress.el) {
if(source.paused) {
t.player.play();
} else {
t.player.seek(source.duration * progress.percent(event, current))
}
return;
}
t.player.switch(index);
t.player.play();
}
})
return item
})
tabFormat()
},
current: function() {
return this.data[this.index]
},
scroll: function() {
var item = this.current()
var li = this.el.child('li.active')
li && li.removeClass('active')
var tab = this.el.child('.tab.active')
tab && tab.removeClass('active')
li = this.el.find('.nav li')[item.group]
li && li.addClass('active')
tab = this.el.find('.tab')[item.group]
tab && tab.addClass('active')
pageScroll(item.el, item.el.offsetTop)
return this
},
title: function() {
if(source.paused)
return
var current = this.current()
document.title = 'Now Playing...' + current['name'] + ' - ' + current['artist'] + ' | ' + originTitle;
},
error: function() {
var current = this.current()
current.el.removeClass('current').addClass('error')
current.error = true
this.errnum++
}
}
var lyrics = {
el: null,
data: null,
index: 0,
create: function(box) {
var current = playlist.index
var that = this
var raw = playlist.current().lrc
var callback = function(body) {
if(current !== playlist.index)
return;
that.data = that.parse(body)
var lrc = ''
that.data.forEach(function(line, index) {
lrc += '<p'+(index===0?' class="current"':'')+'>'+line[1]+'</p>';
})
that.el = box.createChild('div', {
className: 'inner',
innerHTML: lrc
}, 'replace')
that.index = 0;
}
if(raw && raw.startsWith('http'))
this.fetch(raw, callback)
else
callback(raw)
},
update: function(currentTime) {
if(!this.data)
return
if (this.index > this.data.length - 1 || currentTime < this.data[this.index][0] || (!this.data[this.index + 1] || currentTime >= this.data[this.index + 1][0])) {
for (var i = 0; i < this.data.length; i++) {
if (currentTime >= this.data[i][0] && (!this.data[i + 1] || currentTime < this.data[i + 1][0])) {
this.index = i;
var y = -(this.index-1);
this.el.style.transform = 'translateY('+y+'rem)';
this.el.style.webkitTransform = 'translateY('+y+'rem)';
this.el.getElementsByClassName('current')[0].removeClass('current');
this.el.getElementsByTagName('p')[i].addClass('current');
}
}
}
},
parse: function(lrc_s) {
if (lrc_s) {
lrc_s = lrc_s.replace(/([^\]^\n])\[/g, function(match, p1){return p1 + '\n['});
const lyric = lrc_s.split('\n');
var lrc = [];
const lyricLen = lyric.length;
for (var i = 0; i < lyricLen; i++) {
// match lrc time
const lrcTimes = lyric[i].match(/\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/g);
// match lrc text
const lrcText = lyric[i]
.replace(/.*\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/g, '')
.replace(/<(\d{2}):(\d{2})(\.(\d{2,3}))?>/g, '')
.replace(/^\s+|\s+$/g, '');
if (lrcTimes) {
// handle multiple time tag
const timeLen = lrcTimes.length;
for (var j = 0; j < timeLen; j++) {
const oneTime = /\[(\d{2}):(\d{2})(\.(\d{2,3}))?]/.exec(lrcTimes[j]);
const min2sec = oneTime[1] * 60;
const sec2sec = parseInt(oneTime[2]);
const msec2sec = oneTime[4] ? parseInt(oneTime[4]) / ((oneTime[4] + '').length === 2 ? 100 : 1000) : 0;
const lrcTime = min2sec + sec2sec + msec2sec;
lrc.push([lrcTime, lrcText]);
}
}
}
// sort by time
lrc = lrc.filter(function(item){return item[1]});
lrc.sort(function(a, b){return a[0] - b[0]});
return lrc;
} else {
return [];
}
},
fetch: function(url, callback) {
fetch(url)
.then(function(response) {
return response.text()
}).then(function(body) {
callback(body)
}).catch(function(ex) {})
}
}
var preview = {
el: null,
create: function () {
var current = playlist.current()
this.el.innerHTML = '<div class="cover"><div class="disc"><img src="'+(current.cover)+'" class="blur" /></div></div>'
+ '<div class="info"><h4 class="title">'+current.name+'</h4><span>'+current.artist+'</span>'
+ '<div class="lrc"></div></div>'
this.el.child('.cover').addEventListener('click', t.player.options.events['play-pause'])
lyrics.create(this.el.child('.lrc'))
}
}
var progress = {
el: null,
bar: null,
create: function() {
var current = playlist.current().el
if(current) {
if(this.el) {
this.el.parentNode.removeClass('current')
.removeEventListener(utils.nameMap.dragStart, this.drag)
this.el.remove()
}
this.el = current.createChild('div', {
className: 'progress'
})
this.el.attr('data-dtime', utils.secondToTime(0))
this.bar = this.el.createChild('div', {
className: 'bar',
})
current.addClass('current')
current.addEventListener(utils.nameMap.dragStart, this.drag);
playlist.scroll()
}
},
update: function(percent) {
this.bar.width(Math.floor(percent * 100) + '%')
this.el.attr('data-ptime', utils.secondToTime(percent * source.duration))
},
seeking: function(type) {
if(type)
this.el.addClass('seeking')
else
this.el.removeClass('seeking')
},
percent: function(e, el) {
var percentage = ((e.clientX || e.changedTouches[0].clientX) - el.left()) / el.width();
percentage = Math.max(percentage, 0);
return Math.min(percentage, 1)
},
drag: function(e) {
e.preventDefault()
var current = playlist.current().el
var thumbMove = function(e) {
e.preventDefault()
var percentage = progress.percent(e, current)
progress.update(percentage)
lyrics.update(percentage * source.duration);
};
var thumbUp = function(e) {
e.preventDefault()
current.removeEventListener(utils.nameMap.dragEnd, thumbUp)
current.removeEventListener(utils.nameMap.dragMove, thumbMove)
var percentage = progress.percent(e, current)
progress.update(percentage)
t.player.seek(percentage * source.duration)
source.disableTimeupdate = false
progress.seeking(false)
};
source.disableTimeupdate = true
progress.seeking(true)
current.addEventListener(utils.nameMap.dragMove, thumbMove)
current.addEventListener(utils.nameMap.dragEnd, thumbUp)
}
}
var controller = {
el: null,
btns: {},
step: 'next',
create: function () {
if(!t.player.options.controls)
return
var that = this
t.player.options.controls.forEach(function(item) {
if(that.btns[item])
return;
var opt = {
onclick: function(event){
that.events[item] ? that.events[item](event) : t.player.options.events[item](event)
}
}
switch(item) {
case 'volume':
opt.className = ' ' + (source.muted ? 'off' : 'on')
opt.innerHTML = '<div class="bar"></div>'
opt['on'+utils.nameMap.dragStart] = that.events['volume']
opt.onclick = null
break;
case 'mode':
opt.className = ' ' + t.player.options.mode
break;
default:
opt.className = ''
break;
}
opt.className = item + opt.className + ' btn'
that.btns[item] = that.el.createChild('div', opt)
})
that.btns['volume'].bar = that.btns['volume'].child('.bar')
},
events: {
mode: function(e) {
switch(t.player.options.mode) {
case 'loop':
t.player.options.mode = 'random'
break;
case 'random':
t.player.options.mode = 'order'
break;
default:
t.player.options.mode = 'loop'
}
controller.btns['mode'].className = 'mode ' + t.player.options.mode + ' btn'
store.set('_PlayerMode', t.player.options.mode)
},
volume: function(e) {
e.preventDefault()
var current = e.currentTarget
var drag = false
var thumbMove = function(e) {
e.preventDefault()
t.player.volume(controller.percent(e, current))
drag = true
};
var thumbUp = function(e) {
e.preventDefault()
current.removeEventListener(utils.nameMap.dragEnd, thumbUp)
current.removeEventListener(utils.nameMap.dragMove, thumbMove)
if(drag) {
t.player.muted()
t.player.volume(controller.percent(e, current))
} else {
if (source.muted) {
t.player.muted()
t.player.volume(source.volume)
} else {
t.player.muted('muted')
controller.update(0)
}
}
};
current.addEventListener(utils.nameMap.dragMove, thumbMove)
current.addEventListener(utils.nameMap.dragEnd, thumbUp)
},
backward: function(e) {
controller.step = 'prev'
t.player.mode()
},
forward: function(e) {
controller.step = 'next'
t.player.mode()
},
},
update: function(percent) {
controller.btns['volume'].className = 'volume '+ (!source.muted && percent > 0? 'on' :'off') +' btn'
controller.btns['volume'].bar.width(Math.floor(percent * 100) + '%')
},
percent: function(e, el) {
var percentage = ((e.clientX || e.changedTouches[0].clientX) - el.left()) / el.width();
percentage = Math.max(percentage, 0);
return Math.min(percentage, 1);
}
}
var events = {
onerror: function() {
playlist.error()
t.player.mode()
},
ondurationchange: function() {
if (source.duration !== 1) {
progress.el.attr('data-dtime', utils.secondToTime(source.duration))
}
},
onloadedmetadata: function() {
t.player.seek(0)
progress.el.attr('data-dtime', utils.secondToTime(source.duration))
},
onplay: function() {
t.parentNode.addClass('playing')
showtip(this.attr('title'))
NOWPLAYING = t
},
onpause: function() {
t.parentNode.removeClass('playing')
NOWPLAYING = null
},
ontimeupdate: function() {
if(!this.disableTimeupdate) {
progress.update(this.currentTime / this.duration)
lyrics.update(this.currentTime)
}
},
onended: function(argument) {
t.player.mode()
t.player.play()
}
}
var buttons = {
el: {},
create: function() {
if(!t.player.options.btns)
return
var that = this
t.player.options.btns.forEach(function(item) {
if(that.el[item])
return;
that.el[item] = t.createChild('div', {
className: item + ' btn',
onclick: function(event){
t.player.fetch().then(function() {
t.player.options.events[item](event)
})
}
});
});
}
}
var init = function(config) {
if(t.player.created)
return;
t.player.options = Object.assign(option, config);
t.player.options.mode = store.get('_PlayerMode') || t.player.options.mode
// 初始化button、controls以及click事件
buttons.create()
// 初始化audio or video
source = t.createChild(t.player.options.type, events);
// 初始化播放列表、预览、控件按钮等
info.create();
t.parentNode.addClass(t.player.options.type)
t.player.created = true;
}
init(config)
//自己修改-start
//检查api.i-meto.com接口是否正常
t.player.meto = true;
vendorJs('fancybox', function() {
jQuery.ajax({
url: 'https://api.i-meto.com/meting/api',
type: 'get',
async: true,
timeout: 5000,
complete : function(XMLHttpRequest, status){
if (XMLHttpRequest.status != 200) {
t.player.meto = false;
}
}
});
}, window.jQuery); //加载jquery
//自己修改-end
return t;
}