90ff4fe2ff
added changing maps all done like this https://www.youtube.com/watch?v=U7fYOnedjzs&list=PLcjhmZ8oLT0r9dSiIK6RB_PuBWlG1KSq_&index=9
36 lines
745 B
JavaScript
36 lines
745 B
JavaScript
class TextMessage {
|
|
constructor({ text, onComplete }) {
|
|
this.text = text;
|
|
this.onComplete = onComplete;
|
|
this.element = null;
|
|
}
|
|
|
|
createElement() {
|
|
this.element = document.createElement("div");
|
|
this.element.classList.add("TextMessage");
|
|
|
|
this.element.innerHTML = (`
|
|
<p class="TextMessage_p">${this.text}</p>
|
|
<button class="TextMessage_button">Next</button>
|
|
`);
|
|
|
|
this.element.querySelector("button").addEventListener("click", () => {
|
|
this.done();
|
|
});
|
|
|
|
this.actionListener = new KeyPressListener("Enter", () => {
|
|
this.actionListener.unbind();
|
|
this.done();
|
|
})
|
|
}
|
|
|
|
done() {
|
|
this.element.remove();
|
|
this.onComplete();
|
|
}
|
|
|
|
init(container) {
|
|
this.createElement();
|
|
container.appendChild(this.element);
|
|
}
|
|
} |