You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
HTML
42 lines
1.1 KiB
HTML
4 years ago
|
{% extends 'base.html' %}
|
||
|
|
||
|
{% block head %}
|
||
|
<script src="{{ url_for('static', filename='socket.js') }}"></script>
|
||
|
{% endblock %}
|
||
|
|
||
|
{% block content %}
|
||
|
<h1>Games waiting:</h1>
|
||
|
|
||
|
<form action="/room" method="POST" id="create-room">
|
||
|
<input type="text" placeholder="Name" name="name">
|
||
|
<button class="create-room" type="submit">Create game</button>
|
||
|
<input type="hidden" name="secret" class="insert-secret"/>
|
||
|
</form>
|
||
|
|
||
|
<ul class="active-lobbies"></ul>
|
||
|
|
||
|
|
||
|
<script>
|
||
|
onload(() => {
|
||
|
socket.on('room_list', draw_rooms);
|
||
|
|
||
|
function draw_rooms(list) {
|
||
|
console.log(list);
|
||
|
const root = $('.active-lobbies');
|
||
|
root.innerHTML = "";
|
||
|
|
||
|
list.forEach(room => {
|
||
|
const elm = create_elm(`<li>${room.name} with ${room.players.map(x => (x.online ? '● ' : '○ ') + x.name).join(", ")} <a href="/room/${room.id}">JOIN</a></li>`)[0]
|
||
|
root.appendChild(elm)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
$('form#create-room').addEventListener('submit', e => {
|
||
|
e.target.elements.secret.value = localStorage.getItem('secret')
|
||
|
});
|
||
|
|
||
|
draw_rooms({{ rooms | safe }})
|
||
|
})
|
||
|
|
||
|
</script>
|
||
|
{% endblock %}
|