Update templates/index.html
This commit is contained in:
parent
3d2997772b
commit
bc70f56954
1 changed files with 8 additions and 9 deletions
|
@ -32,38 +32,37 @@
|
|||
|
||||
<script>
|
||||
// Configuration values provided by the server
|
||||
const TOKEN_RESET_HOUR = {{ token_reset_time_utc }}; // e.g., 0 for midnight UTC
|
||||
const DOWNTIME_MINUTES = {{ downtime_before_token_reset }}; // e.g., 30 minutes
|
||||
const TOKEN_RESET_HOUR = {{ config.token_reset_time_utc }}; // e.g., 0 for midnight UTC
|
||||
const DOWNTIME_MINUTES = {{ config.downtime_before_token_reset }}; // e.g., 30 minutes
|
||||
|
||||
function updateCountdown() {
|
||||
const now = new Date();
|
||||
const resetTime = new Date();
|
||||
|
||||
// Set to next occurrence of the reset time
|
||||
// Calculate next reset time
|
||||
const resetTime = new Date();
|
||||
resetTime.setUTCHours(TOKEN_RESET_HOUR, 0, 0, 0);
|
||||
if (now > resetTime) {
|
||||
resetTime.setDate(resetTime.getDate() + 1);
|
||||
}
|
||||
|
||||
// Calculate downtime start
|
||||
// Calculate when registration should close
|
||||
const downtimeStart = new Date(resetTime);
|
||||
downtimeStart.setMinutes(downtimeStart.getMinutes() - DOWNTIME_MINUTES);
|
||||
|
||||
// Update form visibility based on whether we're in downtime
|
||||
const isRegistrationOpen = now < downtimeStart;
|
||||
|
||||
// Update UI based on registration status
|
||||
document.getElementById('registration-form').style.display =
|
||||
isRegistrationOpen ? 'block' : 'none';
|
||||
document.getElementById('registration-closed').style.display =
|
||||
isRegistrationOpen ? 'none' : 'block';
|
||||
|
||||
// Update info message based on status
|
||||
// Update info message based on registration status
|
||||
const infoMessage = document.getElementById('info-message');
|
||||
infoMessage.textContent = isRegistrationOpen
|
||||
? 'A registration token will be emailed to you.'
|
||||
: 'Please come back after the token resets.';
|
||||
|
||||
// Format time until reset (not until downtime)
|
||||
// Always show countdown to reset time (not downtime)
|
||||
const timeUntilReset = resetTime - now;
|
||||
const hours = String(Math.floor(timeUntilReset / (1000 * 60 * 60))).padStart(2, '0');
|
||||
const minutes = String(Math.floor((timeUntilReset % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0');
|
||||
|
|
Loading…
Add table
Reference in a new issue