diff options
| author | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-14 17:57:28 +0100 |
|---|---|---|
| committer | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-14 17:57:28 +0100 |
| commit | 0aab565ffb594069abaf6b3e25c25737523a7bf3 (patch) | |
| tree | 23c6aac1aebc58055a4e6e1d7cfc443c5a169eb5 | |
| parent | 06d6cf87acfd4582beb6beb314c6f1d7c3fe9675 (diff) | |
Only the history is pending
| -rw-r--r-- | src/main.js | 24 | ||||
| -rw-r--r-- | src/timer.js | 13 |
2 files changed, 20 insertions, 17 deletions
diff --git a/src/main.js b/src/main.js index 7e9f988..4c88167 100644 --- a/src/main.js +++ b/src/main.js @@ -3,7 +3,7 @@ import "bulma/css/bulma.css"; import "@fortawesome/fontawesome-free/css/all.css"; import "./style.css"; import { Notyf } from "notyf"; -import { Timer } from "./utils"; +import { Timer } from "./timer"; import { Team, Game } from "./data"; import { Manager, CourtManager, PlayerManager, GuestManager } from "./manage"; @@ -74,10 +74,17 @@ export class GameManager extends Manager { let activeRegularCount = this.players.active().length; let activeGuestCount = this.guests.active().length; let activePlayerCount = activeRegularCount + activeGuestCount; - console.log("There are a total of " + activePlayerCount + " players available."); + console.log( + "There are a total of " + activePlayerCount + " players available." + ); let activeCourtCount = this.courts.active().length; - console.log("There are a total of " + activeCourtCount + " courts available."); - let possibleMatches = Math.min(Math.floor(activePlayerCount / 4), activeCourtCount); + console.log( + "There are a total of " + activeCourtCount + " courts available." + ); + let possibleMatches = Math.min( + Math.floor(activePlayerCount / 4), + activeCourtCount + ); return possibleMatches; } selectPlayers(count) { @@ -136,20 +143,19 @@ export class GameManager extends Manager { for (let i = 0; i < this.data.length; i++) { this.data[i].status = true; } + // Increment the number of games played this.store(); this.render(); document.getElementById("timer-start").click(); - const notification = new Notyf(); - notification.success("Round confirmed!"); } reset() { localStorage.removeItem("round"); localStorage.removeItem(this.description); localStorage.removeItem(this.courts.description); + // Clear the number of games played + localStorage.removeItem(this.guests.description); document.getElementById("timer-stop").click(); window.location.reload(); - const notification = new Notyf(); - notification.error("Session has been reset!"); } } @@ -167,9 +173,11 @@ function addGameBehaviour(g) { }); document.getElementById("confirm").addEventListener("click", () => { g.confirm(); + getNotifier().success("Round confirmed!"); }); document.getElementById("reset").addEventListener("click", () => { g.reset(); + getNotifier().error("Session has been reset!"); }); } diff --git a/src/timer.js b/src/timer.js index 7c70550..c00ffdc 100644 --- a/src/timer.js +++ b/src/timer.js @@ -2,17 +2,12 @@ const milliSecond = 1000; export class Timer { pointer = 0; + mins = Number(sessionStorage.getItem("mins")) || 12; + running = Boolean(Number(sessionStorage.getItem("running"))) || false; + deadline = Number(sessionStorage.getItem("deadline")) || new Date().getTime(); constructor() { - this.mins = Number(sessionStorage.getItem("mins")) || 12; - this.running = Boolean(Number(sessionStorage.getItem("running"))) || false; - this.deadline = - Number(sessionStorage.getItem("deadline")) || new Date().getTime(); - if (this.running) { - this.start(false); - } else { - this.reset(); - } + this.running ? this.start(false) : this.reset(); addTimerBehaviour(this); } store() { |
