summaryrefslogtreecommitdiff
path: root/scripts/gui
diff options
context:
space:
mode:
authorKyle Gunger <corechg@gmail.com>2020-09-29 14:41:43 -0400
committerKyle Gunger <corechg@gmail.com>2020-09-29 14:41:43 -0400
commit5ffbbc8524fb5c42b00c741e9868e99e3f7c3fe4 (patch)
treef123e548863c2bc8bdddc09d4d22fe4e969703c3 /scripts/gui
parent673d16d8f2fb9d7b7df5f6fcadfbc665f329887c (diff)
Start join game implementation
Diffstat (limited to 'scripts/gui')
-rw-r--r--scripts/gui/lobby.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/gui/lobby.js b/scripts/gui/lobby.js
index 7d2b6cd..5939697 100644
--- a/scripts/gui/lobby.js
+++ b/scripts/gui/lobby.js
@@ -41,10 +41,22 @@ class TopBar{
// #############
// Game represents a single game in the lobby view. It has methods for setting up the elements and such.
-class Game{
- constructor (name, packs, maxp, id)
- {
- }
+function createGameEl (options = {id: 0, name: ""}, el)
+{
+ let e = document.createElement("div");
+ e.className = "game";
+
+ let title = document.createElement("h2");
+ title.textContent = options.name;
+ e.appendChild(title);
+
+ let join = document.createElement("button");
+ join.className = "join";
+ join.textContent = "Join";
+ join.addEventListener("click", game.joinGame.bind(game, options.id));
+ e.appendChild(join);
+
+ el.appendChild(e);
}
// ##############
@@ -130,7 +142,7 @@ class Lobby {
// { data.packs } list of the pack names used by this game
// { data.id } room identifier (uuid)
addGame (data) {
-
+ createGameEl(data, this.e.games);
}
// Called when a new public game is removed on the server