aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorKaran Jayachandra <mail@karanjayachandra.com>2025-11-09 15:57:07 +0100
committerKaran Jayachandra <mail@karanjayachandra.com>2025-11-09 15:57:07 +0100
commit3dc01fbb930a4eacf416a9cc7911d90da75e6c33 (patch)
treedd25d62d619d62ed7d2657e37352caaa749abfd7 /index.js
parent6456fae865aae8b2ba398b5f78f2589c93d0643d (diff)
Moved a lot of the functionality
Diffstat (limited to 'index.js')
-rw-r--r--index.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/index.js b/index.js
index 5d34c96..98236a4 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,7 @@
+import { Round } from "./game.mjs";
import { generateCourts } from "./court.mjs";
import { generatePlayers } from "./player.mjs";
+import { addToggleBehaviour } from "./utils.mjs";
// Court handling
let courts = generateCourts();
@@ -8,17 +10,21 @@ addToggleBehaviour(courts, "court_");
// Regulars handling
let regulars = generatePlayers();
addToggleBehaviour(regulars, "regular_");
-
-function addToggleBehaviour(list, description) {
- let renderedHTML = list.map((i) => {return i.render();}).join('');
- let listId = description + 'list';
- document.getElementById(listId).innerHTML = renderedHTML;
- for (let index = 0; index < list.length; ++index) {
- const p = document.getElementById(description + index);
- p.addEventListener("click", () => {
- list[index].toggle();
- p.classList.toggle('secondary');
- p.classList.toggle('outline');
- });
+const fileInput = document.querySelector("#file-js input[type=file]");
+ if (fileInput !== null) {
+ fileInput.onchange = () => {
+ if (fileInput.files.length > 0) {
+ const fileName = document.querySelector("#file-js .file-name");
+ fileName.textContent = fileInput.files[0].name;
+ console.log(fileInput.files[0]);
+ }
}
-} \ No newline at end of file
+};
+
+// Game handling
+let games = new Round(0, courts);
+let renderedHTML = games.render();
+document.getElementById("game_list").innerHTML = renderedHTML;
+document.getElementById("propose").addEventListener("click", () => {
+ console.log("Propose new games!");
+}) \ No newline at end of file