From b97f1ade009887d1436dc558f1e3262a97a54d42 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 11 Apr 2006 21:30:34 +0000 Subject: Removed element for simplicity. --- html/rrdui.js | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'html') 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; -- cgit v1.2.3