mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 19:58:25 +02:00
Add fullscreen mode for chat
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -33,6 +33,8 @@ function selectChannel(channel_id) {
|
||||
|
||||
selected_channel_id = channel_id
|
||||
|
||||
window.history.replaceState({}, null, `#channel-${channel['id']}`)
|
||||
|
||||
let channelTitle = document.getElementById('channel-title')
|
||||
channelTitle.innerText = channel['name']
|
||||
|
||||
@ -84,8 +86,12 @@ function setChannels(new_channels) {
|
||||
fetchMessages(channel['id'])
|
||||
}
|
||||
|
||||
if (new_channels && (!selected_channel_id || !channels[selected_channel_id]))
|
||||
selectChannel(Object.keys(channels)[0])
|
||||
if (new_channels && (!selected_channel_id || !channels[selected_channel_id])) {
|
||||
if (window.location.hash)
|
||||
selectChannel(window.location.hash.substring(9))
|
||||
else
|
||||
selectChannel(Object.keys(channels)[0])
|
||||
}
|
||||
}
|
||||
|
||||
function receiveMessage(message) {
|
||||
@ -180,6 +186,20 @@ function redrawMessages() {
|
||||
fetchMoreButton.classList.remove('d-none')
|
||||
}
|
||||
|
||||
function toggleFullscreen() {
|
||||
let chatContainer = document.getElementById('chat-container')
|
||||
if (!chatContainer.getAttribute('data-fullscreen')) {
|
||||
chatContainer.setAttribute('data-fullscreen', 'true')
|
||||
chatContainer.classList.add('position-absolute', 'top-0', 'start-0', 'vh-100', 'z-3')
|
||||
window.history.replaceState({}, null, `?fullscreen=1#channel-${selected_channel_id}`)
|
||||
}
|
||||
else {
|
||||
chatContainer.removeAttribute('data-fullscreen')
|
||||
chatContainer.classList.remove('position-absolute', 'top-0', 'start-0', 'vh-100', 'z-3')
|
||||
window.history.replaceState({}, null, `?fullscreen=0#channel-${selected_channel_id}`)
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
/**
|
||||
* Process the received data from the server.
|
||||
|
Reference in New Issue
Block a user