From 2b5a120bd3900d5cecbe355d336a4ea8d3a1b31a Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Wed, 12 Nov 2025 14:37:19 +0100 Subject: Prettified the code and cleaned up the light/dark mode --- index.js | 62 +++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 6d74bd2..35f564e 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,6 @@ import { CourtManager } from "./court.mjs"; import { PlayerManager, addLoadBehaviour } from "./player.mjs"; import { Round, generateDummyGames, proposeGames } from "./game.mjs"; - // Court and player handling let c = new CourtManager(); let p = new PlayerManager(); @@ -11,34 +10,39 @@ addLoadBehaviour(p); // Game handling let proposal; let session = []; // Persist this in local storage with 1 day limit -if (session.length === 0) {session.push(new Round(generateDummyGames(c.listData, "---"), 0))}; +if (session.length === 0) { + session.push(new Round(generateDummyGames(c.listData, "---"), 0)); +} document.getElementById("game_list").innerHTML = session.at(-1).render(); document.getElementById("propose").addEventListener("click", () => { - let normalize = Number(document.getElementById("skill").value); - console.log(normalize); - let players = p.listData.map(function(p) { - p.skill = Math.ceil(p.skill / normalize); - return p; - }) - proposal = proposeGames(players, c.listData); - document.getElementById("game_list").innerHTML = new Round(proposal).render(); -}) + let normalize = Number(document.getElementById("skill").value); + console.log(normalize); + let players = p.listData.map(function (p) { + p.skill = Math.ceil(p.skill / normalize); + return p; + }); + proposal = proposeGames(players, c.listData); + document.getElementById("game_list").innerHTML = new Round(proposal).render(); +}); document.getElementById("confirm").addEventListener("click", () => { - console.log("Confirm the proposal on screen for round " + session.length + "."); - session.push(new Round(proposal, session.length)); - // Need to update the number of games played here - document.getElementById("game_list").innerHTML = session.at(-1).render(); - document.getElementById("timer-start").click(); - const notification = new Notyf({ - duration: 30 * 1000, - position: {x: 'center', y: 'top'}, - types: [{ - type: 'success', - background: 'green', - duration: 1000 * 1000, - dismissible: true - }] - }); - notification.success("Round confirmed!"); - -}) \ No newline at end of file + console.log( + "Confirm the proposal on screen for round " + session.length + "." + ); + session.push(new Round(proposal, session.length)); + // Need to update the number of games played here + document.getElementById("game_list").innerHTML = session.at(-1).render(); + document.getElementById("timer-start").click(); + const notification = new Notyf({ + duration: 30 * 1000, + position: { x: "center", y: "top" }, + types: [ + { + type: "success", + background: "green", + duration: 1000 * 1000, + dismissible: true, + }, + ], + }); + notification.success("Round confirmed!"); +}); -- cgit v1.3.1