From 09e655dc8fa914d8347e1e2102f2482109829c91 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Thu, 30 Nov 2006 01:39:21 +0000 Subject: Make the category links into a refs so they can be bookmarked. --- www/ajax/rrdui.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'www/ajax/rrdui.js') 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); } -- cgit v1.2.3