From b6be82b8edefa452e72ed53391971e53d9dccf83 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 25 Jul 2014 23:28:21 +0200 Subject: jsrrdgraph: Fixed jshint warnings/errors Many fall in the category missing semicolon, but there are legitimate bugs (like throwing an error with an undefined variable, using isInfinite instead of !isFinite or fabs instead of Math.abs). At some places, I moved the variable declarations to avoid duplicate definition warnings. Redundant breaks have been removed (after return / throw). Global variables were implicitly defined in RrdDataFile (which caught my attention) and Base64, these have been made local. Also fixed some whitespace errors. Yay, the consistency. Not all (style) issues are fixed. --- js/RrdCmdLine.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'js/RrdCmdLine.js') 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 = { }, set_option: function(option, value) { + var args = value.split(':'); + var index = value.indexOf(':'); switch(option) { case 'base': case 'b': @@ -193,12 +195,12 @@ RrdCmdLine.prototype = { break; case 'color': case 'c': - var index = value.indexOf('#'); + index = value.indexOf('#'); if (index === -1) throw "invalid color def format"; var name = value.substr(0,index); if (!this.graph.GRC[name]) - throw "invalid color name '"+name+"'" + throw "invalid color name '" + name + "'"; this.graph.GRC[name] = value.substr(index); // FIXME check color break; case 'end': @@ -212,7 +214,7 @@ RrdCmdLine.prototype = { break; case 'graph-render-mode': case 'G': - // im->graph_antialias + // im->graph_antialias break; case 'height': case 'h': @@ -225,7 +227,7 @@ RrdCmdLine.prototype = { break; case 'lower-limit': case 'l': - this.graph.setminval = parseFloat(value) + this.graph.setminval = parseFloat(value); break; case 'zoom': case 'm': @@ -235,11 +237,10 @@ RrdCmdLine.prototype = { break; case 'font': case 'n': - var args = value.split(':'); if (args.length !== 3) throw "invalid text property format"; if (!this.graph.TEXT[args[0]]) - throw "invalid fonttag '"+args[0]+"'" + throw "invalid font tag '" + args[0] + "'"; if (args[1] > 0) this.graph.TEXT[args[0]].size = args[1]; if (args[2]) @@ -292,7 +293,6 @@ RrdCmdLine.prototype = { if (value === 'none') { this.graph.draw_x_grid = false; } else { - var args = value.split(':'); if (args.length !== 8) throw "invalid x-grid format"; this.graph.xlab_user.gridtm = this.graph.tmt_conv(args[0]); @@ -318,7 +318,6 @@ RrdCmdLine.prototype = { if (value === 'none') { this.graph.draw_y_grid = false; } else { - var index = value.indexOf(':'); if (index === -1) throw "invalid y-grid format"; this.graph.ygridstep = parseFloat(value.substr(0,index)); @@ -338,7 +337,6 @@ RrdCmdLine.prototype = { throw "invalid argument for --units: "+value; break; case 'right-axis': - var index = value.indexOf(':'); if (index === -1) throw "invalid right-axis format expected scale:shift"; this.graph.second_axis_scale = parseFloat(value.substr(0,index)); @@ -378,7 +376,6 @@ RrdCmdLine.prototype = { this.graph.draw_3d_border = parseInt(value, 10); break; case 'grid-dash': - var index = value.indexOf(':'); if (index === -1) throw "expected grid-dash format float:float"; this.graph.grid_dash_on = parseFloat(value.substr(0,index)); @@ -399,20 +396,17 @@ RrdCmdLine.prototype = { var rrdfile = vnames[1]; var name = args[n++]; var cf = args[n++]; - var step = undefined; - var reduce = undefined; - var start = undefined; - var end = undefined; + var step, reduce, start, end; if (args.length > n) { for (var j = n, xlen = args.length ; j < xlen ; j++) { var opts = args[j].split("="); if (opts[0] === "step") step = opts[1]; - if (opts[0] === "reduce") reduce = opts[1] + if (opts[0] === "reduce") reduce = opts[1]; if (opts[0] === "start") start = opts[1]; if (opts[0] === "end") end = opts[1]; } } - this.graph.gdes_add_def(vname, rrdfile, name, cf, step, start, end, reduce) + this.graph.gdes_add_def(vname, rrdfile, name, cf, step, start, end, reduce); }, // CDEF:vname=RPN expression parse_cdef: function (line) -- cgit v1.1