JS: Fix scrutinizer warnings and indentation for filters

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2017-10-04 15:32:02 +02:00
committed by Julius Härtl
parent 516e396a58
commit 9014ae1490
4 changed files with 55 additions and 46 deletions

View File

@@ -20,10 +20,11 @@
* *
*/ */
/** global: OC */
app.controller('AppController', function ($scope, $location, $http, $route, $log, $rootScope, $stateParams) { app.controller('AppController', function ($scope, $location, $http, $route, $log, $rootScope, $stateParams) {
$rootScope.sidebar = { $rootScope.sidebar = {
show: false show: false
}; };
$scope.sidebar = $rootScope.sidebar; $scope.sidebar = $rootScope.sidebar;
$scope.user = oc_current_user; $scope.user = oc_current_user;
}); });

View File

@@ -20,6 +20,7 @@
* *
*/ */
/** global: oc_defaults */
app.controller('BoardController', function ($rootScope, $scope, $stateParams, StatusService, BoardService, StackService, CardService, LabelService, $state, $transitions, $filter) { app.controller('BoardController', function ($rootScope, $scope, $stateParams, StatusService, BoardService, StackService, CardService, LabelService, $state, $transitions, $filter) {
$scope.sidebar = $rootScope.sidebar; $scope.sidebar = $rootScope.sidebar;
@@ -45,8 +46,8 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
$scope.board = BoardService.getCurrent(); $scope.board = BoardService.getCurrent();
StackService.clear(); //FIXME: Is this still needed? StackService.clear(); //FIXME: Is this still needed?
$scope.setPageTitle = function() { $scope.setPageTitle = function () {
if(BoardService.getCurrent()) { if (BoardService.getCurrent()) {
document.title = BoardService.getCurrent().title + " | Deck - " + oc_defaults.name; document.title = BoardService.getCurrent().title + " | Deck - " + oc_defaults.name;
} else { } else {
document.title = "Deck - " + oc_defaults.name; document.title = "Deck - " + oc_defaults.name;

View File

@@ -20,7 +20,7 @@
* *
*/ */
app.filter('iconWhiteFilter', function() { app.filter('iconWhiteFilter', function () {
return function (hex) { return function (hex) {
// RGB2HLS by Garry Tan // RGB2HLS by Garry Tan
// http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c // http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
@@ -30,36 +30,37 @@ app.filter('iconWhiteFilter', function() {
g: parseInt(result[2], 16), g: parseInt(result[2], 16),
b: parseInt(result[3], 16) b: parseInt(result[3], 16)
} : null; } : null;
if(result !== null) { if (result === null) {
var r = color.r/255; return "";
var g = color.g/255; }
var b = color.b/255; var r = color.r / 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b); var g = color.g / 255;
var h, s, l = (max + min) / 2; var b = color.b / 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if(max == min){ if (max == min) {
h = s = 0; // achromatic h = s = 0; // achromatic
}else{ } else {
var d = max - min; var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch(max){ switch (max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break; case r:
case g: h = (b - r) / d + 2; break; h = (g - b) / d + (g < b ? 6 : 0);
case b: h = (r - g) / d + 4; break; break;
} case g:
h /= 6; h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
} }
// TODO: Maybe just darken/lighten the color h /= 6;
if(l<0.5) { }
return "-white"; if (l < 0.5) {
} else { return "-white";
return "";
}
//var rgba = "rgba(" + color.r + "," + color.g + "," + color.b + ",0.7)";
//return rgba;
} else { } else {
return ""; return "";
} }
} }
}); });

View File

@@ -20,7 +20,7 @@
* *
*/ */
app.filter('textColorFilter', function() { app.filter('textColorFilter', function () {
return function (hex) { return function (hex) {
// RGB2HLS by Garry Tan // RGB2HLS by Garry Tan
// http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c // http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
@@ -30,26 +30,32 @@ app.filter('textColorFilter', function() {
g: parseInt(result[2], 16), g: parseInt(result[2], 16),
b: parseInt(result[3], 16) b: parseInt(result[3], 16)
} : null; } : null;
if(result !== null) { if (result !== null) {
var r = color.r/255; var r = color.r / 255;
var g = color.g/255; var g = color.g / 255;
var b = color.b/255; var b = color.b / 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b); var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2; var h, s, l = (max + min) / 2;
if(max == min){ if (max == min) {
h = s = 0; // achromatic h = s = 0; // achromatic
}else{ } else {
var d = max - min; var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch(max){ switch (max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break; case r:
case g: h = (b - r) / d + 2; break; h = (g - b) / d + (g < b ? 6 : 0);
case b: h = (r - g) / d + 4; break; break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
} }
h /= 6; h /= 6;
} }
if(l<0.5) { if (l < 0.5) {
return "#ffffff"; return "#ffffff";
} else { } else {
return "#000000"; return "#000000";