Work in progress.
This commit is contained in:
parent
f4a565ab67
commit
560d63a20a
@ -1,4 +1,5 @@
|
|||||||
iframe.peertube-plugin-livechat {
|
iframe.peertube-plugin-livechat {
|
||||||
|
border: 1px solid black;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
function parseUUIDs (s) {
|
||||||
|
if (!s) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
let a = s.split('\n')
|
||||||
|
a = a.map(line => {
|
||||||
|
return line.replace(/#.*$/, '')
|
||||||
|
.replace(/^\s+/, '')
|
||||||
|
.replace(/\s+$/, '')
|
||||||
|
})
|
||||||
|
return a.filter(line => line !== '')
|
||||||
|
}
|
||||||
|
|
||||||
function register ({ registerHook, peertubeHelpers }) {
|
function register ({ registerHook, peertubeHelpers }) {
|
||||||
registerHook({
|
registerHook({
|
||||||
target: 'action:video-watch.player.loaded',
|
target: 'action:video-watch.player.loaded',
|
||||||
@ -5,7 +18,7 @@ function register ({ registerHook, peertubeHelpers }) {
|
|||||||
peertubeHelpers.getSettings().then(s => {
|
peertubeHelpers.getSettings().then(s => {
|
||||||
const liveOn = !!s['chat-all-lives']
|
const liveOn = !!s['chat-all-lives']
|
||||||
const nonLiveOn = !!s['chat-all-non-lives']
|
const nonLiveOn = !!s['chat-all-non-lives']
|
||||||
const uuids = s['chat-videos-list'] ? s['chat-videos-list'].split('\n') : []
|
const uuids = parseUUIDs(s['chat-videos-list'])
|
||||||
const iframeUri = s['chat-uri'] || ''
|
const iframeUri = s['chat-uri'] || ''
|
||||||
if ( iframeUri === '' ) {
|
if ( iframeUri === '' ) {
|
||||||
console.log('[peertube-plugin-livechat] no uri, can\'t add chat.')
|
console.log('[peertube-plugin-livechat] no uri, can\'t add chat.')
|
||||||
@ -38,6 +51,8 @@ function register ({ registerHook, peertubeHelpers }) {
|
|||||||
const iframe = document.createElement('iframe')
|
const iframe = document.createElement('iframe')
|
||||||
iframe.setAttribute('src', chatUrl)
|
iframe.setAttribute('src', chatUrl)
|
||||||
iframe.setAttribute('class', 'peertube-plugin-livechat')
|
iframe.setAttribute('class', 'peertube-plugin-livechat')
|
||||||
|
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups')
|
||||||
|
iframe.setAttribute('frameborder', '0')
|
||||||
parent.prepend(iframe)
|
parent.prepend(iframe)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
3
main.js
3
main.js
@ -29,7 +29,8 @@ async function register ({
|
|||||||
type: 'input-textarea',
|
type: 'input-textarea',
|
||||||
default: '',
|
default: '',
|
||||||
descriptionHTML: 'Videos UUIDs for which we want a chat. ' +
|
descriptionHTML: 'Videos UUIDs for which we want a chat. ' +
|
||||||
'Can be non-live videos. One per line. ' +
|
'Can be non-live videos. One per line. <br />' +
|
||||||
|
'You can add comments: everything after the # character will be stripped off, and empty lines ignored.<br />' +
|
||||||
'Don\'t add private videos, the UUIDs will be send to frontend.',
|
'Don\'t add private videos, the UUIDs will be send to frontend.',
|
||||||
private: false
|
private: false
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user