Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js index 089e3d4..78e8c9b 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js | |||
@@ -1,70 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); | 24 | Clipperz.Base.module('Clipperz.PM.UI.Common.Components'); |
27 | 25 | ||
28 | Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay = function(anElement, args) { | 26 | Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay = function(anElement, args) { |
29 | args = args || {}; | 27 | args = args || {}; |
30 | 28 | ||
31 | //MochiKit.Logging.logDebug(">>> new TextFormField"); | ||
32 | Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay.superclass.constructor.call(this, anElement, args); | 29 | Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay.superclass.constructor.call(this, anElement, args); |
33 | 30 | ||
34 | this._wrapperElement = null; | 31 | this._wrapperElement = null; |
35 | this._entropyElement = null; | 32 | this._entropyElement = null; |
36 | 33 | ||
37 | this.render(); | 34 | this.render(); |
38 | //MochiKit.Logging.logDebug("<<< new TextFormField"); | ||
39 | 35 | ||
40 | return this; | 36 | return this; |
41 | }; | 37 | }; |
42 | 38 | ||
43 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay, Clipperz.PM.UI.Common.Components.BaseComponent, { | 39 | Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay, Clipperz.PM.UI.Common.Components.BaseComponent, { |
44 | 40 | ||
45 | 'toString': function() { | 41 | 'toString': function() { |
46 | return "Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay"; | 42 | return "Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay"; |
47 | }, | 43 | }, |
48 | 44 | ||
49 | //----------------------------------------------------- | 45 | //----------------------------------------------------- |
50 | 46 | ||
51 | 'wrapperElement': function() { | 47 | 'wrapperElement': function() { |
52 | return this._wrapperElement; | 48 | return this._wrapperElement; |
53 | }, | 49 | }, |
54 | 50 | ||
55 | 'setWrapperElement': function(aValue) { | 51 | 'setWrapperElement': function(aValue) { |
56 | this._wrapperElement = aValue; | 52 | this._wrapperElement = aValue; |
57 | }, | 53 | }, |
58 | 54 | ||
59 | //----------------------------------------------------- | 55 | //----------------------------------------------------- |
60 | 56 | ||
61 | 'passwordElement': function() { | 57 | 'passwordElement': function() { |
62 | return this.element(); | 58 | return this.element(); |
63 | }, | 59 | }, |
64 | 60 | ||
65 | //----------------------------------------------------- | 61 | //----------------------------------------------------- |
66 | 62 | ||
67 | 'entropyElement': function() { | 63 | 'entropyElement': function() { |
68 | return this._entropyElement; | 64 | return this._entropyElement; |
69 | }, | 65 | }, |
70 | 66 | ||
@@ -81,57 +77,46 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.PasswordEntropyDisplay, Cl | |||
81 | this.setWrapperElement(this.element().wrap({tag:'div'})); | 77 | this.setWrapperElement(this.element().wrap({tag:'div'})); |
82 | this.setEntropyElement(Clipperz.DOM.Helper.append(this.wrapperElement().dom, {tag:'div', cls:'passwordEntropy', html:" "}, true)); | 78 | this.setEntropyElement(Clipperz.DOM.Helper.append(this.wrapperElement().dom, {tag:'div', cls:'passwordEntropy', html:" "}, true)); |
83 | // this.setEntropyElement(Clipperz.DOM.Helper.insertBefore(this.element(), {tag:'div', cls:'passwordEntropy', html:" "}, true)); | 79 | // this.setEntropyElement(Clipperz.DOM.Helper.insertBefore(this.element(), {tag:'div', cls:'passwordEntropy', html:" "}, true)); |
84 | this.entropyElement().wrap({tag:'div', cls:'passwordEntropyWrapper'}); | 80 | this.entropyElement().wrap({tag:'div', cls:'passwordEntropyWrapper'}); |
85 | 81 | ||
86 | this.updateEntropyElement(); | 82 | this.updateEntropyElement(); |
87 | 83 | ||
88 | this.connect('onkeyup', 'updateEntropyElement'); | 84 | this.connect('onkeyup', 'updateEntropyElement'); |
89 | this.connect('onchange', 'updateEntropyElement'); | 85 | this.connect('onchange', 'updateEntropyElement'); |
90 | this.connect('onblur', 'updateEntropyElement'); | 86 | this.connect('onblur', 'updateEntropyElement'); |
91 | */ | 87 | */ |
92 | MochiKit.Signal.disconnectAllTo(this); | 88 | MochiKit.Signal.disconnectAllTo(this); |
93 | 89 | ||
94 | this.setEntropyElement(this.element()); | 90 | this.setEntropyElement(this.element()); |
95 | this.entropyElement().addClass("entropyLevelIndicator"); | 91 | this.entropyElement().addClass("entropyLevelIndicator"); |
96 | 92 | ||
97 | this.updateEntropyElement(); | 93 | this.updateEntropyElement(); |
98 | 94 | ||
99 | this.connect('onkeyup', 'updateEntropyElement'); | 95 | this.connect('onkeyup', 'updateEntropyElement'); |
100 | this.connect('onchange', 'updateEntropyElement'); | 96 | this.connect('onchange', 'updateEntropyElement'); |
101 | this.connect('onblur', 'updateEntropyElement'); | 97 | this.connect('onblur', 'updateEntropyElement'); |
102 | }, | 98 | }, |
103 | 99 | ||
104 | //----------------------------------------------------- | 100 | //----------------------------------------------------- |
105 | 101 | ||
106 | 'computeEntropyForString': function(aValue) { | 102 | 'computeEntropyForString': function(aValue) { |
107 | return Clipperz.PM.Crypto.passwordEntropy(aValue); | 103 | return Clipperz.PM.Crypto.passwordEntropy(aValue); |
108 | }, | 104 | }, |
109 | 105 | ||
110 | //----------------------------------------------------- | 106 | //----------------------------------------------------- |
111 | 107 | ||
112 | 'updateEntropyElement': function(anEvent) { | 108 | 'updateEntropyElement': function(anEvent) { |
113 | /* | ||
114 | //MochiKit.Logging.logDebug(">>> PasswordEntropyDisplay.updateEntropyElement"); | ||
115 | varmaxExtent; | ||
116 | varentropy; | ||
117 | |||
118 | entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); | ||
119 | //MochiKit.Logging.logDebug("--- PasswordEntropyDisplay.updateEntropyElement - entropy: " + entropy); | ||
120 | this.entropyElement().setStyle('background-position', "0px " + -entropy + "px"); | ||
121 | this.entropyElement().setWidth(this.passwordElement().getWidth() * (entropy/128)); | ||
122 | //MochiKit.Logging.logDebug("<<< PasswordEntropyDisplay.updateEntropyElement"); | ||
123 | */ | ||
124 | varentropy; | 109 | varentropy; |
125 | 110 | ||
126 | entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); | 111 | entropy = Math.min(128, this.computeEntropyForString(this.passwordElement().dom.value)); |
127 | 112 | ||
128 | if (entropy == 0) { | 113 | if (entropy == 0) { |
129 | this.entropyElement().setStyle('background-position', "0px 26px"); | 114 | this.entropyElement().setStyle('background-position', "0px 26px"); |
130 | } else { | 115 | } else { |
131 | this.entropyElement().setStyle('background-position', "0px -" + (128-entropy)*26 + "px"); | 116 | this.entropyElement().setStyle('background-position', "0px -" + (128-entropy)*26 + "px"); |
132 | } | 117 | } |
133 | }, | 118 | }, |
134 | 119 | ||
135 | //----------------------------------------------------- | 120 | //----------------------------------------------------- |
136 | __syntaxFix__: '__syntaxFix__' | 121 | __syntaxFix__: '__syntaxFix__' |
137 | }); | 122 | }); |