JS: Fix scrutinizer warnings and indentation for filters
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
516e396a58
commit
9014ae1490
@@ -20,10 +20,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/** global: OC */
|
||||
app.controller('AppController', function ($scope, $location, $http, $route, $log, $rootScope, $stateParams) {
|
||||
$rootScope.sidebar = {
|
||||
show: false
|
||||
};
|
||||
$scope.sidebar = $rootScope.sidebar;
|
||||
$scope.user = oc_current_user;
|
||||
$rootScope.sidebar = {
|
||||
show: false
|
||||
};
|
||||
$scope.sidebar = $rootScope.sidebar;
|
||||
$scope.user = oc_current_user;
|
||||
});
|
||||
@@ -20,6 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/** global: oc_defaults */
|
||||
app.controller('BoardController', function ($rootScope, $scope, $stateParams, StatusService, BoardService, StackService, CardService, LabelService, $state, $transitions, $filter) {
|
||||
|
||||
$scope.sidebar = $rootScope.sidebar;
|
||||
@@ -45,8 +46,8 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
|
||||
|
||||
$scope.board = BoardService.getCurrent();
|
||||
StackService.clear(); //FIXME: Is this still needed?
|
||||
$scope.setPageTitle = function() {
|
||||
if(BoardService.getCurrent()) {
|
||||
$scope.setPageTitle = function () {
|
||||
if (BoardService.getCurrent()) {
|
||||
document.title = BoardService.getCurrent().title + " | Deck - " + oc_defaults.name;
|
||||
} else {
|
||||
document.title = "Deck - " + oc_defaults.name;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
app.filter('iconWhiteFilter', function() {
|
||||
app.filter('iconWhiteFilter', function () {
|
||||
return function (hex) {
|
||||
// RGB2HLS by Garry Tan
|
||||
// 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),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
if(result !== null) {
|
||||
var r = color.r/255;
|
||||
var g = color.g/255;
|
||||
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 (result === null) {
|
||||
return "";
|
||||
}
|
||||
var r = color.r / 255;
|
||||
var g = color.g / 255;
|
||||
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){
|
||||
h = s = 0; // achromatic
|
||||
}else{
|
||||
var d = max - min;
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||
switch(max){
|
||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||
case g: h = (b - r) / d + 2; break;
|
||||
case b: h = (r - g) / d + 4; break;
|
||||
}
|
||||
h /= 6;
|
||||
if (max == min) {
|
||||
h = s = 0; // achromatic
|
||||
} else {
|
||||
var d = max - min;
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||
switch (max) {
|
||||
case r:
|
||||
h = (g - b) / d + (g < b ? 6 : 0);
|
||||
break;
|
||||
case g:
|
||||
h = (b - r) / d + 2;
|
||||
break;
|
||||
case b:
|
||||
h = (r - g) / d + 4;
|
||||
break;
|
||||
}
|
||||
// TODO: Maybe just darken/lighten the color
|
||||
if(l<0.5) {
|
||||
return "-white";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
//var rgba = "rgba(" + color.r + "," + color.g + "," + color.b + ",0.7)";
|
||||
//return rgba;
|
||||
h /= 6;
|
||||
}
|
||||
if (l < 0.5) {
|
||||
return "-white";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
app.filter('textColorFilter', function() {
|
||||
app.filter('textColorFilter', function () {
|
||||
return function (hex) {
|
||||
// RGB2HLS by Garry Tan
|
||||
// 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),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
if(result !== null) {
|
||||
var r = color.r/255;
|
||||
var g = color.g/255;
|
||||
var b = color.b/255;
|
||||
if (result !== null) {
|
||||
var r = color.r / 255;
|
||||
var g = color.g / 255;
|
||||
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
|
||||
}else{
|
||||
} else {
|
||||
var d = max - min;
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||
switch(max){
|
||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||
case g: h = (b - r) / d + 2; break;
|
||||
case b: h = (r - g) / d + 4; break;
|
||||
switch (max) {
|
||||
case r:
|
||||
h = (g - b) / d + (g < b ? 6 : 0);
|
||||
break;
|
||||
case g:
|
||||
h = (b - r) / d + 2;
|
||||
break;
|
||||
case b:
|
||||
h = (r - g) / d + 4;
|
||||
break;
|
||||
}
|
||||
h /= 6;
|
||||
}
|
||||
if(l<0.5) {
|
||||
if (l < 0.5) {
|
||||
return "#ffffff";
|
||||
} else {
|
||||
return "#000000";
|
||||
|
||||
Reference in New Issue
Block a user