From 41c5ef3e4f128efd3fbba27c4bdd99ea71b65ecb Mon Sep 17 00:00:00 2001 From: Manuel Luis SanmartĂ­n Rozada Date: Fri, 3 Apr 2015 23:26:36 +0200 Subject: jsrrdgraph: Fix tabs and spaces --- js/RrdGfxCanvas.js | 2 +- js/RrdGfxPdf.js | 38 +++++++++++++++++++------------------- js/RrdGfxSvg.js | 49 +++++++++++++++++++++++++------------------------ js/RrdGraph.js | 8 ++++---- 4 files changed, 49 insertions(+), 48 deletions(-) diff --git a/js/RrdGfxCanvas.js b/js/RrdGfxCanvas.js index 110c032..7f79b6b 100644 --- a/js/RrdGfxCanvas.js +++ b/js/RrdGfxCanvas.js @@ -105,7 +105,7 @@ RrdGfxCanvas.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, das } else if (X0 === X1) { X0 += 0.5; X1 += 0.5; - } + } this.ctx.moveTo(X0, Y0); this.ctx.lineTo(X1, Y1); diff --git a/js/RrdGfxPdf.js b/js/RrdGfxPdf.js index 7cde098..868d521 100644 --- a/js/RrdGfxPdf.js +++ b/js/RrdGfxPdf.js @@ -154,20 +154,20 @@ RrdGfxPdf.CORE_FONTS= { RrdGfxPdf.prototype.parse_color = function(str) { - var bits; - if ((bits = /^#?([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(str))) { - return [parseInt(bits[1]+bits[1], 16), parseInt(bits[2]+bits[2], 16), parseInt(bits[3]+bits[3], 16), 1.0]; - } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { - return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), 1.0]; - } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { - return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), parseInt(bits[4], 16)/255]; - } else if ((bits = /^rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)$/.exec(str))) { - return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), 1.0]; - } else if ((bits = /^rgba\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([0-9.]+)\)$/.exec(str))) { - return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), parseFloat(bits[4], 10)]; - } else { - throw "Unknow color format '"+str+"'"; - } + var bits; + if ((bits = /^#?([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(str))) { + return [parseInt(bits[1]+bits[1], 16), parseInt(bits[2]+bits[2], 16), parseInt(bits[3]+bits[3], 16), 1.0]; + } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { + return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), 1.0]; + } else if ((bits = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(str))) { + return [parseInt(bits[1], 16), parseInt(bits[2], 16), parseInt(bits[3], 16), parseInt(bits[4], 16)/255]; + } else if ((bits = /^rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)$/.exec(str))) { + return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), 1.0]; + } else if ((bits = /^rgba\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([0-9.]+)\)$/.exec(str))) { + return [parseInt(bits[1], 10), parseInt(bits[2], 10), parseInt(bits[3], 10), parseFloat(bits[4], 10)]; + } else { + throw "Unknow color format '"+str+"'"; + } }; RrdGfxPdf.prototype.size = function (width, height) @@ -358,12 +358,12 @@ RrdGfxPdf.prototype.text = function (x, y, color, font, tabwidth, angle, h_align var tm = []; tm[0] = Math.cos(angle*Math.PI/180.0); - tm[1] = Math.sin(angle*Math.PI/180.0); - tm[2] = -tm[1]; - tm[3] = tm[0]; + tm[1] = Math.sin(angle*Math.PI/180.0); + tm[2] = -tm[1]; + tm[3] = tm[0]; - tm[4] = x + (tm[1] * y) - (tm[0] * x); - tm[5] = y - (tm[0] * y) - (tm[1] * x); + tm[4] = x + (tm[1] * y) - (tm[0] * x); + tm[5] = y - (tm[0] * y) - (tm[1] * x); var rgba = this.parse_color(color); this._save(); diff --git a/js/RrdGfxSvg.js b/js/RrdGfxSvg.js index 927cb14..533abb8 100644 --- a/js/RrdGfxSvg.js +++ b/js/RrdGfxSvg.js @@ -24,7 +24,8 @@ * RrdGfxSvg * @constructor */ -var RrdGfxSvg = function(svgId) { +var RrdGfxSvg = function(svgId) +{ this.svg = document.getElementById(svgId); this.svgns = "http://www.w3.org/2000/svg"; this.xmlns = "http://www.w3.org/XML/1998/namespace"; @@ -32,7 +33,7 @@ var RrdGfxSvg = function(svgId) { this.path_color = null; this.path_width = null; this.dash = false; - this.dash_offset = null; + this.dash_offset = null; this.dash_array = null; }; @@ -70,10 +71,10 @@ RrdGfxSvg.prototype.line = function (X0, Y0, X1, Y1, width, color) { var shape = document.createElementNS(this.svgns, "line"); - X0 = Math.round(X0)+0.5; - Y0 = Math.round(Y0)+0.5; - X1 = Math.round(X1)+0.5; - Y1 = Math.round(Y1)+0.5; + X0 = Math.round(X0)+0.5; + Y0 = Math.round(Y0)+0.5; + X1 = Math.round(X1)+0.5; + Y1 = Math.round(Y1)+0.5; shape.setAttributeNS(null, "x1", X0); shape.setAttributeNS(null, "y1", Y0); @@ -91,10 +92,10 @@ RrdGfxSvg.prototype.dashed_line = function (X0, Y0, X1, Y1, width, color, dash_o { var shape = document.createElementNS(this.svgns, "line"); - X0 = Math.round(X0)+0.5; - Y0 = Math.round(Y0)+0.5; - X1 = Math.round(X1)+0.5; - Y1 = Math.round(Y1)+0.5; + X0 = Math.round(X0)+0.5; + Y0 = Math.round(Y0)+0.5; + X1 = Math.round(X1)+0.5; + Y1 = Math.round(Y1)+0.5; shape.setAttributeNS(null, "x1", X0); shape.setAttributeNS(null, "y1", Y0); @@ -129,12 +130,12 @@ RrdGfxSvg.prototype.rectangle = function (X0, Y0, X1, Y1, width, style) RrdGfxSvg.prototype.new_area = function (X0, Y0, X1, Y1, X2, Y2, color) { - X0 = Math.round(X0)+0.5; - Y0 = Math.round(Y0)+0.5; - X1 = Math.round(X1)+0.5; - Y1 = Math.round(Y1)+0.5; - X2 = Math.round(X2)+0.5; - Y2 = Math.round(Y2)+0.5; + X0 = Math.round(X0)+0.5; + Y0 = Math.round(Y0)+0.5; + X1 = Math.round(X1)+0.5; + Y1 = Math.round(Y1)+0.5; + X2 = Math.round(X2)+0.5; + Y2 = Math.round(Y2)+0.5; this.path_color = color; this.path = 'M'+X0+','+Y0; @@ -144,8 +145,8 @@ RrdGfxSvg.prototype.new_area = function (X0, Y0, X1, Y1, X2, Y2, color) RrdGfxSvg.prototype.add_point = function (x, y) { - x = Math.round(x)+0.5; - y = Math.round(y)+0.5; + x = Math.round(x)+0.5; + y = Math.round(y)+0.5; this.path += ' L'+x+','+y; }; @@ -188,24 +189,24 @@ RrdGfxSvg.prototype.stroke_end = function () RrdGfxSvg.prototype.moveTo = function (x,y) { - x = Math.round(x)+0.5; - y = Math.round(y)+0.5; + x = Math.round(x)+0.5; + y = Math.round(y)+0.5; this.path += ' M'+x+','+y; }; RrdGfxSvg.prototype.lineTo = function (x,y) { - x = Math.round(x)+0.5; - y = Math.round(y)+0.5; + x = Math.round(x)+0.5; + y = Math.round(y)+0.5; this.path += ' L'+x+','+y; }; RrdGfxSvg.prototype.text = function (x, y, color, font, tabwidth, angle, h_align, v_align, text) { - x = Math.round(x); - y = Math.round(y); + x = Math.round(x); + y = Math.round(y); var svgtext = document.createElementNS(this.svgns, "text"); diff --git a/js/RrdGraph.js b/js/RrdGraph.js index 25823aa..1a9cc9f 100644 --- a/js/RrdGraph.js +++ b/js/RrdGraph.js @@ -27,8 +27,8 @@ */ var RrdGraphDescError = function (message) { - this.name = "RrdGraphDescError"; - this.message = (message) ? message : "Error"; + this.name = "RrdGraphDescError"; + this.message = (message) ? message : "Error"; }; RrdGraphDescError.prototype = new Error(); @@ -430,8 +430,8 @@ RrdGraphDesc.prototype.hrule = function (graph, value, color, legend, dashes, da */ var RrdVdefError = function (message) { - this.name = "RrdVdefError"; - this.message = (message) ? message : "Error"; + this.name = "RrdVdefError"; + this.message = (message) ? message : "Error"; }; RrdVdefError.prototype = new Error(); -- cgit v1.1