diff --git a/src/index.html b/src/index.html
index f6e3433..b31fe0d 100644
--- a/src/index.html
+++ b/src/index.html
@@ -42,6 +42,7 @@
UIColor is a website used to convert HEX & RGB colors to
diff --git a/src/js/app.js b/src/js/app.js
index 535e207..1cd4d30 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -37,7 +37,10 @@ app.config(['$routeProvider',
templateUrl: 'templates/rgb-to-ui.html',
controller: 'RgbToUICtrl',
})
-
+ .when('/ui-to-all', {
+ templateUrl: 'templates/ui-to-all.html',
+ controller: 'UiToAllCtrl',
+ })
.otherwise({
redirectTo: '/hex-to-ui'
});
diff --git a/src/js/controllers.js b/src/js/controllers.js
index 43a541a..4ea515b 100644
--- a/src/js/controllers.js
+++ b/src/js/controllers.js
@@ -4,5 +4,6 @@ angular.module('controllers', [
'controllers.header',
'controllers.hextoui',
'controllers.rgbtoui',
+ 'controllers.uitoall'
]);
\ No newline at end of file
diff --git a/src/js/controllers/ui-to-all.js b/src/js/controllers/ui-to-all.js
new file mode 100644
index 0000000..328c90f
--- /dev/null
+++ b/src/js/controllers/ui-to-all.js
@@ -0,0 +1,67 @@
+var app = angular.module('controllers.uitoall', ['ngRoute', 'ui.bootstrap', 'colorpicker.module']);
+
+app.controller("UiToAllCtrl", function (appConfig, $scope, $filter, $rootScope) {
+
+ $scope.title = "UIColor to Hex & Rgb Converter";
+
+ // Roll Tide
+ $scope.uiColorValid = true;
+ $scope.uiColorString = "";
+
+ $scope.color = {
+ "r": "",
+ "g": "",
+ "b": "",
+ "hex": ""
+ };
+
+ function convertUiToRgbAndHex(r, g, b) {
+ $scope.color.r = Math.round(r * 255);
+ $scope.color.g = Math.round(g * 255);
+ $scope.color.b = Math.round(b * 255);
+
+ $scope.color.hex = componentToHex($scope.color.r) + componentToHex($scope.color.g) + componentToHex($scope.color.b);
+ }
+
+ function componentToHex(c) {
+ var hex = c.toString(16);
+ return hex.length == 1 ? "0" + hex : hex;
+ }
+
+ $scope.$watch('uiColorString', function (newVal, oldval) {
+ if (newVal !== "") {
+ var parseRegex = /[rR]ed: ?([\d.]*?)f?,? green: ?([\d.]*?)f?,? blue: ?([\d.]*?)f?,? /;
+ var parsedGroups = parseRegex.exec(newVal);
+
+ if (parsedGroups) {
+ var red = parseFloat(parsedGroups[1]);
+ var green = parseFloat(parsedGroups[2]);
+ var blue = parseFloat(parsedGroups[3]);
+
+ if (red <= 1 && green <= 1 && blue <= 1) {
+ convertUiToRgbAndHex(red, green, blue);
+ updateCopyText();
+ $rootScope.$broadcast('ColorChanged', $scope.color.hex);
+ $scope.uiColorValid = true;
+ } else {
+ $rootScope.$broadcast('ColorChanged', appConfig.themePrimary);
+ $scope.uiColorValid = false;
+ console.log("Invalid UIColor.");
+ }
+ } else {
+ $rootScope.$broadcast('ColorChanged', appConfig.themePrimary);
+ $scope.uiColorValid = false;
+ console.log("Invalid UIColor.");
+ }
+ } else {
+ $rootScope.$broadcast('ColorChanged', appConfig.themePrimary);
+ }
+
+ }, true);
+
+ function updateCopyText() {
+ $scope.copyRgb = "rgb(" + $scope.color.r + ", " + $scope.color.g + ", " + $scope.color.b + ")";
+ $scope.copyHex = "#" + $scope.color.hex;
+ }
+
+});
\ No newline at end of file
diff --git a/src/templates/ui-to-all.html b/src/templates/ui-to-all.html
new file mode 100644
index 0000000..10d9310
--- /dev/null
+++ b/src/templates/ui-to-all.html
@@ -0,0 +1,42 @@
+{{ title }}
+
+
+
+
+
+
+
+
+
+
+
+
UIColor not valid
+
+
+
+
RGB
+ {{ copyRgb }}
+
+
+
+
+
+
HEX
+ {{ copyHex }}
+
+
+
+
+
+
\ No newline at end of file