diff options
author | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-10-01 18:10:37 +0200 |
---|---|---|
committer | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-10-01 18:10:37 +0200 |
commit | 6f162dcf90a6aa671eb351dc25cb01e2d9cbd3cb (patch) | |
tree | ce9121463419cb27e6bd4e0c4215c037550f8ff7 /WebInterface/NodeJSServer/src/modules/ui/server-listing.js | |
parent | e463bf3eb7115f1f141da2162b0624f90472ff9c (diff) |
A lot of changes
I shoud have written a better commit, I know!
Diffstat (limited to 'WebInterface/NodeJSServer/src/modules/ui/server-listing.js')
-rw-r--r-- | WebInterface/NodeJSServer/src/modules/ui/server-listing.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/WebInterface/NodeJSServer/src/modules/ui/server-listing.js b/WebInterface/NodeJSServer/src/modules/ui/server-listing.js index 0069ac6..ace8a0e 100644 --- a/WebInterface/NodeJSServer/src/modules/ui/server-listing.js +++ b/WebInterface/NodeJSServer/src/modules/ui/server-listing.js @@ -1,3 +1,5 @@ +import LoginModal from './login-modal.js'; + /** * Class for handling the server list */ @@ -5,9 +7,11 @@ export default class ServerListing { /** * Creates reference to container * @param {string} serverListId ID of the server list div + * @param {BannerController} notifications Notification Manager */ - constructor(serverListId) { + constructor(serverListId, notifications) { this.serverListing = document.getElementById(serverListId); + this.notifications = notifications; } /** @@ -20,8 +24,10 @@ export default class ServerListing { /** * Populates servers from a given array of games * @param {array} array Array of available games + * @param {ServerClient} serverClient Server Client to handle login + * @param {array} ui UI Elements to reload after login */ - addElements(array) { + addElements(array, serverClient, ui) { for (let server of array) { const name = server['name']; const playerList = server['users']; @@ -46,13 +52,16 @@ export default class ServerListing { playerCountSpan.textContent = playerAmount; playerCountStaticSpan.textContent = 'Spieler online'; joinButton.textContent = 'Beitreten'; + joinButton.addEventListener('click', () => { + new LoginModal(name, serverClient, this.notifications, ui); + }); rightAlignDiv.appendChild(onlineDot); rightAlignDiv.appendChild(playerCountSpan); rightAlignDiv.appendChild(playerCountStaticSpan); rightAlignDiv.appendChild(joinButton); serverDiv.appendChild(nameSpan); - serverDiv.appendChild(rightAlignDiv) + serverDiv.appendChild(rightAlignDiv); this.serverListing.appendChild(serverDiv); } } |