Skip to content
Snippets Groups Projects
Commit 3bcf4a9e authored by atm2g19's avatar atm2g19
Browse files

improved gameloader

parent b8487919
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,8 @@ function setup() { ...@@ -18,7 +18,8 @@ function setup() {
GamesList = createDiv(); GamesList = createDiv();
createP("Current running games: ").parent(GamesList); createP("Current running games: ").parent(GamesList);
GamesList = createElement("ul").parent(GamesList); // createElement("br").parent(GamesList);
GamesList = createElement("div").parent(GamesList);
refreshList(); refreshList();
...@@ -42,12 +43,18 @@ function refreshList() { ...@@ -42,12 +43,18 @@ function refreshList() {
while (children.length > 0) children[0].remove(); while (children.length > 0) children[0].remove();
for (let _game of json) { for (let _game of json) {
let child = createElement("li"); let child = createElement("div");
child.parent(GamesList); child.parent(GamesList);
child.html(JSON.stringify(_game)); child.html(`Join game:<br/>${_game.name}<br/>Players:${_game.players}`);
let join_button = createButton("Join"); // let join_button = createButton("Join");
join_button.parent(child); // join_button.parent(child);
join_button.mouseClicked(joinGame.bind(_game)); child.mouseClicked(joinGame.bind(_game));
child.style("text-align", "center")
child.style("float", "left")
child.style("padding", "7px")
child.style("background-color", "lightblue")
child.style("margin", "2px")
// child.html(`<a href='/games/${game}/game.html?id=${_game.id}'>Join</a>`, true); // child.html(`<a href='/games/${game}/game.html?id=${_game.id}'>Join</a>`, true);
// createElement("li", `${JSON.stringify(game)}`).parent(GamesList); // createElement("li", `${JSON.stringify(game)}`).parent(GamesList);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment