diff options
Diffstat (limited to 'www/ajax/rrdui.js')
-rw-r--r-- | www/ajax/rrdui.js | 34 |
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); } |