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