Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /* global API */ |
||
25 | (function () { |
||
26 | 'use strict'; |
||
27 | |||
28 | /** |
||
29 | * @ngdoc function |
||
30 | * @name passmanApp.controller:MainCtrl |
||
31 | * @description |
||
32 | * # MainCtrl |
||
33 | * Controller of the passmanApp |
||
34 | */ |
||
35 | angular.module('passmanExtension') |
||
36 | .controller('PasswordPromptCtrl', ['$scope', 'Settings', '$location', '$rootScope', function ($scope, Settings, $window, $rootScope) { |
||
37 | $scope.settings = {}; |
||
38 | |||
39 | API.runtime.sendMessage(API.runtime.id, {method: "getMasterPasswordSet"}).then(function (isSet) { |
||
40 | $scope.masterPwSet = isSet; |
||
41 | $scope.$apply(); |
||
42 | }); |
||
43 | $rootScope.$broadcast('hideHeader'); |
||
44 | $scope.master_password_remember = false; |
||
45 | $scope.master_password = ''; |
||
46 | $scope.apply_settings = function () { |
||
47 | $scope.saving = true; |
||
48 | $scope.inValidPassword = false; |
||
49 | API.runtime.sendMessage(API.runtime.id, { |
||
50 | method: 'isMasterPasswordValid', |
||
51 | args: $scope.master_password |
||
52 | }).then(function (isValid) { |
||
53 | if (isValid) { |
||
54 | API.runtime.sendMessage(API.runtime.id, { |
||
55 | method: "setMasterPassword", |
||
56 | args: {password: $scope.master_password, savePassword: $scope.master_password_remember} |
||
57 | }).then(function () { |
||
58 | setTimeout(function () { |
||
59 | window.location = '#!/'; |
||
60 | $scope.saving = false; |
||
61 | $rootScope.$broadcast('showHeader'); |
||
62 | |||
63 | }, 750); |
||
64 | }); |
||
65 | } else { |
||
66 | $scope.saving = false; |
||
67 | $scope.inValidPassword = true; |
||
68 | } |
||
69 | $scope.$apply(); |
||
70 | }); |
||
71 | |||
72 | }; |
||
73 | $scope.showResetPassword = function () { |
||
74 | $scope.resetPassword = true; |
||
75 | }; |
||
76 | |||
77 | $scope.resetExtension = function () { |
||
78 | $scope.confirmReset = true; |
||
79 | }; |
||
80 | |||
81 | $scope.confirmedResetExtension = function () { |
||
82 | API.runtime.sendMessage(API.runtime.id, {method: 'resetSettings'}).then(function () { |
||
83 | setTimeout(function () { |
||
84 | window.close(); |
||
85 | }, 500); |
||
86 | }); |
||
87 | }; |
||
88 | |||
89 | }]); |
||
90 | }()); |
||
91 | |||
92 |