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 | |
parent | 2fcfb1f6edea8c3011d1fba1b43b43474138af29 (diff) |
Removed <category> element for simplicity.
-rw-r--r-- | html/rrdui.js | 46 | ||||
-rwxr-xr-x | tools/rrdui-cgi.py | 16 |
2 files changed, 28 insertions, 34 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; diff --git a/tools/rrdui-cgi.py b/tools/rrdui-cgi.py index 282d428..175502e 100755 --- a/tools/rrdui-cgi.py +++ b/tools/rrdui-cgi.py @@ -82,12 +82,6 @@ def listGraphs(): graphs = loadGraphs() categories = {} - for item in graphs: - if not item.valid: - continue - if not categories.has_key(item.category): - categories[item.category] = [] - categories[item.category].append(item) groups = categories.keys() groups.sort() @@ -95,13 +89,9 @@ def listGraphs(): print "Content-Type: text/xml\n" print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" print "<data>" - for group in groups: - print " <category name=\"%s\">" % group - categories[group].sort() - for item in categories[group]: - print " <graph name=\"%s\" width=\"%d\" height=\"%d\" title=\"%s\" interval=\"%s\"/>" % \ - (item.name, item.width, item.height, item.title, item.interval) - print " </category>" + for item in graphs: + print " <graph name=\"%s\" category=\"%s\" width=\"%d\" height=\"%d\" title=\"%s\" interval=\"%s\"/>" % \ + (item.name, item.category, item.width, item.height, item.title, item.interval) print "</data>" |