Spaces:
Running
Running
Download script.js from MavinGC/pump-doctor-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/MavinGC/pump-doctor-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/MavinGC/pump-doctor-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/MavinGC/pump-doctor-pro/resolve/main/script.js
1.83 kB
| // Shared functions across the application | |
| // Load recent calculations on homepage | |
| document.addEventListener('DOMContentLoaded', function() { | |
| if (document.getElementById('recentCalculations')) { | |
| loadRecentCalculations(); | |
| } | |
| }); | |
| function loadRecentCalculations() { | |
| const calculations = JSON.parse(localStorage.getItem('pumpCalculations') || '[]'); | |
| const tableBody = document.getElementById('recentCalculations'); | |
| if (calculations.length === 0) { | |
| tableBody.innerHTML = '<tr><td colspan="6" class="py-4 text-center text-gray-400">No recent calculations found</td></tr>'; | |
| return; | |
| } | |
| tableBody.innerHTML = calculations.slice(0, 5).map(calc => ` | |
| <tr class="border-b border-slate-700 hover:bg-slate-700 transition-colors"> | |
| <td class="py-3">${calc.date}</td> | |
| <td>${calc.type.charAt(0).toUpperCase() + calc.type.slice(1)}</td> | |
| <td>${calc.flowRate} m³/h</td> | |
| <td>${calc.head} m</td> | |
| <td>${calc.efficiency}</td> | |
| <td> | |
| <a href="calculator.html" class="text-primary hover:text-red-400 transition-colors"> | |
| <i data-feather="repeat" class="w-4 h-4"></i> | |
| </a> | |
| </td> | |
| </tr> | |
| `).join(''); | |
| feather.replace(); | |
| } | |
| // Theme toggle functionality | |
| function toggleDarkMode() { | |
| const html = document.documentElement; | |
| html.classList.toggle('dark'); | |
| localStorage.setItem('darkMode', html.classList.contains('dark')); | |
| } | |
| // Check for saved theme preference | |
| if (localStorage.getItem('darkMode') === 'false') { | |
| document.documentElement.classList.remove('dark'); | |
| } | |
| // Format numbers with units | |
| function formatNumber(value, unit) { | |
| if (isNaN(value)) return '-'; | |
| return `${parseFloat(value.toFixed(2))} ${unit}`; | |
| } |