diff options
| author | Karan Jayachandra <mail@karanjayachandra.com> | 2025-11-13 21:49:33 +0100 |
|---|---|---|
| committer | Karan Jayachandra <mail@karanjayachandra.com> | 2025-11-13 21:49:33 +0100 |
| commit | 4693fcf941e1ab30821b8d514beb5d79e5e2b20a (patch) | |
| tree | 3a654c04f95c0668a428e4223ca202d8e5fb547f /court.mjs | |
| parent | 944fc2715e967a51e4ccca49d87e987ee2727bc2 (diff) | |
Cleaned up the home folder
Diffstat (limited to 'court.mjs')
| -rw-r--r-- | court.mjs | 53 |
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(); - } -} |
