blob: cb1f2ac779150a4c2a8977e204eae3ce40c5a726 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
import Modal from './modal.js';
import '../hash.js';
export default class LoginModal extends Modal {
constructor(serverName, serverClient) {
super(serverName);
this.serverName = serverName;
this.serverClient = serverClient;
let passBox = document.createElement('div');
let nameBox = document.createElement('div');
let sendBox = document.createElement('div');
let passwordLabel = document.createElement('label');
let passwordInput = document.createElement('input');
passwordLabel.setAttribute('for', 'password-input');
passwordLabel.textContent = 'Passwort:';
passwordLabel.title = 'Das Passwort des Spiels'
passwordInput.id = 'password-input';
passwordInput.type = 'password';
passwordInput.placeholder = 'Passwort';
let nameLabel = document.createElement('label');
let nameInput = document.createElement('input');
nameLabel.setAttribute('for', 'name-input');
nameLabel.textContent = 'Benutzername:';
nameLabel.title = 'Dein Anzeigename'
nameInput.id = 'name-input';
nameInput.type = 'text';
nameInput.autocomplete = 'on';
nameInput.placeholder = 'Name';
let sendButton = document.createElement('button');
sendButton.className = 'btn';
sendButton.textContent = 'Login';
sendButton.id = 'login-button';
passBox.appendChild(passwordLabel);
passBox.appendChild(passwordInput);
nameBox.appendChild(nameLabel);
nameBox.appendChild(nameInput);
sendBox.appendChild(sendButton);
this.body.appendChild(passBox);
this.body.appendChild(nameBox);
this.body.appendChild(sendBox);
this.nameInput = nameInput;
this.passwordInput = passwordInput;
this.loginButton = sendButton;
this.registerLoginBtn();
}
registerLoginBtn() {
this.loginButton.addEventListener('click', () => {
console.log('button pressed')
let userName = this.nameInput.value;
this.passwordInput.value.getHash()
.then((result) => {
this.serverClient.sendLogin(this.serverName, result, userName);
this.close();
});
});
}
}
|