CoolFace
Apppublic

babalinyo/marineguard

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
script.js58 linesDownload Raw Back to root
1 2// Simulate real-time data updates3document.addEventListener('DOMContentLoaded', function() {4    // Update sensor data periodically5    setInterval(updateSensorData, 5000);6    7    // Initialize feather icons8    feather.replace();9});10 11function updateSensorData() {12// Simulate updating sensor values13    const tempElement = document.querySelector('.temp-value');14    const phElement = document.querySelector('.ph-value');15    const turbidityElement = document.querySelector('.turbidity-value');16    const oxygenElement = document.querySelector('.oxygen-value');17    18    if (tempElement) {19        const newTemp = (24 + Math.random() * 1).toFixed(1);20        tempElement.textContent = `${newTemp}°C`;21    }22    23    if (phElement) {24        const newPh = (7.0 + Math.random() * 0.4).toFixed(1);25        phElement.textContent = newPh;26    }27    28    if (turbidityElement) {29        const newTurbidity = (10 + Math.random() * 5).toFixed(1);30        turbidityElement.textContent = `${newTurbidity} NTU`;31    }32    33    if (oxygenElement) {34        const newOxygen = (6.5 + Math.random() * 0.6).toFixed(1);35        oxygenElement.textContent = `${newOxygen} mg/L`;36    }37}38// Simulate vehicle status updates39function updateVehicleStatus() {40    const batteryText = document.querySelector('.battery-text');41    const batteryFill = document.querySelector('.battery-fill');42    43    if (batteryText && batteryFill) {44        const level = 80 + Math.floor(Math.random() * 15);45        batteryText.textContent = `${level}%`;46        batteryFill.style.width = `${level}%`;47    }48}49// Update vehicle status every 30 seconds50setInterval(updateVehicleStatus, 30000);51// Initialize map (placeholder)52function initMap() {53    console.log('Initializing map...');54    // In a real app, this would initialize a mapping library55}56 57// Call when page loads58window.addEventListener('load', initMap);