utils.js: separate attr and id
I was using the attribute as the object id in the html page. By splitting the two, I can have the same attribute set in multiple places on a single page independently.
This commit is contained in:
parent
7c7bf03d71
commit
66a637815e
|
@ -8,12 +8,12 @@
|
|||
<tr><td><a href="library.py">Library Browser</a></td></tr>
|
||||
<tr><td><a href="library2.py">Library Browser 2</a></td></tr>
|
||||
<tr><td><a href="controls.html">Remote Controls</a></td></tr>
|
||||
<tr><td id="version"></td><td id="uptime"></td></tr>
|
||||
<tr><td id="vers"></td><td id="up"></td></tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
set_attr("version");
|
||||
set_attr("uptime");
|
||||
set_attr("version", "vers");
|
||||
set_attr("uptime", "up");
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
// Bryan Schumaker (12 / 27 / 2010)
|
||||
|
||||
function set_attr(attr)
|
||||
function set_attr(attr, id)
|
||||
{
|
||||
var req = new XMLHttpRequest();
|
||||
req.onreadystatechange = function()
|
||||
{
|
||||
if (req.readyState == 4 && req.status == 200)
|
||||
{
|
||||
document.getElementById(attr).innerHTML = req.responseText;
|
||||
document.getElementById(id).innerHTML = req.responseText;
|
||||
}
|
||||
}
|
||||
|
||||
req.open('GET', "controls.py?a=" + attr, true)
|
||||
req.send()
|
||||
setTimeout("set_attr(\"" + attr + "\")", 3000)
|
||||
setTimeout("set_attr(\"" + attr + "\", \"" + id + "\")", 3000)
|
||||
}
|
||||
|
||||
function do_request(action)
|
||||
|
|
Loading…
Reference in New Issue