Skip to content
Snippets Groups Projects
Commit 9621e3a3 authored by Richard Zameitat's avatar Richard Zameitat :cat2:
Browse files

styling and housekeeping

parent e7b34ac7
No related branches found
No related tags found
No related merge requests found
free.css 0 → 100644
._ext-openExcellenceMedia_container .videoLinkList {
--c-rwth-violett: rgb(97,33,88);
--c-link-bg: var(--c-rwth-violett);
--c-link-fg: #fff;
}
._ext-openExcellenceMedia_container .videoLinkList {
list-style-type: none;
padding: 0;
display: flex;
flex-direction: row;
}
._ext-openExcellenceMedia_container .videoLinkList .videoLink {
display: inline-block;
padding: .5em 1em;
background: var(--c-link-bg);
color: var(--c-link-fg);
margin: .25em .5em;
border-radius: .2em;
}
console.debug(document.readyState, ''+window.location)
if (window.location.host === 'engage.streaming.rwth-aachen.de') { if (window.location.host === 'engage.streaming.rwth-aachen.de') {
console.debug(window, window.parent, window.top) if (!window.location.href.startsWith('https://engage.streaming.rwth-aachen.de/paella/ui/watch.html'))
console.warn('looks like we are running outside a player context‽')
const inFrame = (window.parent !== window) const inFrame = (window.parent !== window)
console.debug('running in video context ... deatching URLs ...', inFrame) const vId = new URLSearchParams(location.search).get('id')
let vId = new URLSearchParams(location.search).get('id') fetch(`https://engage.streaming.rwth-aachen.de/search/episode.json?${new URLSearchParams({id:vId}).toString()}`)
fetch(`https://engage.streaming.rwth-aachen.de/search/episode.json?id=${new URLSearchParams(location.search).get('id')}`)
.then(d=>d.json()) .then(d=>d.json())
.then(meta => { .then(meta => {
window._meta = meta window._meta = meta
...@@ -20,22 +19,15 @@ if (window.location.host === 'engage.streaming.rwth-aachen.de') { ...@@ -20,22 +19,15 @@ if (window.location.host === 'engage.streaming.rwth-aachen.de') {
if (resAI < resBI) return -1 if (resAI < resBI) return -1
return 0 return 0
}) })
videoTracks.forEach(t=>console.log(t.id, t.mimetype, t.video.resolution, t.url)) videoTracks.forEach(t=>console.debug(t.id, t.mimetype, t.video.resolution, t.url))
if (inFrame) { if (inFrame) {
console.debug('posting message')
window.parent.postMessage({videoTracks, meta}, '*') window.parent.postMessage({videoTracks, meta}, '*')
window.addEventListener('message', msg => { } else {
console.debug('got message in frame', msg) // TODO: add download links to video
console.debug('is from parent', msg.origin === window.parent)
})
} }
}) })
} else if (window.location.host === 'moodle.rwth-aachen.de') { } else if (window.location.host === 'moodle.rwth-aachen.de') {
window.addEventListener('message', msg => { window.addEventListener('message', msg => {
window._lastMsg = msg;
window._msgSrc = msg.source;
console.log('msg', msg)
let mainFrame = document.querySelector('div[role=main]') let mainFrame = document.querySelector('div[role=main]')
let sourceFrame = null; let sourceFrame = null;
let _frames = [...document.querySelectorAll('iframe')].filter(f => f.contentWindow === msg.source) let _frames = [...document.querySelectorAll('iframe')].filter(f => f.contentWindow === msg.source)
...@@ -44,38 +36,35 @@ if (window.location.host === 'engage.streaming.rwth-aachen.de') { ...@@ -44,38 +36,35 @@ if (window.location.host === 'engage.streaming.rwth-aachen.de') {
let videoLinkList = genLinkContainer(msg.data.videoTracks, msg.data.meta) let videoLinkList = genLinkContainer(msg.data.videoTracks, msg.data.meta)
mainFrame.appendChild(videoLinkList) mainFrame.appendChild(videoLinkList)
window._sf = sourceFrame // if video frame was found: step out of the video container(s) and place links just below the frame
console.debug('sourceFrame', sourceFrame, sourceFrame.parentNode)
let beforeNode = sourceFrame let beforeNode = sourceFrame
while (beforeNode.parentNode && beforeNode.parentNode.matches('.occontainer_inner,.occontainer_outer')) { while (beforeNode.parentNode && beforeNode.parentNode.matches('.occontainer_inner,.occontainer_outer')) {
beforeNode = beforeNode.parentNode beforeNode = beforeNode.parentNode
} }
if (beforeNode && beforeNode.parentNode) { if (beforeNode && beforeNode.parentNode) {
beforeNode.parentNode.insertBefore(videoLinkList, beforeNode) beforeNode.parentNode.insertBefore(videoLinkList, beforeNode.nextSibling)
} }
return false; return false;
}) })
let frame = document.querySelector('iframe.ocplayer')
if (frame) {
console.debug('posting to child')
frame.contentWindow.postMessage('hello child', '*')
}
} }
function genLinkContainer(tracks, meta) { function genLinkContainer(tracks, meta) {
let videoTitle = meta['search-results'].result.dcTitle || '?' let videoTitle = meta['search-results'].result.dcTitle || '?'
let details = document.createElement('details') let details = document.createElement('details')
details.classList.add('_ext-openExcellenceMedia_container')
let summary = document.createElement('summary') let summary = document.createElement('summary')
summary.innerText = `Download video: ${videoTitle}` summary.innerText = `Download video: ${videoTitle}`
details.appendChild(summary) details.appendChild(summary)
let videoLinkList = document.createElement('ul') let videoLinkList = document.createElement('ul')
videoLinkList.classList.add('videoLinkList')
tracks.forEach(track => { tracks.forEach(track => {
let li = document.createElement('li') let li = document.createElement('li')
let a = document.createElement('a') let a = document.createElement('a')
a.classList.add('videoLink')
a.href = track.url a.href = track.url
a.innerText = `${track.video.resolution} (${track.mimetype})` a.innerText = `${track.video.resolution} (${track.mimetype.replace(/^video\//, '')})`
li.appendChild(a) li.appendChild(a)
videoLinkList.appendChild(li) videoLinkList.appendChild(li)
}) })
......
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "openExcellence", "name": "openExcellenceMedia",
"version": "0.0.1", "version": "0.0.1",
"description": "", "description": "",
"icons": { "icons": {
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
{ {
"all_frames": true, "all_frames": true,
"matches": ["https://moodle.rwth-aachen.de/*", "https://engage.streaming.rwth-aachen.de/*"], "matches": ["https://moodle.rwth-aachen.de/*", "https://engage.streaming.rwth-aachen.de/*"],
"js": ["free.js"] "js": ["free.js"],
"css": ["free.css"]
} }
] ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment