Добавил сайт

This commit is contained in:
2024-01-15 03:50:54 +03:00
parent 68e421b336
commit 3f65dd50d3
9 changed files with 355 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
class AnomalyLogs {
// Конструктор
constructor() {
this.last_index = -1;
}
// Отправка запроса на сервер
SendRequest() {
var request = {};
request.command = 'anomaly_logs';
request.parameters = {
'last_index': this.last_index
};
let request_data = JSON.stringify(request);
socket.send(request_data);
}
// Обработка ответа от сервера
// respone -- ответ сервера
ProcessResponse(response) {
this.UpdateData(response);
}
// Обновление данных
// respone -- ответ от сервера
UpdateData(response) {
let logs = response["result"];
if (logs == null)
return;
var last_index = this.last_index;
for (const key in logs) {
var row = window.anomaly_logs_table.insertRow();
var cell = row.insertCell(0);
cell.innerHTML = logs[key];
let index = Number(key);
if (index > last_index)
last_index = index;
}
this.last_index = last_index
}
}
function UpdateAnomalyLogs() {
window.anomaly_logs.SendRequest()
}
+4
View File
@@ -0,0 +1,4 @@
function InitAnomalyLogs() {
window.anomaly_logs = new AnomalyLogs();
window.anomaly_logs_table = document.getElementById("anomaly-logs-table");
}