diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 9dad7ba608e5cb81bac744fa1618b7f5bd546643..87f6154007c897eaa60fb10eea6c395b77a0b8c0 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -58,55 +58,38 @@ ServerConnector.init(); ServerConnector.getMinOverlayColorInt = function() { var self = this; - var userColor; return self.getLoggedUser().then(function(user) { - userColor = user.getMinColor(); - return self.getConfigurationParam(ConfigurationType.MIN_COLOR_VAL); - }).then(function(systemMinColor) { + var userColor = user.getMinColor(); + return self.returnUserOrSystemColor(userColor, self.getConfigurationParam(ConfigurationType.MIN_COLOR_VAL)); + }); +}; + +ServerConnector.returnUserOrSystemColor = function(userColor, systemPromisedColor) { + return systemPromisedColor.then(function(systemColor) { var color = userColor; if (userColor === null || userColor === undefined || userColor === "") { - color = systemMinColor; + color = systemColor; } color = parseInt(color, 16); /* jslint bitwise: true */ color = (color & 0xFFFFFF); return color; }); -}; +} ServerConnector.getSimpleOverlayColorInt = function() { var self = this; - var userColor; return self.getLoggedUser().then(function(user) { - userColor = user.getSimpleColor(); - return self.getConfigurationParam(ConfigurationType.SIMPLE_COLOR_VAL); - }).then(function(systemSimpleColor) { - var color = userColor; - if (userColor === null || userColor === undefined || userColor === "") { - color = systemSimpleColor; - } - color = parseInt(color, 16); - /* jslint bitwise: true */ - color = (color & 0xFFFFFF); - return color; + var userColor = user.getSimpleColor(); + return self.returnUserOrSystemColor(userColor, self.getConfigurationParam(ConfigurationType.SIMPLE_COLOR_VAL)); }); }; ServerConnector.getMaxOverlayColorInt = function() { var self = this; - var userColor; return self.getLoggedUser().then(function(user) { - userColor = user.getMaxColor(); - return self.getConfigurationParam(ConfigurationType.MAX_COLOR_VAL); - }).then(function(systemMaxColor) { - var color = userColor; - if (userColor === null || userColor === undefined || userColor === "") { - color = systemMaxColor; - } - color = parseInt(color, 16); - /* jslint bitwise: true */ - color = (color & 0xFFFFFF); - return color; + var userColor = user.getMaxColor(); + return self.returnUserOrSystemColor(userColor, self.getConfigurationParam(ConfigurationType.MAX_COLOR_VAL)); }); };