root/indexgraph.html @ f62e9a91
301039da | Hamish Coleman | <html>
|
|
<head>
|
|||
<title>graph tree view test</title>
|
|||
</head>
|
|||
<body>
|
|||
<table>
|
|||
<tr>
|
|||
<td> <a href="javascript:index_load()">reload index</a> </td>
|
|||
<td> <a href="javascript:reload_graph()">reload graph</a> </td>
|
|||
<td> <a href="javascript:setall_graph('day')">Day</a> </td>
|
|||
<td> <a href="javascript:setall_graph('week')">Week</a> </td>
|
|||
<td> <a href="javascript:setall_graph('month')">Month</a> </td>
|
|||
<td> <a href="javascript:setall_graph('year')">Year</a> </td>
|
|||
f32530f7 | Hamish Coleman | <td> <div id="status"></div> </td>
|
|
301039da | Hamish Coleman | </tr>
|
|
</table>
|
|||
<div id="list">
|
|||
</div>
|
|||
<script language="javascript">
|
|||
function add_one_graph(g) {
|
|||
var div = document.createElement('div');
|
|||
div.appendChild(document.createTextNode(g.sequence+" "));
|
|||
div.appendChild(document.createTextNode("hh:mm:ss "));
|
|||
var title = document.createElement('b');
|
|||
title.appendChild(document.createTextNode(g.title));
|
|||
div.appendChild(title);
|
|||
div.appendChild(document.createElement('br'));
|
|||
var a = document.createElement('a');
|
|||
a.setAttribute("href",g.URL);
|
|||
var img = document.createElement('img');
|
|||
img.setAttribute('height',g.img.ysize);
|
|||
img.setAttribute('width',g.img.xsize);
|
|||
img.setAttribute('src',g.img.URL.day);
|
|||
img.setAttribute('name',g.name);
|
|||
a.appendChild(img);
|
|||
div.appendChild(a);
|
|||
div.appendChild(document.createElement('br'));
|
|||
div.appendChild(document.createElement('br'));
|
|||
return div;
|
|||
}
|
|||
var global_index;
|
|||
function index_available(index) {
|
|||
global_index = index;
|
|||
var div = document.createElement('div');
|
|||
for (g in index.graph) {
|
|||
div.appendChild(add_one_graph(index.graph[g]));
|
|||
}
|
|||
var list = document.getElementById('list');
|
|||
div.setAttribute("id","list");
|
|||
list.parentNode.replaceChild(div,list);
|
|||
f32530f7 | Hamish Coleman | ||
//setTimeout('reload_graph()',300000);
|
|||
301039da | Hamish Coleman | }
|
|
function setall_graph(type) {
|
|||
f32530f7 | Hamish Coleman | var status = document.getElementById('status');
|
|
status.innerHTML='GET';
|
|||
301039da | Hamish Coleman | for (i in global_index.graph) {
|
|
f32530f7 | Hamish Coleman | status.innerHTML=i;
|
|
301039da | Hamish Coleman | var g = global_index.graph[i];
|
|
document.images[g.name].src = g.img.URL[type];
|
|||
}
|
|||
f32530f7 | Hamish Coleman | status.innerHTML='';
|
|
301039da | Hamish Coleman | }
|
|
function reload_graph() {
|
|||
f32530f7 | Hamish Coleman | var status = document.getElementById('status');
|
|
status.innerHTML='GET';
|
|||
301039da | Hamish Coleman | var now = new Date();
|
|
for (i in global_index.graph) {
|
|||
f32530f7 | Hamish Coleman | status.innerHTML=i;
|
|
301039da | Hamish Coleman | var g = global_index.graph[i];
|
|
document.images[g.name].src = document.images[g.name].src
|
|||
+ "?" + now.getTime();
|
|||
}
|
|||
f32530f7 | Hamish Coleman | status.innerHTML='';
|
|
301039da | Hamish Coleman | }
|
|
function index_load() {
|
|||
var status = document.getElementById('status');
|
|||
var req = new XMLHttpRequest();
|
|||
status.innerHTML='GET';
|
|||
req.open("GET","http://logs.zot.org/mrtg/indexmrtg.cgi",/*async*/true);
|
|||
req.onreadystatechange = function() {
|
|||
if (req.readyState == 4 /*complete*/) {
|
|||
status.innerHTML +=',GOT';
|
|||
var index = eval('(' + req.responseText + ')');
|
|||
status.innerHTML +=',BUILD';
|
|||
index_available(index);
|
|||
status.innerHTML='';
|
|||
}
|
|||
};
|
|||
req.send(/*no params*/null);
|
|||
}
|
|||
</script>
|
|||
</body>
|
|||
</html>
|