diff options
| author | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-11 16:23:12 +0100 |
|---|---|---|
| committer | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-11 16:23:12 +0100 |
| commit | 5dcf65616f82cb9b652f6913c93e26ff50983fdf (patch) | |
| tree | d5e04b77772b5845d4bd3106ad968322d41739a9 /index.js | |
| parent | dd0c6a458ef5229a5fddf0e7cae25fb3a5d495f7 (diff) | |
Data load added
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1,22 +1,30 @@ import { Round } from "./game.mjs"; import { generateCourts } from "./court.mjs"; -import { generatePlayers } from "./player.mjs"; +import { csvToPlayers, generatePlayers } from "./player.mjs"; import { addToggleBehaviour } from "./utils.mjs"; // Court handling let courts = generateCourts(); addToggleBehaviour(courts, "court_"); + // Regulars handling let regulars = generatePlayers(); addToggleBehaviour(regulars, "regular_"); -const fileInput = document.querySelector("#file-js input[type=file]"); +const fileInput = document.querySelector("#player-load 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]); + const file = fileInput.files[0]; + if (file) { + const reader = new FileReader(); + reader.onload = function(e) { + const content = e.target.result; + regulars = csvToPlayers(content); + addToggleBehaviour(regulars, "regular_"); + }; + reader.readAsText(file); + } } } }; |
