Change all_sessions to buttons
This commit is contained in:
parent
40dd6ea865
commit
dd0490ee13
@ -12,6 +12,17 @@ ws.onmessage = function(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msg.hasOwnProperty('allsessions')) {
|
if (msg.hasOwnProperty('allsessions')) {
|
||||||
document.getElementById('all_sessions').innerText = msg.allsessions.join(', ');
|
const all_sessions = document.getElementById('all_sessions');
|
||||||
|
|
||||||
|
while (all_sessions.children.length) all_sessions.lastChild.remove();
|
||||||
|
|
||||||
|
for (let session of msg.allsessions) {
|
||||||
|
const button = document.createElement('button');
|
||||||
|
button.innerText = session;
|
||||||
|
button.onclick = async (e) => await fetch('api/join_session', {
|
||||||
|
method: 'POST', body: JSON.stringify({sessionid: session})
|
||||||
|
});
|
||||||
|
all_sessions.appendChild(button);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
2
ui.html
2
ui.html
@ -10,7 +10,7 @@
|
|||||||
this is the UI
|
this is the UI
|
||||||
<br>
|
<br>
|
||||||
<span id="current_session">You are not in any session.</span><br>
|
<span id="current_session">You are not in any session.</span><br>
|
||||||
<span id="all_sessions"></span><br>
|
<div id="all_sessions"></div><br>
|
||||||
<br>
|
<br>
|
||||||
<button id="btn_create_session">Create session</button>
|
<button id="btn_create_session">Create session</button>
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
|
Loading…
Reference in New Issue
Block a user