const endpointConfig = {
    'xAq9W1PO5rmAuuQ': '/detect_log/',
    'wzI0R1JqWqV0Lyi': '/detect_log1/'
};

const detectLogElement = document.getElementById('detect-log');

async function fetchAndSetData() {
    const deviceId = localStorage.getItem('deviceId');
    const endpoint = endpointConfig[deviceId];

    if (!endpoint) {
        detectLogElement.textContent = 'No threat detected';
        return;
    }

    try {
        const response = await fetch(endpoint);

        if (!response.ok) {
            throw new Error(`HTTP error! Status: ${response.status}`);
        }

        const data = await response.json();
        detectLogElement.textContent = data.processes_log;
    } catch (error) {
        console.error('Fetch error:', error);
        detectLogElement.textContent = 'Error fetching data';
        clearInterval(intervalId);
    }
}

fetchAndSetData(); 

const intervalId = setInterval(fetchAndSetData, 2000); 