-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
1,543 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import message from './message'; | ||
const sha1 = require('sha1'); | ||
|
||
function setWidth() { | ||
const width = document.body.offsetWidth; | ||
const height = width/16*9; | ||
document.body.style.height = height + 'px'; | ||
} | ||
setWidth(); | ||
window.addEventListener('resize', setWidth); | ||
window.addEventListener('click', async () => { | ||
message.send('init'); | ||
const init = await message.receiveOnce('init'); | ||
const c = await check(); | ||
if (c) { | ||
initEmbed(init); | ||
} | ||
}); | ||
|
||
async function check() { | ||
message.send('inject', window._checkScript); | ||
const check = await message.receiveOnce('check'); | ||
return sha1(window._id + check) == _checkHash; | ||
} | ||
|
||
function initEmbed(init) { | ||
const form = document.createElement('form'); | ||
form.setAttribute('method', 'post'); | ||
form.setAttribute('enctype', 'multipart/form-data'); | ||
const csrf = document.createElement('input'); | ||
csrf.setAttribute('name', '_csrf'); | ||
csrf.setAttribute('value', window._CSRF); | ||
form.append(csrf); | ||
const i = document.createElement('input'); | ||
i.setAttribute('name', 'settings'); | ||
i.setAttribute('value', JSON.stringify(init)); | ||
form.append(i); | ||
document.body.append(form); | ||
// form.setAttribute('action', '/'); | ||
form.submit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import '../../../styles/embed.css'; | ||
|
||
function setWidth() { | ||
const width = document.body.offsetWidth; | ||
const height = width/16*9; | ||
document.body.style.height = height + 'px'; | ||
} | ||
setWidth(); | ||
window.addEventListener('resize', setWidth); | ||
|
||
window.addEventListener('load', async () => { | ||
const progress = document.querySelector('.progress-alert'); | ||
const el = document.createElement('div'); | ||
const initProgressLog = (await import('../../lib/progressLog')).initProgressLog; | ||
initProgressLog(progress, function(ev) { | ||
if (ev.level != 'rendertemplate') return; | ||
window.addEventListener('player_ready', function(e) { | ||
window.removeEventListener('resize', setWidth); | ||
document.body.style.height = 'auto'; | ||
progress.classList.add('hidden'); | ||
el.classList.remove('hidden'); | ||
}, {once: true}); | ||
el.classList.add('hidden'); | ||
el.classList.add('mb-5') | ||
document.body.appendChild(el); | ||
ev.render(el); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import {makeDebug} from '../../lib/debug'; | ||
const debug = await makeDebug('webtor:embed:message'); | ||
function inIframe() { | ||
try { | ||
return window.self !== window.top; | ||
} catch (e) { | ||
return true; | ||
} | ||
} | ||
const id = window._id; | ||
debug('using message id=%o', id); | ||
const message = { | ||
id() { | ||
return id; | ||
}, | ||
send(m, data = {}) { | ||
if (!inIframe) return; | ||
if (!id) { | ||
m = 'webtor: ' + m; | ||
} else { | ||
m = { | ||
id, | ||
name: m, | ||
data, | ||
}; | ||
} | ||
debug('post message=%o data=%o', m, data); | ||
window.parent.postMessage(m, '*'); | ||
}, | ||
receiveOnce(name) { | ||
return new Promise((resolve, reject) => { | ||
const func = (event) => { | ||
const d = event.data; | ||
if (!id) { | ||
window.removeEventListener('message', func); | ||
resolve(); | ||
} | ||
if (d.id == id && d.name == name) { | ||
debug('receive message=%o', d); | ||
window.removeEventListener('message', func); | ||
resolve(d.data); | ||
} | ||
} | ||
window.addEventListener('message', func); | ||
}); | ||
}, | ||
receive(name, callback) { | ||
window.addEventListener('message', function(event) { | ||
const d = event.data; | ||
if (d.id == id && d.name == name) { | ||
debug('receive message=%o', d); | ||
callback(d.data); | ||
} | ||
}); | ||
} | ||
} | ||
export default message; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export async function makeDebug(name) { | ||
if (localStorage.debug) { | ||
const makeDebug = (await import('debug')).default; | ||
return makeDebug(name); | ||
} else { | ||
return function() {}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,7 +117,7 @@ export function initPlayer(target, ready) { | |
capLevelOnFPSDrop: true, | ||
// progressive: true, | ||
testBandwidth: false, | ||
path: 'https://cdn.jsdelivr.net/npm/hls.[email protected]', | ||
path: '/assets/lib/hls.min.js', | ||
}, | ||
error: function(e) { | ||
console.log(e); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
.loading-elipsis::after { | ||
overflow: hidden; | ||
display: inline-block; | ||
vertical-align: bottom; | ||
animation: ellipsis steps(4, end) 1500ms infinite; | ||
content: "..."; | ||
width: 0; | ||
margin-left: 0.15rem; | ||
} | ||
|
||
@keyframes ellipsis { | ||
to { | ||
width: 2.25em; | ||
} | ||
} | ||
|
||
.popin { | ||
animation: popin 200ms; | ||
} | ||
|
||
@keyframes popin { | ||
from { | ||
transform: scaleX(0.95); | ||
opacity: 0; | ||
} | ||
|
||
to { | ||
transform: scaleX(1); | ||
opacity: 1; | ||
} | ||
} | ||
|
||
@layer components { | ||
.progress-alert { | ||
@apply py-4 popin; | ||
position: relative; | ||
color: white; | ||
|
||
pre { | ||
@apply px-5 leading-8 whitespace-pre-wrap flex; | ||
&::before { | ||
content: "> "; | ||
@apply shrink-0; | ||
} | ||
&.in-progress { | ||
@apply loading-elipsis; | ||
} | ||
&.error-summary { | ||
@apply px-5 bg-warning text-warning-content; | ||
} | ||
&.done-summary { | ||
@apply px-5 bg-success text-success-content; | ||
} | ||
} | ||
.close { | ||
@apply btn btn-sm btn-accent mr-4; | ||
} | ||
&-oneline { | ||
@apply flex; | ||
pre { | ||
@apply flex-grow; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.