From 1b9af74cdc117bc9a48841d6f7b5ae396302d3b8 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Mon, 27 Dec 2010 12:41:33 -0500 Subject: [PATCH] Added utils.js The utils.js file is an external javascript file that will make it easier to set attributes / do controls from more than one page. --- html/utils.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 html/utils.js diff --git a/html/utils.js b/html/utils.js new file mode 100644 index 00000000..03f86a41 --- /dev/null +++ b/html/utils.js @@ -0,0 +1,25 @@ +// Bryan Schumaker (12 / 27 / 2010) + +function set_attr(attr) +{ + var req = new XMLHttpRequest(); + req.onreadystatechange = function() + { + if (req.readyState == 4 && req.status == 200) + { + document.getElementById(attr).innerHTML = req.responseText; + } + } + + req.open('GET', "controls.py?a=" + attr, true) + req.send() + setTimeout("set_attr(\"" + attr + "\")", 3000) +} + +function do_request(action) +{ + var http = new XMLHttpRequest(); + http.open('GET', "controls.py?a=" + action, true); + http.send(); + return http; +}