Update BitcoinProgressBar.js

This commit is contained in:
DJObleezy 2025-03-27 09:48:39 -07:00 committed by GitHub
parent 58397c2c9b
commit 1e85ebb48d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,7 +45,7 @@ const BitcoinMinuteRefresh = (function () {
</div> </div>
<span id="terminal-clock" class="terminal-clock">00:00:00</span> <span id="terminal-clock" class="terminal-clock">00:00:00</span>
</div> </div>
<!-- Removed for now
<div class="minute-progress-container"> <div class="minute-progress-container">
<div class="minute-labels"> <div class="minute-labels">
<span>0s</span> <span>0s</span>
@ -64,7 +64,7 @@ const BitcoinMinuteRefresh = (function () {
Next refresh at the top of the minute Next refresh at the top of the minute
</div> </div>
</div> </div>
-->
<div id="uptime-timer" class="uptime-timer"> <div id="uptime-timer" class="uptime-timer">
<div class="uptime-title">UPTIME</div> <div class="uptime-title">UPTIME</div>
<div class="uptime-display"> <div class="uptime-display">
@ -549,56 +549,17 @@ const BitcoinMinuteRefresh = (function () {
*/ */
function updateMinuteProgress() { function updateMinuteProgress() {
try { try {
// Get current server time // Get current server time - keep this for other functions that might use it
const now = new Date(Date.now() + (serverTimeOffset || 0)); const now = new Date(Date.now() + (serverTimeOffset || 0));
const seconds = now.getSeconds();
const milliseconds = now.getMilliseconds();
// Calculate precise progress within the minute (0-1) // We need to keep track of minutes for other functionality
const progress = (seconds + (milliseconds / 1000)) / 60;
// Update the progress bar
const progressBar = document.getElementById('minute-progress-inner');
if (progressBar) {
// Set the width based on the current progress through the minute
progressBar.style.width = (progress * 100) + "%";
// Add effects when close to the end of the minute
if (seconds >= 50) {
progressBar.classList.add('near-refresh');
document.getElementById('refresh-status').textContent = `Refresh in ${60 - seconds} seconds...`;
} else {
progressBar.classList.remove('near-refresh');
document.getElementById('refresh-status').textContent = 'Next refresh at the top of the minute';
}
// Flash when reaching 00 seconds (new minute)
if (seconds === 0 && milliseconds < 500) {
progressBar.classList.add('refresh-now');
document.getElementById('refresh-status').textContent = 'Refreshing data...';
// Remove the class after animation completes
setTimeout(() => {
progressBar.classList.remove('refresh-now');
}, 1000);
} else {
progressBar.classList.remove('refresh-now');
}
}
// Check if we've crossed into a new minute
const currentMinute = now.getMinutes(); const currentMinute = now.getMinutes();
if (lastMinuteValue !== -1 && currentMinute !== lastMinuteValue && seconds === 0) {
// Trigger refresh on minute change (only when seconds are 0)
if (typeof refreshCallback === 'function') {
console.log('New minute started - triggering refresh...');
refreshCallback();
}
}
// Update last minute value // Update last minute value (keeping this for any other code that might rely on it)
lastMinuteValue = currentMinute; lastMinuteValue = currentMinute;
// No progress bar updates or effects
} catch (e) { } catch (e) {
console.error("BitcoinMinuteRefresh: Error updating progress bar:", e); console.error("BitcoinMinuteRefresh: Error updating progress bar:", e);
} }
@ -654,6 +615,12 @@ const BitcoinMinuteRefresh = (function () {
if (minimizedUptimeElement) { if (minimizedUptimeElement) {
minimizedUptimeElement.textContent = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`; minimizedUptimeElement.textContent = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
} }
// NEW CODE: Update the dashboard's uptime display if it exists
const dashboardUptimeElement = document.getElementById('uptimeTimer');
if (dashboardUptimeElement) {
dashboardUptimeElement.innerHTML = `<strong>Uptime:</strong> ${String(hours).padStart(2, '0')}h ${String(minutes).padStart(2, '0')}m ${String(seconds).padStart(2, '0')}s`;
}
} catch (e) { } catch (e) {
console.error("BitcoinMinuteRefresh: Error updating uptime:", e); console.error("BitcoinMinuteRefresh: Error updating uptime:", e);
} }
@ -686,6 +653,12 @@ const BitcoinMinuteRefresh = (function () {
uptimeElement = document.getElementById('uptime-timer'); uptimeElement = document.getElementById('uptime-timer');
} }
// NEW CODE: Check if dashboard uptime element exists
const dashboardUptimeElement = document.getElementById('uptimeTimer');
if (dashboardUptimeElement) {
console.log("BitcoinMinuteRefresh: Found dashboard uptime element, will sync with it");
}
// Try to get stored server time information // Try to get stored server time information
try { try {
serverTimeOffset = parseFloat(localStorage.getItem('serverTimeOffset') || '0'); serverTimeOffset = parseFloat(localStorage.getItem('serverTimeOffset') || '0');
@ -849,4 +822,4 @@ document.addEventListener('DOMContentLoaded', function () {
} else { } else {
console.log("BitcoinMinuteRefresh: No refresh function found, will need to be initialized manually"); console.log("BitcoinMinuteRefresh: No refresh function found, will need to be initialized manually");
} }
}); });