2021-01-11 12:36:45 +00:00
|
|
|
class RessourceDisplay {
|
|
|
|
constructor(displayElement) {
|
|
|
|
this.displayElement = displayElement;
|
2021-11-30 15:22:16 +00:00
|
|
|
this.userId = this.displayElement.dataset.userId;
|
2022-07-04 12:09:17 +00:00
|
|
|
app.socket.on('PATCH', (patch) => {this.onPATCH(patch);});
|
|
|
|
app.subscribeUser(this.userId).then((user) => {this.init(user);});
|
2021-01-11 12:36:45 +00:00
|
|
|
}
|
|
|
|
|
2021-11-30 15:22:16 +00:00
|
|
|
init(user) {throw 'Not implemented';}
|
2021-01-11 12:36:45 +00:00
|
|
|
|
2022-07-04 12:09:17 +00:00
|
|
|
onPATCH(patch) {throw 'Not implemented';}
|
2021-01-11 12:36:45 +00:00
|
|
|
|
|
|
|
setElement(element, value) {
|
|
|
|
switch (element.tagName) {
|
|
|
|
case 'INPUT':
|
|
|
|
element.value = value;
|
|
|
|
M.updateTextFields();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
element.innerText = value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-12-01 13:15:20 +00:00
|
|
|
|
|
|
|
setElements(elements, value) {
|
|
|
|
let element;
|
|
|
|
|
|
|
|
for (element of elements) {
|
|
|
|
this.setElement(element, value);
|
|
|
|
}
|
|
|
|
}
|
2021-01-11 12:36:45 +00:00
|
|
|
}
|