const tournaments = JSON.parse(document.getElementById('tournaments_list').textContent) const sockets = {} const messages = document.getElementById('messages') document.addEventListener('DOMContentLoaded', () => { if (document.location.hash) { document.querySelectorAll('button[data-bs-toggle="tab"]').forEach(elem => { if ('#' + elem.innerText.toLowerCase() === document.location.hash.toLowerCase()) { elem.click() } }) } document.querySelectorAll('button[data-bs-toggle="tab"]').forEach( elem => elem.addEventListener( 'click', () => document.location.hash = '#' + elem.innerText.toLowerCase())) for (let tournament of tournaments) { let socket = new WebSocket( 'ws://' + window.location.host + '/ws/draw/' + tournament.id + '/' ) sockets[tournament.id] = socket function addMessage(message, type, timeout = 0) { const wrapper = document.createElement('div') wrapper.innerHTML = [ `