aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js62
1 files changed, 33 insertions, 29 deletions
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!");
+});