forked from Garde-Studios/minecraft-docker-server
24 lines
501 B
JavaScript
24 lines
501 B
JavaScript
import { P } from '../Squaremap.js';
|
|
|
|
class Pin {
|
|
constructor(def) {
|
|
this.pinned = def;
|
|
|
|
this.element = P.createElement("img", "pin", this);
|
|
|
|
this.element.onclick = () => this.toggle();
|
|
|
|
this.pin(this.pinned);
|
|
}
|
|
toggle() {
|
|
this.pin(!this.pinned);
|
|
}
|
|
pin(pin) {
|
|
this.pinned = pin;
|
|
this.element.className = pin ? "pinned" : "unpinned";
|
|
this.element.src = `images/${this.element.className}.png`;
|
|
}
|
|
}
|
|
|
|
export { Pin };
|