Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ <h2>Import Hello Club Events</h2>
</div>

</div>
<script src="script.js?v=20251030"></script>
<script src="script.js?v=20251030b"></script>
</body>
</html>

5 changes: 5 additions & 0 deletions data/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ function updateNTPStatus(data) {
tooltip += `\nAuto-sync: every ${data.autoSyncInterval} min`;
}
ntpStatusElement.title = tooltip;

// Update the time display with the timezone-adjusted time from the server
if (data.time && timeElement) {
timeElement.textContent = data.time;
}
} else {
ntpStatusElement.className = 'ntp-status ntp-error';
ntpStatusElement.textContent = '✗';
Expand Down
52 changes: 47 additions & 5 deletions test-server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ let schedules = [
}
];

let currentTimezone = 'Pacific/Auckland'; // Default timezone

let operators = [
{ username: "operator1", password: "pass123" },
{ username: "operator2", password: "test456" }
Expand Down Expand Up @@ -124,6 +126,18 @@ function getNextWeekday(targetDay, hour, minute) {
return result.toISOString();
}

// Helper function to get formatted time in selected timezone
function getFormattedTime() {
const now = new Date();
return now.toLocaleTimeString('en-US', {
timeZone: currentTimezone,
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
});
}

// Client tracking
const clients = new Map();
let nextClientId = 1;
Expand All @@ -149,8 +163,8 @@ wss.on('connection', (ws) => {
sendMessage(ws, {
event: 'ntp_status',
synced: true,
time: new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true }),
timezone: 'Pacific/Auckland',
time: getFormattedTime(),
timezone: currentTimezone,
dateTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
autoSyncInterval: 30
});
Expand Down Expand Up @@ -357,6 +371,34 @@ function handleMessage(clientId, ws, msg) {
console.log('🔄 Factory reset completed');
break;

case 'set_timezone':
if (client.role !== 'admin') {
sendError(ws, 'Permission denied - admin only');
return;
}
const newTimezone = msg.timezone;
if (!newTimezone) {
sendError(ws, 'Timezone required');
return;
}
currentTimezone = newTimezone;
sendMessage(ws, {
event: 'timezone_changed',
timezone: currentTimezone,
message: 'Timezone updated successfully. Please refresh schedules.'
});
// Broadcast updated NTP status with new timezone to all clients
broadcast({
event: 'ntp_status',
synced: true,
time: getFormattedTime(),
timezone: currentTimezone,
dateTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
autoSyncInterval: 30
});
console.log(`🌍 Timezone changed to: ${currentTimezone}`);
break;

// Hello Club Integration
case 'get_helloclub_settings':
if (client.role !== 'admin') {
Expand Down Expand Up @@ -669,13 +711,13 @@ setInterval(() => {
}
}, 1000);

// Simulate NTP status updates
// Simulate NTP status updates (every 5 seconds)
setInterval(() => {
broadcast({
event: 'ntp_status',
synced: true,
time: new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true }),
timezone: 'Pacific/Auckland',
time: getFormattedTime(),
timezone: currentTimezone,
dateTime: new Date().toISOString().replace('T', ' ').substring(0, 19),
autoSyncInterval: 30
});
Expand Down