-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.js
38 lines (32 loc) · 1.2 KB
/
view.js
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
// view.js
class AttendantView {
constructor() {
this.inputCodeField = document.getElementById("inputCode");
this.personNameElement = document.getElementById("attendantName");
this.checkButton = document.getElementById('present');
this.listElement = document.getElementById('list');
this.listInfoElement = document.querySelector('.list_info');
}
bindCodeInput(handler) {
this.inputCodeField.addEventListener("input", () => {
const inputCode = this.inputCodeField.value;
handler(inputCode);
});
}
bindCheckButton(handler) {
this.checkButton.addEventListener('click', () => {
handler(this.personNameElement.textContent);
});
}
displayAttendantName(attendantName) {
this.personNameElement.textContent = attendantName;
}
displayListInfo(totalRegistered, totalPresent) {
this.listInfoElement.innerText = `${totalRegistered} persons registered and ${totalPresent} is/are present`;
}
addNameToList(personName) {
let namePrint = document.createElement('p');
namePrint.innerText = personName;
this.listElement.appendChild(namePrint);
}
}