summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-11-30 03:18:37 +0000
committerStef Walter <stef@memberwebs.com>2006-11-30 03:18:37 +0000
commit5c5c34aa5a9a04c80be9d75f5c4e50d3ef4c9413 (patch)
tree53a5c7f3ea1441ea76eea807843503e553bb7531
parent09e655dc8fa914d8347e1e2102f2482109829c91 (diff)
Order categories alphabetically.
-rw-r--r--www/ajax/rrdui.js33
1 files changed, 18 insertions, 15 deletions
diff --git a/www/ajax/rrdui.js b/www/ajax/rrdui.js
index 74bd8f2..f6c907e 100644
--- a/www/ajax/rrdui.js
+++ b/www/ajax/rrdui.js
@@ -12,7 +12,7 @@ if(ENDPOINT.charAt(0) != '/')
/* TODO: Loading indicator */
var categoryCurrent = null;
-var categoriesList = new Object();
+var categoriesList = new Array();
var categoryArea = document.getElementById("headers");
var xmlData = null;
var gdoc = null;
@@ -45,25 +45,22 @@ function loadedGraphData(doc)
displayCategories();
- var cat;
+ var cat, i;
// Initially load any bookmarked category
if(location.hash)
{
cat = location.hash.substr(1);
- if(categoriesList[cat])
- categoryCurrent = cat;
+ for(i = 0; i < categoriesList.length; i++)
+ {
+ if(cat == categoriesList[i])
+ categoryCurrent = cat;
+ }
}
// No category loaded, choose inital
if(!categoryCurrent)
- {
- for(cat in categoriesList)
- {
- categoryCurrent = cat;
- break;
- }
- }
+ categoryCurrent = categoriesList[0];
displayCurrentPage();
}
@@ -596,8 +593,8 @@ function changeCategory(evt)
function displayCategories()
{
- categoriesList = new Object();
- var cat, i, name;
+ var categories = new Object();
+ var cat, i;
/* Get the template and clean it up a bit */
var template = document.getElementById("header-template");
@@ -611,11 +608,17 @@ function displayCategories()
cat = "Other";
graphs.item(i).setAttribute("category", "Other");
}
- categoriesList[cat] = true;
+ categories[cat] = true;
}
- for(name in categoriesList)
+ categoriesList = new Array();
+ for(cat in categories)
+ categoriesList.push(cat);
+ categoriesList.sort();
+
+ for(i in categoriesList)
{
+ var name = categoriesList[i];
var el = template.cloneNode(false);
el.removeAttribute("id");
el.appendChild(document.createTextNode(name));