esp32-sk6812/data/htdocs/anim.js

31 lines
563 B
JavaScript

function callURL(url)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
function getjson(url, handler_func)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if(this.readyState == 4 && this.status == 200) {
var data = JSON.parse(this.responseText);
handler_func(data);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
function getAnimList(handler_func)
{
return getjson("/api/listanim", handler_func);
}
function setAnim(id)
{
callURL("/api/setanim?anim=" + id);
}