ocarina/html/utils.js
Bryan Schumaker ef5be29197 web: better controls
I split out the web controls to a new file, and can set the status of
the play button correctly when the page is loaded.  Finally, the
set_play_button() function is called on a timer so changes on the
application will be reflected on the web page eventually.
2010-12-27 19:00:27 -05:00

39 lines
792 B
JavaScript

// Bryan Schumaker (12 / 27 / 2010)
function set_attr(attr, id)
{
var req = new XMLHttpRequest();
req.onreadystatechange = function()
{
if (req.readyState == 4 && req.status == 200)
{
document.getElementById(id).innerHTML = req.responseText;
}
}
req.open('GET', "controls.py?a=" + attr, true);
req.send();
setTimeout("set_attr(\"" + attr + "\", \"" + id + "\")", 3000)
}
function set_attr_once(attr, id)
{
var req = new XMLHttpRequest();
req.onreadystatechange = function()
{
if (req.readyState == 4 && req.status == 200)
{
document.getElementById(id).innerHTML = req.responseText;
}
}
req.open('GET', "controls.py?a=" + attr, true);
req.send();
}
function send_request(url)
{
var http = new XMLHttpRequest();
http.open('GET', url, true);
http.send();
}