Builtin Prosody, Share chat url: ability to show/hide the scrollbar in readonly mode.
This commit is contained in:
parent
7db4d355fb
commit
04b1945239
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## ???
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* Builtin Prosody, Share chat url: ability to show/hide the scrollbar in readonly mode.
|
||||||
|
|
||||||
## 5.2.4
|
## 5.2.4
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
@ -134,5 +134,15 @@ table.peertube-plugin-livechat-prosody-list-rooms td {
|
|||||||
label {
|
label {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.livechat-shareurl-custom-readonly {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: wrap;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
label:not(:first-child) {
|
||||||
|
margin-left: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import { isAutoColorsAvailable } from 'shared/lib/autocolors'
|
|||||||
|
|
||||||
interface ShareForm {
|
interface ShareForm {
|
||||||
readonly: HTMLInputElement
|
readonly: HTMLInputElement
|
||||||
|
withscroll: HTMLInputElement
|
||||||
|
withscrollLabelEl: HTMLElement
|
||||||
url: HTMLInputElement
|
url: HTMLInputElement
|
||||||
autoColors?: HTMLInputElement
|
autoColors?: HTMLInputElement
|
||||||
}
|
}
|
||||||
@ -14,6 +16,7 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
const [
|
const [
|
||||||
labelShare,
|
labelShare,
|
||||||
labelReadonly,
|
labelReadonly,
|
||||||
|
labelWithscroll,
|
||||||
tipsOBS,
|
tipsOBS,
|
||||||
labelCopy,
|
labelCopy,
|
||||||
labelCopied,
|
labelCopied,
|
||||||
@ -23,6 +26,7 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
peertubeHelpers.translate('Share chat link'),
|
peertubeHelpers.translate('Share chat link'),
|
||||||
peertubeHelpers.translate('Read-only'),
|
peertubeHelpers.translate('Read-only'),
|
||||||
|
peertubeHelpers.translate('Show the scrollbar'),
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
peertubeHelpers.translate('Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.'),
|
peertubeHelpers.translate('Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.'),
|
||||||
peertubeHelpers.translate('Copy'),
|
peertubeHelpers.translate('Copy'),
|
||||||
@ -72,6 +76,8 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
container.append(divCustom)
|
container.append(divCustom)
|
||||||
|
|
||||||
const divReadonly = document.createElement('div')
|
const divReadonly = document.createElement('div')
|
||||||
|
divReadonly.classList.add('livechat-shareurl-custom-readonly')
|
||||||
|
|
||||||
divCustom.append(divReadonly)
|
divCustom.append(divReadonly)
|
||||||
const readonly = document.createElement('input')
|
const readonly = document.createElement('input')
|
||||||
readonly.setAttribute('type', 'checkbox')
|
readonly.setAttribute('type', 'checkbox')
|
||||||
@ -80,6 +86,13 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
readonlyLabelEl.prepend(readonly)
|
readonlyLabelEl.prepend(readonly)
|
||||||
divReadonly.append(readonlyLabelEl)
|
divReadonly.append(readonlyLabelEl)
|
||||||
|
|
||||||
|
const withscroll = document.createElement('input')
|
||||||
|
withscroll.setAttribute('type', 'checkbox')
|
||||||
|
const withscrollLabelEl = document.createElement('label')
|
||||||
|
withscrollLabelEl.textContent = labelWithscroll
|
||||||
|
withscrollLabelEl.prepend(withscroll)
|
||||||
|
divReadonly.append(withscrollLabelEl)
|
||||||
|
|
||||||
let autoColors
|
let autoColors
|
||||||
if (isAutoColorsAvailable(settings['chat-type'], settings['converse-theme'])) {
|
if (isAutoColorsAvailable(settings['chat-type'], settings['converse-theme'])) {
|
||||||
const label = document.createElement('label')
|
const label = document.createElement('label')
|
||||||
@ -93,6 +106,9 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
readonly.onclick = () => {
|
readonly.onclick = () => {
|
||||||
renderContent(container)
|
renderContent(container)
|
||||||
}
|
}
|
||||||
|
withscroll.onclick = () => {
|
||||||
|
renderContent(container)
|
||||||
|
}
|
||||||
|
|
||||||
if (autoColors) {
|
if (autoColors) {
|
||||||
autoColors.onclick = () => {
|
autoColors.onclick = () => {
|
||||||
@ -121,6 +137,8 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
|
|
||||||
form = {
|
form = {
|
||||||
readonly,
|
readonly,
|
||||||
|
withscroll,
|
||||||
|
withscrollLabelEl,
|
||||||
url,
|
url,
|
||||||
autoColors
|
autoColors
|
||||||
}
|
}
|
||||||
@ -135,7 +153,15 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
permanent: true
|
permanent: true
|
||||||
}
|
}
|
||||||
if (form.readonly.checked) {
|
if (form.readonly.checked) {
|
||||||
uriOptions.readonly = true
|
if (form.withscroll.checked) {
|
||||||
|
uriOptions.readonly = true
|
||||||
|
} else {
|
||||||
|
uriOptions.readonly = 'noscroll'
|
||||||
|
}
|
||||||
|
form.withscrollLabelEl.style.display = 'initial'
|
||||||
|
} else {
|
||||||
|
// Hide the withscroll checkbox
|
||||||
|
form.withscrollLabelEl.style.display = 'none'
|
||||||
}
|
}
|
||||||
const iframeUri = getIframeUri(registerOptions, settings, video, uriOptions)
|
const iframeUri = getIframeUri(registerOptions, settings, video, uriOptions)
|
||||||
form.url.setAttribute('value', iframeUri ?? '')
|
form.url.setAttribute('value', iframeUri ?? '')
|
||||||
@ -148,6 +174,7 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
const v = {
|
const v = {
|
||||||
version: 1, // in case we add incompatible values in a near feature
|
version: 1, // in case we add incompatible values in a near feature
|
||||||
readonly: !!form.readonly.checked,
|
readonly: !!form.readonly.checked,
|
||||||
|
withscroll: !!form.withscroll.checked,
|
||||||
autocolors: !!form.autoColors?.checked
|
autocolors: !!form.autoColors?.checked
|
||||||
}
|
}
|
||||||
window.localStorage.setItem('peertube-plugin-livechat-shareurl', JSON.stringify(v))
|
window.localStorage.setItem('peertube-plugin-livechat-shareurl', JSON.stringify(v))
|
||||||
@ -168,6 +195,7 @@ async function shareChatUrl (registerOptions: RegisterOptions, settings: any, vi
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
form.readonly.checked = !!v.readonly
|
form.readonly.checked = !!v.readonly
|
||||||
|
form.withscroll.checked = !!v.withscroll
|
||||||
if (form.autoColors) {
|
if (form.autoColors) {
|
||||||
form.autoColors.checked = !!v.autocolors
|
form.autoColors.checked = !!v.autocolors
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { logger } from './logger'
|
|||||||
import { computeAutoColors } from './colors'
|
import { computeAutoColors } from './colors'
|
||||||
|
|
||||||
interface UriOptions {
|
interface UriOptions {
|
||||||
readonly?: boolean
|
readonly?: boolean | 'noscroll'
|
||||||
ignoreAutoColors?: boolean
|
ignoreAutoColors?: boolean
|
||||||
permanent?: boolean
|
permanent?: boolean
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ function getIframeUri (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (uriOptions.readonly) {
|
if (uriOptions.readonly) {
|
||||||
iFrameUri.searchParams.set('_readonly', 'true')
|
iFrameUri.searchParams.set('_readonly', (typeof uriOptions.readonly === 'string') ? uriOptions.readonly : 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
iframeUriStr = iFrameUri.href
|
iframeUriStr = iFrameUri.href
|
||||||
|
@ -82,7 +82,8 @@ interface InitConverseParams {
|
|||||||
websocketServiceUrl: string
|
websocketServiceUrl: string
|
||||||
authenticationUrl: string
|
authenticationUrl: string
|
||||||
advancedControls: boolean
|
advancedControls: boolean
|
||||||
forceReadonly: boolean
|
forceReadonly: boolean | 'noscroll'
|
||||||
|
noScroll: boolean
|
||||||
theme: string
|
theme: string
|
||||||
}
|
}
|
||||||
window.initConverse = async function initConverse ({
|
window.initConverse = async function initConverse ({
|
||||||
@ -108,6 +109,9 @@ window.initConverse = async function initConverse ({
|
|||||||
}
|
}
|
||||||
if (forceReadonly) {
|
if (forceReadonly) {
|
||||||
body?.classList.add('livechat-readonly')
|
body?.classList.add('livechat-readonly')
|
||||||
|
if (forceReadonly === 'noscroll') {
|
||||||
|
body?.classList.add('livechat-noscroll')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const params: any = {
|
const params: any = {
|
||||||
|
@ -25,3 +25,7 @@ body.livechat-readonly #conversejs {
|
|||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body.livechat-readonly.livechat-noscroll converse-chat-content {
|
||||||
|
overflow-y: hidden !important;
|
||||||
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
authenticationUrl: '{{AUTHENTICATION_URL}}',
|
authenticationUrl: '{{AUTHENTICATION_URL}}',
|
||||||
advancedControls: '{{ADVANCEDCONTROLS}}' === 'true',
|
advancedControls: '{{ADVANCEDCONTROLS}}' === 'true',
|
||||||
theme: '{{CONVERSEJS_THEME}}',
|
theme: '{{CONVERSEJS_THEME}}',
|
||||||
forceReadonly: '{{FORCEREADONLY}}' === 'true'
|
forceReadonly: '{{FORCEREADONLY}}' === 'noscroll' ? '{{FORCEREADONLY}}' : '{{FORCEREADONLY}}' === 'true'
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": false,
|
"If enabled, there will be a chat next to the video.": false,
|
||||||
"Share chat link": false,
|
"Share chat link": false,
|
||||||
"Read-only": false,
|
"Read-only": false,
|
||||||
|
"Show the scrollbar": false,
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
||||||
"Copy": false,
|
"Copy": false,
|
||||||
"Link copied": false,
|
"Link copied": false,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": false,
|
"If enabled, there will be a chat next to the video.": false,
|
||||||
"Share chat link": false,
|
"Share chat link": false,
|
||||||
"Read-only": false,
|
"Read-only": false,
|
||||||
|
"Show the scrollbar": false,
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
||||||
"Copy": false,
|
"Copy": false,
|
||||||
"Link copied": false,
|
"Link copied": false,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": "Activado, abre el chat junto al vídeo",
|
"If enabled, there will be a chat next to the video.": "Activado, abre el chat junto al vídeo",
|
||||||
"Share chat link": "Compartir el enlace de esta sala de chat",
|
"Share chat link": "Compartir el enlace de esta sala de chat",
|
||||||
"Read-only": "Sólo lectura",
|
"Read-only": "Sólo lectura",
|
||||||
|
"Show the scrollbar": false,
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": "Sugerencias para los streamers: para agregar el chat a su OBS, genere un enlace de «solo lectura» y utilícelo como «fuente o canal web».",
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": "Sugerencias para los streamers: para agregar el chat a su OBS, genere un enlace de «solo lectura» y utilícelo como «fuente o canal web».",
|
||||||
"Copy": "Copiar",
|
"Copy": "Copiar",
|
||||||
"Link copied": "Enlace copiado",
|
"Link copied": "Enlace copiado",
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": "Gaituta badago, txat bat agertuko da bideoaren ondoan.",
|
"If enabled, there will be a chat next to the video.": "Gaituta badago, txat bat agertuko da bideoaren ondoan.",
|
||||||
"Share chat link": false,
|
"Share chat link": false,
|
||||||
"Read-only": false,
|
"Read-only": false,
|
||||||
|
"Show the scrollbar": false,
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
||||||
"Copy": false,
|
"Copy": false,
|
||||||
"Link copied": false,
|
"Link copied": false,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": "Si activé, un salon de discussion sera affiché à coté de la vidéo.",
|
"If enabled, there will be a chat next to the video.": "Si activé, un salon de discussion sera affiché à coté de la vidéo.",
|
||||||
"Share chat link": "Partager le lien du salon de discussion",
|
"Share chat link": "Partager le lien du salon de discussion",
|
||||||
"Read-only": "Lecture seule",
|
"Read-only": "Lecture seule",
|
||||||
|
"Show the scrollbar": "Afficher la barre de défilement",
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": "Astuce pour les streamers et streameuses : pour ajouter le tchat à votre OBS, générez un lien «lecture seule» et utilisez le comme «source navigateur web».",
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": "Astuce pour les streamers et streameuses : pour ajouter le tchat à votre OBS, générez un lien «lecture seule» et utilisez le comme «source navigateur web».",
|
||||||
"Copy": "Copier",
|
"Copy": "Copier",
|
||||||
"Link copied": "Lien copié",
|
"Link copied": "Lien copié",
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": "Se abilitato, ci sarà una chat accanto al video",
|
"If enabled, there will be a chat next to the video.": "Se abilitato, ci sarà una chat accanto al video",
|
||||||
"Share chat link": false,
|
"Share chat link": false,
|
||||||
"Read-only": false,
|
"Read-only": false,
|
||||||
|
"Show the scrollbar": false,
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
||||||
"Copy": false,
|
"Copy": false,
|
||||||
"Link copied": false,
|
"Link copied": false,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": "Se activat la messatjariá serà a costat de la vidèo.",
|
"If enabled, there will be a chat next to the video.": "Se activat la messatjariá serà a costat de la vidèo.",
|
||||||
"Share chat link": "Partejar lo ligam de la discussion",
|
"Share chat link": "Partejar lo ligam de la discussion",
|
||||||
"Read-only": "Lectura sola",
|
"Read-only": "Lectura sola",
|
||||||
|
"Show the scrollbar": false,
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": "Astúcia pels difusors : per apondre la messatjariá a vòstre OBS, generatz un ligam « lectura sola» e utilizatz-lo coma « font navegador web ».",
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": "Astúcia pels difusors : per apondre la messatjariá a vòstre OBS, generatz un ligam « lectura sola» e utilizatz-lo coma « font navegador web ».",
|
||||||
"Copy": "Copiar",
|
"Copy": "Copiar",
|
||||||
"Link copied": "Ligam copiat",
|
"Link copied": "Ligam copiat",
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"If enabled, there will be a chat next to the video.": "Jeśli włączono, czat pojawi się po lewej stronie filmu.",
|
"If enabled, there will be a chat next to the video.": "Jeśli włączono, czat pojawi się po lewej stronie filmu.",
|
||||||
"Share chat link": false,
|
"Share chat link": false,
|
||||||
"Read-only": false,
|
"Read-only": false,
|
||||||
|
"Show the scrollbar": false,
|
||||||
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
"Tips for streamers: To add the chat to your OBS, generate a read-only link and use it as a browser source.": false,
|
||||||
"Copy": false,
|
"Copy": false,
|
||||||
"Link copied": false,
|
"Link copied": false,
|
||||||
|
@ -53,7 +53,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
let wsUri: string
|
let wsUri: string
|
||||||
let authenticationUrl: string = ''
|
let authenticationUrl: string = ''
|
||||||
let advancedControls: boolean = false
|
let advancedControls: boolean = false
|
||||||
let forceReadonly: boolean = false
|
let forceReadonly: 'true' | 'false' | 'noscroll' = 'false'
|
||||||
let converseJSTheme: string = settings['converse-theme'] as string
|
let converseJSTheme: string = settings['converse-theme'] as string
|
||||||
if (!/^\w+$/.test(converseJSTheme)) {
|
if (!/^\w+$/.test(converseJSTheme)) {
|
||||||
converseJSTheme = 'peertube'
|
converseJSTheme = 'peertube'
|
||||||
@ -87,7 +87,9 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
'api/auth'
|
'api/auth'
|
||||||
advancedControls = true
|
advancedControls = true
|
||||||
if (req.query._readonly === 'true') {
|
if (req.query._readonly === 'true') {
|
||||||
forceReadonly = true
|
forceReadonly = 'true'
|
||||||
|
} else if (req.query._readonly === 'noscroll') {
|
||||||
|
forceReadonly = 'noscroll'
|
||||||
}
|
}
|
||||||
} else if (chatType === 'builtin-converse') {
|
} else if (chatType === 'builtin-converse') {
|
||||||
if (!settings['chat-server']) {
|
if (!settings['chat-server']) {
|
||||||
@ -210,7 +212,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
page = page.replace(/{{ADVANCEDCONTROLS}}/g, advancedControls ? 'true' : 'false')
|
page = page.replace(/{{ADVANCEDCONTROLS}}/g, advancedControls ? 'true' : 'false')
|
||||||
page = page.replace(/{{CONVERSEJS_THEME}}/g, converseJSTheme)
|
page = page.replace(/{{CONVERSEJS_THEME}}/g, converseJSTheme)
|
||||||
page = page.replace(/{{CONVERSEJS_AUTOCOLORS}}/g, autocolorsStyles)
|
page = page.replace(/{{CONVERSEJS_AUTOCOLORS}}/g, autocolorsStyles)
|
||||||
page = page.replace(/{{FORCEREADONLY}}/g, forceReadonly ? 'true' : 'false')
|
page = page.replace(/{{FORCEREADONLY}}/g, forceReadonly)
|
||||||
|
|
||||||
res.status(200)
|
res.status(200)
|
||||||
res.type('html')
|
res.type('html')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user