Work in progress.

This commit is contained in:
John Livingston 2021-02-19 15:19:20 +01:00
parent f4a565ab67
commit 560d63a20a
3 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,5 @@
iframe.peertube-plugin-livechat {
border: 1px solid black;
width: 100%;
height: 300px;
resize: vertical;

View File

@ -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 }) {
registerHook({
target: 'action:video-watch.player.loaded',
@ -5,7 +18,7 @@ function register ({ registerHook, peertubeHelpers }) {
peertubeHelpers.getSettings().then(s => {
const liveOn = !!s['chat-all-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'] || ''
if ( iframeUri === '' ) {
console.log('[peertube-plugin-livechat] no uri, can\'t add chat.')
@ -38,6 +51,8 @@ function register ({ registerHook, peertubeHelpers }) {
const iframe = document.createElement('iframe')
iframe.setAttribute('src', chatUrl)
iframe.setAttribute('class', 'peertube-plugin-livechat')
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups')
iframe.setAttribute('frameborder', '0')
parent.prepend(iframe)
})
}

View File

@ -29,7 +29,8 @@ async function register ({
type: 'input-textarea',
default: '',
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.',
private: false
})