От Алекс Гайвер. https://github.com/GyverLibs/GyverPortal/tree/7ba61a44fbf1224095980736638c6c551f9837b2
и в конце концов, добавляя различные плюшки, мы получим ровно то же самое, что и в штатном веб интерфейсе, но в гораздо более урезанном варианте.
не понимаю.
Вот скопировал с консоли
Код: Выделить всё
var xhr01 = 0;
var timerId01 = 0;
var status01=0;
get01();
function get01() {
clearTimeout(timerId01);
xhr01 = new XMLHttpRequest();
xhr01.open("GET", "", true);
xhr01.timeout = 2000;
xhr01.send();
xhr01.addEventListener("readystatechange", processRequest, true);
}
document.addEventListener("visibilitychange", handleVisibilityChange, false);
function processRequest() {
if (xhr01.status == 200) {
document.getElementById("statusconnect").innerHTML = "Подключено";
status01 = document.getElementById("statusconnect");
status01.style.background = "lime";
}
if (xhr01.status != 200) {
document.getElementById("statusconnect").innerHTML = "Нет связи";
status01 = document.getElementById("statusconnect");
status01.style.background = "red";
}
clearTimeout(timerId01);
timerId01 = setTimeout(get01, 2000);
}
xhr01.ontimeout = function() {
document.getElementById("statusconnect").innerHTML = "Нет связи";
status01 = document.getElementById("statusconnect");
status01.style.background = "red";
};
function handleVisibilityChange() {
clearTimeout(timerId01);
timerId01 = setTimeout(get01, 2000);
}
Для кнопок сделал справа и слева, по координатам можно, но сложновато для меня.
вот, возможно, и ответ на моргание)))