diff --git a/static/js/main.js b/static/js/main.js index 3a881cf..7cd4803 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -2212,6 +2212,98 @@ function resetDashboardChart() { } } + +// Add keyboard event listener for Alt+W to reset wallet address +$(document).keydown(function (event) { + // Check if Alt+W is pressed (key code 87 is 'W') + if (event.altKey && event.keyCode === 87) { + resetWalletAddress(); + + // Prevent default browser behavior + event.preventDefault(); + } +}); + +// Function to reset wallet address in configuration and clear chart data +function resetWalletAddress() { + if (confirm("Are you sure you want to reset your wallet address? This will also clear all chart data and redirect you to the configuration page.")) { + // First clear chart data using the existing API endpoint + $.ajax({ + url: '/api/reset-chart-data', + method: 'POST', + success: function () { + console.log("Chart data reset successfully"); + + // Then reset the chart display locally + if (trendChart) { + trendChart.data.labels = []; + trendChart.data.datasets[0].data = []; + trendChart.update('none'); + } + + // Then reset wallet address + fetch('/api/config') + .then(response => response.json()) + .then(config => { + // Reset the wallet address to default + config.wallet = "yourwallethere"; + + // Save the updated configuration + return fetch('/api/config', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(config) + }); + }) + .then(response => response.json()) + .then(data => { + console.log("Wallet address reset successfully:", data); + // Also clear arrow indicator states + arrowIndicator.clearAll(); + // Redirect to the boot page for reconfiguration + window.location.href = window.location.origin + "/"; + }) + .catch(error => { + console.error("Error resetting wallet address:", error); + alert("There was an error resetting your wallet address. Please try again."); + }); + }, + error: function (xhr, status, error) { + console.error("Error clearing chart data:", error); + // Continue with wallet reset even if chart reset fails + resetWalletAddressOnly(); + } + }); + } +} + +// Fallback function if chart reset fails +function resetWalletAddressOnly() { + fetch('/api/config') + .then(response => response.json()) + .then(config => { + config.wallet = "yourwallethere"; + return fetch('/api/config', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(config) + }); + }) + .then(response => response.json()) + .then(data => { + console.log("Wallet address reset successfully (without chart reset):", data); + window.location.href = window.location.origin + "/"; + }) + .catch(error => { + console.error("Error resetting wallet address:", error); + alert("There was an error resetting your wallet address. Please try again."); + }); +} + $(document).ready(function () { // Apply theme based on stored preference - moved to beginning for better initialization try { @@ -2309,7 +2401,7 @@ $(document).ready(function () { y: { title: { display: true, - text: 'HASHRATE', + text: 'HASHRATE (TH/S)', color: theme.PRIMARY, font: { family: "'VT323', monospace", diff --git a/templates/boot.html b/templates/boot.html index b128647..eb63472 100644 --- a/templates/boot.html +++ b/templates/boot.html @@ -68,9 +68,9 @@ }); -
Loading mining data...