aboutsummaryrefslogtreecommitdiff
path: root/court.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'court.mjs')
-rw-r--r--court.mjs53
1 files changed, 0 insertions, 53 deletions
diff --git a/court.mjs b/court.mjs
deleted file mode 100644
index 713c488..0000000
--- a/court.mjs
+++ /dev/null
@@ -1,53 +0,0 @@
-import { Manager } from "./utils.mjs";
-
-class Court {
- constructor(id, status) {
- this.id = id;
- this.status = typeof status !== "undefined" ? status : true;
- this.name = "Court " + (id + 1);
- }
- toggle() {
- this.status = !this.status;
- this.print();
- }
- print() {
- let status = this.status ? "active" : "inactive";
- console.log(this.name + " is currently " + status);
- }
- render() {
- let color = this.status ? "is-success" : "is-danger";
- let type = `class="button is-medium ${color}"`;
- return `<button id=${"court_" + this.id} ${type}>${this.name}</button>`;
- }
-}
-
-export class CourtManager extends Manager {
- maxCourtCount = 12;
-
- constructor() {
- super("court", []);
- console.log("Loading court data.");
- let data = JSON.parse(localStorage.getItem(this.description));
- if (data === null || data.length != this.maxCourtCount) {
- console.log("Court data unavailable: " + data);
- this.generate();
- return;
- }
- for (let i = 0; i < this.maxCourtCount; i++) {
- this.listData.push(new Court(data[i].id, data[i].status));
- }
- console.log("Loaded " + this.listData.length + " courts.");
- this.render();
- this.addBehaviour();
- }
- generate() {
- console.log("Generating court data.");
- for (let i = 0; i < this.maxCourtCount; i++) {
- this.listData.push(new Court(i));
- }
- console.log("Generated data for " + this.listData.length + " courts");
- this.store();
- this.render();
- this.addBehaviour();
- }
-}