diff --git a/assets/js/main.js b/assets/js/main.js index b79be0f..7ad28dc 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -211,8 +211,6 @@ const app = { this.el.btnReset.addEventListener('click', () => this.resetTimer()); this.el.btnLap.addEventListener('click', () => this.recordLap()); this.el.btnNext.addEventListener('click', () => this.recordRelaySplit()); - this.el.btnAddParticipant = document.getElementById('btn-add-participant'); - if (this.el.btnAddParticipant) this.el.btnAddParticipant.addEventListener('click', () => this.addParticipant()); this.el.btnRelaySplit.addEventListener('click', () => this.recordRelaySplit()); this.el.btnSaveMain.addEventListener('click', () => this.saveCurrentTimer()); this.el.btnSaveBuilder.addEventListener('click', () => this.saveCurrentTimer()); @@ -231,7 +229,7 @@ const app = { this.el.settingIsCountdown.addEventListener('change', () => this.resetTimer()); this.el.lapSort.addEventListener('change', () => this.renderHistory()); - // this.el.participantCount.addEventListener('input', () => this.renderParticipantInputs()); + this.el.participantCount.addEventListener('input', () => this.renderParticipantInputs()); this.el.savedTimersDropdown.addEventListener('change', (e) => { if (e.target.value) { @@ -375,7 +373,7 @@ const app = { } else if (mode.hasRelay) { this.el.listTitle.textContent = 'Relay Splits'; this.el.listHead.innerHTML = 'ParticipantStart TimeSplit TimeTotal Time'; - const count = 2; this.renderParticipantInputs(); + this.renderParticipantInputs(); } else if (mode.isCustom) { this.el.listTitle.textContent = 'Activities'; this.el.listHead.innerHTML = 'ActivityDurationStatus'; @@ -398,42 +396,22 @@ const app = { }, renderParticipantInputs() { - const participantInputs = document.querySelectorAll(".participant-name-input"); - const count = participantInputs.length; + const count = Math.min(12, Math.max(1, parseInt(this.el.participantCount.value) || 1)); + this.el.participantCount.value = count; - let html = ""; + let html = ''; for (let i = 1; i <= count; i++) { - const input = participantInputs[i - 1]; - const nameValue = input.value; const defaultColor = this.relayColors[(i - 1) % this.relayColors.length]; html += `
#${i} - +
`; } this.el.participantNamesContainer.innerHTML = html; - if (this.el.btnAddParticipant) this.el.btnAddParticipant.disabled = count >= 12; - } - - addParticipant() { - const count = document.querySelectorAll(".participant-name-input").length; - if (count >= 12) return; - - const i = count + 1; - const defaultColor = this.relayColors[(i - 1) % this.relayColors.length]; - const newHtml = ` -
- #${i} - - -
- `; - this.el.participantNamesContainer.insertAdjacentHTML("beforeend", newHtml); - if (this.el.btnAddParticipant) this.el.btnAddParticipant.disabled = i >= 12; - } + }, handleStartClick() { if (!this.el.sessionTitle.value.trim()) { @@ -930,7 +908,7 @@ const app = { }, updateRelayActiveDisplay() { - const maxParticipants = document.querySelectorAll(".participant-name-input").length; + const maxParticipants = parseInt(this.el.participantCount.value) || 1; if (this.currentParticipant > maxParticipants) { this.el.relayActiveParticipantContainer.classList.add('d-none'); this.el.relayParticipantTimer.classList.add('d-none'); @@ -952,7 +930,7 @@ const app = { const now = this.elapsedTime; const lastTime = this.history.length > 0 ? this.history[this.history.length - 1].time : 0; const delta = now - lastTime; - const maxParticipants = document.querySelectorAll(".participant-name-input").length; + const maxParticipants = parseInt(this.el.participantCount.value) || 1; if (this.currentParticipant > maxParticipants && !isFinal) return; diff --git a/index.php b/index.php index 02cc7fc..a746724 100644 --- a/index.php +++ b/index.php @@ -249,9 +249,10 @@ $projectImage = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
-

Participants

-
- +

Participants

+
+ +