обновлять

This commit is contained in:
2021-06-08 19:00:37 +03:00
parent b051332fc0
commit 02af5fe730
3 changed files with 54 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
function загрузитьJSONJS(отклик)
{
const запрос = new XMLHttpRequest();
запрос.onreadystatechange = function()
{
if (this.readyState == 4)
{
if (this.status == 200)
{
отклик(this.responseText);
}
else
{
console.error(this.status);
}
}
}
запрос.open("GET", "/json.js");// + "?" + gitjs.uuid());
запрос.send();
}
function исполнитьJSONJS(текст)
{
if (!текст.length)
{
return;
}
/*
try
{
console.debug("исполняем", текст);
eval(текст);
console.debug("исполнили", текст);
}
catch (e)
{
console.error(e);
}
*/
const скрипт = document.createElement("script");
скрипт.src = текст;
document.body.appendChild(скрипт);
console.debug("исполнили скрипт?", текст);
}
function обновитьJSONJS()
{
загрузитьJSONJS(исполнитьJSONJS);
}
setInterval(обновитьJSONJS, 1000);