From 3351beb61c7dbb914790710906d7db0c523fdf37 Mon Sep 17 00:00:00 2001 From: 135e2 <135e2@135e2.tk> Date: Thu, 29 Dec 2022 17:23:58 +0800 Subject: revert: Revert "chore: load css & js locally..." This reverts commit 45dba0654aa9c8ba210b8d5b80cdc388c408beef. Conflicts: layout/_partial/head.ejs layout/_partial/scripts.ejs --- source/css/shikwasa.chapter.min.css | 1 - source/css/shikwasa.min.css | 1 - source/js/shikwasa.chapter.min.js | 1 - source/js/shikwasa.min.js | 1 - 4 files changed, 4 deletions(-) delete mode 100644 source/css/shikwasa.chapter.min.css delete mode 100644 source/css/shikwasa.min.css delete mode 100644 source/js/shikwasa.chapter.min.js delete mode 100644 source/js/shikwasa.min.js (limited to 'source') diff --git a/source/css/shikwasa.chapter.min.css b/source/css/shikwasa.chapter.min.css deleted file mode 100644 index 40112f6..0000000 --- a/source/css/shikwasa.chapter.min.css +++ /dev/null @@ -1 +0,0 @@ -@-webkit-keyframes stretch{0%,to{box-shadow:0 0}50%{box-shadow:0 -5px}}@keyframes stretch{0%,to{box-shadow:0 0}50%{box-shadow:0 -5px}}.shk .shk-controls_extra .shk-btn.shk-btn_chapter{display:none}.shk[data-has-chapter] .shk-controls_extra .shk-btn.shk-btn_chapter{display:inline-block}.shk-chapter{background:var(--color-theme);border:1px solid rgba(0,41,37,.05);border-radius:2px;bottom:0;box-shadow:0 0 10px rgba(0,41,37,.07);box-sizing:border-box;height:0;left:20px;margin:0 auto;opacity:0;overflow:hidden;position:absolute;right:20px;transition:height .2s ease-in-out,bottom .1s ease-in-out,opacity .1s linear,visibility .1s .2s;visibility:hidden;z-index:0}.shk[data-show-chapter] .shk-chapter{bottom:120px;height:340px;opacity:1;transition:height .2s ease-in-out,bottom .1s ease-in-out,opacity .1s linear;visibility:visible}.shk-btn_close{fill:var(--color-primary);font-size:0;position:absolute;right:4px;top:4px}.shk-btn .shk-icon_close{height:16px;width:16px}.shk-chapter_main{box-sizing:border-box;height:calc(100% - 60px);margin:40px 0 20px;-webkit-mask-image:linear-gradient(180deg,transparent,#202124 5%,#202124 95%,transparent);mask-image:linear-gradient(180deg,transparent,#202124 5%,#202124 95%,transparent);overflow-x:hidden;overflow-y:scroll;padding:0 40px;scroll-behavior:smooth}.shk-chapter_list{box-sizing:border-box;list-style:none;margin:10px 0 0;padding:0}.shk-chapter_item{margin:5px 0}.shk-chapter .shk-chapter_btn{align-items:center;box-sizing:border-box;color:var(--color-text);display:flex;flex-flow:row nowrap;justify-content:flex-start;overflow:hidden;width:100%}.shk-chapter .shk-chapter_btn:after{border-radius:2px}.shk-chapter_btn div{fill:currentColor;color:currentColor}.shk-chapter_item[data-active] .shk-chapter_btn div{color:var(--color-primary);font-weight:600}.shk-icon_chapter{flex-shrink:0;height:12px;width:12px}.shk[data-play=playing] .shk-chapter_item[data-active] .shk-icon_playing,.shk[data-play=playing] .shk-chapter_item[data-active] .shk-icon_playing:after,.shk[data-play=playing] .shk-chapter_item[data-active] .shk-icon_playing:before{display:block}.shk-icon_playing,.shk-icon_playing:after,.shk-icon_playing:before{-webkit-animation:stretch 1s ease-in-out infinite;animation:stretch 1s ease-in-out infinite;background:currentColor;color:currentColor;display:none;height:5px;left:4px;top:6px;width:3px}.shk-icon_playing{-webkit-animation-delay:.16s;animation-delay:.16s;position:relative}.shk-icon_playing:after,.shk-icon_playing:before{content:"";position:absolute;top:0}.shk-icon_playing:before{-webkit-animation-delay:-.16s;animation-delay:-.16s;left:-4px}.shk-icon_playing:after{left:4px}.shk-icon_triangle{align-items:flex-start;display:flex;flex-shrink:0}.shk[data-play=playing] .shk-chapter_item[data-active] .shk-icon_triangle{display:none}.shk-icon_triangle svg{fill:currentColor;height:12px;width:12px}.shk-chapter_duration{color:var(--color-secondary);flex-shrink:0;font-weight:200;margin:0 5%;min-width:60px;text-align:left}.shk-chapter_title_wrap{flex-grow:1;overflow:hidden;white-space:nowrap}.shk-chapter_item[data-active] .shk-chapter_title_wrap[data-overflow]{-webkit-mask-image:linear-gradient(90deg,transparent,#202124 2%,#202124 98%,transparent);mask-image:linear-gradient(90deg,transparent,#202124 2%,#202124 98%,transparent)}.shk-chapter_title_inner{-webkit-animation-duration:inherit;animation-duration:inherit;display:flex}.shk-chapter_item[data-active] .shk-chapter_title_wrap[data-overflow] .shk-chapter_title_inner{box-sizing:border-box;padding:0 3%}.shk-chapter_item[data-active] .shk-chapter_title_wrap[data-overflow] .shk-chapter_title_inner:after{content:attr(data-chapter);display:block}.shk-chapter_title{color:var(--color-text);overflow:hidden;text-align:left;text-overflow:ellipsis}.shk-chapter_item[data-active] .shk-chapter_title{overflow:visible}.shk-chapter_item[data-active] .shk-chapter_title_wrap[data-overflow] .shk-chapter_title,.shk-chapter_item[data-active] .shk-chapter_title_wrap[data-overflow] .shk-chapter_title_inner:after{-webkit-animation:marquee linear infinite;animation:marquee linear infinite;-webkit-animation-duration:inherit;animation-duration:inherit;color:currentColor;padding-right:60px}@media (max-width:640px){.shk-chapter{left:10px;right:10px}.shk-chapter_main{padding:0 10px}} \ No newline at end of file diff --git a/source/css/shikwasa.min.css b/source/css/shikwasa.min.css deleted file mode 100644 index d6deb0f..0000000 --- a/source/css/shikwasa.min.css +++ /dev/null @@ -1 +0,0 @@ -.shk{--color-primary:#0d6efd;--color-opac:#b9b9b94d;--color-theme:#fff;--color-secondary:#767676;--color-text:#333;--color-shadow:#b9b6b680;--color-handle-shadow-mobile:#b9b6b6;--background-body:var(--color-theme);--color-title:var(--color-text);--color-artist:var(--color-secondary);--color-button:var(--color-primary);--color-button-disabled:var(--color-opac);--color-button-active-background:var(--color-opac);--color-handle:var(--color-primary);--color-handle-disabled:#b9b9b9;--color-bar-loaded:var(--color-opac);--color-bar-played:var(--color-primary);--color-time:var(--color-secondary);--color-spinner:var(--color-primary);--color-live-symbol:var(--color-primary);--color-live-text:var(--color-primary);--shadow-body:2px 2px 8px -2px var(--color-shadow);--shadow-body-mobile:0 -2px 6px -2px var(--color-shadow);--shadow-handle:0px 2px 10px 2px var(--color-shadow);--shadow-handle-mobile:2px 2px 8px -2px var(--color-handle-shadow-mobile)}.shk[data-theme=dark]{--color-theme:#333;--color-secondary:#b9b6b6;--color-text:#f8f9fa;--color-handle-shadow-mobile:#141414;--color-shadow:#14141480}@media (prefers-color-scheme:dark){.shk[data-theme=auto]{--color-theme:#333;--color-secondary:#b9b6b6;--color-text:#fff;--color-handle-shadow-mobile:#141414;--color-shadow:#14141480}}@-webkit-keyframes rotate{to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes rotate{to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@-webkit-keyframes marquee{0%{-webkit-transform:translate(0);transform:translate(0)}to{-webkit-transform:translateX(-100%);transform:translateX(-100%)}}@keyframes marquee{0%{-webkit-transform:translate(0);transform:translate(0)}to{-webkit-transform:translateX(-100%);transform:translateX(-100%)}}.shk{border:none;color:var(--color-text);cursor:auto;font-family:inherit;font-size:16px;font-weight:400;line-height:1.42;position:relative}.js-focus-visible :focus:not(.focus-visible),.js-focus-visible:focus:not(.focus-visible){outline:none}.shk[data-fixed-type=fixed]{bottom:0;left:0;margin:0;position:fixed;width:100%}.shk[data-fixed-type=fixed][data-fixed-pos=top]{bottom:auto;top:0}.shk[data-seeking] .shk-player{cursor:grabbing}.shk button{font-family:inherit}.shk-player{background:var(--background-body);border-radius:2px;box-sizing:border-box;height:120px;position:relative;z-index:10}.shk-body{align-items:stretch;display:flex;flex-flow:row nowrap;position:relative;-webkit-user-select:none;-ms-user-select:none;user-select:none;width:100%}.shk-cover{background-repeat:no-repeat;background-size:cover;flex:0 0 auto;height:80px;margin-right:16px;width:80px}.shk-main{display:flex;flex-grow:1;flex-wrap:nowrap;justify-content:flex-start;position:relative}.shk-text{overflow:hidden}.shk-artist,.shk-title{margin:auto;white-space:nowrap}.shk-artist{color:var(--color-artist);font-weight:500;text-overflow:clip}.shk-title_wrap[data-overflow]{-webkit-mask-image:linear-gradient(90deg,transparent,#202124 5%,#202124 95%,transparent);mask-image:linear-gradient(90deg,transparent,#202124 5%,#202124 95%,transparent)}.shk-title_inner{display:inline-flex;overflow:visible}.shk-title_wrap[data-overflow] .shk-title_inner{-webkit-animation-duration:inherit;animation-duration:inherit;box-sizing:border-box;padding:0 3%;white-space:nowrap}.shk-title_wrap[data-overflow] .shk-title_inner:after{content:attr(data-title);display:inline-block}.shk-title,.shk-title_wrap[data-overflow] .shk-title_inner:after{color:var(--color-title);font-size:1.33em;font-weight:300}.shk-title_wrap[data-overflow] .shk-title,.shk-title_wrap[data-overflow] .shk-title_inner:after{-webkit-animation:marquee linear infinite;animation:marquee linear infinite;-webkit-animation-duration:inherit;animation-duration:inherit;padding-right:60px}.shk-btn{fill:currentColor;-webkit-appearance:none;appearance:none;background:transparent;border:none;box-sizing:content-box;color:var(--color-button);cursor:pointer;font-size:1em;line-height:normal;padding:10px;position:relative}.shk-btn:disabled{color:var(--color-button-disabled);cursor:not-allowed}.shk-btn:after{background:var(--color-button-active-background);border-radius:50%;content:"";height:100%;left:50%;opacity:0;pointer-events:none;position:absolute;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);transition:opacity 1s cubic-bezier(0,0,.2,1),visibility 1s linear;visibility:hidden;width:100%;z-index:-1}.shk-btn:not(:disabled):active:after{opacity:1;visibility:visible}a.shk-btn:visited{color:var(--color-button)}.shk-btn svg{height:24px;vertical-align:middle;width:24px}.shk-controls{flex:0 0 auto;margin:0 auto;position:relative;width:280px}.shk-controls .shk-btn{border-radius:100%}.shk-controls>div{align-items:center;display:flex;flex-flow:row nowrap}.shk-controls_basic{justify-content:space-between}.shk-controls_extra{background:var(--background-body);bottom:0;height:100%;justify-content:flex-end;margin-right:44px;opacity:0;overflow:hidden;padding-right:0 8px;position:absolute;right:0;transition:width .2s ease-in-out,opacity .1s linear .1s,visibility .2s;visibility:hidden;white-space:nowrap;width:0;z-index:10}.shk[data-extra] .shk-controls_extra{opacity:1;transition:width .2s ease-in-out,opacity .1s linear;visibility:visible;width:calc(100% - 44px)}.shk[data-extra] .shk-controls_extra .shk-btn{display:inline-block}.shk-btn_toggle svg{height:32px;width:32px}.shk[data-play=paused] .shk-btn_play,.shk[data-play=playing] .shk-btn_pause{display:inline}.shk[data-play=paused] .shk-btn_pause,.shk[data-play=playing] .shk-btn_play{display:none}.shk-btn_speed{font-size:.86em;font-weight:400;height:44px;padding:0;width:44px}.shk-btn_more{position:relative;-webkit-transform:none;transform:none;transition:-webkit-transform .2s .1s;transition:transform .2s .1s;transition:transform .2s .1s,-webkit-transform .2s .1s;z-index:11}.shk[data-extra] .shk-btn_more{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.shk[data-mute] svg.shk-btn_mute,svg.shk-btn_unmute{display:inline-block}.shk[data-mute] svg.shk-btn_unmute,svg.shk-btn_mute{display:none}.shk-bar_wrap{cursor:pointer;position:relative;z-index:1}.shk-bar{background:var(--background-body);box-sizing:border-box;height:4px;position:relative;width:100%}.shk-bar_loaded,.shk-bar_played{bottom:0;left:0;position:absolute;top:0;transition:width .1s ease-in;width:0}.shk-bar_loaded{background:var(--color-bar-loaded)}.shk-bar_played{background:var(--color-bar-played)}.shk[data-seeking] .shk-bar_played{transition:none}.shk-bar-handle{background:var(--color-handle);border:0;border-radius:20px;box-sizing:content-box;cursor:grab;height:20px;padding:0;position:absolute;right:-10px;width:20px}.shk-bar-handle:disabled{background-color:var(--color-handle-disabled);box-shadow:none;cursor:not-allowed}.shk-bar-handle:active{cursor:grabbing}.shk-display{position:absolute}.shk-loader{color:var(--color-spinner);display:none;vertical-align:middle}.shk[data-loading] .shk-loader{display:inline-block}.shk-loader svg{-webkit-animation:rotate 1.4s linear infinite;animation:rotate 1.4s linear infinite;height:12px;position:relative;width:12px}.shk-visuallyhidden:not(:focus):not(:active){clip:rect(0 0 0 0);border:0;-webkit-clip-path:inset(100%);clip-path:inset(100%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.shk-time{color:var(--color-time);display:inline-block;font-size:.8em;font-weight:300;vertical-align:middle}.shk .shk-live{align-items:center;color:var(--color-live-text);display:none;font-family:sans-serif;font-size:.8em;text-transform:uppercase}.shk .shk-live:before{background:var(--color-live-symbol);border-radius:50%;content:"";height:.5em;margin-right:2px;width:.5em}.shk-icons,.shk[data-live] .shk-bar,.shk[data-live] .shk-time{display:none}.shk[data-live] .shk-live{display:inline-flex}@media (min-width:641px){.shk-player{box-shadow:var(--shadow-body);margin-top:4px;padding:20px 16px}.shk-main{align-items:flex-end;flex-direction:row;max-width:calc(100% - 96px);padding:10px 0}.shk-text{flex:2 1 auto}.shk-bar_wrap{left:0;padding:4px 0 16px;position:absolute;right:0;top:-4px}.shk-bar{transition:height .15s ease-in}.shk-bar_wrap:hover .shk-bar{height:10px}.shk-bar-handle{border:4px solid transparent;box-shadow:var(--shadow-handle);top:-9.5px;-webkit-transform:scale(.0001);transform:scale(.0001);transition:all .1s ease-in}.shk-bar-handle.focus-visible,.shk-bar_wrap:hover .shk-bar-handle:not(:disabled){border-color:#fff;-webkit-transform:scale(.8);transform:scale(.8)}.shk-display{right:8px;top:-6px}.shk-loader{margin-right:4px}.shk-time_duration:before{content:"/";margin:0 4px}}@media (max-width:640px){.shk-player{box-shadow:var(--shadow-body-mobile);padding:5px 16px}.shk[data-fixed-type=auto]{bottom:0;left:0;position:fixed;width:100%}.shk[data-fixed-type=auto][data-fixed-pos=top]{bottom:auto;top:0}.shk[data-live] .shk-bar_wrap{height:4px}.shk-cover{display:none}.shk-main{align-items:center;flex-direction:column;max-width:none;padding:0;width:100%}.shk-text{flex:0 0 auto;text-align:center;width:100%}.shk-artist_wrap{font-size:.8em;line-height:1.1}.shk-artist{display:inline-block}.shk-title,.shk-title_wrap[data-overflow] .shk-title_inner:after{font-size:1em;line-height:1}.shk-bar_wrap{margin:0 60px;padding:8px 0}.shk-bar-handle{box-shadow:var(--shadow-handle-mobile);display:inline-block;top:-8px}.shk-bar{background:var(--color-opac);border-radius:2px}.shk-display{left:0;right:0;top:-16px}.shk-loader{left:-10px;position:absolute;top:-5px}.shk-time{display:flex;flex-flow:row nowrap;font-size:.7em;justify-content:space-between;line-height:1;margin:0 5px}.shk-time_now{text-align:right;width:40px}.shk-time_duration{text-align:left;width:40px}.shk-live{position:absolute;right:0;top:0}} \ No newline at end of file diff --git a/source/js/shikwasa.chapter.min.js b/source/js/shikwasa.chapter.min.js deleted file mode 100644 index 070e180..0000000 --- a/source/js/shikwasa.chapter.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):(a="undefined"==typeof globalThis?a||self:globalThis,a.Chapter=b())})(this,function(){"use strict";var a=Math.round;function b(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function c(a){for(var c,e=1;ee?"0"+e:e,f=10>f?"0"+f:f,0===d)?"".concat(e,":").concat(f):(d=10>d?"0"+d:d,"".concat(d,":").concat(e,":").concat(f))}function f(a,b){var c=2{b.classList.add(a)})),a.attrs&&Object.keys(a.attrs).forEach(c=>{b.setAttribute(c,a.attrs[c])}),a.innerHTML&&(b.innerHTML=a.innerHTML),b}function h(a,b){return"function"==typeof a.toggleAttribute?void a.toggleAttribute(b):void(a.hasAttribute(b)?a.removeAttribute(b):a.setAttribute(b,""))}function i(a,b,c,d,e,f){var g=(a-b)/1e3/c;f.scrollTop=d+e*g,1>g&&window.requestAnimationFrame(a=>{i(a,b,c,d,e,f)})}var j;class k{constructor(a){this.ctx=a,this.list=[],this.initEvents(),this.current=null,this._currentSrc=null,this._chapterPatched=!1}init(){this.patchPlayer(),this.ui=new l(this.ctx),this.ctx.on("chapterchange",a=>{var b=a&&a.newVal?a.newVal.id:null;this.ui.setChapterActive(b)})}initEvents(){this.ctx.on("audioupdate",a=>{this._chapterPatched||(this.init(),this._chapterPatched=!0),this.updateList(a)}),this.ctx.on("audioparse",a=>{this.updateList(a)}),this.ctx.on("timeupdate",this.onTimeupdate.bind(this))}clearList(){this.ui.chapterList.innerHTML="",this.list=[],this.current=null}updateList(a){this.list.length&&this.clearList(),a.chapters.length&&(this.list=this.handleChapters(a),this.ui.renderChapterList(this.ctx.chapters),this.clickChapterHandler()),this.ui.handleChapterPanel(this.ctx,a)}handleChapters(a){if(a.chapters&&a.chapters.length)return a.chapters.map((a,b)=>(/^ch\d+$/.test(a.id)||(a.id="ch".concat(b)),a))}patchPlayer(){var a=this;Object.defineProperties(this.ctx,{chapters:{get(){return a.list}},currentChapter:{get(){return a.current}}}),this.ctx.events.playerEvents.push("chapterchange"),this.ctx.updateChapter=function(a){this.setCurrent(this.list[a]),this.ctx.seek(this.current.startTime),this.ctx.play()}.bind(a)}setCurrent(a){var b=this.current?c({},this.current):null;this.current=a,this.ctx.events.trigger("chapterchange",{newVal:this.current,oldVal:b})}onTimeupdate(a){if(this._currentSrc!==a.currentTarget.src)return void(this._currentSrc=a.currentTarget.src);var b=this.searchDirection(this.ctx.currentTime,this.current);if(b){var c,d=this.list.indexOf(this.current);c=-1===d?this.list:1===b?this.list.slice(d):this.list.slice(0,d+1);var e=c.find(a=>!this.searchDirection(this.ctx.currentTime,a));this.setCurrent(e)}}searchDirection(b,c){return b=a(b),!c||"object"!=typeof c||c.endTime<=b?1:c.startTime>b?-1:0}clickChapterHandler(){Array.from(this.ui.chapterList.children).forEach(a=>{a.addEventListener("click",()=>{if(this.ctx.seekable){var b=a.getAttribute("data-id").match(/\d+$/);b&&this.ctx.updateChapter(+b[0])}})})}destroy(){this.ui.destroy()}}class l{constructor(a,b){this.initEl(a),this.initEvents(a,b),this.renderChapterList(a.chapters),a.ui.el.append(this.el),this.activeChapterEl=null}initEl(a){this.el=g({className:"shk-chapter",innerHTML:"\n
\n
    \n
    \n \n"});var b={title:"view chapters","aria-label":"view chapters"};a.seekable||(b.disabled=""),this.chapterBtn=g({tag:"button",className:["shk-btn","shk-btn_chapter"],attrs:b,innerHTML:"\n \n \n \n "}),a.ui.seekControls.push(this.chapterBtn),a.ui.extraControls.append(this.chapterBtn),this.closeBtn=this.el.querySelector(".shk-btn_close"),this.chapterList=this.el.querySelector(".shk-chapter_list"),this.overflowLayer=this.el.querySelector(".shk-chapter_main")}initEvents(a){this.chapterBtn.addEventListener("click",()=>{h(a.el,"data-show-chapter")}),a.ui.hideExtraControl(this.chapterBtn),this.closeBtn.addEventListener("click",()=>{a.el.removeAttribute("data-show-chapter")}),j=()=>{if(this.activeChapterEl){var a=this.activeChapterEl.querySelector(".shk-chapter_title_wrap"),b=this.activeChapterEl.querySelector(".shk-chapter_title");f.call(this,a,b)}},window.addEventListener("resize",j)}handleChapterPanel(a,b){b.chapters.length?a.el.setAttribute("data-has-chapter",""):a.el.removeAttribute("data-has-chapter"),b.chapters.length&&a.seekable||a.el.removeAttribute("data-show-chapter")}renderChapterList(a){a.length&&a.forEach(a=>{var b=this.renderChapterItem(a);this.chapterList.append(b)})}renderChapterItem(a){var b=e(a.startTime),c="\n \n ");return g({tag:"li",className:"shk-chapter_item",innerHTML:c,attrs:{"data-id":a.id}})}setChapterActive(a){this.chapterList.querySelectorAll(".shk-chapter_item").forEach(b=>{if(b.getAttribute("data-id")===a){b.setAttribute("data-active",""),this.scrollIntoView(b),this.activeChapterEl=b;var c=b.querySelector(".shk-chapter_title"),d=b.querySelector(".shk-chapter_title_wrap");f(d,c)}else b.removeAttribute("data-active")})}scrollIntoView(a){if("hidden"!==this.el.style.visibility){var b=window.getComputedStyle(this.overflowLayer).marginTop,c=window.getComputedStyle(this.chapterList).marginTop,d=parseInt(b)+parseInt(c),e=0e?"0"+e:e,f=10>f?"0"+f:f,0===d)?"".concat(e,":").concat(f):(d=10>d?"0"+d:d,"".concat(d,":").concat(e,":").concat(f))}function f(a){var b=parseFloat(a).toFixed(2);return"0"===b.slice(-1)?b.slice(0,-1):b}function g(a,b){var c=2{b[a]=b[a]||"boolean"==typeof b[a]?b[a]:r[a]}),"function"==typeof b.container&&(b.container=b.container());var c=s.fixedOptions.find(a=>a===b.fixed.type);return c||(b.fixed.type=r.fixed.type),Array.isArray(b.speedOptions)||(b.speedOptions=[b.speedOptions]),-1===b.speedOptions.indexOf(1)&&b.speedOptions.push(1),b.speedOptions=b.speedOptions.map(a=>parseFloat(a)).filter(a=>!isNaN(a)),1c-a),b}function i(){var a=0{c[a]=c[a]||b[a]||s.audioOptions[a]}),c}function j(){return k.apply(this,arguments)}function k(){return k=d(function*(){var a=0{b.read(a,{onSuccess:c,onError:d})})}function m(){var a,b,c,d=0"CHAP"===a.id).map(a=>!!(a.data&&a.data.subFrames&&a.data.subFrames.TIT2)&&{id:a.data.id,startTime:a.data.startTime/1e3,endTime:a.data.endTime/1e3,title:a.data.subFrames.TIT2.data}).sort((c,a)=>c.id-a.id)),{title:e,artist:f,cover:a,duration:c,chapters:b}}function n(a){a.tag=a.tag||"div";var b=document.createElement(a.tag);return a.className&&("string"==typeof a.className?b.classList.add(a.className):a.className.forEach(a=>{b.classList.add(a)})),a.attrs&&Object.keys(a.attrs).forEach(c=>{b.setAttribute(c,a.attrs[c])}),a.innerHTML&&(b.innerHTML=a.innerHTML),b}function o(a,b){return"function"==typeof a.toggleAttribute?void a.toggleAttribute(b):void(a.hasAttribute(b)?a.removeAttribute(b):a.setAttribute(b,""))}function p(a,b){function c(a){return!!(a&&a!==document&&"HTML"!==a.nodeName&&"BODY"!==a.nodeName&&"classList"in a&&"contains"in a.classList)}function d(a){a.classList.contains("focus-visible")||(a.classList.add("focus-visible"),a.setAttribute("data-focus-visible-added",""))}function f(a){a.hasAttribute("data-focus-visible-added")&&(a.classList.remove("focus-visible"),a.removeAttribute("data-focus-visible-added"))}function g(){n=!1}function h(a){!c(a.target)||n&&d(a.target)}function i(a){!c(a.target)||(a.target.classList.contains("focus-visible")||a.target.hasAttribute("data-focus-visible-added"))&&(o=!0,window.clearTimeout(p),p=window.setTimeout(function(){o=!1},100),f(a.target))}function j(){"hidden"===document.visibilityState&&(o&&(n=!0),k())}function k(){a.addEventListener("mousemove",m),a.addEventListener("mousedown",m),a.addEventListener("mouseup",m),a.addEventListener("pointermove",m),a.addEventListener("pointerdown",m),a.addEventListener("pointerup",m),a.addEventListener("touchmove",m,!!b&&{passive:!0}),a.addEventListener("touchstart",m,!!b&&{passive:!0}),a.addEventListener("touchend",m,!!b&&{passive:!0})}function l(c){a.removeEventListener("mousemove",m),a.removeEventListener("mousedown",m),a.removeEventListener("mouseup",m),a.removeEventListener("pointermove",c),a.removeEventListener("pointerdown",m),a.removeEventListener("pointerup",m),a.removeEventListener("touchmove",m,!!b&&{passive:!0}),a.removeEventListener("touchstart",m,!!b&&{passive:!0}),a.removeEventListener("touchend",m,!!b&&{passive:!0})}function m(){n=!1,l()}var n=!0,o=!1,p=null;a.addEventListener("keydown",function(b){b.metaKey||b.altKey||b.ctrlKey||(c(document.activeElement)&&a.contains(document.activeElement)&&d(document.activeElement),n=!0)},!0),a.addEventListener("mousedown",g,!0),a.addEventListener("pointerdown",g,!0),a.addEventListener("touchstart",g,!b||{passive:!0,capture:!0}),a.addEventListener("visibilitychange",j,!0),k(),a.addEventListener("focus",h,!0),a.addEventListener("blur",i,!0),a.classList.add("js-focus-visible")}var q,r={container:()=>document.querySelector("body"),parser:null,fixed:{type:"auto",position:"bottom"},download:!1,themeColor:"#0d6efd",theme:"auto",autoPlay:!1,muted:!1,preload:"metadata",speedOptions:[.5,.75,1,1.25,1.5],audio:null},s={fixedOptions:["auto","static","fixed"],audioOptions:{title:"Unknown Title",artist:"Unknown Artist",duration:NaN,cover:null,chapters:[],src:null,album:"",live:!1}},t=null,u=!0;class v{constructor(a){this.mounted=!1,this.icons=n({className:"shk-icons",innerHTML:"\n \n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n\n \n \n \n \n"}),this.initEl(),this.initOptions(a)}initEl(){var a=this;return d(function*(){a.el=n({className:["shk","shikwasa"],attrs:{"data-name":"shikwasa"},innerHTML:"\n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n \n \n \n \n
    \n
    \n \n
    \n
    \n
    \n \n loading\n \n \n \n \n \n \n \n \n \n \n 00:0000:00\n \n
    live
    \n
    \n
    \n
    \n
    \n"}),a.playBtn=a.el.querySelector(".shk-btn_toggle"),a.fwdBtn=a.el.querySelector(".shk-btn_forward"),a.bwdBtn=a.el.querySelector(".shk-btn_backward"),a.speedBtn=a.el.querySelector(".shk-btn_speed"),a.moreBtn=a.el.querySelector(".shk-btn_more"),a.muteBtn=a.el.querySelector(".shk-btn_volume"),a.extraControls=a.el.querySelector(".shk-controls_extra"),a.texts=a.el.querySelector(".shk-text"),a.artist=a.el.querySelector(".shk-artist"),a.artistWrap=a.el.querySelector(".shk-artist_wrap"),a.titleWrap=a.el.querySelector(".shk-title_wrap"),a.titleInner=a.el.querySelector(".shk-title_inner"),a.title=a.el.querySelector(".shk-title"),a.currentTime=a.el.querySelector(".shk-time_now"),a.duration=a.el.querySelector(".shk-time_duration"),a.bar=a.el.querySelector(".shk-bar"),a.barWrap=a.el.querySelector(".shk-bar_wrap"),a.audioPlayed=a.el.querySelector(".shk-bar_played"),a.audioLoaded=a.el.querySelector(".shk-bar_loaded"),a.handle=a.el.querySelector(".shk-bar-handle"),a.cover=a.el.querySelector(".shk-cover"),a.seekControls=[a.fwdBtn,a.bwdBtn,a.handle]})()}initOptions(a){this.el.style="--color-primary: ".concat(a.themeColor),this.el.setAttribute("data-theme",a.theme),a.download&&a.audio&&a.audio.src&&(this.downloadBtn=n({tag:"a",className:["shk-btn","shk-btn_download"],attrs:{title:"download","aria-label":"download",href:"string"==typeof a.download?a.download:a.audio.src,download:"",target:"_blank",rel:"noopener noreferrer"},innerHTML:"\n \n \n \n "}),this.extraControls.append(this.downloadBtn)),this.el.setAttribute("data-fixed-type",a.fixed.type),"static"!==a.fixed.type&&"top"===a.fixed.position&&this.el.setAttribute("data-fixed-pos",a.fixed.position);var b=a.autoPlay?"playing":"paused";this.el.setAttribute("data-play",b),a.muted&&this.el.setAttribute("data-mute","")}initEvents(a){this.moreBtn.addEventListener("click",()=>{o(this.el,"data-extra")}),Array.from(this.extraControls.children).forEach(a=>{this.hideExtraControl(a)}),p(this.el,a),q=()=>{u&&(u=!1,setTimeout(()=>u=!0,100),g.call(this,this.titleWrap,this.title))},window.addEventListener("resize",q)}setAudioInfo(){var a=0{setTimeout(()=>{this.el.removeAttribute("data-extra")},800)})}mount(a,b){a.innerHTML="",a.append(this.el),this.icons&&a.append(this.icons),this.mounted=!0,this.initEvents(b),g(this.titleWrap,this.title)}destroy(){window.removeEventListener("resize",q),t&&URL.revokeObjectURL(t)}}class w{constructor(){this.audioEvents=["abort","canplay","canplaythrough","complete","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],this.playerEvents=["audioupdate","audioparse"],this.events={}}on(a,b){this.type(a)&&"function"==typeof b&&(!this.events[a]&&(this.events[a]=[]),this.events[a].push(b))}trigger(a){var b=1a(b))}type(a){return-1===this.playerEvents.indexOf(a)?-1===this.audioEvents.indexOf(a)?(console.error("Shikwasa: unknown event name: ".concat(a)),null):"audio":"player"}}var x=[],y=[],z="undefined"!=typeof window&&/mobile/i.test(window.navigator.userAgent),A=z?"touchstart":"mousedown",B=z?"touchmove":"mousemove",C=z?"touchend":"mouseup",D=!1;if("undefined"!=typeof window)try{var E=Object.defineProperty({},"passive",{get:function(){return D=!0,!1}});window.addEventListener("testPassvie",null,E),window.removeEventListener("testPassvie",null,E)}catch(a){D=!1}var F=D&&z;class G{constructor(a){this.id=x.length,x.push(this),this.comps={},this._audio={},this._hasMediaSession=!1,this._initSeek=0,this.live=!1,this._canplay=!1,this._dragging=!1,this.events=new w,this.options=h(a),this.renderComponents(),this.initUI(this.options),this.initAudio(),this.ui.mount(this.options.container,D)}get duration(){return this.audio&&this.audio.duration?this.audio.duration:this._audio.duration}get seekable(){return!this.live&&!!this.duration}set seekable(a){a?this.ui.seekControls.forEach(a=>{a.removeAttribute("disabled")}):this.ui.seekControls.forEach(a=>{a.setAttribute("disabled","")})}get currentTime(){return this.audio?this.audio.currentTime:void 0}get playbackRate(){return this.audio?this.audio.playbackRate:void 0}set playbackRate(a){this.audio&&(this.audio.playbackRate=a,this.audio.defaultPlaybackRate=a)}get muted(){return this.audio?this.audio.muted:void 0}set muted(a){this.audio&&(this.audio.muted=a,this.audio.defaultMuted=a)}initUI(){this.ui=new v(this.options),this.el=this.ui.el,this.initControlEvents(),this.initBarEvents()}initControlEvents(){this.ui.playBtn.addEventListener("click",()=>{this.toggle()}),this.ui.muteBtn.addEventListener("click",()=>{this.muted=!this.muted,o(this.el,"data-mute")}),this.ui.fwdBtn.addEventListener("click",()=>{this.seekBySpan()}),this.ui.bwdBtn.addEventListener("click",()=>{this.seekBySpan({forward:!1})}),this.ui.speedBtn.addEventListener("click",()=>{var a=this.options.speedOptions.indexOf(this.playbackRate),b=this.options.speedOptions;this.playbackRate=a+1>=b.length?b[0]:b[a+1],this.ui.setSpeed(this.playbackRate)})}initBarEvents(){var a=0,b=a=>{this.ui.setProgress(null,this.ui.getPercentByPos(a),this.duration)},c=d=>{d.preventDefault(),document.removeEventListener(B,b),document.removeEventListener(C,c),a=this.ui.getPercentByPos(d)*this.duration,this.seek(a),this._dragging=!1,setTimeout(()=>this.el.removeAttribute("data-seeking"),50)};this.ui.barWrap.addEventListener(A,a=>{this.seekable&&(a.preventDefault(),this.el.setAttribute("data-seeking",""),this._dragging=!0,document.addEventListener(B,b,!!F&&{passive:!0}),document.addEventListener(C,c))}),this.ui.handle.addEventListener("keydown",a=>{if(this.seekable){var b=a.key.replace("Arrow",""),c=["PageDown","PageUp"],d=["Home","End"],e=-1!==["Left","Down"].indexOf(b),f=-1!==["Right","Up"].indexOf(b),g=b===c[0],h=b===c[1],i=b===d[0],j=b===d[1];if(e||f||-1!==c.indexOf(b)||-1!==d.indexOf(b)){if(i)return void this.seek(0);if(j)return void this.seek(this.duration);var k=(h||g?.1:.01)*(f||h?1:-1),l=this._canplay?this.currentTime:this._initSeek,m=k*this.duration+l;this.seek(m)}}})}initAudio(){this.options.audio.src&&(this.audio=new Audio,this.initAudioEvents(),this.events.audioEvents.forEach(a=>{this.audio.addEventListener(a,b=>{this.events.trigger(a,b)})}),this.audio.preload=this.options.preload,this.muted=this.options.muted,this.update(this.options.audio))}initAudioEvents(){this.on("play",()=>{this.ui.setPlaying(),x.forEach(a=>{a.id!==this.id&&a.audio&&!a.audio.paused&&a.pause()})}),this.on("pause",()=>{this.ui.setPaused()}),this.on("ended",()=>{this.ui.setPaused(),this.seek(0)}),this.on("waiting",()=>{this.el.setAttribute("data-loading","")}),this.on("durationchange",()=>{this.duration!==1/0&&this.live&&(this.live=!1),this.duration&&1!==this.duration&&this.duration!==1/0&&(this.seekable=!0,this.ui.setTime("duration",this.duration))}),this.on("canplay",()=>{this._canplay||(this._canplay=!0,this._initSeek&&(this.seek(this._initSeek),this._initSeek=0)),this.duration!==1/0||this.live||(this.live=!0,this.ui.setLive(this.live))}),this.on("canplaythrough",()=>{this.el.removeAttribute("data-loading")}),this.on("progress",()=>{if(this.audio.buffered.length){var a=this.audio.buffered.length?this.audio.buffered.end(this.audio.buffered.length-1)/this.duration:0;this.ui.setBar("loaded",a)}}),this.on("timeupdate",()=>{this._dragging||this.ui.setProgress(this.audio.currentTime,null,this.duration)}),this.on("abort",()=>{this.ui.setPaused()}),this.on("audioupdate",a=>{this.seekable=a.duration&&a.duration!==1/0,this.updateMetadata(a)}),this.on("audioparse",a=>{this.seekable=a.duration&&a.duration!==1/0,this.updateMetadata(a)})}initMediaSession(){var a=this;if("mediaSession"in navigator){this._hasMediaSession=!0,this.setMediaMetadata(this._audio);var b={play:this.play.bind(a),pause:this.pause.bind(a),seekforward:this.seekBySpan.bind(a),seekbackward:()=>this.seekBySpan({forward:!1}),seekto:this.seek.bind(a)};Object.keys(b).forEach(a=>{navigator.mediaSession.setActionHandler(a,b[a])})}}setMediaMetadata(a){var b=a.cover?[{src:a.cover,sizes:"150x150"}]:void 0;navigator.mediaSession.metadata=new MediaMetadata({title:a.title,artist:a.artist,album:a.album,artwork:b})}on(a,b){this.events.on(a,b)}play(){if(this.audio.paused){var a=this.audio.play();return a instanceof Promise?(a.then(()=>{this.initMediaSession()}),a.catch(a=>{("NotAllowedError"===a.name||"NotSupportedError"===a.name)&&this.pause()})):this.initMediaSession(),a}}pause(){this.audio.paused||this.audio.pause()}toggle(){return this.audio.paused?this.play():this.pause()}seek(c){this.seekable&&(c=parseInt(c),isNaN(c)&&console.error("Shikwasa: seeking time is NaN"),c=b(c,this.duration),c=a(c,0),this.ui.setProgress(c,null,this.duration),this._canplay?this.audio.currentTime=c:this._initSeek=c)}seekBySpan(){var{time:a=10,forward:b=!0}=0{this._audio=a||this._audio,this.events.trigger("audioparse",this._audio)})}else throw new Error("Shikwasa: audio source is not specified")}updateMetadata(a){this.audio.title=a.title,this.ui.setAudioInfo(a),this._hasMediaSession&&this.setMediaMetadata(a)}destroyAudio(){this.audio.pause(),this.audio.src="",this.audio.load(),this.audio=null}destroy(){this.destroyAudio(),this.ui.destroy(),Object.keys(this.comps).forEach(a=>{this.comps[a].destroy&&"function"==typeof this.comps[a].destroy&&this.comps[a].destroy()}),this.comps=null,this.options.container.innerHTML=""}renderComponents(){y.length&&y.forEach(a=>{this.comps[a._name]=new a(this)})}}G.use=function(a){y.push(a)};return console.log("%c\uD83C\uDF4A%c Shikwasa Podcast Player v2.1.3 %c https://shikwasa.js.org","background-color:#00869B40;padding:4px;","background:#00869B80;color:#fff;padding:4px 0","padding: 2px 0;"),G}); \ No newline at end of file -- cgit v1.2.3