aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--js/RrdCmdLine.js26
-rw-r--r--js/RrdDataFile.js21
-rw-r--r--js/RrdGfxCanvas.js13
-rw-r--r--js/RrdGfxPdf.js8
-rw-r--r--js/RrdGfxSvg.js2
-rw-r--r--js/RrdGraph.js65
-rw-r--r--js/RrdJson.js103
-rw-r--r--js/RrdRpn.js4
-rw-r--r--js/RrdTime.js42
-rw-r--r--js/base64.js5
-rw-r--r--js/rrdFile.js2
-rw-r--r--js/sprintf.js35
-rw-r--r--js/strftime.js77
13 files changed, 185 insertions, 218 deletions
diff --git a/js/RrdCmdLine.js b/js/RrdCmdLine.js
index ceec693..a2be92e 100644
--- a/js/RrdCmdLine.js
+++ b/js/RrdCmdLine.js
@@ -184,6 +184,8 @@ RrdCmdLine.prototype = {
184 }, 184 },
185 set_option: function(option, value) 185 set_option: function(option, value)
186 { 186 {
187 var args = value.split(':');
188 var index = value.indexOf(':');
187 switch(option) { 189 switch(option) {
188 case 'base': 190 case 'base':
189 case 'b': 191 case 'b':
@@ -193,12 +195,12 @@ RrdCmdLine.prototype = {
193 break; 195 break;
194 case 'color': 196 case 'color':
195 case 'c': 197 case 'c':
196 var index = value.indexOf('#'); 198 index = value.indexOf('#');
197 if (index === -1) 199 if (index === -1)
198 throw "invalid color def format"; 200 throw "invalid color def format";
199 var name = value.substr(0,index); 201 var name = value.substr(0,index);
200 if (!this.graph.GRC[name]) 202 if (!this.graph.GRC[name])
201 throw "invalid color name '"+name+"'" 203 throw "invalid color name '" + name + "'";
202 this.graph.GRC[name] = value.substr(index); // FIXME check color 204 this.graph.GRC[name] = value.substr(index); // FIXME check color
203 break; 205 break;
204 case 'end': 206 case 'end':
@@ -212,7 +214,7 @@ RrdCmdLine.prototype = {
212 break; 214 break;
213 case 'graph-render-mode': 215 case 'graph-render-mode':
214 case 'G': 216 case 'G':
215 // im->graph_antialias 217 // im->graph_antialias
216 break; 218 break;
217 case 'height': 219 case 'height':
218 case 'h': 220 case 'h':
@@ -225,7 +227,7 @@ RrdCmdLine.prototype = {
225 break; 227 break;
226 case 'lower-limit': 228 case 'lower-limit':
227 case 'l': 229 case 'l':
228 this.graph.setminval = parseFloat(value) 230 this.graph.setminval = parseFloat(value);
229 break; 231 break;
230 case 'zoom': 232 case 'zoom':
231 case 'm': 233 case 'm':
@@ -235,11 +237,10 @@ RrdCmdLine.prototype = {
235 break; 237 break;
236 case 'font': 238 case 'font':
237 case 'n': 239 case 'n':
238 var args = value.split(':');
239 if (args.length !== 3) 240 if (args.length !== 3)
240 throw "invalid text property format"; 241 throw "invalid text property format";
241 if (!this.graph.TEXT[args[0]]) 242 if (!this.graph.TEXT[args[0]])
242 throw "invalid fonttag '"+args[0]+"'" 243 throw "invalid font tag '" + args[0] + "'";
243 if (args[1] > 0) 244 if (args[1] > 0)
244 this.graph.TEXT[args[0]].size = args[1]; 245 this.graph.TEXT[args[0]].size = args[1];
245 if (args[2]) 246 if (args[2])
@@ -292,7 +293,6 @@ RrdCmdLine.prototype = {
292 if (value === 'none') { 293 if (value === 'none') {
293 this.graph.draw_x_grid = false; 294 this.graph.draw_x_grid = false;
294 } else { 295 } else {
295 var args = value.split(':');
296 if (args.length !== 8) 296 if (args.length !== 8)
297 throw "invalid x-grid format"; 297 throw "invalid x-grid format";
298 this.graph.xlab_user.gridtm = this.graph.tmt_conv(args[0]); 298 this.graph.xlab_user.gridtm = this.graph.tmt_conv(args[0]);
@@ -318,7 +318,6 @@ RrdCmdLine.prototype = {
318 if (value === 'none') { 318 if (value === 'none') {
319 this.graph.draw_y_grid = false; 319 this.graph.draw_y_grid = false;
320 } else { 320 } else {
321 var index = value.indexOf(':');
322 if (index === -1) 321 if (index === -1)
323 throw "invalid y-grid format"; 322 throw "invalid y-grid format";
324 this.graph.ygridstep = parseFloat(value.substr(0,index)); 323 this.graph.ygridstep = parseFloat(value.substr(0,index));
@@ -338,7 +337,6 @@ RrdCmdLine.prototype = {
338 throw "invalid argument for --units: "+value; 337 throw "invalid argument for --units: "+value;
339 break; 338 break;
340 case 'right-axis': 339 case 'right-axis':
341 var index = value.indexOf(':');
342 if (index === -1) 340 if (index === -1)
343 throw "invalid right-axis format expected scale:shift"; 341 throw "invalid right-axis format expected scale:shift";
344 this.graph.second_axis_scale = parseFloat(value.substr(0,index)); 342 this.graph.second_axis_scale = parseFloat(value.substr(0,index));
@@ -378,7 +376,6 @@ RrdCmdLine.prototype = {
378 this.graph.draw_3d_border = parseInt(value, 10); 376 this.graph.draw_3d_border = parseInt(value, 10);
379 break; 377 break;
380 case 'grid-dash': 378 case 'grid-dash':
381 var index = value.indexOf(':');
382 if (index === -1) 379 if (index === -1)
383 throw "expected grid-dash format float:float"; 380 throw "expected grid-dash format float:float";
384 this.graph.grid_dash_on = parseFloat(value.substr(0,index)); 381 this.graph.grid_dash_on = parseFloat(value.substr(0,index));
@@ -399,20 +396,17 @@ RrdCmdLine.prototype = {
399 var rrdfile = vnames[1]; 396 var rrdfile = vnames[1];
400 var name = args[n++]; 397 var name = args[n++];
401 var cf = args[n++]; 398 var cf = args[n++];
402 var step = undefined; 399 var step, reduce, start, end;
403 var reduce = undefined;
404 var start = undefined;
405 var end = undefined;
406 if (args.length > n) { 400 if (args.length > n) {
407 for (var j = n, xlen = args.length ; j < xlen ; j++) { 401 for (var j = n, xlen = args.length ; j < xlen ; j++) {
408 var opts = args[j].split("="); 402 var opts = args[j].split("=");
409 if (opts[0] === "step") step = opts[1]; 403 if (opts[0] === "step") step = opts[1];
410 if (opts[0] === "reduce") reduce = opts[1] 404 if (opts[0] === "reduce") reduce = opts[1];
411 if (opts[0] === "start") start = opts[1]; 405 if (opts[0] === "start") start = opts[1];
412 if (opts[0] === "end") end = opts[1]; 406 if (opts[0] === "end") end = opts[1];
413 } 407 }
414 } 408 }
415 this.graph.gdes_add_def(vname, rrdfile, name, cf, step, start, end, reduce) 409 this.graph.gdes_add_def(vname, rrdfile, name, cf, step, start, end, reduce);
416 }, 410 },
417 // CDEF:vname=RPN expression 411 // CDEF:vname=RPN expression
418 parse_cdef: function (line) 412 parse_cdef: function (line)
diff --git a/js/RrdDataFile.js b/js/RrdDataFile.js
index 4ebb220..2c0e846 100644
--- a/js/RrdDataFile.js
+++ b/js/RrdDataFile.js
@@ -42,21 +42,23 @@ RrdDataFile.prototype = {
42 var cal_start, cal_end; 42 var cal_start, cal_end;
43 var best_full_rra = 0, best_part_rra = 0, chosen_rra = 0; 43 var best_full_rra = 0, best_part_rra = 0, chosen_rra = 0;
44 var best_full_step_diff = 0, best_part_step_diff = 0, tmp_step_diff = 0, tmp_match = 0, best_match = 0; 44 var best_full_step_diff = 0, best_part_step_diff = 0, tmp_step_diff = 0, tmp_match = 0, best_match = 0;
45 var full_match, rra_base; 45 var full_match;
46 var first_full = 1; 46 var first_full = 1;
47 var first_part = 1; 47 var first_part = 1;
48 var data_ptr; 48 var data_ptr;
49 var rows; 49 var rows;
50 var rra;
51 var i, ii;
50 52
51 var cf_idx = gdp.cf; 53 var cf_idx = gdp.cf;
52 var ds_cnt = rrd.getNrDSs(); 54 var ds_cnt = rrd.getNrDSs();
53 var rra_cnt = rrd.getNrRRAs(); 55 var rra_cnt = rrd.getNrRRAs();
54 56
55 for (var i = 0; i < ds_cnt; i++) 57 for (i = 0; i < ds_cnt; i++)
56 gdp.ds_namv[i] = rrd.rrd_header.getDSbyIdx(i).getName(); 58 gdp.ds_namv[i] = rrd.rrd_header.getDSbyIdx(i).getName();
57 59
58 for (var i = 0; i < rra_cnt; i++) { 60 for (i = 0; i < rra_cnt; i++) {
59 var rra = rrd.getRRAInfo(i); 61 rra = rrd.getRRAInfo(i);
60 if (RrdGraphDesc.cf_conv(rra.getCFName()) === cf_idx) { 62 if (RrdGraphDesc.cf_conv(rra.getCFName()) === cf_idx) {
61 cal_end = (rrd.getLastUpdate() - (rrd.getLastUpdate() % (rra.getPdpPerRow() * rra.pdp_step))); 63 cal_end = (rrd.getLastUpdate() - (rrd.getLastUpdate() % (rra.getPdpPerRow() * rra.pdp_step)));
62 cal_start = (cal_end - (rra.getPdpPerRow() * rra.row_cnt * rra.pdp_step)); 64 cal_start = (cal_end - (rra.getPdpPerRow() * rra.row_cnt * rra.pdp_step));
@@ -87,7 +89,7 @@ RrdDataFile.prototype = {
87 else throw "the RRD does not contain an RRA matching the chosen CF"; 89 else throw "the RRD does not contain an RRA matching the chosen CF";
88 90
89 var rra_info = rrd.getRRAInfo(chosen_rra); 91 var rra_info = rrd.getRRAInfo(chosen_rra);
90 var rra = rrd.getRRA(chosen_rra); 92 rra = rrd.getRRA(chosen_rra);
91 93
92 ft_step = rrd.rrd_header.pdp_step * rra_info.getPdpPerRow(); 94 ft_step = rrd.rrd_header.pdp_step * rra_info.getPdpPerRow();
93 gdp.start -= (gdp.start % ft_step); 95 gdp.start -= (gdp.start % ft_step);
@@ -107,13 +109,13 @@ RrdDataFile.prototype = {
107 109
108 for (i = start_offset; i < rra.row_cnt - end_offset; i++) { 110 for (i = start_offset; i < rra.row_cnt - end_offset; i++) {
109 if (i < 0) { 111 if (i < 0) {
110 for (var ii = 0; ii < ds_cnt; ii++) 112 for (ii = 0; ii < ds_cnt; ii++)
111 gdp.data[data_ptr++] = Number.NaN; 113 gdp.data[data_ptr++] = Number.NaN;
112 } else if (i >= rra.row_cnt) { 114 } else if (i >= rra.row_cnt) {
113 for (var ii = 0; ii < ds_cnt; ii++) 115 for (ii = 0; ii < ds_cnt; ii++)
114 gdp.data[data_ptr++] = Number.NaN; 116 gdp.data[data_ptr++] = Number.NaN;
115 } else { 117 } else {
116 for (var ii = 0; ii < ds_cnt; ii++) 118 for(ii = 0; ii < ds_cnt; ii++)
117 gdp.data[data_ptr++] = rra.getEl(i, ii); 119 gdp.data[data_ptr++] = rra.getEl(i, ii);
118 } 120 }
119 } 121 }
@@ -153,8 +155,7 @@ RrdDataFile.prototype = {
153 }, 155 },
154 fetch_async: function(gdp, ft_step, callback, callback_arg) 156 fetch_async: function(gdp, ft_step, callback, callback_arg)
155 { 157 {
156 var rrd; 158 if (gdp.rrd === null) return -1;
157 if (gdp.rrd == null) return -1;
158 159
159 if (gdp.rrd in this.rrdfiles) { 160 if (gdp.rrd in this.rrdfiles) {
160 callback(callback_arg, this.build(gdp, ft_step, this.rrdfiles[gdp.rrd])); 161 callback(callback_arg, this.build(gdp, ft_step, this.rrdfiles[gdp.rrd]));
diff --git a/js/RrdGfxCanvas.js b/js/RrdGfxCanvas.js
index 070b806..0d1784e 100644
--- a/js/RrdGfxCanvas.js
+++ b/js/RrdGfxCanvas.js
@@ -57,7 +57,7 @@ RrdGfxCanvas.prototype.line = function (X0, Y0, X1, Y1, width, color)
57 } 57 }
58 this.ctx.save(); 58 this.ctx.save();
59 this.ctx.lineWidth = width; 59 this.ctx.lineWidth = width;
60 this.ctx.strokeStyle = color 60 this.ctx.strokeStyle = color;
61 this.ctx.beginPath(); 61 this.ctx.beginPath();
62 this.ctx.moveTo(X0, Y0); 62 this.ctx.moveTo(X0, Y0);
63 this.ctx.lineTo(X1, Y1); 63 this.ctx.lineTo(X1, Y1);
@@ -67,6 +67,7 @@ RrdGfxCanvas.prototype.line = function (X0, Y0, X1, Y1, width, color)
67 67
68RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, dash_on, dash_off) 68RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, dash_on, dash_off)
69{ 69{
70 var swap, n;
70 X0 = Math.round(X0); 71 X0 = Math.round(X0);
71 Y0 = Math.round(Y0); 72 Y0 = Math.round(Y0);
72 X1 = Math.round(X1); 73 X1 = Math.round(X1);
@@ -81,12 +82,12 @@ RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, das
81 Y0 += 0.5; 82 Y0 += 0.5;
82 Y1 += 0.5; 83 Y1 += 0.5;
83 if (X0 > X1) { 84 if (X0 > X1) {
84 var swap = X0; 85 swap = X0;
85 X0 = X1; 86 X0 = X1;
86 X1 = swap; 87 X1 = swap;
87 } 88 }
88 this.ctx.moveTo(X0, Y0); 89 this.ctx.moveTo(X0, Y0);
89 var n=0; 90 n = 0;
90 while(X0<=X1) { 91 while(X0<=X1) {
91 if (n%2 === 1) { 92 if (n%2 === 1) {
92 X0 += dash_on; 93 X0 += dash_on;
@@ -101,12 +102,12 @@ RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, das
101 X0 += 0.5; 102 X0 += 0.5;
102 X1 += 0.5; 103 X1 += 0.5;
103 if (Y0 > Y1) { 104 if (Y0 > Y1) {
104 var swap = Y0; 105 swap = Y0;
105 Y0 = Y1; 106 Y0 = Y1;
106 Y1 = swap; 107 Y1 = swap;
107 } 108 }
108 this.ctx.moveTo(X0, Y0); 109 this.ctx.moveTo(X0, Y0);
109 var n=0; 110 n = 0;
110 while(Y0<=Y1) { 111 while(Y0<=Y1) {
111 if (n%2 === 1) { 112 if (n%2 === 1) {
112 Y0 += dash_on; 113 Y0 += dash_on;
@@ -201,7 +202,7 @@ RrdGfxCanvas.prototype.lineTo = function (x,y)
201{ 202{
202 x = Math.round(x)+0.5; 203 x = Math.round(x)+0.5;
203 y = Math.round(y)+0.5; 204 y = Math.round(y)+0.5;
204 this.ctx.lineTo(x, y) 205 this.ctx.lineTo(x, y);
205}; 206};
206 207
207RrdGfxCanvas.prototype.text = function (x, y, color, font, tabwidth, angle, h_align, v_align, text) 208RrdGfxCanvas.prototype.text = function (x, y, color, font, tabwidth, angle, h_align, v_align, text)
diff --git a/js/RrdGfxPdf.js b/js/RrdGfxPdf.js
index 9203020..230d441 100644
--- a/js/RrdGfxPdf.js
+++ b/js/RrdGfxPdf.js
@@ -267,7 +267,7 @@ RrdGfxPdf.prototype.moveTo = function (x,y)
267 267
268RrdGfxPdf.prototype.lineTo = function (x,y) 268RrdGfxPdf.prototype.lineTo = function (x,y)
269{ 269{
270 this._lineTo(x, y) 270 this._lineTo(x, y);
271}; 271};
272 272
273RrdGfxPdf.prototype.text = function (x, y, color, font, tabwidth, angle, h_align, v_align, text) 273RrdGfxPdf.prototype.text = function (x, y, color, font, tabwidth, angle, h_align, v_align, text)
@@ -319,7 +319,7 @@ RrdGfxPdf.prototype.text = function (x, y, color, font, tabwidth, angle, h_align
319 } 319 }
320 320
321 x = x*this.k; 321 x = x*this.k;
322 y = (this.h-y)*this.k 322 y = (this.h-y)*this.k;
323 323
324 var tm = []; 324 var tm = [];
325 tm[0] = Math.cos(angle*Math.PI/180.0); 325 tm[0] = Math.cos(angle*Math.PI/180.0);
@@ -834,7 +834,7 @@ RrdGfxPdf.prototype._putstream = function(s)
834 this._out('stream'); 834 this._out('stream');
835 this._out(s); 835 this._out(s);
836 this._out('endstream'); 836 this._out('endstream');
837}, 837};
838 838
839RrdGfxPdf.prototype._out = function(s) 839RrdGfxPdf.prototype._out = function(s)
840{ 840{
@@ -964,7 +964,7 @@ RrdGfxPdf.prototype._putcatalog = function()
964 this._out('/OpenAction [3 0 R /FitH null]'); 964 this._out('/OpenAction [3 0 R /FitH null]');
965 else if(this.ZoomMode=='real') 965 else if(this.ZoomMode=='real')
966 this._out('/OpenAction [3 0 R /XYZ null null 1]'); 966 this._out('/OpenAction [3 0 R /XYZ null null 1]');
967 else if(!(typeof this.ZoomMode === 'string')) 967 else if(typeof this.ZoomMode !== 'string')
968 this._out('/OpenAction [3 0 R /XYZ null null '+sprintf('%.2F',this.ZoomMode/100)+']'); 968 this._out('/OpenAction [3 0 R /XYZ null null '+sprintf('%.2F',this.ZoomMode/100)+']');
969 969
970 if(this.LayoutMode=='single') 970 if(this.LayoutMode=='single')
diff --git a/js/RrdGfxSvg.js b/js/RrdGfxSvg.js
index 2bdc1b9..ffc0071 100644
--- a/js/RrdGfxSvg.js
+++ b/js/RrdGfxSvg.js
@@ -25,7 +25,7 @@
25 * @constructor 25 * @constructor
26 */ 26 */
27var RrdGfxSvg = function(svgId) { 27var RrdGfxSvg = function(svgId) {
28 this.svg = document.getElementById(svgId) 28 this.svg = document.getElementById(svgId);
29 this.svgns = "http://www.w3.org/2000/svg"; 29 this.svgns = "http://www.w3.org/2000/svg";
30 this.xmlns = "http://www.w3.org/XML/1998/namespace"; 30 this.xmlns = "http://www.w3.org/XML/1998/namespace";
31 this.path = null; 31 this.path = null;
diff --git a/js/RrdGraph.js b/js/RrdGraph.js
index 55a131d..7171a9c 100644
--- a/js/RrdGraph.js
+++ b/js/RrdGraph.js
@@ -88,7 +88,7 @@ var RrdGraphDesc = function (graph)
88 88
89 /** ** **/ 89 /** ** **/
90 var args = []; // FIXME other way ¿? 90 var args = []; // FIXME other way ¿?
91 var type = arguments[1] 91 var type = arguments[1];
92 args[0] = arguments[0]; 92 args[0] = arguments[0];
93 for(var i = 2; i < arguments.length; i++) args[i-1] = arguments[i]; 93 for(var i = 2; i < arguments.length; i++) args[i-1] = arguments[i];
94 94
@@ -707,7 +707,7 @@ var RrdGraph = function (gfx, data)
707{ 707{
708 this.gfx = gfx; /* graphics object */ 708 this.gfx = gfx; /* graphics object */
709 this.data = data; /* fetch data object */ 709 this.data = data; /* fetch data object */
710 this.data_need_fetch = [] /* List of data that need to be fetched */ 710 this.data_need_fetch = []; /* List of data that need to be fetched */
711 711
712 this.minval = Number.NaN; /* extreme values in the data */ 712 this.minval = Number.NaN; /* extreme values in the data */
713 this.maxval = Number.NaN; 713 this.maxval = Number.NaN;
@@ -1197,13 +1197,13 @@ RrdGraph.prototype.print_calc = function()
1197 case RrdGraphDesc.GF_HRULE: 1197 case RrdGraphDesc.GF_HRULE:
1198 if (isNaN(this.gdes[i].yrule)) { /* we must set this here or the legend printer can not decide to print the legend */ 1198 if (isNaN(this.gdes[i].yrule)) { /* we must set this here or the legend printer can not decide to print the legend */
1199 this.gdes[i].yrule = this.gdes[vidx].vf.val; 1199 this.gdes[i].yrule = this.gdes[vidx].vf.val;
1200 }; 1200 }
1201 graphelement = 1; 1201 graphelement = 1;
1202 break; 1202 break;
1203 case RrdGraphDesc.GF_VRULE: 1203 case RrdGraphDesc.GF_VRULE:
1204 if (this.gdes[i].xrule === 0) { /* again ... the legend printer needs it */ 1204 if (this.gdes[i].xrule === 0) { /* again ... the legend printer needs it */
1205 this.gdes[i].xrule = this.gdes[vidx].vf.when; 1205 this.gdes[i].xrule = this.gdes[vidx].vf.when;
1206 }; 1206 }
1207 graphelement = 1; 1207 graphelement = 1;
1208 break; 1208 break;
1209 case RrdGraphDesc.GF_COMMENT: 1209 case RrdGraphDesc.GF_COMMENT:
@@ -1216,7 +1216,6 @@ RrdGraph.prototype.print_calc = function()
1216 break; 1216 break;
1217 case RrdGraphDesc.GF_STACK: 1217 case RrdGraphDesc.GF_STACK:
1218 throw new RrdGraphError("STACK should already be turned into LINE or AREA here"); 1218 throw new RrdGraphError("STACK should already be turned into LINE or AREA here");
1219 break;
1220 } 1219 }
1221 } 1220 }
1222 return graphelement; 1221 return graphelement;
@@ -1287,7 +1286,7 @@ RrdGraph.prototype.reduce_data = function(gdes, cur_step)
1287 newval = gdes.data[srcptr + i*gdes.ds_cnt + col]; 1286 newval = gdes.data[srcptr + i*gdes.ds_cnt + col];
1288 break; 1287 break;
1289 } 1288 }
1290 } 1289 }
1291 } 1290 }
1292 1291
1293 if (validval === 0) { 1292 if (validval === 0) {
@@ -1316,8 +1315,8 @@ RrdGraph.prototype.reduce_data = function(gdes, cur_step)
1316 row_cnt -= reduce_factor; 1315 row_cnt -= reduce_factor;
1317 } 1316 }
1318 if (end_offset) { 1317 if (end_offset) {
1319 for (col = 0; col < gdes.ds_cnt; col++) 1318 for (col = 0; col < gdes.ds_cnt; col++)
1320 gdes.data[dstptr++] = Number.NaN; 1319 gdes.data[dstptr++] = Number.NaN;
1321 } 1320 }
1322}; 1321};
1323 1322
@@ -1396,7 +1395,7 @@ RrdGraph.prototype.data_fetch_async = function ()
1396 } 1395 }
1397 } 1396 }
1398 this.data_need_fetch.push(0); 1397 this.data_need_fetch.push(0);
1399 } 1398 }
1400 1399
1401 for (var i = 0, gdes_c = this.gdes.length; i < gdes_c; i++) { 1400 for (var i = 0, gdes_c = this.gdes.length; i < gdes_c; i++) {
1402 if (this.data_need_fetch[i] == 0) { 1401 if (this.data_need_fetch[i] == 0) {
@@ -1619,7 +1618,6 @@ RrdGraph.prototype.data_proc = function()
1619 break; 1618 break;
1620 case RrdGraphDesc.GF_STACK: 1619 case RrdGraphDesc.GF_STACK:
1621 throw new RrdGraphError("STACK should already be turned into LINE or AREA here"); 1620 throw new RrdGraphError("STACK should already be turned into LINE or AREA here");
1622 break;
1623 default: 1621 default:
1624 break; 1622 break;
1625 } 1623 }
@@ -1699,7 +1697,7 @@ RrdGraph.prototype.leg_place = function (calc_width)
1699 } 1697 }
1700 1698
1701 if (this.gdes[i].legend != null) { 1699 if (this.gdes[i].legend != null) {
1702 this.gdes[i].legend = this.gdes[i].legend.replace(/\\t/gi, "\t") /* turn \\t into tab */ 1700 this.gdes[i].legend = this.gdes[i].legend.replace(/\\t/gi, "\t"); /* turn \\t into tab */
1703 leg_cc = this.gdes[i].legend.length; 1701 leg_cc = this.gdes[i].legend.length;
1704 } else { 1702 } else {
1705 leg_cc = 0; 1703 leg_cc = 0;
@@ -1863,7 +1861,7 @@ RrdGraph.prototype.horizontal_log_grid = function ()
1863 [ 1.0, 2.0, 4.0, 6.0, 8.0, 10., 0.0, 0.0, 0.0, 0.0 ], 1861 [ 1.0, 2.0, 4.0, 6.0, 8.0, 10., 0.0, 0.0, 0.0, 0.0 ],
1864 [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10. ], 1862 [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10. ],
1865 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] /* last line */ 1863 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] /* last line */
1866 ]; 1864 ];
1867 var i, j, val_exp, min_exp; 1865 var i, j, val_exp, min_exp;
1868 var nex; /* number of decades in data */ 1866 var nex; /* number of decades in data */
1869 var logscale; /* scale in logarithmic space */ 1867 var logscale; /* scale in logarithmic space */
@@ -1885,7 +1883,7 @@ RrdGraph.prototype.horizontal_log_grid = function ()
1885 /* major spacing for less dynamic data */ 1883 /* major spacing for less dynamic data */
1886 do { 1884 do {
1887 mid++; 1885 mid++;
1888 for (i = 0; yloglab[mid][i + 1] < 10.0; i++) {}; 1886 for (i = 0; yloglab[mid][i + 1] < 10.0; i++) ;
1889 mspac = logscale * Math.log(10.0 / yloglab[mid][i])/Math.LN10; 1887 mspac = logscale * Math.log(10.0 / yloglab[mid][i])/Math.LN10;
1890 } while (mspac > 1.56 * this.TEXT.LEGEND.size && yloglab[mid][0] > 0); // FIXME 2->1.56 ?? 1888 } while (mspac > 1.56 * this.TEXT.LEGEND.size && yloglab[mid][0] > 0); // FIXME 2->1.56 ??
1891 if (mid) mid--; 1889 if (mid) mid--;
@@ -1966,7 +1964,7 @@ RrdGraph.prototype.horizontal_log_grid = function ()
1966 if (mid < 4 && exfrac === 1) { /* minor grid */ 1964 if (mid < 4 && exfrac === 1) { /* minor grid */
1967 if (flab === 0) { /* find first and last minor line behind current major line * i is the first line and j tha last */ 1965 if (flab === 0) { /* find first and last minor line behind current major line * i is the first line and j tha last */
1968 min_exp = val_exp - 1; 1966 min_exp = val_exp - 1;
1969 for (i = 1; yloglab[mid][i] < 10.0; i++) {}; 1967 for (i = 1; yloglab[mid][i] < 10.0; i++) ;
1970 i = yloglab[mid][i - 1] + 1; 1968 i = yloglab[mid][i - 1] + 1;
1971 j = 10; 1969 j = 10;
1972 } else { 1970 } else {
@@ -2002,7 +2000,7 @@ RrdGraph.prototype.horizontal_log_grid = function ()
2002 if (mid < 4 && exfrac === 1) { /* draw minor lines after highest major line */ 2000 if (mid < 4 && exfrac === 1) { /* draw minor lines after highest major line */
2003 if (flab === 0) { /* find first and last minor line below current major line * i is the first line and j tha last */ 2001 if (flab === 0) { /* find first and last minor line below current major line * i is the first line and j tha last */
2004 min_exp = val_exp - 1; 2002 min_exp = val_exp - 1;
2005 for (i = 1; yloglab[mid][i] < 10.0; i++) {}; 2003 for (i = 1; yloglab[mid][i] < 10.0; i++) ;
2006 i = yloglab[mid][i - 1] + 1; 2004 i = yloglab[mid][i - 1] + 1;
2007 j = 10; 2005 j = 10;
2008 } else { 2006 } else {
@@ -2386,20 +2384,20 @@ RrdGraph.prototype.grid_paint = function()
2386 this.GRC.FONT, this.TEXT.TITLE, this.tabwidth, 0.0, RrdGraph.GFX_H_CENTER, RrdGraph.GFX_V_TOP, this.title); 2384 this.GRC.FONT, this.TEXT.TITLE, this.tabwidth, 0.0, RrdGraph.GFX_H_CENTER, RrdGraph.GFX_V_TOP, this.title);
2387 /* rrdtool 'logo' */ 2385 /* rrdtool 'logo' */
2388 if (!this.no_rrdtool_tag){ 2386 if (!this.no_rrdtool_tag){
2389 var color = this.parse_color(this.GRC.FONT); 2387 var color = this.parse_color(this.GRC.FONT);
2390 color[3] = 0.3; 2388 color[3] = 0.3;
2391 var water_color = this.color2rgba(color); 2389 var water_color = this.color2rgba(color);
2392 var xpos = this.legendposition === RrdGraph.LEGEND_POS_EAST ? this.xOriginLegendY : this.ximg - 4; 2390 var xpos = this.legendposition === RrdGraph.LEGEND_POS_EAST ? this.xOriginLegendY : this.ximg - 4;
2393 this.gfx.text(xpos, 5, water_color, this.TEXT.WATERMARK, this.tabwidth, 2391 this.gfx.text(xpos, 5, water_color, this.TEXT.WATERMARK, this.tabwidth,
2394 -90, RrdGraph.GFX_H_LEFT, RrdGraph.GFX_V_TOP, "RRDTOOL / TOBI OETIKER"); 2392 -90, RrdGraph.GFX_H_LEFT, RrdGraph.GFX_V_TOP, "RRDTOOL / TOBI OETIKER");
2395 } 2393 }
2396 /* graph watermark */ 2394 /* graph watermark */
2397 if (this.watermark) { 2395 if (this.watermark) {
2398 var color = this.parse_color(this.GRC.FONT) 2396 var color = this.parse_color(this.GRC.FONT);
2399 color[3] = 0.3; 2397 color[3] = 0.3;
2400 var water_color = this.color2rgba(color); 2398 var water_color = this.color2rgba(color);
2401 this.gfx.text(this.ximg / 2, this.yimg - 6, water_color, this.TEXT.WATERMARK , this.tabwidth, 0, 2399 this.gfx.text(this.ximg / 2, this.yimg - 6, water_color, this.TEXT.WATERMARK , this.tabwidth, 0,
2402 RrdGraph.GFX_H_CENTER, RrdGraph.GFX_V_BOTTOM, this.watermark); 2400 RrdGraph.GFX_H_CENTER, RrdGraph.GFX_V_BOTTOM, this.watermark);
2403 } 2401 }
2404 /* graph labels */ 2402 /* graph labels */
2405 if (!(this.no_legend) && !(this.only_graph)) { 2403 if (!(this.no_legend) && !(this.only_graph)) {
@@ -2664,11 +2662,11 @@ RrdGraph.prototype.graph_paint_init = function()
2664// this.gdes[i].end_orig = this.end; 2662// this.gdes[i].end_orig = this.end;
2665 } 2663 }
2666 2664
2667} 2665};
2668 2666
2669RrdGraph.prototype.graph_paint_draw = function() 2667RrdGraph.prototype.graph_paint_draw = function()
2670{ 2668{
2671 var areazero = 0.0 2669 var areazero = 0.0;
2672 var lastgdes = null; 2670 var lastgdes = null;
2673 2671
2674 if (this.data_calc() === -1) 2672 if (this.data_calc() === -1)
@@ -2773,7 +2771,7 @@ RrdGraph.prototype.graph_paint_draw = function()
2773 this.gfx.moveTo(x, y); 2771 this.gfx.moveTo(x, y);
2774 x = ii + this.xorigin; 2772 x = ii + this.xorigin;
2775 y = last_y; 2773 y = last_y;
2776 this.gfx.lineTo(x, y) 2774 this.gfx.lineTo(x, y);
2777 } else { 2775 } else {
2778 var x = ii - 1 + this.xorigin; 2776 var x = ii - 1 + this.xorigin;
2779 var y = this.ytr(this.gdes[i].p_data[ii - 1]); 2777 var y = this.ytr(this.gdes[i].p_data[ii - 1]);
@@ -2886,7 +2884,6 @@ RrdGraph.prototype.graph_paint_draw = function()
2886 break; 2884 break;
2887 case RrdGraphDesc.GF_STACK: 2885 case RrdGraphDesc.GF_STACK:
2888 throw new RrdGraphError("STACK should already be turned into LINE or AREA here"); 2886 throw new RrdGraphError("STACK should already be turned into LINE or AREA here");
2889 break;
2890 } 2887 }
2891 } 2888 }
2892//cairo_reset_clip(this.cr); 2889//cairo_reset_clip(this.cr);
@@ -2920,16 +2917,16 @@ RrdGraph.prototype.graph_paint_draw = function()
2920 2917
2921RrdGraph.prototype.graph_paint = function () 2918RrdGraph.prototype.graph_paint = function ()
2922{ 2919{
2923 this.graph_paint_init() 2920 this.graph_paint_init();
2924 if (this.data_fetch() === -1) 2921 if (this.data_fetch() === -1)
2925 return -1; 2922 return -1;
2926 return this.graph_paint_draw() 2923 return this.graph_paint_draw();
2927}; 2924};
2928 2925
2929RrdGraph.prototype.graph_paint_async = function () 2926RrdGraph.prototype.graph_paint_async = function ()
2930{ 2927{
2931 this.graph_paint_init() 2928 this.graph_paint_init();
2932 this.data_fetch_async() 2929 this.data_fetch_async();
2933}; 2930};
2934 2931
2935RrdGraph.prototype.find_var = function(key) 2932RrdGraph.prototype.find_var = function(key)
diff --git a/js/RrdJson.js b/js/RrdJson.js
index fcbf76b..4ddcbc2 100644
--- a/js/RrdJson.js
+++ b/js/RrdJson.js
@@ -26,11 +26,11 @@
26 */ 26 */
27var RrdJson = function() { 27var RrdJson = function() {
28 if (arguments.length == 1) { 28 if (arguments.length == 1) {
29 this.init1.apply(this, arguments); 29 this.init1.apply(this, arguments);
30 } else if (arguments.length == 2) { 30 } else if (arguments.length == 2) {
31 this.init2.apply(this, arguments); 31 this.init2.apply(this, arguments);
32 } else if (arguments.length == 3) { 32 } else if (arguments.length == 3) {
33 this.init3.apply(this, arguments); 33 this.init3.apply(this, arguments);
34 } 34 }
35}; 35};
36 36
@@ -40,12 +40,12 @@ RrdJson.prototype = {
40 40
41 init1: function (rrdgraph) 41 init1: function (rrdgraph)
42 { 42 {
43 this.graph = rrdgraph 43 this.graph = rrdgraph;
44 }, 44 },
45 init2: function (rrdgraph, jsonstr) 45 init2: function (rrdgraph, jsonstr)
46 { 46 {
47 this.json = JSON.parse(jsonstr); 47 this.json = JSON.parse(jsonstr);
48 this.graph = rrdgraph 48 this.graph = rrdgraph;
49 }, 49 },
50 init3: function (gfx, fetch, jsonstr) 50 init3: function (gfx, fetch, jsonstr)
51 { 51 {
@@ -69,7 +69,7 @@ RrdJson.prototype = {
69 if (color in this.graph.GRC) { 69 if (color in this.graph.GRC) {
70 this.graph.GRC[color] = this.json.color[color]; 70 this.graph.GRC[color] = this.json.color[color];
71 } else { 71 } else {
72 throw "invalid color name '"+name+"'"; 72 throw "invalid color '" + color + "'";
73 } 73 }
74 } 74 }
75 break; 75 break;
@@ -191,16 +191,21 @@ RrdJson.prototype = {
191 this.graph.second_axis_format = this.json.right_axis_format; 191 this.graph.second_axis_format = this.json.right_axis_format;
192 break; 192 break;
193 case 'legend_position': 193 case 'legend_position':
194 if (this.json.legend_position === "north") { 194 switch (this.json.legend_position) {
195 this.graph.legendposition = this.graph.LEGEND_POS.NORTH; 195 case "north":
196 } else if (this.json.legend_position === "west") { 196 this.graph.legendposition = this.graph.LEGEND_POS.NORTH;
197 this.graph.legendposition = this.graph.LEGEND_POS.WEST; 197 break;
198 } else if (this.json.legend_position === "south") { 198 case "west":
199 this.graph.legendposition = this.graph.LEGEND_POS.SOUTH; 199 this.graph.legendposition = this.graph.LEGEND_POS.WEST;
200 } else if (this.json.legend_position === "east") { 200 break;
201 this.graph.legendposition = this.graph.LEGEND_POS.EAST; 201 case "south":
202 } else { 202 this.graph.legendposition = this.graph.LEGEND_POS.SOUTH;
203 throw "unknown legend-position '"+value+"'"; 203 break;
204 case "east":
205 this.graph.legendposition = this.graph.LEGEND_POS.EAST;
206 break;
207 default:
208 throw "unknown legend-position '" + this.json.legend_position + "'";
204 } 209 }
205 break; 210 break;
206 case 'legend_direction': 211 case 'legend_direction':
@@ -209,7 +214,7 @@ RrdJson.prototype = {
209 } else if (this.json.legend_direction === "bottomup") { 214 } else if (this.json.legend_direction === "bottomup") {
210 this.graph.legenddirection = this.graph.LEGEND_DIR.BOTTOM_UP; 215 this.graph.legenddirection = this.graph.LEGEND_DIR.BOTTOM_UP;
211 } else { 216 } else {
212 throw "unknown legend-position '"+value+"'"; 217 throw "unknown legend-direction'" + this.json.legend_direction + "'";
213 } 218 }
214 break; 219 break;
215 case 'border': 220 case 'border':
@@ -272,21 +277,21 @@ RrdJson.prototype = {
272 switch (gdes[i].align) { 277 switch (gdes[i].align) {
273 case 'left': 278 case 'left':
274 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_LEFT); 279 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_LEFT);
275 break 280 break;
276 case 'right': 281 case 'right':
277 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_RIGHT); 282 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_RIGHT);
278 break 283 break;
279 case 'justified': 284 case 'justified':
280 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_JUSTIFIED); 285 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_JUSTIFIED);
281 break 286 break;
282 case 'center': 287 case 'center':
283 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_CENTER); 288 this.graph.gdes_add_textalign(RrdGraphDesc.TXA_CENTER);
284 break 289 break;
285 } 290 }
286 break; 291 break;
287// DEF:<vname>=<rrdfile>:<ds-name>:<CF>[:step=<step>][:start=<time>][:end=<time>][:reduce=<CF>] 292// DEF:<vname>=<rrdfile>:<ds-name>:<CF>[:step=<step>][:start=<time>][:end=<time>][:reduce=<CF>]
288 case 'DEF': 293 case 'DEF':
289 this.graph.gdes_add_def(gdes[i].vname, gdes[i].rrdfile, gdes[i].name, gdes[i].cf, gdes[i].step, gdes[i].start, gdes[i].end, gdes[i].reduce) 294 this.graph.gdes_add_def(gdes[i].vname, gdes[i].rrdfile, gdes[i].name, gdes[i].cf, gdes[i].step, gdes[i].start, gdes[i].end, gdes[i].reduce);
290 break; 295 break;
291// CDEF:vname=RPN expression 296// CDEF:vname=RPN expression
292 case 'CDEF': 297 case 'CDEF':
@@ -311,7 +316,7 @@ RrdJson.prototype = {
311 316
312 if (this.graph.alt_autoscale != false || full) 317 if (this.graph.alt_autoscale != false || full)
313 this.json.alt_autoscale = this.graph.alt_autoscale; 318 this.json.alt_autoscale = this.graph.alt_autoscale;
314 319
315 if (this.graph.base != 1000 || full) 320 if (this.graph.base != 1000 || full)
316 this.json.base = this.graph.base; 321 this.json.base = this.graph.base;
317 322
@@ -338,7 +343,7 @@ RrdJson.prototype = {
338 if (this.graph.GRC.FRAME != 'rgba(0, 0, 0, 1.0)' || full) 343 if (this.graph.GRC.FRAME != 'rgba(0, 0, 0, 1.0)' || full)
339 this.json.color.FRAME = this.graph.GRC.FRAME; 344 this.json.color.FRAME = this.graph.GRC.FRAME;
340 345
341 if (Object.keys(this.json.color) == 0) delete this.json.color; 346 if (!Object.keys(this.json.color).length) delete this.json.color;
342 347
343 if (this.graph.full_size_mode != false || full) 348 if (this.graph.full_size_mode != false || full)
344 this.json.full_size_mode = this.graph.full_size_mode; 349 this.json.full_size_mode = this.graph.full_size_mode;
@@ -351,10 +356,10 @@ RrdJson.prototype = {
351 356
352 if (this.graph.force_rules_legend != false || full) 357 if (this.graph.force_rules_legend != false || full)
353 this.json.force_rules_legend = this.graph.force_rules_legend; 358 this.json.force_rules_legend = this.graph.force_rules_legend;
354 359
355 if (this.graph.no_legend != false || full) 360 if (this.graph.no_legend != false || full)
356 this.json.no_legend = this.graph.no_legend; 361 this.json.no_legend = this.graph.no_legend;
357 362
358 this.json.width = this.graph.xsize; 363 this.json.width = this.graph.xsize;
359 this.json.height = this.graph.ysize; 364 this.json.height = this.graph.ysize;
360 365
@@ -363,10 +368,10 @@ RrdJson.prototype = {
363 368
364 if (this.graph.alt_autoscale_min != false || full) 369 if (this.graph.alt_autoscale_min != false || full)
365 this.json.alt_autoscale_min = this.graph.alt_autoscale_min; 370 this.json.alt_autoscale_min = this.graph.alt_autoscale_min;
366 371
367 if (this.graph.only_graph != false || full) 372 if (this.graph.only_graph != false || full)
368 this.json.only_graph = this.graph.only_graph; 373 this.json.only_graph = this.graph.only_graph;
369 374
370 if (this.graph.unitslength != 6 || full) 375 if (this.graph.unitslength != 6 || full)
371 this.json.units_length = this.graph.unitslength; 376 this.json.units_length = this.graph.unitslength;
372 377
@@ -381,7 +386,7 @@ RrdJson.prototype = {
381 386
382 if (this.graph.gridfit != true || full) 387 if (this.graph.gridfit != true || full)
383 this.json.no_gridfit = this.graph.gridfit; 388 this.json.no_gridfit = this.graph.gridfit;
384 389
385 this.json.font = {}; 390 this.json.font = {};
386 if (this.graph.TEXT.DEFAULT.size != 11 || this.graph.TEXT.LEGEND.font != this.graph.DEFAULT_FONT || full) 391 if (this.graph.TEXT.DEFAULT.size != 11 || this.graph.TEXT.LEGEND.font != this.graph.DEFAULT_FONT || full)
387 this.json.font.DEFAULT = { size: this.graph.TEXT.DEFAULT.size, font: this.graph.TEXT.DEFAULT.font}; 392 this.json.font.DEFAULT = { size: this.graph.TEXT.DEFAULT.size, font: this.graph.TEXT.DEFAULT.font};
@@ -396,31 +401,31 @@ RrdJson.prototype = {
396 if (this.graph.TEXT.WATERMARK.size != 8 || this.graph.TEXT.WATERMARK.font != this.graph.DEFAULT_FONT || full) 401 if (this.graph.TEXT.WATERMARK.size != 8 || this.graph.TEXT.WATERMARK.font != this.graph.DEFAULT_FONT || full)
397 this.json.font.WATERMARK = { size: this.graph.TEXT.WATERMARK.size, font: this.graph.TEXT.WATERMARK.font}; 402 this.json.font.WATERMARK = { size: this.graph.TEXT.WATERMARK.size, font: this.graph.TEXT.WATERMARK.font};
398 403
399 if (Object.keys(this.json.font) == 0) delete this.json.font; 404 if (!Object.keys(this.json.font).length) delete this.json.font;
400 405
401 if (this.graph.logarithmic != false || full) 406 if (this.graph.logarithmic != false || full)
402 this.json.logarithmic = this.graph.logarithmic; 407 this.json.logarithmic = this.graph.logarithmic;
403 408
404 if (this.graph.rigid != false || full) 409 if (this.graph.rigid != false || full)
405 this.json.rigid = this.graph.rigid; 410 this.json.rigid = this.graph.rigid;
406 411
407// this.json.step = this.graph.step; // FIXME 412// this.json.step = this.graph.step; // FIXME
408 413
409 if (this.graph.tabwidth != 40 || full) 414 if (this.graph.tabwidth != 40 || full)
410 this.json.tabwidth = this.graph.tabwidth; 415 this.json.tabwidth = this.graph.tabwidth;
411 416
412 if (this.graph.title != '' || full) 417 if (this.graph.title != '' || full)
413 this.json.title = this.graph.title; 418 this.json.title = this.graph.title;
414 419
415 if (!isNaN(this.graph.setmaxval) || full) 420 if (!isNaN(this.graph.setmaxval) || full)
416 this.json.upper_limit = this.graph.setmaxval; 421 this.json.upper_limit = this.graph.setmaxval;
417 422
418 if (this.graph.ylegend != null || full) 423 if (this.graph.ylegend != null || full)
419 this.json.vertical_label = this.graph.ylegend; 424 this.json.vertical_label = this.graph.ylegend;
420 425
421 if (this.graph.watermark != null || full) 426 if (this.graph.watermark != null || full)
422 this.json.watermark = this.graph.watermark; 427 this.json.watermark = this.graph.watermark;
423 428
424 if (this.graph.unitsexponent != 9999 || full) 429 if (this.graph.unitsexponent != 9999 || full)
425 this.json.units_exponent = this.graph.unitsexponent; 430 this.json.units_exponent = this.graph.unitsexponent;
426 431
@@ -432,10 +437,10 @@ RrdJson.prototype = {
432// this.json.y_grid = // FIXME 437// this.json.y_grid = // FIXME
433 438
434// this.json.lazy = this.graph.lazy; 439// this.json.lazy = this.graph.lazy;
435 440
436 if (this.graph.force_units_si != false || full) 441 if (this.graph.force_units_si != false || full)
437 this.json.units = 'si'; // FIXME 442 this.json.units = 'si'; // FIXME
438 443
439 if (this.graph.no_rrdtool_tag != false || full) 444 if (this.graph.no_rrdtool_tag != false || full)
440 this.json.disable_rrdtool_tag = this.graph.no_rrdtool_tag; 445 this.json.disable_rrdtool_tag = this.graph.no_rrdtool_tag;
441 446
@@ -451,13 +456,13 @@ RrdJson.prototype = {
451 456
452 if (this.graph.draw_3d_border != 2 || full) 457 if (this.graph.draw_3d_border != 2 || full)
453 this.json.border = this.graph.draw_3d_border; 458 this.json.border = this.graph.draw_3d_border;
454 459
455 if (this.graph.grid_dash_on != 1 || this.graph.grid_dash_off != 1 || full) 460 if (this.graph.grid_dash_on != 1 || this.graph.grid_dash_off != 1 || full)
456 this.json.grid_dash = [this.graph.grid_dash_on, this.graph.grid_dash_off] 461 this.json.grid_dash = [this.graph.grid_dash_on, this.graph.grid_dash_off];
457 462
458 if (this.graph.dynamic_labels != false || full) 463 if (this.graph.dynamic_labels != false || full)
459 this.json.dynamic_labels = this.graph.dynamic_labels; 464 this.json.dynamic_labels = this.graph.dynamic_labels;
460 465
461 this.json.gdes = []; 466 this.json.gdes = [];
462 for (var i = 0, gdes_c = this.graph.gdes.length; i < gdes_c; i++) { 467 for (var i = 0, gdes_c = this.graph.gdes.length; i < gdes_c; i++) {
463 switch (this.graph.gdes[i].gf) { 468 switch (this.graph.gdes[i].gf) {
@@ -465,7 +470,7 @@ RrdJson.prototype = {
465 case RrdGraphDesc.GF_GPRINT: 470 case RrdGraphDesc.GF_GPRINT:
466 this.json.gdes.push({ 471 this.json.gdes.push({
467 type: 'GPRINT', 472 type: 'GPRINT',
468 vname: this.graph.gdes[i].vname, 473 vname: this.graph.gdes[i].vname,
469 cf: RrdGraphDesc.cf2str(this.graph.gdes[i].cf), 474 cf: RrdGraphDesc.cf2str(this.graph.gdes[i].cf),
470 format: this.graph.gdes[i].format, 475 format: this.graph.gdes[i].format,
471 strftm: (this.graph.gdes[i].strftm === false ? undefined : this.graph.gdes[i].strftm) }); 476 strftm: (this.graph.gdes[i].strftm === false ? undefined : this.graph.gdes[i].strftm) });
@@ -526,16 +531,16 @@ RrdJson.prototype = {
526 switch (this.graph.gdes[i].txtalign) { 531 switch (this.graph.gdes[i].txtalign) {
527 case RrdGraphDesc.TXA_LEFT: 532 case RrdGraphDesc.TXA_LEFT:
528 align = 'left'; 533 align = 'left';
529 break 534 break;
530 case RrdGraphDesc.TXA_RIGHT: 535 case RrdGraphDesc.TXA_RIGHT:
531 align = 'right'; 536 align = 'right';
532 break 537 break;
533 case RrdGraphDesc.TXA_JUSTIFIED: 538 case RrdGraphDesc.TXA_JUSTIFIED:
534 align = 'justified'; 539 align = 'justified';
535 break 540 break;
536 case RrdGraphDesc.TXA_CENTER: 541 case RrdGraphDesc.TXA_CENTER:
537 align = 'center'; 542 align = 'center';
538 break 543 break;
539 } 544 }
540 545
541 this.json.gdes.push({ 546 this.json.gdes.push({
@@ -559,7 +564,7 @@ RrdJson.prototype = {
559 // reduce: RrdGraphDesc.cf2str(this.graph.gdes[i].cf_reduce) 564 // reduce: RrdGraphDesc.cf2str(this.graph.gdes[i].cf_reduce)
560 reduce: undefined 565 reduce: undefined
561 }); 566 });
562 567
563 break; 568 break;
564// CDEF:vname=RPN expression 569// CDEF:vname=RPN expression
565 case RrdGraphDesc.GF_CDEF: 570 case RrdGraphDesc.GF_CDEF:
diff --git a/js/RrdRpn.js b/js/RrdRpn.js
index cbb5e8f..5ca8daf 100644
--- a/js/RrdRpn.js
+++ b/js/RrdRpn.js
@@ -478,7 +478,7 @@ RrdRpn.prototype.calc = function (data_idx, output, output_idx)
478 break; 478 break;
479 case RrdRpn.OP_ISINF: 479 case RrdRpn.OP_ISINF:
480 if(stptr < 0) throw new RrdRpnError(); 480 if(stptr < 0) throw new RrdRpnError();
481 this.rpnstack[stptr] = isInfinite(this.rpnstack[stptr]) ? 1.0 : 0.0; 481 this.rpnstack[stptr] = !isFinite(this.rpnstack[stptr]) ? 1.0 : 0.0;
482 break; 482 break;
483 case RrdRpn.OP_SQRT: 483 case RrdRpn.OP_SQRT:
484 if(stptr < 0) throw new RrdRpnError(); 484 if(stptr < 0) throw new RrdRpnError();
@@ -603,7 +603,7 @@ RrdRpn.prototype.calc = function (data_idx, output, output_idx)
603 break; 603 break;
604 case RrdRpn.OP_ABS: 604 case RrdRpn.OP_ABS:
605 if(stptr < 0) throw new RrdRpnError(); 605 if(stptr < 0) throw new RrdRpnError();
606 this.rpnstack[stptr] = fabs(this.rpnstack[stptr]); 606 this.rpnstack[stptr] = Math.abs(this.rpnstack[stptr]);
607 break; 607 break;
608 case RrdRpn.OP_END: 608 case RrdRpn.OP_END:
609 break; 609 break;
diff --git a/js/RrdTime.js b/js/RrdTime.js
index 95ea0ae..c1de1fc 100644
--- a/js/RrdTime.js
+++ b/js/RrdTime.js
@@ -25,12 +25,12 @@
25 * RrdTimeError 25 * RrdTimeError
26 * @constructor 26 * @constructor
27 */ 27 */
28var RrdTimeError = function (message) 28var RrdTimeError = function (message)
29{ 29{
30 this.prototype = Error.prototype; 30 this.prototype = Error.prototype;
31 this.name = "RrdTimeError"; 31 this.name = "RrdTimeError";
32 this.message = (message) ? message : "Error"; 32 this.message = (message) ? message : "Error";
33}; 33};
34 34
35/** 35/**
36 * RrdTime 36 * RrdTime
@@ -40,7 +40,7 @@ var RrdTime = function(tspec) /* parser */
40{ 40{
41 var date = new Date(); 41 var date = new Date();
42 var hr = 0; 42 var hr = 0;
43 43
44 this.tspec = tspec; 44 this.tspec = tspec;
45 45
46 this.tokens = (tspec+'').match(/[0-9]+|[A-Za-z]+|[:.+-\/]/g); 46 this.tokens = (tspec+'').match(/[0-9]+|[A-Za-z]+|[:.+-\/]/g);
@@ -70,18 +70,20 @@ var RrdTime = function(tspec) /* parser */
70 break; /* jump to OFFSET-SPEC part */ 70 break; /* jump to OFFSET-SPEC part */
71 case RrdTime.EPOCH: 71 case RrdTime.EPOCH:
72 this.type = RrdTime.RELATIVE_TO_EPOCH; 72 this.type = RrdTime.RELATIVE_TO_EPOCH;
73 /* falls through */
73 case RrdTime.START: 74 case RrdTime.START:
74 case RrdTime.END: 75 case RrdTime.END:
75 if (this.tokid === RrdTime.EPOCH) 76 if (this.tokid === RrdTime.EPOCH)
76 this.type = RrdTime.RELATIVE_TO_START_TIME; 77 this.type = RrdTime.RELATIVE_TO_START_TIME;
77 else 78 else
78 this.type = RrdTime.RELATIVE_TO_END_TIME; 79 this.type = RrdTime.RELATIVE_TO_END_TIME;
79 this.tm_sec = 0; 80 this.tm_sec = 0;
80 this.tm_min = 0; 81 this.tm_min = 0;
81 this.tm_hour = 0; 82 this.tm_hour = 0;
82 this.tm_mday = 0; 83 this.tm_mday = 0;
83 this.tm_mon = 0; 84 this.tm_mon = 0;
84 this.tm_year = 0; 85 this.tm_year = 0;
86 /* falls through */
85 case RrdTime.NOW: 87 case RrdTime.NOW:
86 var time_reference = this.tokid; 88 var time_reference = this.tokid;
87 this.gettok(); 89 this.gettok();
@@ -126,8 +128,10 @@ var RrdTime = function(tspec) /* parser */
126 break; 128 break;
127 case RrdTime.TEATIME: 129 case RrdTime.TEATIME:
128 hr += 4; 130 hr += 4;
131 /* falls through */
129 case RrdTime.NOON: 132 case RrdTime.NOON:
130 hr += 12; 133 hr += 12;
134 /* falls through */
131 case RrdTime.MIDNIGHT: 135 case RrdTime.MIDNIGHT:
132 this.tm_hour = hr; 136 this.tm_hour = hr;
133 this.tm_min = 0; 137 this.tm_min = 0;
@@ -137,7 +141,6 @@ var RrdTime = function(tspec) /* parser */
137 break; 141 break;
138 default: 142 default:
139 throw new RrdTimeError("unparsable time: "+this.token+" "+this.sct); 143 throw new RrdTimeError("unparsable time: "+this.token+" "+this.sct);
140 break;
141 } /* ugly case statement */ 144 } /* ugly case statement */
142 145
143 /* 146 /*
@@ -303,7 +306,7 @@ RrdTime.RELATIVE_TO_START_TIME = 1;
303RrdTime.RELATIVE_TO_END_TIME = 2; 306RrdTime.RELATIVE_TO_END_TIME = 2;
304RrdTime.RELATIVE_TO_EPOCH = 3; 307RrdTime.RELATIVE_TO_EPOCH = 3;
305 308
306RrdTime.prototype.gettok = function () 309RrdTime.prototype.gettok = function ()
307{ 310{
308 if (this.tokidx >= this.toklen) { 311 if (this.tokidx >= this.toklen) {
309 this.tokid = RrdTime.EOF; 312 this.tokid = RrdTime.EOF;
@@ -332,7 +335,7 @@ RrdTime.prototype.gettok = function ()
332 return this.tokid; 335 return this.tokid;
333}; 336};
334 337
335RrdTime.prototype.plus_minus = function (doop) 338RrdTime.prototype.plus_minus = function (doop)
336{ 339{
337 var op = RrdTime.PLUS; 340 var op = RrdTime.PLUS;
338 var prev_multiplier = -1; 341 var prev_multiplier = -1;
@@ -377,6 +380,7 @@ RrdTime.prototype.plus_minus = function (doop)
377 return; 380 return;
378 case RrdTime.WEEKS: 381 case RrdTime.WEEKS:
379 delta *= 7; 382 delta *= 7;
383 /* falls through */
380 case RrdTime.DAYS: 384 case RrdTime.DAYS:
381 this.tm_mday += ( op == RrdTime.PLUS) ? delta : -delta; 385 this.tm_mday += ( op == RrdTime.PLUS) ? delta : -delta;
382 return; 386 return;
@@ -446,12 +450,12 @@ RrdTime.prototype.tod = function() /* tod() computes the time of day (TIME-OF-DA
446 this.tm_min = minute; 450 this.tm_min = minute;
447 this.tm_sec = 0; 451 this.tm_sec = 0;
448 if (this.tm_hour == 24) { 452 if (this.tm_hour == 24) {
449 this.tm_hour = 0; 453 this.tm_hour = 0;
450 this.tm_mday++; 454 this.tm_mday++;
451 } 455 }
452}; 456};
453 457
454RrdTime.prototype.assign_date = function(mday, mon, year) 458RrdTime.prototype.assign_date = function(mday, mon, year)
455{ 459{
456 if (year > 138) { 460 if (year > 138) {
457 if (year > 1970) { 461 if (year > 1970) {
@@ -472,14 +476,14 @@ RrdTime.prototype.assign_date = function(mday, mon, year)
472 this.tm_year = year; 476 this.tm_year = year;
473}; 477};
474 478
475RrdTime.prototype.day = function () 479RrdTime.prototype.day = function ()
476{ 480{
477 var mday = 0, wday, mon, year = this.tm_year; 481 var mday = 0, wday, mon, year = this.tm_year;
478 var tlen;
479 482
480 switch (this.tokid) { 483 switch (this.tokid) {
481 case RrdTime.YESTERDAY: 484 case RrdTime.YESTERDAY:
482 this.tm_mday--; 485 this.tm_mday--;
486 /* falls through */
483 case RrdTime.TODAY: 487 case RrdTime.TODAY:
484 this.gettok(); 488 this.gettok();
485 break; 489 break;
@@ -565,7 +569,7 @@ RrdTime.prototype.day = function ()
565 } 569 }
566}; 570};
567 571
568RrdTime.prototype.localtime = function (tm) 572RrdTime.prototype.localtime = function (tm)
569{ 573{
570 var date = new Date(tm*1000); 574 var date = new Date(tm*1000);
571 this.tm_sec = date.getSeconds(); 575 this.tm_sec = date.getSeconds();
@@ -577,13 +581,13 @@ RrdTime.prototype.localtime = function (tm)
577 this.tm_wday = date.getDay(); 581 this.tm_wday = date.getDay();
578}; 582};
579 583
580RrdTime.prototype.mktime = function() 584RrdTime.prototype.mktime = function()
581{ 585{
582 var date = new Date(this.tm_year+1900, this.tm_mon, this.tm_mday, this.tm_hour, this.tm_min, this.tm_sec); 586 var date = new Date(this.tm_year+1900, this.tm_mon, this.tm_mday, this.tm_hour, this.tm_min, this.tm_sec);
583 return Math.round(date.getTime()/1000.0); 587 return Math.round(date.getTime()/1000.0);
584}; 588};
585 589
586RrdTime.proc_start_end = function(start_t, end_t) 590RrdTime.proc_start_end = function(start_t, end_t)
587{ 591{
588 var start, end; 592 var start, end;
589 593
diff --git a/js/base64.js b/js/base64.js
index 7d9536a..4cd5c96 100644
--- a/js/base64.js
+++ b/js/base64.js
@@ -113,7 +113,8 @@ var Base64 = {
113 _utf8_decode : function (utftext) { 113 _utf8_decode : function (utftext) {
114 var string = ""; 114 var string = "";
115 var i = 0; 115 var i = 0;
116 var c = c1 = c2 = 0; 116 var c, c1, c2, c3;
117 c = c1 = c2 = 0;
117 118
118 while ( i < utftext.length ) { 119 while ( i < utftext.length ) {
119 120
@@ -140,4 +141,4 @@ var Base64 = {
140 return string; 141 return string;
141 } 142 }
142 143
143} 144};
diff --git a/js/rrdFile.js b/js/rrdFile.js
index eabebc7..3385df5 100644
--- a/js/rrdFile.js
+++ b/js/rrdFile.js
@@ -431,7 +431,7 @@ function RRDFile(bf,file_options) {
431 } 431 }
432 432
433 this.getRRA = function(idx) { 433 this.getRRA = function(idx) {
434 rra_info=this.rrd_header.getRRAInfo(idx); 434 var rra_info = this.rrd_header.getRRAInfo(idx);
435 return new RRDRRA(rrd_data, 435 return new RRDRRA(rrd_data,
436 this.rrd_header.rra_ptr_idx+idx*this.rrd_header.rra_ptr_el_size, 436 this.rrd_header.rra_ptr_idx+idx*this.rrd_header.rra_ptr_el_size,
437 rra_info, 437 rra_info,
diff --git a/js/sprintf.js b/js/sprintf.js
index 4d61fa2..244fe2a 100644
--- a/js/sprintf.js
+++ b/js/sprintf.js
@@ -19,60 +19,55 @@
19"use strict"; 19"use strict";
20 20
21function sprintf() 21function sprintf()
22{ 22{
23 var argc = 0; 23 var argc = 0;
24 var args = arguments; 24 var args = arguments;
25 var fmt = args[argc++]; 25 var fmt = args[argc++];
26 26
27 function lpad (str, padString, length) 27 function lpad (str, padString, length)
28 { 28 {
29 while (str.length < length) 29 while (str.length < length)
30 str = padString + str; 30 str = padString + str;
31 return str; 31 return str;
32 }; 32 }
33 33
34 function format (match, width, dot, precision, length, conversion) 34 function format (match, width, dot, precision, length, conversion)
35 { 35 {
36 if (match === '%%') return '%'; 36 if (match === '%%') return '%';
37 37
38 var value = args[argc++]; 38 var value = args[argc++];
39 var prefix; 39 var prefix;
40 40
41 if (width === undefined) 41 if (width === undefined)
42 width = 0; 42 width = 0;
43 else 43 else
44 width = +width; 44 width = +width;
45 45
46 if (precision === undefined) 46 if (precision === undefined)
47 precision = conversion == 'd' ? 0 : 6; 47 precision = conversion == 'd' ? 0 : 6;
48 else 48 else
49 precision = +precision; 49 precision = +precision;
50 50
51 switch (conversion) { 51 switch (conversion) {
52 case 's': 52 case 's':
53 case 'c': 53 case 'c':
54 return value; 54 return value;
55 break;
56 case 'd': 55 case 'd':
57 return parseInt(value, 10); 56 return parseInt(value, 10);
58 break;
59 case 'e': 57 case 'e':
60 prefix = value < 0 ? '-' : ''; 58 prefix = value < 0 ? '-' : '';
61 return lpad(prefix+Math.abs(value).toExponential(precision),' ',width); 59 return lpad(prefix+Math.abs(value).toExponential(precision),' ',width);
62 break;
63 case 'F': 60 case 'F':
64 case 'f': 61 case 'f':
65 prefix = value < 0 ? '-' : ''; 62 prefix = value < 0 ? '-' : '';
66 return lpad(prefix+Math.abs(value).toFixed(precision),' ',width); 63 return lpad(prefix+Math.abs(value).toFixed(precision),' ',width);
67 break;
68 case 'g': 64 case 'g':
69 prefix = value < 0 ? '-' : ''; 65 prefix = value < 0 ? '-' : '';
70 return lpad(prefix+Math.abs(value).toPrecision(precision),' ',width); 66 return lpad(prefix+Math.abs(value).toPrecision(precision),' ',width);
71 break;
72 default: 67 default:
73 return match; 68 return match;
74 } 69 }
75 70
76 }; 71 }
77 return fmt.replace(/%(\d+)?(\.(\d+))?(l?)([%scdfFeg])/g,format); 72 return fmt.replace(/%(\d+)?(\.(\d+))?(l?)([%scdfFeg])/g,format);
78}; 73}
diff --git a/js/strftime.js b/js/strftime.js
index 0933c27..b3698c8 100644
--- a/js/strftime.js
+++ b/js/strftime.js
@@ -27,80 +27,57 @@ function strftime (fmt, time)
27 var months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; 27 var months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ];
28 var fmonths = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; 28 var fmonths = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
29 29
30 function pad2 (number) 30 function pad2 (number)
31 { 31 {
32 return (number < 10 ? '0' : '') + number 32 return (number < 10 ? '0' : '') + number;
33 }; 33 }
34 34
35 function pad3(number) 35 function pad3(number)
36 { 36 {
37 return (number < 10 ? '00' : number < 100 ? '0' : '') + number 37 return (number < 10 ? '00' : number < 100 ? '0' : '') + number;
38 }; 38 }
39 39
40 function lpad (str, padString, length) 40 function format(match, opt)
41 {
42 while (str.length < length)
43 str = padString + str;
44 return str;
45 };
46
47 function format(match, opt)
48 { 41 {
49 if (match === '%%') return '%'; 42 if (match === '%%') return '%';
50 43
51 switch (opt) { 44 switch (opt) {
52 case 'a': 45 case 'a':
53 return days[d.getDay()]; 46 return days[d.getDay()];
54 break;
55 case 'A': 47 case 'A':
56 return fdays[d.getDay()]; 48 return fdays[d.getDay()];
57 break;
58 case 'b': 49 case 'b':
59 return months[d.getMonth()]; 50 return months[d.getMonth()];
60 break;
61 case 'B': 51 case 'B':
62 return fmonths[d.getMonth()]; 52 return fmonths[d.getMonth()];
63 break;
64 case 'c': 53 case 'c':
65 return d.toLocaleString(); 54 return d.toLocaleString();
66 break;
67 case 'd': 55 case 'd':
68 return pad2(d.getDate()); 56 return pad2(d.getDate());
69 break;
70 case 'H': 57 case 'H':
71 return pad2(d.getHours()); 58 return pad2(d.getHours());
72 break; 59 case 'I':
73 case 'I':
74 var hours = d.getHours()%12; 60 var hours = d.getHours()%12;
75 return pad2(hours === 0 ? 12 : hours); 61 return pad2(hours === 0 ? 12 : hours);
76 break;
77 case 'j': 62 case 'j':
78 var d01 = new Date (d.getFullYear(), 0, 1); 63 var d01 = new Date (d.getFullYear(), 0, 1);
79 return pad3(Math.ceil((d.getTime()-d01.getTime())/86400000)+1); 64 return pad3(Math.ceil((d.getTime()-d01.getTime())/86400000)+1);
80 break; 65 case 'm':
81 case 'm':
82 return pad2(d.getMonth()); 66 return pad2(d.getMonth());
83 break;
84 case 'M': 67 case 'M':
85 return pad2(d.getMinutes()); 68 return pad2(d.getMinutes());
86 break;
87 case 'p': 69 case 'p':
88 return d.getHours() >= 12 ? 'PM' : 'AM'; 70 return d.getHours() >= 12 ? 'PM' : 'AM';
89 break;
90 case 's': 71 case 's':
91 return pad2(d.getSeconds()); 72 return pad2(d.getSeconds());
92 break;
93 case 'S': 73 case 'S':
94 return d.getTime()/1000; 74 return d.getTime()/1000;
95 break;
96 case 'u': 75 case 'u':
97 return d.getDay() === 0 ? 7 : d.getDay(); 76 return d.getDay() === 0 ? 7 : d.getDay();
98 break; 77 case 'U':
99 case 'U':
100 var d01 = new Date(d.getFullYear(),0,1); 78 var d01 = new Date(d.getFullYear(),0,1);
101 return pad2(Math.round((Math.ceil((d.getTime()-d01.getTime())/86400000)+1 + 6 - d.getDay())/7)); 79 return pad2(Math.round((Math.ceil((d.getTime()-d01.getTime())/86400000)+1 + 6 - d.getDay())/7));
102 break; 80 case 'V':
103 case 'V':
104 var d01 = new Date(d.getFullYear(), 0, 1); 81 var d01 = new Date(d.getFullYear(), 0, 1);
105 var w = Math.round((Math.ceil((d.getTime()-d01.getTime())/86400000)+1 + 7 - (d.getDay() === 0 ? 7 : d.getDay()))/7); 82 var w = Math.round((Math.ceil((d.getTime()-d01.getTime())/86400000)+1 + 7 - (d.getDay() === 0 ? 7 : d.getDay()))/7);
106 var d31 = new Date(d.getFullYear(), 11, 31); 83 var d31 = new Date(d.getFullYear(), 11, 31);
@@ -115,32 +92,24 @@ function strftime (fmt, time)
115 if (w === 53 && d31.getDay() < 4) w = 1; 92 if (w === 53 && d31.getDay() < 4) w = 1;
116 } 93 }
117 return pad2(w); 94 return pad2(w);
118 break;
119 case 'w': 95 case 'w':
120 return d.getDay(); 96 return d.getDay();
121 break; 97 case 'W':
122 case 'W': 98 var d01 = new Date(d.getFullYear(),0,1);
123 var d01 = new Date(d.getFullYear(),0,1);
124 return pad2(Math.round((Math.ceil((d.getTime()-d01.getTime())/86400000)+1 + 7 - (d.getDay() === 0 ? 7 : d.getDay()))/7)); 99 return pad2(Math.round((Math.ceil((d.getTime()-d01.getTime())/86400000)+1 + 7 - (d.getDay() === 0 ? 7 : d.getDay()))/7));
125 break;
126 case 'x': 100 case 'x':
127 return pad2(d.getDate())+'/'+pad2(d.getMonth())+'/'+d.getFullYear() 101 return pad2(d.getDate())+'/'+pad2(d.getMonth())+'/'+d.getFullYear();
128 break;
129 case 'X': 102 case 'X':
130 return pad2(d.getHours())+':'+pad2(d.getMinutes())+':'+pad2(d.getSeconds()); 103 return pad2(d.getHours())+':'+pad2(d.getMinutes())+':'+pad2(d.getSeconds());
131 break; 104 case 'y':
132 case 'y':
133 return pad2(d.getFullYear()%100); 105 return pad2(d.getFullYear()%100);
134 break;
135 case 'Y': 106 case 'Y':
136 return d.getFullYear(); 107 return d.getFullYear();
137 break;
138 case 'Z': 108 case 'Z':
139 return d.toString().replace(/^.*\(([^)]+)\)$/, '$1'); 109 return d.toString().replace(/^.*\(([^)]+)\)$/, '$1');
140 break;
141 default: 110 default:
142 return match; 111 return match;
143 } 112 }
144 }; 113 }
145 return fmt.replace(/%([aAbBcdHIjmMpsSUVwWxXyYZ%])/g, format); 114 return fmt.replace(/%([aAbBcdHIjmMpsSUVwWxXyYZ%])/g, format);
146}; 115}