diff options
author | Stef Walter <stef@memberwebs.com> | 2006-04-11 21:30:34 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2006-04-11 21:30:34 +0000 |
commit | b97f1ade009887d1436dc558f1e3262a97a54d42 (patch) | |
tree | 0a4ae49ea9fbb0ae2bfee1493132c1207ee2f793 /html/rrdui.js | |
parent | 2fcfb1f6edea8c3011d1fba1b43b43474138af29 (diff) |
Removed <category> element for simplicity.
Diffstat (limited to 'html/rrdui.js')
-rw-r--r-- | html/rrdui.js | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/html/rrdui.js b/html/rrdui.js index fb0c109..7528ecc 100644 --- a/html/rrdui.js +++ b/html/rrdui.js @@ -87,8 +87,8 @@ function displayCurrentPage() } } - var data = findCategoryData(categoryCurrent); - if(!xmlData || !data) + var graphs = findCategoryGraphs(categoryCurrent); + if(!graphs) { displayError("Graph data isn't loaded from server", area); return; @@ -97,12 +97,9 @@ function displayCurrentPage() var tend = nowTime(); var tbeg = tend - 86400; /* One day by default */ - var children = data.childNodes; - for(i = 0; i < children.length; i++) + for(i = 0; i < graphs.length; i++) { - var child = children.item(i); - if(child.nodeType != 1 || child.nodeName != "graph") - continue; + var child = graphs[i]; var name = child.getAttribute("name"); if(!name || !name.length) @@ -163,6 +160,8 @@ function displayCurrentPage() function reloadGraph(img, force) { + img._last = nowTime(); + if(!img._visible) return; @@ -193,8 +192,6 @@ function reloadGraph(img, force) /* HACK: The onload event for IMG is called with a strange event target */ img.onload = new Function("reloadedGraph('" + img.id + "');"); img.setAttribute("src", uri); - - img._last = nowTime(); } } @@ -225,7 +222,7 @@ function autoScroll(img) /* If we're displaying 'now' somewhere in the graph... */ var now = nowTime(); - if((img._tend + img._tinterval + 2) >= now) + if((img._tend + (img._tinterval * 2)) >= now) { var diff = now - img._last; @@ -549,21 +546,21 @@ function actionGotoChange() * GROUP CATEGORIES */ -function findCategoryData(cat) +function findCategoryGraphs(cat) { var i; if(!xmlData) return null; - var cats = xmlData.getElementsByTagName("category"); - for(i = 0; i < cats.length; i++) + var ret = new Array(); + var graphs = xmlData.getElementsByTagName("graph"); + for(i = 0; i < graphs.length; i++) { - if(cats.item(i).getAttribute("name") == cat) - return cats.item(i); + if(graphs.item(i).getAttribute("category") == cat) + ret.push(graphs.item(i)); } - - return null; + return ret; } function changeCategory(evt) @@ -575,16 +572,23 @@ function changeCategory(evt) function displayCategories() { - var i; + var cats = new Object(); + var cat, i, name; /* Get the template and clean it up a bit */ var template = document.getElementById("header-template"); - var groups = xmlData.getElementsByTagName("category"); - for(i = 0; i < groups.length; i++) + var graphs = xmlData.getElementsByTagName("graph"); + for(i = 0; i < graphs.length; i++) { - var name = groups.item(i).getAttribute("name"); + cat = graphs.item(i).getAttribute("category"); + if(!cat) + cat = "Other"; + cats[cat] = true; + } + for(name in cats) + { if(!categoryCurrent) categoryCurrent = name; |