mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 19:58:25 +02:00
Add script to create channels per tournament, pools and teams. Put channels in categories
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
|
||||
const MAX_MESSAGES = 50
|
||||
|
||||
const channel_categories = ['general', 'tournament', 'team', 'private']
|
||||
let channels = {}
|
||||
let messages = {}
|
||||
let selected_channel_id = null
|
||||
@ -62,20 +63,27 @@ function sendMessage() {
|
||||
|
||||
function setChannels(new_channels) {
|
||||
channels = {}
|
||||
let navTab = document.getElementById('nav-channels-tab')
|
||||
navTab.innerHTML = ''
|
||||
let categoryLists = {}
|
||||
for (let category of channel_categories) {
|
||||
categoryLists[category] = document.getElementById(`nav-${category}-channels-tab`)
|
||||
categoryLists[category].innerHTML = ''
|
||||
categoryLists[category].parentElement.classList.add('d-none')
|
||||
}
|
||||
|
||||
for (let channel of new_channels) {
|
||||
channels[channel['id']] = channel
|
||||
if (!messages[channel['id']])
|
||||
messages[channel['id']] = new Map()
|
||||
|
||||
let categoryList = categoryLists[channel['category']]
|
||||
categoryList.parentElement.classList.remove('d-none')
|
||||
|
||||
let navItem = document.createElement('li')
|
||||
navItem.classList.add('list-group-item')
|
||||
navItem.id = `tab-channel-${channel['id']}`
|
||||
navItem.setAttribute('data-bs-dismiss', 'offcanvas')
|
||||
navItem.onclick = () => selectChannel(channel['id'])
|
||||
navTab.appendChild(navItem)
|
||||
categoryList.appendChild(navItem)
|
||||
|
||||
let channelButton = document.createElement('button')
|
||||
channelButton.classList.add('nav-link')
|
||||
|
Reference in New Issue
Block a user