web_defender/Device/static/ransomware/js/detectlog.js
2024-12-09 13:43:16 +05:30

35 lines
971 B
JavaScript

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);