Jony/assets/js/joe.short.min.js

1 line
16 KiB
JavaScript
Raw Normal View History

2021-05-28 02:23:59 +00:00
function getChildren(t,e){for(let s of t.children)if(s.className===e)return s;return null}document.addEventListener("DOMContentLoaded",()=>{$(".joe_detail__article p:empty").remove(),customElements.define("joe-mtitle",class extends HTMLElement{constructor(){super(),this.innerHTML=`\n\t\t\t\t<span class="joe_mtitle">\n\t\t\t\t\t<span class="joe_mtitle__text">\n\t\t\t\t\t\t${this.getAttribute("title")||"默认标题"}\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t`}}),customElements.define("joe-mp3",class extends HTMLElement{constructor(){super(),this.options={name:this.getAttribute("name"),url:this.getAttribute("url"),theme:this.getAttribute("theme")||"#1989fa",cover:this.getAttribute("cover"),autoplay:!!this.getAttribute("autoplay")},this.render()}render(){if(!this.options.url)return this.innerHTML="音频地址未填写!";this.innerHTML='<span style="display: block" class="_content"></span>',new APlayer({container:getChildren(this,"_content"),theme:this.options.theme,autoplay:this.options.autoplay,audio:[{url:this.options.url,name:this.options.name,cover:this.options.cover}]})}}),customElements.define("joe-music",class extends HTMLElement{constructor(){super(),this.options={id:this.getAttribute("id"),color:this.getAttribute("color")||"#1989fa",autoplay:!!this.getAttribute("autoplay")},this.render()}render(){if(!this.options.id)return this.innerHTML="网易云歌曲ID未填写";this.innerHTML='<span style="display: block" class="_content"></span>',fetch("https://api.i-meto.com/meting/api?server=netease&type=song&id="+this.options.id).then(async t=>{const e=await t.json();new APlayer({container:getChildren(this,"_content"),lrcType:3,theme:this.options.color,autoplay:this.options.autoplay,audio:e})})}}),customElements.define("joe-mlist",class extends HTMLElement{constructor(){super(),this.options={id:this.getAttribute("id"),color:this.getAttribute("color")||"#1989fa",autoplay:!!this.getAttribute("autoplay")},this.render()}render(){if(!this.options.id)return this.innerHTML="网易云歌单ID未填写";this.innerHTML='<span style="display: block" class="_content"></span>',fetch("https://api.i-meto.com/meting/api?server=netease&type=playlist&id="+this.options.id).then(async t=>{const e=await t.json();new APlayer({container:getChildren(this,"_content"),lrcType:3,theme:this.options.color,autoplay:this.options.autoplay,audio:e})})}}),customElements.define("joe-abtn",class extends HTMLElement{constructor(){super(),this.options={icon:this.getAttribute("icon")||"",color:this.getAttribute("color")||"#ff6800",href:this.getAttribute("href")||"#",radius:this.getAttribute("radius")||"17.5px",content:this.getAttribute("content")||"多彩按钮"},this.innerHTML=`\n <a class="joe_abtn" style="background: ${this.options.color}; border-radius: ${this.options.radius}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">\n <span class="joe_abtn__icon">\n <i class="${this.options.icon} fa"></i>\n </span>\n <span class="joe_abtn__content">\n ${this.options.content}\n </span>\n </a>\n `}}),customElements.define("joe-anote",class extends HTMLElement{constructor(){super(),this.options={icon:this.getAttribute("icon")||"fa-download",href:this.getAttribute("href")||"#",type:/^secondary$|^success$|^warning$|^error$|^info$/.test(this.getAttribute("type"))?this.getAttribute("type"):"secondary",content:this.getAttribute("content")||"标签按钮"},this.innerHTML=`\n\t\t\t\t\t<a class="joe_anote ${this.options.type}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">\n\t\t\t\t\t\t<span class="joe_anote__icon">\n\t\t\t\t\t\t\t<i class="fa ${this.options.icon}"></i>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span class="joe_anote__content">\n\t\t\t\t\t\t\t${this.options.content}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</a>\n\t\t\t\t`}}),customElements.define("joe-dotted",class extends HTMLElement{constructor(){super()