diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-07-16 09:34:37 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-07-16 09:37:44 +0200 |
commit | 56dd29bd798b4a6f87c1f463e149d860a570bc04 (patch) | |
tree | a4019f3d8043c440f5fa39f792c48864b9792196 | |
parent | 55658914713c35b9b2bdea682103743c5265ff68 (diff) | |
download | sonarqube-56dd29bd798b4a6f87c1f463e149d860a570bc04.tar.gz sonarqube-56dd29bd798b4a6f87c1f463e149d860a570bc04.zip |
Fix some JS quality flaws
-rw-r--r-- | sonar-server/src/main/webapp/javascripts/application.js | 5 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/javascripts/protovis-sonar.js | 19 |
2 files changed, 13 insertions, 11 deletions
diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js index b3085ad709f..ca1345c981e 100644 --- a/sonar-server/src/main/webapp/javascripts/application.js +++ b/sonar-server/src/main/webapp/javascripts/application.js @@ -44,7 +44,7 @@ var SelectBox = { init: function (id) { var box = document.getElementById(id); var node; - SelectBox.cache[id] = new Array(); + SelectBox.cache[id] = []; var cache = SelectBox.cache[id]; for (var i = 0; (node = box.options[i]); i++) { cache.push({value: node.value, text: node.text, displayed: 1}); @@ -53,7 +53,8 @@ var SelectBox = { redisplay: function (id) { // Repopulate HTML select box from cache var box = document.getElementById(id); - box.options.length = 0; // clear all options + // clear all options + box.options.length = 0; for (var i = 0, j = SelectBox.cache[id].length; i < j; i++) { var node = SelectBox.cache[id][i]; if (node.displayed) { diff --git a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js index 022c58b11ca..116003371eb 100644 --- a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js +++ b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js @@ -29,7 +29,7 @@ SonarWidgets.StackArea = function (divId) { this.colors = function (colors) { this.wColors = colors; return this; - } + }; }; SonarWidgets.StackArea.prototype.render = function () { @@ -49,7 +49,7 @@ SonarWidgets.StackArea.prototype.render = function () { for (j = 0; j < metrics.size(); j++) { total[i] += trendData[j][i].y; } - total[i] = "" + Math.round(total[i] * 10) / 10 + total[i] = "" + Math.round(total[i] * 10) / 10; } /* Computes the highest Y value */ @@ -67,7 +67,8 @@ SonarWidgets.StackArea.prototype.render = function () { /* Computes minimum width of left margin according to the max Y value so that the Y-axis is correctly displayed */ var leftMargin = 25; var maxYLength = (Math.round(maxY) + "").length; - minMargin = maxYLength * 7 + Math.floor(maxYLength / 3) * 2; // first part is for numbers and second for commas (1000-separator) + // first part is for numbers and second for commas (1000-separator) + minMargin = maxYLength * 7 + Math.floor(maxYLength / 3) * 2; if (minMargin > leftMargin) { leftMargin = minMargin; } @@ -81,7 +82,7 @@ SonarWidgets.StackArea.prototype.render = function () { return d; })), function (d) { - return d.x + return d.x; }).range(0, w); var y = pv.Scale.linear(0, maxY).range(0, h - headerHeight); var idx_numbers = trendData[0].size(); @@ -206,25 +207,25 @@ SonarWidgets.StackArea.prototype.render = function () { return s.e.size() > 0; }) .fillStyle(function () { - return this.index == idx ? eventHoverColor : eventColor; + return this.index === idx ? eventHoverColor : eventColor; }) .add(pv.Dot) .radius(3) .visible(function (s) { - return s.e.size() > 0 && this.index == idx; + return s.e.size() > 0 && this.index === idx; }) .left(w / 2 + 8) .top(24) .shape("triangle") .fillStyle(function () { - return this.index == idx ? eventHoverColor : eventColor; + return this.index === idx ? eventHoverColor : eventColor; }) .strokeStyle("grey") .anchor("right") .add(pv.Label) .font(headerFont) .text(function (s) { - return s.e.size() == 0 ? "" : s.e[0] + ( s.e[1] ? " (... +" + (s.e.size() - 1) + ")" : ""); + return s.e.size() === 0 ? "" : s.e[0] + ( s.e[1] ? " (... +" + (s.e.size() - 1) + ")" : ""); }); /* An invisible bar to capture events (without flickering). */ @@ -336,7 +337,7 @@ SonarWidgets.Timeline.prototype.render = function () { return d; })), function (d) { - return d.x + return d.x; }).range(0, w); var y = new Array(trendData.size()); for (var i = 0; i < trendData.size(); i++) { |