diff options
| author | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-12 14:37:19 +0100 |
|---|---|---|
| committer | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-12 14:37:19 +0100 |
| commit | 2b5a120bd3900d5cecbe355d336a4ea8d3a1b31a (patch) | |
| tree | 69b614eafcd781055603a36568f46aa538329bb1 /court.mjs | |
| parent | 3a4a0f6f2bf9aff14c00c6acee637319d7458bbb (diff) | |
Prettified the code and cleaned up the light/dark mode
Diffstat (limited to 'court.mjs')
| -rw-r--r-- | court.mjs | 84 |
1 files changed, 43 insertions, 41 deletions
@@ -1,50 +1,52 @@ 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 type = this.status ? `class="button is-success"` : 'class="button is-danger"'; - return `<button id=${"court_" + this.id} ${type}>${this.name}</button>`; - } + 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 type = this.status + ? `class="button is-medium is-success"` + : 'class="button is-medium is-danger"'; + return `<button id=${"court_" + this.id} ${type}>${this.name}</button>`; + } } export class CourtManager extends Manager { - maxCourtCount = 12; + 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(); + 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)); } - 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(); + console.log("Loaded " + this.listData.length + " courts."); + this.render(); + } + generate() { + console.log("Generating court data."); + for (let i = 0; i < this.maxCourtCount; i++) { + this.listData.push(new Court(i)); } -}
\ No newline at end of file + console.log("Generated data for " + this.listData.length + " courts"); + this.store(); + this.render(); + } +} |
