diff options
author | TrueDoctor <d-kobert@web.de> | 2018-09-30 00:00:06 +0200 |
---|---|---|
committer | TrueDoctor <d-kobert@web.de> | 2018-09-30 00:00:06 +0200 |
commit | 7db0e121521733273a8ca3977e91e6f88756f38a (patch) | |
tree | af132ad3652163f323118601b9d196b207360f0a /WebInterface/NodeJSServer/src/modules/ui/server-listing.js | |
parent | 632781d1adf54287ecfe7cbcbc17074e14a769b2 (diff) | |
parent | f97f25ea54a0f888d2195d6868346854a2a005e0 (diff) |
Merge branch 'WebApi' of https://github.com/TrueDoctor/DiscoBot into WebApi
Diffstat (limited to 'WebInterface/NodeJSServer/src/modules/ui/server-listing.js')
-rw-r--r-- | WebInterface/NodeJSServer/src/modules/ui/server-listing.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/WebInterface/NodeJSServer/src/modules/ui/server-listing.js b/WebInterface/NodeJSServer/src/modules/ui/server-listing.js new file mode 100644 index 0000000..be66573 --- /dev/null +++ b/WebInterface/NodeJSServer/src/modules/ui/server-listing.js @@ -0,0 +1,42 @@ +export default class ServerListing { + constructor(serverListId) { + this.serverListing = document.getElementById(serverListId); + } + + flushElements() { + this.serverListing.innerHTML = ''; + } + + addElements(array) { + for (let server of array) { + const name = server['name']; + const playerList = server['users']; + const playerAmount = playerList.length; + + let serverDiv = document.createElement('div'); + let nameSpan = document.createElement('span'); + 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'; + 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'; + + serverDiv.appendChild(nameSpan); + serverDiv.appendChild(onlineDot); + serverDiv.appendChild(playerCountSpan); + serverDiv.appendChild(playerCountStaticSpan); + serverDiv.appendChild(joinButton); + this.serverListing.appendChild(serverDiv); + } + } +} |