Peertube-dl/lib/Peertube/DL/public/js/peertube-dl-web.js

2 lines
7.1 KiB
JavaScript
Raw Normal View History

(()=>{"use strict";class e{constructor(){this.query_selector="#poping-notice",this.closePopingNotice.addEventListener("click",(e=>{this.setVisible(!1)}))}setVisible(e){e?this.element.classList.add("active"):this.element.classList.remove("active")}setMessage(e){if(!e instanceof Array)throw"Message is not instance of Array.";let t=document.createElement("p");for(let o of e)if("string"==typeof o||o instanceof String)o=document.createTextNode(o),t.appendChild(o);else{if(!(o instanceof Node))throw"Node is not a instance of Node nor a String";t.appendChild(o)}this.popingNoticeContent.innerHTML="",this.popingNoticeContent.appendChild(t)}get querySelector(){return this.query_selector}get element(){return document.querySelector(this.querySelector)}get popingNoticeContent(){return this.element.querySelector("#poping-notice-content")}get closePopingNotice(){return this.element.querySelector("#close-poping-notice")}}class t{constructor(e){this.query_selector="#download-form",this.callback=t=>{t.preventDefault(),e(this.downloadFormUrl.value)},this.addEventListeners()}addEventListeners(){this.downloadFormButton.addEventListener("click",this.callback),this.element.addEventListener("submit",this.callback)}get downloadFormButton(){return this.element.querySelector("#download-form-button")}get downloadFormUrl(){return this.element.querySelector("#download-form-url")}get querySelector(){return this.query_selector}get element(){return document.querySelector(this.querySelector)}}class o{constructor(){this.query_selector="#modal-loading"}setVisible(e){e?this.element.classList.add("active"):this.element.classList.remove("active")}get element(){return document.querySelector(this.querySelector)}get querySelector(){return this.query_selector}}class i{constructor(){this.query_selector="#modal-video-container",this.addEventListeners()}setVisible(e){e?this.element.classList.add("active"):(this.element.classList.remove("active"),this.downloadVideoPrepare.classList.add("active"),this.downloadVideoLoading.classList.remove("active"),this.downloadVideo.classList.remove("active"))}addEventListeners(){this.downloadVideoPrepare.addEventListener("click",this.downloadPrepareHandler.bind(this)),this.closeAndResetVideoContainer.addEventListener("click",(e=>{this.setVisible(!1)}))}downloadPrepareHandler(e){this.downloadVideoPrepare.classList.remove("active"),this.downloadVideoLoading.classList.add("active"),this.generateBlobVideo(this.URLVideo).then((e=>{this.downloadVideo.href=URL.createObjectURL(e),this.downloadVideo.download=this.filename,this.downloadVideoLoading.classList.remove("active"),this.downloadVideo.classList.add("active")}))}async generateBlobVideo(e){return await fetch(e,{mode:"cors"}).then((e=>e.blob())).catch((t=>this.generateBlobVideoByProxy(e)))}async generateBlobVideoByProxy(e){return await fetch("/proxy_to_get",{method:"POST",mode:"cors",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})}).then((e=>e.blob()))}onCanPlay(e){video.addEventListener("canplay",(t=>{e()}))}setURLVideo(e){this.url_video=e,video.src=e}setFilename(e){this.filename=e}get closeAndResetVideoContainer(){return this.element.querySelector("#close-and-reset-video-container")}get downloadVideo(){return this.element.querySelector("#download-video")}get URLVideo(){return this.url_video}get closeAndResetVideoContainer(){return this.element.querySelector("#close-and-reset-video-container")}get downloadVideoLoading(){return this.element.querySelector("#download-video-loading")}get downloadVideoPrepare(){return this.element.querySelector("#download-video-prepare")}get video(){return this.element.querySelector("#video")}get element(){return document.querySelector(this.querySelector)}get querySelector(){return this.query_selector}}class r{constructor(){this.query_selector="#modal-format-selector",this.addEventListeners()}appendFormat(e,t,o,i){let r=document.createElement("a");r.innerText=o?"Id: "+t.id+"\nFormat: "+t.mimeType+"\nQualityLabel: "+t.qualityLabel+"p\nBitrate: "+t.bitrate+"\n"+(void 0!==t.audioSampleRate?"AudioSampleRate: "+t.audioSa
//# sourceMappingURL=peertube-dl-web.js.map