zorn/test/js/zorn.js

361 lines
25 KiB
JavaScript
Raw Normal View History

2024-02-26 20:59:47 -05:00
(()=>{var y='<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#ffffff" stroke-width="1.5"><path d="M6.90588 4.53682C6.50592 4.2998 6 4.58808 6 5.05299V18.947C6 19.4119 6.50592 19.7002 6.90588 19.4632L18.629 12.5162C19.0211 12.2838 19.0211 11.7162 18.629 11.4838L6.90588 4.53682Z" fill="#ffffff" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>';var b='<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#ffffff" stroke-width="1.5" data-darkreader-inline-color="" style="--darkreader-inline-color: #e8e6e3;"><path d="M6 18.4V5.6C6 5.26863 6.26863 5 6.6 5H9.4C9.73137 5 10 5.26863 10 5.6V18.4C10 18.7314 9.73137 19 9.4 19H6.6C6.26863 19 6 18.7314 6 18.4Z" fill="#ffffff" stroke="#ffffff" stroke-width="1.5" data-darkreader-inline-fill="" data-darkreader-inline-stroke="" style="--darkreader-inline-fill: #ffffff; --darkreader-inline-stroke: #ffffff;"></path><path d="M14 18.4V5.6C14 5.26863 14.2686 5 14.6 5H17.4C17.7314 5 18 5.26863 18 5.6V18.4C18 18.7314 17.7314 19 17.4 19H14.6C14.2686 19 14 18.7314 14 18.4Z" fill="#ffffff" stroke="#ffffff" stroke-width="1.5" data-darkreader-inline-fill="" data-darkreader-inline-stroke="" style="--darkreader-inline-fill: #ffffff; --darkreader-inline-stroke: #ffffff;"></path></svg>';var x='<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#ffffff"><path d="M7 4H4V7" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M17 4H20V7" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M7 20H4V17" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M17 20H20V17" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>';var w='<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" viewBox="0 0 24 24" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg" color="#ffffff" data-darkreader-inline-color="" style="--darkreader-inline-color: #e8e6e3;"><path d="M1 15V9C1 5.68629 3.68629 3 7 3H17C20.3137 3 23 5.68629 23 9V15C23 18.3137 20.3137 21 17 21H7C3.68629 21 1 18.3137 1 15Z" stroke="#ffffff" stroke-width="1.5" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #ffffff;"></path><path d="M10.5 10L10.3284 9.82843C9.79799 9.29799 9.07857 9 8.32843 9V9C6.76633 9 5.5 10.2663 5.5 11.8284V12.1716C5.5 13.7337 6.76633 15 8.32843 15V15C9.07857 15 9.79799 14.702 10.3284 14.1716L10.5 14" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #ffffff;"></path><path d="M18.5 10L18.3284 9.82843C17.798 9.29799 17.0786 9 16.3284 9V9C14.7663 9 13.5 10.2663 13.5 11.8284V12.1716C13.5 13.7337 14.7663 15 16.3284 15V15C17.0786 15 17.798 14.702 18.3284 14.1716L18.5 14" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #ffffff;"></path></svg>';var C='<?xml version="1.0" encoding="UTF-8"?><svg width="24px" stroke-width="1.5" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#ffffff"><path d="M3 13C3 17.9706 7.02944 22 12 22C16.9706 22 21 17.9706 21 13C21 8.02944 16.9706 4 12 4" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9 9L9 16" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M15 9L13 9C12.4477 9 12 9.44772 12 10L12 11.5C12 12.0523 12.4477 12.5 13 12.5L14 12.5C14.5523 12.5 15 12.9477 15 13.5L15 15C15 15.5523 14.5523 16 14 16L12 16" stroke="#ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M12 4L4.5 4M4.5 4L6.5 2M4.5 4L6.5 6" stroke="#ffffff" st
2024-02-26 05:21:51 -05:00
<h2 class="zorn-title hide"></h2>
<div oncontextmenu="return false" class="zorn-player-controls">
<div class="row-2">
<div class="video-progress">
<progress id="progress-bar" value="0" min="0"></progress>
<input class="seek" id="seek" value="0" min="0" type="range" step="1">
<div class="seek-tooltip" id="seek-tooltip">00:00</div>
</div>
</div>
<div class="row-1">
<div class="row-1-start">
<div class="volume-controls">
2024-02-26 20:59:47 -05:00
<button data-title="Mute (m)" class="volume-button" id="volume-button">${v}</button>
2024-02-26 05:21:51 -05:00
<input class="volume" id="volume" value="1" type="range" max="1" min="0" step="0.01"/>
</div>
<div class="time">
<time id="time-elapsed">00:00</time>
<span> / </span>
<time id="duration">00:00</time>
</div>
</div>
<div class="row-1-center">
2024-02-26 20:59:47 -05:00
<button id="skip-back">${F}</button>
<button id="play-pause">${h}</button>
<button id="skip-forth">${B}</button>
2024-02-26 05:21:51 -05:00
</div>
<div class="row-1-end">
2024-02-26 20:59:47 -05:00
<button id="subtitles">${A}</button>
<button id="fullscreen">${E}</button>
2024-02-26 05:21:51 -05:00
</div>
</div>
</div>
<style>
:root {
--zorn-progress-bar-bg: rgba(100, 100, 100, 0.5);
--zorn-progress-bar: rgba(255, 0, 0, 0.5);
--zorn-thumb: red;
--zorn-rounded-corners: 4px;
}
.zorn-context-menu {
background: linear-gradient(45deg, #0a141c 0%, rgba(10, 20, 28, 1) 100%);
border-radius: 6px;
border: 1px rgba(255, 255, 255, 0.08) solid;
}
.zorn-context-menu ul {
list-style: none;
margin: 0px;
padding: 0px;
}
.zorn-context-menu ul li {
padding: 8px 32px 8px 16px;
margin: 4px;
border-radius: 4px;
font-family: arial;
}
.zorn-context-menu ul li:hover {
background: rgba(255, 255, 255, 0.1);
cursor: pointer;
}
.zorn-context-menu ul li i {
font-size: 14px;
margin-right: 12px;
width: 12px;
}
.video-container {
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
font-family: Arial, Helvetica, sans-serif;
color: white;
}
.video-container .zorn-player-dialogs #buffering {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 0px 24px;
border-radius: 6px;
}
.video-container .zorn-player-dialogs #buffering h2 {
font-size: 52px;
}
.video-container .zorn-player-dialogs #invalid-src {
display: none;
position: absolute;
top: 50%;
left: 24px;
transform: translate(0px, -50%);
padding: 0px 24px;
border-radius: 6px;
}
.video-container .zorn-player-dialogs #invalid-src h2 {
font-size: 52px;
}
.video-container .zorn-player {
display: inline-flex;
}
.video-container .zorn-title {
display: none;
position: absolute;
top: 0px;
background: #000;
width: auto;
margin: 12px;
padding: 12px 24px;
border-radius: 10px;
font-size: 18px;
}
.video-container .hide {
opacity: 0;
pointer-events: none;
}
.video-container .zorn-player-title {
position: absolute;
top: 0px;
width: 100%;
background-image: linear-gradient(to top, rgba(12, 12, 12, 0), rgba(12, 12, 12, 0.75));
padding: 12px 24px;
font-size: 18px;
font-weight: bold;
}
.video-container .subtitles-menu {
display: none;
position: absolute;
right: 60px;
2024-02-26 20:59:47 -05:00
bottom: 70px;
2024-02-26 05:21:51 -05:00
background: #000 9;
list-style: none;
padding: 6px;
border-radius: 6px;
2024-02-26 20:59:47 -05:00
background: rgb(0 0 0 / 50%);
2024-02-26 05:21:51 -05:00
}
.video-container .subtitles-menu button {
background-color: transparent;
color: white;
border: none;
border-radius: 4px;
width: 100%;
text-align: left;
padding: 6px 12px;
cursor: pointer;
}
.video-container .subtitles-menu button:hover {
background: #fff 29;
}
.video-container .subtitles-menu .hide {
opacity: 0;
pointer-events: none;
}
.video-container .zorn-player-controls {
display: inline-flex;
right: 0;
left: 0;
padding: 10px;
position: absolute;
bottom: -1px;
transition: all 0.2s ease;
background-image: linear-gradient(to bottom, rgba(12, 12, 12, 0), rgba(12, 12, 12, 0.75));
flex-direction: inherit;
}
.video-container .zorn-player-controls .row-1 {
display: flex;
justify-content: space-between;
width: 100%;
}
.video-container .zorn-player-controls .row-1-start {
display: flex;
align-items: center;
}
.video-container .zorn-player-controls .row-1-center {
display: flex;
justify-content: center;
}
.video-container .zorn-player-controls .row-1-end {
display: flex;
align-items: center;
}
.video-container .zorn-player-controls button {
aspect-ratio: 1;
height: 32px;
width: 32px;
color: white;
background-color: transparent;
border: none;
margin: 0px 6px;
}
2024-02-26 20:59:47 -05:00
.volume-controls {
display: flex;
align-items: center;
2024-02-26 05:21:51 -05:00
}
.video-container .zorn-player-controls .volume-controls:hover > #volume {
opacity: 1;
transition: 0.3s opacity, 0.3s width;
margin: 0px;
width: 72px;
}
.video-container .zorn-player-controls #volume {
opacity: 0;
transition: 0.3s opacity, 0.3s width;
2024-02-26 20:59:47 -05:00
margin: 0px 12px 0px -6px;
2024-02-26 05:21:51 -05:00
width: 0px;
}
.video-container .zorn-player-controls #volume-button svg {
aspect-ratio: 1;
height: 16px;
width: 16px;
fill: white;
padding: 3px 0px 0px 0px;
}
.video-container .zorn-player-controls .video-progress {
position: relative;
height: 6.4px;
margin: 24px 0px;
width: 100%;
}
.video-container .zorn-player-controls progress {
border-radius: 1rem;
width: 100%;
height: 8.4px;
position: absolute;
top: 0;
}
.video-container .zorn-player-controls progress::-webkit-progress-bar {
border-radius: 1rem;
background: var(--zorn-progress-bar-bg);
}
.video-container .zorn-player-controls progress::-webkit-progress-value {
background: var(--zorn-progress-bar);
border-radius: 1rem;
}
.video-container .zorn-player-controls progress::-moz-progress-bar {
border-radius: 1rem;
background: var(--zorn-progress-bar-bg);
}
.video-container .zorn-player-controls .seek {
position: absolute;
top: 0;
width: 100%;
cursor: pointer;
margin: 0;
}
.video-container .zorn-player-controls .seek:hover + .seek-tooltip {
display: block;
}
.video-container .zorn-player-controls .seek-tooltip {
display: none;
position: relative;
top: -32px;
margin-left: -30px;
font-size: 12px;
content: attr(data-title);
font-weight: bold;
color: #fff;
background-color: rgba(0, 0, 0, .5);
border-radius: 4px;
padding: 6px;
width: fit-content;
}
.video-container .zorn-player-controls input[type=range] {
height: 8.4px;
background: transparent;
cursor: pointer;
opacity: 0;
}
.video-container .zorn-player-controls input[type=range]:focus {
outline: none;
}
.video-container .zorn-player-controls input[type=range]:focus::-webkit-slider-runnable-track {
background: transparent;
}
.video-container .zorn-player-controls input[type=range]:focus::-moz-range-track {
outline: none;
}
.video-container .zorn-player-controls input[type=range]::-webkit-slider-runnable-track {
width: 100%;
cursor: pointer;
border-radius: 1.3px;
-webkit-appearance: none;
transition: all 0.4s ease;
}
.video-container .zorn-player-controls input[type=range]::-webkit-slider-thumb {
height: 12px;
width: 12px;
border-radius: 10px;
background: var(--zorn-thumb);
cursor: pointer;
-webkit-appearance: none;
margin-left: -1px;
}
.video-container .zorn-player-controls input[type=range]::-moz-range-track {
width: 100%;
height: 8.4px;
cursor: pointer;
border: 1px solid transparent;
background: transparent;
border-radius: 0;
}
.video-container .zorn-player-controls input[type=range].volume {
height: 5px;
background-color: #fff;
}
.video-container .zorn-player-controls input[type=range].volume::-webkit-slider-runnable-track {
background-color: transparent;
}
.video-container .zorn-player-controls input[type=range].volume::-webkit-slider-thumb {
margin-left: 0;
height: 14px;
width: 14px;
background: #fff;
}
.video-container .zorn-player-controls input[type=range].volume::-moz-range-thumb {
border: 1px solid #fff;
background: #fff;
}
.video-container .zorn-player-controls input[type="range"]::-moz-range-thumb {
height: 12px;
width: 12px;
border-radius: 10px;
border: none;
background: var(--zorn-thumb);
cursor: pointer;
}
.video-container .zorn-player-controls .hide {
opacity: 0;
pointer-events: none;
}
.video-container .zorn-player-controls #progress-bar {
background: var(--zorn-progress-bar-bg);
border: none;
border-radius: 10px;
}
div#buffering {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 90%;
display: flex;
align-items: center;
justify-content: center;
animation: 1s spin linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg)
}
to {
transform: rotate(360deg)
}
}
</style>
2024-02-26 20:59:47 -05:00
`;function $(){e.addEventListener("error",function(t){document.querySelector("#invalid-src").style.display="inherit",document.querySelector(".zorn-player-controls").style.display="none",videoContainer.style.backgroundColor="#101010",setTimeout(()=>{e.style.opacity="0.10",document.querySelector("#buffering").style.display="none"},168)},!0),e.onwaiting=t=>{document.querySelector("#buffering").style.display="inherit",e.style.transition="5s opacity",e.style.opacity="0.25"},e.oncanplaythrough=t=>{document.querySelector("#buffering").style.display="none",e.style.transition="0.3s opacity",e.style.opacity="1"}}function _(){let t=document.querySelector(".zorn-player-controls #play-pause");t.addEventListener("click",r),e.addEventListener("click",r),e.addEventListener("play",o),e.addEventListener("pause",o);function r(){e.paused||e.ended?e.play():e.pause()}function o(){e.paused?(t.setAttribute("data-title","Play (K)"),t.innerHTML=`${h}`):(t.setAttribute("data-title","Pause (K)"),t.innerHTML=`${S}`)}}function q(){let t=document.querySelector(".zorn-player-controls #skip-back"),r=document.querySelector(".zorn-player-controls #skip-forth");t.addEventListener("click",o),r.addEventListener("click",n);function o(){l(-10)}function n(){l(10)}function l(a){e.currentTime+=a}}function Z(){let t=document.getElementById("fullscreen");function r(){document.fullscreenElement?document.exitFullscreen():document.webkitFullscreenElement?document.webkitExitFullscreen():d.webkitRequestFullscreen?d.webkitRequestFullscreen():d.requestFullscreen()}t.onclick=r;function o(){document.fullscreenElement?t.setAttribute("data-title","Exit full screen (f)"):t.setAttribute("data-title","Full screen (f)")}d.addEventListener("fullscreenchange",o),e.addEventListener("dblclick",()=>{r()})}function U(){var t=document.querySelector(".zorn-player-controls #subtitles"),r=[],o=function(p,m,f){var k=document.createElement("li"),u=k.appendChild(document.createElement("button"));return u.setAttribute("id",p),u.className="subtitles-button",m.length>0&&u.setAttribute("lang",m),u.value=f,u.setAttribute("data-state","inactive"),u.appendChild(document.createTextNode(f)),u.addEventListener("click",function(i){r.map(function(g,N,ie){r[N].setAttribute("data-state","inactive")});for(var s=this.getAttribute("lang"),c=0;c<e.textTracks.length;c++)e.textTracks[c].language==s?(e.textTracks[c].mode="showing",this.setAttribute("data-state","active")):e.textTracks[c].mode="hidden";n.style.display="none"}),r.push(u),k},n;if(e.textTracks){var l=document.createDocumentFragment(),n=l.appendChild(document.createElement("ul"));n.className="subtitles-menu",n.appendChild(o("subtitles-off","","Off"));for(var a=0;a<e.textTracks.length;a++)n.appendChild(o("subtitles-"+e.textTracks[a].language,e.textTracks[a].language,e.textTracks[a].label));d.appendChild(n)}t.addEventListener("click",function(p){n&&(n.style.display=n.style.display=="block"?"none":"block")})}function G(){let t=document.getElementById("volume-button"),r=document.getElementById("volume");function o(){e.muted&&(e.muted=!1),e.volume=r.value}r.addEventListener("input",o);function n(){t.setAttribute("data-title","Mute (M)"),e.muted||e.volume===0?(t.innerHTML=`${H}`,t.setAttribute("data-title","Unmute (M)")):e.volume>0&&e.volume<=.5?t.innerHTML=`${I}`:t.innerHTML=`${v}`}e.addEventListener("volumechange",n);function l(){e.muted=!e.muted,e.muted?(r.setAttribute("data-volume",r.value),r.value=0):r.value=r.dataset.volume}t.addEventListener("click",l)}function K(){let t=document.getElementById("time-elapsed"),r=document.getElementById("duration");function o(i){let s=new Date(i*1e3).toISOString().substr(11,8);return{minutes:s.substr(3,2),seconds:s.substr(6,2)}}e.addEventListener("loadedmetadata",p);function n(){let i=o(Math.round(e.currentTime));t.innerText=`${i.minutes}:${i.seconds}`,t.setAttribute("datetime",`${i.minutes}m ${i.seconds}s`)}e.addEventListener("timeupdate",n);let l=document.getElementById("progress-bar"),a=document.getElementById("seek");function p(){let i=Math.round(e.duration);a.setAttribute("max",i),l.setAttribute("max",i);let s=o
2024-02-26 05:21:51 -05:00
<div id="buffering" class="zorn-dialog">
2024-02-26 20:59:47 -05:00
${P}
2024-02-26 05:21:51 -05:00
</div>
2024-02-26 20:59:47 -05:00
`;function D(){function t(){var a=document.querySelector(".video-container > h2");e.paused||(document.querySelector(".zorn-player-controls").classList.add("hide"),a.classList.add("hide"))}function r(){var a=document.querySelector(".video-container > h2");document.querySelector(".zorn-player-controls").classList.remove("hide"),a.classList.remove("hide")}e.addEventListener("mouseenter",r),e.addEventListener("mouseleave",t),document.querySelector(".zorn-player-controls").addEventListener("mouseenter",r),document.querySelector(".zorn-player-controls").addEventListener("mouseleave",t);var o=null,n=!0;function l(){o=null,d.style.cursor="none",n=!1,t()}document.onmousemove=function(){o&&(window.clearTimeout(o),r()),n||(d.style.cursor="default",n=!0),o=window.setTimeout(l,3200)}}function O(t){if(e.hasAttribute("keyboard-shortcut-fullscreen"))var r=e.getAttribute("keyboard-shortcut-fullscreen");else var r="f";if(e.hasAttribute("keyboard-shortcut-mute"))var o=e.getAttribute("keyboard-shortcut-mute");else var o="m";if(e.hasAttribute("keyboard-shortcut-playpause"))var n=e.getAttribute("keyboard-shortcut-playpause");else var n="k";if(e.hasAttribute("keyboard-shortcut-skipback"))var l=e.getAttribute("keyboard-shortcut-skipback");else var l="j";if(e.hasAttribute("keyboard-shortcut-skipforth"))var a=e.getAttribute("keyboard-shortcut-skipforth");else var a="l";function p(m){let{key:f}=m;f===n?(e.paused||e.ended?e.play():e.pause(),e.paused?Show_Controls():setTimeout(()=>{Hide_Controls()},1200)):f===o?(e.muted=!e.muted,e.muted?(volume.setAttribute("data-volume",volume.value),volume.value=0):volume.value=volume.dataset.volume):f===r?document.fullscreenElement?document.exitFullscreen():document.webkitFullscreenElement?document.webkitExitFullscreen():d.webkitRequestFullscreen?d.webkitRequestFullscreen():d.requestFullscreen():f===l?e.currentTime+=-10:f===a&&(e.currentTime+=10)}document.addEventListener("keyup",p)}e.insertAdjacentHTML("afterend",j);e.insertAdjacentHTML("afterend",R);$();O();_();D();q();Z();U();G();K();Buffering();})();