summaryrefslogtreecommitdiff
path: root/www/ajax/rrdui.js
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-11-30 01:39:21 +0000
committerStef Walter <stef@memberwebs.com>2006-11-30 01:39:21 +0000
commit09e655dc8fa914d8347e1e2102f2482109829c91 (patch)
treebce6790ff2c00d75cc9dd2a17c7a8810f16ffbb3 /www/ajax/rrdui.js
parent4707deeca1dded8e20e92a21a4d16a5c56c97401 (diff)
Make the category links into a refs so they can be bookmarked.
Diffstat (limited to 'www/ajax/rrdui.js')
-rw-r--r--www/ajax/rrdui.js34
1 files changed, 27 insertions, 7 deletions
diff --git a/www/ajax/rrdui.js b/www/ajax/rrdui.js
index d4ea8b6..74bd8f2 100644
--- a/www/ajax/rrdui.js
+++ b/www/ajax/rrdui.js
@@ -12,6 +12,7 @@ if(ENDPOINT.charAt(0) != '/')
/* TODO: Loading indicator */
var categoryCurrent = null;
+var categoriesList = new Object();
var categoryArea = document.getElementById("headers");
var xmlData = null;
var gdoc = null;
@@ -43,6 +44,27 @@ function loadedGraphData(doc)
xmlData = doc;
displayCategories();
+
+ var cat;
+
+ // Initially load any bookmarked category
+ if(location.hash)
+ {
+ cat = location.hash.substr(1);
+ if(categoriesList[cat])
+ categoryCurrent = cat;
+ }
+
+ // No category loaded, choose inital
+ if(!categoryCurrent)
+ {
+ for(cat in categoriesList)
+ {
+ categoryCurrent = cat;
+ break;
+ }
+ }
+
displayCurrentPage();
}
@@ -574,7 +596,7 @@ function changeCategory(evt)
function displayCategories()
{
- var cats = new Object();
+ categoriesList = new Object();
var cat, i, name;
/* Get the template and clean it up a bit */
@@ -589,21 +611,19 @@ function displayCategories()
cat = "Other";
graphs.item(i).setAttribute("category", "Other");
}
- cats[cat] = true;
+ categoriesList[cat] = true;
}
- for(name in cats)
+ for(name in categoriesList)
{
- if(!categoryCurrent)
- categoryCurrent = name;
-
var el = template.cloneNode(false);
el.removeAttribute("id");
el.appendChild(document.createTextNode(name));
el.setAttribute("category", name);
+ el.setAttribute("href", "#" + escape(name));
el.onclick = function(evt)
- { return changeCategory(evt || window.event); }
+ { changeCategory(evt || window.event); }
categoryArea.insertBefore(el, template);
}