diff options
author | brantje <brantje@gmail.com> | 2016-09-28 01:14:32 +0300 |
---|---|---|
committer | brantje <brantje@gmail.com> | 2016-09-28 01:14:32 +0300 |
commit | 389fd23b669451167e2e4c5eee0eb3e6274cd37c (patch) | |
tree | d56fcdb5076ed5ef5af7a49a2dcb97a48bf46c29 /js/app/directives | |
parent | 5398d2ba741d2d90ee561f905dff7938ee769902 (diff) |
Add grid view
Diffstat (limited to 'js/app/directives')
-rw-r--r-- | js/app/directives/colorfromstring.js | 34 | ||||
-rw-r--r-- | js/app/directives/passwordgen.js | 2 |
2 files changed, 35 insertions, 1 deletions
diff --git a/js/app/directives/colorfromstring.js b/js/app/directives/colorfromstring.js new file mode 100644 index 00000000..b0552fab --- /dev/null +++ b/js/app/directives/colorfromstring.js @@ -0,0 +1,34 @@ +'use strict'; + +/** + * @ngdoc directive + * @name passmanApp.directive:passwordGen + * @description + * # passwordGen + */ +angular.module('passmanApp') + .directive('colorFromString', ['$window', function ($window) { + return { + restrict: 'A', + scope:{ + string: '=colorFromString' + }, + link: function (scope, el, attr, ctrl) { + function genColor(str) { // java String#hashCode + var hash = 0; + for (var i = 0; i < str.length; i++) { + hash = str.charCodeAt(i) + ((hash << 5) - hash); + } + var c = (hash & 0x00FFFFFF) + .toString(16) + .toUpperCase(); + + return '#' + '00000'.substring(0, 6 - c.length) + c; + } + scope.$watch('string', function(){ + $(el).css('border-color', genColor(scope.string)); + }) + + } + }; + }]); diff --git a/js/app/directives/passwordgen.js b/js/app/directives/passwordgen.js index 32cfdc16..a680f23c 100644 --- a/js/app/directives/passwordgen.js +++ b/js/app/directives/passwordgen.js @@ -151,7 +151,7 @@ angular.module('passmanApp') scope.onError = function(e) { OC.Notification.showTemporary('Press Ctrl+C to copy!'); - } + }; scope.progressDivShow = false; scope.generatePasswordStart = function() { scope.progressDivShow = true; |