summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFrank Wuerthwein <fkw@ucsd.edu>2009-02-27 01:56:27 +0000
committerFrank Wuerthwein <fkw@ucsd.edu>2009-02-27 01:56:27 +0000
commit360ff2880edad7f7a78319e5f37b22dc31eb0143 (patch)
tree234bae0964938fc3b252ddc7e9aea97a3555b2f9 /src/lib
parent73ddf7698ed8a4b8adbc87c4dce750c7d959aa02 (diff)
Better resolution text
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/rrdFlot.js40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/lib/rrdFlot.js b/src/lib/rrdFlot.js
index 18cd857..13c685b 100644
--- a/src/lib/rrdFlot.js
+++ b/src/lib/rrdFlot.js
@@ -107,6 +107,42 @@ rrdFlot.prototype.createHTML = function() {
// ======================================
// Populate RRA and RD info
rrdFlot.prototype.populateRes = function() {
+ function format_time(s) {
+ if (s<120) {
+ return s+"s";
+ } else {
+ var s60=s%60;
+ var m=(s-s60)/60;
+ if ((m<10) && (s60>9)) {
+ return m+":"+s60+"min";
+ } if (m<120) {
+ return m+"min";
+ } else {
+ var m60=m%60;
+ var h=(m-m60)/60;
+ if ((h<12) && (m60>9)) {
+ return h+":"+m60+"h";
+ } if (h<48) {
+ return h+"h";
+ } else {
+ var h24=h%24;
+ var d=(h-h24)/24;
+ if ((d<7) && (h24>0)) {
+ return d+" days "+h24+"h";
+ } if (d<60) {
+ return d+" days";
+ } else {
+ var d30=d%30;
+ var mt=(d-d30)/30;
+ return mt+" months";
+ }
+ }
+ }
+
+ }
+ }
+
+
var form_el=document.getElementById(this.res_id);
// First clean up anything in the element
@@ -119,7 +155,7 @@ rrdFlot.prototype.populateRes = function() {
var step=rra.getStep();
var rows=rra.getNrRows();
var period=step*rows;
- var rra_label=step+"s ("+period+"s total)";
+ var rra_label=format_time(step)+" ("+format_time(period)+" total)";
form_el.appendChild(new Option(rra_label,i));
}
};
@@ -139,7 +175,7 @@ rrdFlot.prototype.populateDScb = function() {
cb_el.type = "checkbox";
cb_el.name = "ds";
cb_el.value = name;
- cb_el.checked = cb_el.defaultChecked = true;
+ cb_el.checked = cb_el.defaultChecked = (i==0);
form_el.appendChild(cb_el);
form_el.appendChild(document.createTextNode(name));
form_el.appendChild(document.createElement('br'));