summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFrank Wuerthwein <fkw@ucsd.edu>2009-05-08 23:45:53 +0000
committerFrank Wuerthwein <fkw@ucsd.edu>2009-05-08 23:45:53 +0000
commitbae54e43b21b732a368426fe1ff4517fc9c3e01a (patch)
tree32e6ec71f24b2b37574dec2db9fc950be9b623b1 /src/lib
parentda74005c2da72cab57c172b5406db76a273c83da (diff)
Move format_time from rrdFlot into rrdFlotSupport
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/rrdFlot.js38
-rw-r--r--src/lib/rrdFlotSupport.js38
2 files changed, 39 insertions, 37 deletions
diff --git a/src/lib/rrdFlot.js b/src/lib/rrdFlot.js
index e57ff6d..bc9a8a6 100644
--- a/src/lib/rrdFlot.js
+++ b/src/lib/rrdFlot.js
@@ -138,42 +138,6 @@ 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
@@ -186,7 +150,7 @@ rrdFlot.prototype.populateRes = function() {
var step=rra.getStep();
var rows=rra.getNrRows();
var period=step*rows;
- var rra_label=format_time(step)+" ("+format_time(period)+" total)";
+ var rra_label=rfs_format_time(step)+" ("+rfs_format_time(period)+" total)";
form_el.appendChild(new Option(rra_label,i));
}
};
diff --git a/src/lib/rrdFlotSupport.js b/src/lib/rrdFlotSupport.js
index ec460fd..3110eda 100644
--- a/src/lib/rrdFlotSupport.js
+++ b/src/lib/rrdFlotSupport.js
@@ -261,3 +261,41 @@ rrdFlotSelection.prototype.trim_data = function(data_list) {
return out_data;
};
+// ======================================
+// Miscelabeous helper functions
+// ======================================
+
+function rfs_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";
+ }
+ }
+ }
+
+ }
+}