Project

General

Profile

Download (2.48 KB) Statistics
| Branch: | Revision:
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> <div id="status"></div> </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>
</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);
}

function setall_graph(type) {
for (i in global_index.graph) {
var g = global_index.graph[i];
document.images[g.name].src = g.img.URL[type];
}
}

function reload_graph() {
var now = new Date();
for (i in global_index.graph) {
var g = global_index.graph[i];
document.images[g.name].src = document.images[g.name].src
+ "?" + now.getTime();
}
}

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>