mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-15 08:56:21 +00:00
1 line
9.4 KiB
Plaintext
1 line
9.4 KiB
Plaintext
{"version":3,"sources":["player.js"],"names":["const","lsKeys","page","urlPrefix","urlIdentifier","urlInput","document","querySelector","reloadBtn","downloadBtn","uploadRoot","titleFormat","videoContainer","player","window","HELP_IMPROVE_VIDEOJS","onError","error","console","content","createElement","innerHTML","toString","swal","title","icon","onAxiosError","statusText","520","521","522","523","524","525","526","527","530","response","status","description","data","toggleReloadBtn","enabled","classList","remove","removeAttribute","add","setAttribute","reloadVideo","value","src","axios","head","then","includes","type","headers","isvideo","startsWith","isaudio","dispose","videoElement","id","className","appendChild","options","language","playbackRates","responsive","plugins","wavesurfer","backend","videojs","let","message","getPluginVersion","WaveSurfer","log","seekButtons","forward","back","replace","history","pushState","catch","addEventListener","mainScript","dataset","location","protocol","host","match","pathname","substring","indexOf","form","event","preventDefault","checkValidity"],"mappings":"AAGAA,IAAMC,OAAS,GAGTC,KAAO,CACXC,UAAW,KACXC,cAAe,KAEfC,SAAUC,SAASC,cAAc,eACjCC,UAAWF,SAASC,cAAc,cAClCE,YAAaH,SAASC,cAAc,gBACpCG,WAAY,KACZC,YAAa,KAEbC,eAAgBN,SAASC,cAAc,oBACvCM,OAAQ,MAIVC,OAAOC,sBAAuB,EAG9Bb,KAAKc,QAAO,SAAGC,GACbC,QAAQD,MAAMA,GAEdjB,IAAMmB,EAAUb,SAASc,cAAc,OAKvC,OAJAD,EAAQE,UAAY,kBACPJ,EAAMK,WAAU,8EAGtBC,KAAK,CACVC,MAAO,qBACPC,KAAM,QAFNN,QAGAA,KAKJjB,KAAKwB,aAAY,SAAGT,GAElBjB,IAYM2B,EAZmB,CACvBC,IAAK,gBACLC,IAAK,qBACLC,IAAK,uBACLC,IAAK,wBACLC,IAAK,qBACLC,IAAK,uBACLC,IAAK,0BACLC,IAAK,gBACLC,IAAK,oBAG6BnB,EAAMoB,SAASC,SAAWrB,EAAMoB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,KAAKE,cAG3BJ,IAAM+F,EAAOzF,SAASC,cAAc,cACpCwF,EAAKV,iBAAiB,UAAQ,SAAEW,GAC9BA,EAAMC,oBAGH/F,KAAKU,iBAEVV,KAAKM,UAAYF,SAASC,cAAc,cACpCL,KAAKM,WACPN,KAAKM,UAAU6E,iBAAiB,SAAO,SAAEW,GAClCD,EAAKG,iBACVhG,KAAK8C,iBAIT9C,KAAK8C","file":"player.js","sourcesContent":["/* global swal, axios, videojs, WaveSurfer */\n\n// eslint-disable-next-line no-unused-vars\nconst lsKeys = {}\n\n// eslint-disable-next-line no-unused-vars\nconst page = {\n urlPrefix: null,\n urlIdentifier: null,\n\n urlInput: document.querySelector('#identifier'),\n reloadBtn: document.querySelector('#reloadBtn'),\n downloadBtn: document.querySelector('#downloadBtn'),\n uploadRoot: null,\n titleFormat: null,\n\n videoContainer: document.querySelector('#playerContainer'),\n player: null\n}\n\n// Disable video.js telemetry (should already be disabled by default since v7 though)\nwindow.HELP_IMPROVE_VIDEOJS = false\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p><code>${error.toString()}</code></p>\n <p>Please check your console for more information.</p>\n `\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : ''\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.toggleReloadBtn = enabled => {\n if (enabled) {\n page.reloadBtn.classList.remove('is-loading')\n page.reloadBtn.removeAttribute('disabled')\n } else {\n page.reloadBtn.classList.add('is-loading')\n page.reloadBtn.setAttribute('disabled', true)\n }\n}\n\npage.reloadVideo = () => {\n if (!page.urlInput.value) return\n\n page.toggleReloadBtn(false)\n const src = `${page.uploadRoot}/${page.urlInput.value}`\n\n axios.head(src).then(response => {\n if (![200, 304].includes(response.status)) {\n page.toggleReloadBtn(true)\n return page.onAxiosError(response)\n }\n\n const type = response.headers['content-type'] || ''\n const isvideo = type.startsWith('video/')\n const isaudio = type.startsWith('audio/')\n if (!isvideo && !isaudio) {\n page.toggleReloadBtn(true)\n return swal('An error occurred!', 'The requested upload does not appear to be a media file.', 'error')\n }\n\n page.urlIdentifier = page.urlInput.value\n\n if (page.player) {\n page.player.dispose()\n page.videoContainer.innerHTML = ''\n }\n\n const videoElement = document.createElement('video-js')\n videoElement.id = 'video-js'\n videoElement.className = 'video-js vjs-default-skin vjs-fluid vjs-big-play-centered'\n videoElement.setAttribute('controls', true)\n videoElement.setAttribute('preload', 'auto')\n\n page.videoContainer.appendChild(videoElement)\n\n const options = {\n language: 'en',\n playbackRates: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],\n responsive: true\n }\n\n if (isaudio) {\n options.plugins = {\n wavesurfer: {\n backend: 'MediaElement'\n }\n }\n }\n\n page.player = videojs('video-js', options, () => {\n let message = `Using video.js ${videojs.VERSION}`\n if (isaudio) {\n message += `with videojs-wavesurfer ${videojs.getPluginVersion('wavesurfer')} and wavesurfer.js ${WaveSurfer.VERSION}`\n }\n videojs.log(message)\n page.player.src({ src, type })\n })\n page.player.seekButtons({ forward: 10, back: 10 })\n\n if (page.titleFormat) {\n document.title = page.titleFormat.replace(/%identifier%/g, page.urlIdentifier)\n }\n\n if (page.downloadBtn) {\n page.downloadBtn.setAttribute('href', src)\n }\n\n window.history.pushState(null, null, page.urlPrefix + page.urlIdentifier)\n page.toggleReloadBtn(true)\n }).catch(error => {\n page.toggleReloadBtn(true)\n if (typeof error.response !== 'undefined') page.onAxiosError(error)\n else page.onError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n const mainScript = document.querySelector('#mainScript')\n if (!mainScript || typeof mainScript.dataset.uploadRoot === 'undefined') return\n\n page.uploadRoot = mainScript.dataset.uploadRoot\n page.titleFormat = mainScript.dataset.titleFormat\n\n let urlPrefix = window.location.protocol + '//' + window.location.host\n const match = window.location.pathname.match(/.*\\/(.*)$/)\n if (!match || !match[1]) {\n return swal('An error occurred!', 'Failed to parse upload identifier from URL.', 'error')\n }\n\n page.urlIdentifier = match[1]\n urlPrefix += window.location.pathname.substring(0, window.location.pathname.indexOf(match[1]))\n page.urlPrefix = urlPrefix\n\n if (!page.urlInput) return\n page.urlInput.value = page.urlIdentifier\n\n // Prevent default form's submit actio\n const form = document.querySelector('#inputForm')\n form.addEventListener('submit', event => {\n event.preventDefault()\n })\n\n if (!page.videoContainer) return\n\n page.reloadBtn = document.querySelector('#reloadBtn')\n if (page.reloadBtn) {\n page.reloadBtn.addEventListener('click', event => {\n if (!form.checkValidity()) return\n page.reloadVideo()\n })\n }\n\n page.reloadVideo()\n})\n"]} |