From 7cec8794b6616d294b6a0e8aab3b9d8b1dcdb6db Mon Sep 17 00:00:00 2001
From: Karan Jayachandra
Date: Sat, 15 Nov 2025 19:12:25 +0100
Subject: Added the change to Pico CSS
---
src/manage.js | 50 ++++++++++++++++++++++++++++++++------------------
1 file changed, 32 insertions(+), 18 deletions(-)
(limited to 'src/manage.js')
diff --git a/src/manage.js b/src/manage.js
index 7449866..f8fe220 100644
--- a/src/manage.js
+++ b/src/manage.js
@@ -1,4 +1,4 @@
-import { Court, Guest, Player } from "./data";
+import { Court, Guest, Regular } from "./data";
export class Manager {
constructor(description, maxCount) {
@@ -49,8 +49,8 @@ export class Manager {
p.addEventListener("click", () => {
this.data[idx].toggle();
this.store();
- p.classList.toggle("is-success");
- p.classList.toggle("is-danger");
+ p.classList.toggle("secondary");
+ p.classList.toggle("outline");
});
}
}
@@ -94,8 +94,10 @@ function normalize(data) {
}
export class GuestManager extends Manager {
- constructor() {
- super("Guest", 18);
+ constructor(description, count) {
+ if ( typeof description === "undefined" ) { description = "Guest"; };
+ if ( typeof count === "undefined" ) { count = 18; };
+ super(description, count);
}
createItem(i) {
return new Guest(i, randomStatus());
@@ -109,6 +111,13 @@ export class GuestManager extends Manager {
active() {
return normalize(super.active());
}
+ update(list) {
+ for (let index = 0; index < this.data.length; index++ ){
+ if (this.data[index].name in list) {
+ this.data[index].games += 1;
+ }
+ }
+ }
}
export function randomLevel() {
@@ -116,33 +125,38 @@ export function randomLevel() {
return Math.floor(Math.random() * maxLevel + 1);
}
-export class RegularManager extends Manager {
+export class RegularManager extends GuestManager {
constructor() {
super("Regular", 71);
addLoadBehaviour(this);
}
createItem(i) {
- return new Player(i, randomStatus(), randomLevel());
+ return new Regular(i, randomStatus(), randomLevel());
}
loadItem(data) {
let id = Number(data.id);
- let name = data.name;
let level = Number(data.level);
let status = Boolean(Number(data.status));
let games = Number(data.games);
- return new Player(id, status, level, games, name);
- }
- active() {
- return normalize(super.active());
+ let firstName = data.firstName;
+ let lastName = data.lastName;
+ return new Regular(id, status, level, games, firstName, lastName);
+ }
+ reset() {
+ for (let index = 0; index < this.data.length; index++ ){
+ this.data[index].games = 0;
+ this.data[index].status = false;
+ }
}
}
function parseLineToPlayer(data) {
- var info = data.split(",");
- var id = Number(info[0].trim());
- var name = info[1].trim() + " " + info[2].trim();
- var level = Number(info[3].trim());
- return new Player(id, randomStatus(), level, 0, name);
+ const info = data.split(",");
+ const id = Number(info[0].trim());
+ const firstName = info[1].trim();
+ const lastName = info[2].trim();
+ const level = Number(info[3].trim());
+ return new Regular(id, randomStatus(), level, 0, firstName, lastName);
}
function parseCsv(data) {
@@ -162,7 +176,7 @@ function parseCsv(data) {
}
function addLoadBehaviour(p) {
- const f = document.querySelector("#player-load input[type=file]");
+ const f = document.getElementById("player-load");
f.addEventListener("change", () => {
const file = f.files[0];
let importData;
--
cgit v1.3.1
From 4ff9794fa2b545134efe341ad012667c67f70d15 Mon Sep 17 00:00:00 2001
From: Karan Jayachandra
Date: Sat, 15 Nov 2025 20:09:51 +0100
Subject: Added the changes to include the game counting
---
index.html | 12 ++++++------
src/data.js | 32 +++++++++++++++++++-------------
src/main.js | 28 ++++++++++++++++++++++------
src/manage.js | 8 +++++---
src/style.css | 4 +++-
5 files changed, 55 insertions(+), 29 deletions(-)
(limited to 'src/manage.js')
diff --git a/index.html b/index.html
index 0b0e641..7a47a8d 100644
--- a/index.html
+++ b/index.html
@@ -11,7 +11,7 @@

-
-
` : playerState;
return `
Court ${this.id + 1}
diff --git a/src/main.js b/src/main.js
index 6d8f35b..3732e51 100644
--- a/src/main.js
+++ b/src/main.js
@@ -19,14 +19,17 @@ export class GameManager extends Manager {
this.render();
addGameBehaviour(this);
}
- createItem(i, description) {
+ createItem(i, description, status) {
if (typeof description === "undefined") {
description = "---";
}
+ if (typeof status === "undefined") {
+ status = true;
+ }
let player = new Regular(null, null, null, null, description, "");
console.log(player);
let team = new Team(player, player);
- return new Game(i, true, team, team);
+ return new Game(i, status, team, team);
}
loadItem(data) {
let id = Number(data.id);
@@ -37,21 +40,22 @@ export class GameManager extends Manager {
}
addBehaviour() {
let confirmedStatus = this.data[0].status;
+
let description = confirmedStatus ? "Round " + this.round : "Proposal";
- document.getElementById("Game_description").innerHTML = description;
+ document.getElementById("Game-description").innerHTML = description;
}
addBlockedGames() {
const inactiveCourts = this.courts.inactive();
console.log("Total reserved courts are " + inactiveCourts.length + ".");
for (let court of inactiveCourts) {
- this.data.push(this.createItem(court.id, "RESERVED"));
+ this.data.push(this.createItem(court.id, "RESERVED", false));
}
}
addInactiveGames(possibleMatches) {
const activeCourts = this.courts.active();
const unusedCourts = activeCourts.slice(possibleMatches + 1);
for (let court of unusedCourts) {
- this.data.push(this.createItem(court.id));
+ this.data.push(this.createItem(court.id, "---", false));
}
}
addActiveGames(possibleMatches) {
@@ -92,7 +96,7 @@ export class GameManager extends Manager {
p.print();
});
const shuffledPlayers = shuffle(activePlayers);
- shuffledPlayers.sort((a, b) => a.totalPlayed - b.totalPlayed);
+ shuffledPlayers.sort((a, b) => a.games - b.games);
const selectedPlayers = shuffledPlayers.slice(0, count);
selectedPlayers.sort((a, b) => a.level - b.level);
console.log("Selected players are:");
@@ -128,6 +132,18 @@ export class GameManager extends Manager {
this.data[i].status = true;
}
// Increment the number of games played
+ let selectedPlayers = [];
+ for (let game of this.data) {
+ console.log(game);
+ if ( game.teamOne.playerOne.name !== "RESERVED" ){
+ selectedPlayers.push(game.teamOne.playerOne.name);
+ selectedPlayers.push(game.teamOne.playerTwo.name);
+ selectedPlayers.push(game.teamTwo.playerOne.name);
+ selectedPlayers.push(game.teamTwo.playerTwo.name);
+ }
+ }
+ this.regulars.incrementGames(selectedPlayers);
+ this.guests.incrementGames(selectedPlayers);
this.store();
this.render();
document.getElementById("timer-start").click();
diff --git a/src/manage.js b/src/manage.js
index f8fe220..6ed58bd 100644
--- a/src/manage.js
+++ b/src/manage.js
@@ -38,7 +38,7 @@ export class Manager {
return i.render();
})
.join("");
- let elementId = this.data[0].description + "_list";
+ let elementId = this.data[0].description + "-list";
document.getElementById(elementId).innerHTML = renderedHTML;
this.addBehaviour();
}
@@ -111,12 +111,14 @@ export class GuestManager extends Manager {
active() {
return normalize(super.active());
}
- update(list) {
+ incrementGames(list) {
for (let index = 0; index < this.data.length; index++ ){
- if (this.data[index].name in list) {
+ if (list.includes(this.data[index].name)) {
+ console.log("Added game count to " + this.data[index].name);
this.data[index].games += 1;
}
}
+ this.store();
}
}
diff --git a/src/style.css b/src/style.css
index 197597b..d6ea4de 100644
--- a/src/style.css
+++ b/src/style.css
@@ -7,7 +7,9 @@
text-align: center;
width: 100px;
}
-
+#timer {
+ margin: 0;
+}
@media (min-width: 900px) {
#Regular_list button {
height: 100px;
--
cgit v1.3.1
From fef09593445dcf3a56ee9074b88bde7b0a9f33f9 Mon Sep 17 00:00:00 2001
From: Karan Jayachandra
Date: Sat, 15 Nov 2025 21:59:09 +0100
Subject: Added the changes to fix the bug with class name and changed the SVG
color to match the buttons
---
index.html | 44 +++++++++++++++++++++++++-------------------
public/icon.svg | 4 ++--
src/data.js | 12 ++++++------
src/main.js | 6 ++----
src/manage.js | 16 ++++++++++++----
src/style.css | 6 +++++-
6 files changed, 52 insertions(+), 36 deletions(-)
(limited to 'src/manage.js')
diff --git a/index.html b/index.html
index 7a47a8d..b99eb3f 100644
--- a/index.html
+++ b/index.html
@@ -1,22 +1,26 @@
-
+
Match Up!
+
+
+
+