diff options
author | TrueDoctor <d-kobert@web.de> | 2018-10-01 14:26:46 +0200 |
---|---|---|
committer | TrueDoctor <d-kobert@web.de> | 2018-10-01 14:26:46 +0200 |
commit | a5a5d368cddd6e8a15298002ccb3b10c90a33980 (patch) | |
tree | 85f51826e3463829ec554f303eb886b5290b26a5 /WebInterface/NodeJSServer/src/modules/ui/login-modal.js | |
parent | 1d9dc432584c270307805b165e24fa2d7f566017 (diff) | |
parent | 237e4d43229847bb69aadcfa6e6aca517128913b (diff) |
Merge branch 'WebApi' of https://github.com/TrueDoctor/DiscoBot into WebApi
Diffstat (limited to 'WebInterface/NodeJSServer/src/modules/ui/login-modal.js')
-rw-r--r-- | WebInterface/NodeJSServer/src/modules/ui/login-modal.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/WebInterface/NodeJSServer/src/modules/ui/login-modal.js b/WebInterface/NodeJSServer/src/modules/ui/login-modal.js index cb1f2ac..4c7b872 100644 --- a/WebInterface/NodeJSServer/src/modules/ui/login-modal.js +++ b/WebInterface/NodeJSServer/src/modules/ui/login-modal.js @@ -1,7 +1,17 @@ import Modal from './modal.js'; import '../hash.js'; +/** + * Class to implement a login modal from the parent modal class + */ export default class LoginModal extends Modal { + /** + * Creates necessary elements for login modal + * @param {string} serverName Name of the server, used for login and displayed + * in title + * @param {ServerClient} serverClient Server client object used to send the + * login + */ constructor(serverName, serverClient) { super(serverName); this.serverName = serverName; @@ -15,7 +25,7 @@ export default class LoginModal extends Modal { let passwordInput = document.createElement('input'); passwordLabel.setAttribute('for', 'password-input'); passwordLabel.textContent = 'Passwort:'; - passwordLabel.title = 'Das Passwort des Spiels' + passwordLabel.title = 'Das Passwort des Spiels'; passwordInput.id = 'password-input'; passwordInput.type = 'password'; passwordInput.placeholder = 'Passwort'; @@ -24,7 +34,7 @@ export default class LoginModal extends Modal { let nameInput = document.createElement('input'); nameLabel.setAttribute('for', 'name-input'); nameLabel.textContent = 'Benutzername:'; - nameLabel.title = 'Dein Anzeigename' + nameLabel.title = 'Dein Anzeigename'; nameInput.id = 'name-input'; nameInput.type = 'text'; nameInput.autocomplete = 'on'; @@ -53,15 +63,22 @@ export default class LoginModal extends Modal { this.registerLoginBtn(); } + /** + * Registers event to send login, on button press + */ registerLoginBtn() { - this.loginButton.addEventListener('click', () => { - console.log('button pressed') + let eventListener = () => { + this.loginButton.removeEventListener('click', eventListener); let userName = this.nameInput.value; this.passwordInput.value.getHash() .then((result) => { this.serverClient.sendLogin(this.serverName, result, userName); + + // TODO: Wait for response, if error keep window intact, + // and reenable event listener this.close(); }); - }); + }; + this.loginButton.addEventListener('click', eventListener); } } |