nopaque/app/static/js/RessourceDisplays/RessourceDisplay.js
2022-07-04 14:09:17 +02:00

33 lines
746 B
JavaScript

class RessourceDisplay {
constructor(displayElement) {
this.displayElement = displayElement;
this.userId = this.displayElement.dataset.userId;
app.socket.on('PATCH', (patch) => {this.onPATCH(patch);});
app.subscribeUser(this.userId).then((user) => {this.init(user);});
}
init(user) {throw 'Not implemented';}
onPATCH(patch) {throw 'Not implemented';}
setElement(element, value) {
switch (element.tagName) {
case 'INPUT':
element.value = value;
M.updateTextFields();
break;
default:
element.innerText = value;
break;
}
}
setElements(elements, value) {
let element;
for (element of elements) {
this.setElement(element, value);
}
}
}