diff options
author | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-11-27 12:16:33 +0100 |
---|---|---|
committer | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-11-27 12:16:33 +0100 |
commit | 9f0b255f32dfa81bffe75f89335a78a659b4ce6a (patch) | |
tree | c4345ef6f98fee35f326bc06c29cada542a78e43 /WebInterface/NodeJSServer/src/modules/ui/server-listing.js | |
parent | a653a4efc60ef0bbc18e65cb11a4bd8c06c7ad5c (diff) |
Reworked the code, but currently unable to test, so bugs are bound to be in there
Will test it sometime later. There also might still be stuff, that has yet to be reworked.
Diffstat (limited to 'WebInterface/NodeJSServer/src/modules/ui/server-listing.js')
-rw-r--r-- | WebInterface/NodeJSServer/src/modules/ui/server-listing.js | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/WebInterface/NodeJSServer/src/modules/ui/server-listing.js b/WebInterface/NodeJSServer/src/modules/ui/server-listing.js deleted file mode 100644 index 78ca323..0000000 --- a/WebInterface/NodeJSServer/src/modules/ui/server-listing.js +++ /dev/null @@ -1,67 +0,0 @@ -import LoginModal from './login-modal.js'; - -/** - * Class for handling the server list - */ -export default class ServerListing { - /** - * Creates reference to container - * @param {string} serverListId ID of the server list div - * @param {BannerController} notifications Notification Manager - */ - constructor(serverListId, notifications) { - this.serverListing = document.getElementById(serverListId); - this.notifications = notifications; - } - - /** - * Removes all elements currently in the server listing - */ - flushElements() { - this.serverListing.innerHTML = ''; - } - - /** - * 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, serverClient, ui) { - for (let server of array) { - const name = server['name']; - const playerAmount = server['userCount']; - - let serverDiv = document.createElement('div'); - let nameSpan = document.createElement('span'); - let rightAlignDiv = document.createElement('div'); - let onlineDot = document.createElement('div'); - let playerCountSpan = document.createElement('span'); - let playerCountStaticSpan = document.createElement('span'); - let joinButton = document.createElement('button'); - serverDiv.className = 'server'; - nameSpan.className = 'server-name'; - rightAlignDiv.className = 'right-aligned-items'; - onlineDot.className = 'player-count-dot'; - playerCountSpan.className = 'player-count'; - playerCountStaticSpan.className = 'player-count-static'; - joinButton.className = 'btn join-btn'; - joinButton.id = 'join'; - nameSpan.textContent = name; - 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); - this.serverListing.appendChild(serverDiv); - } - } -} |