Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js b/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js index 7b0b12b..1e94c4b 100644 --- a/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js +++ b/frontend/beta/js/Clipperz/PM/Components/OTP/MainComponent.js | |||
@@ -1,150 +1,148 @@ | |||
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 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | 26 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } |
29 | if (typeof(Clipperz.PM.Components.OTP) == 'undefined') { Clipperz.PM.Components.OTP = {}; } | 27 | if (typeof(Clipperz.PM.Components.OTP) == 'undefined') { Clipperz.PM.Components.OTP = {}; } |
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.Components.OTP.MainComponent = function(anElement, args) { | 31 | Clipperz.PM.Components.OTP.MainComponent = function(anElement, args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | //MochiKit.Logging.logDebug("new OTP.MainComponent"); | 34 | //MochiKit.Logging.logDebug("new OTP.MainComponent"); |
37 | Clipperz.PM.Components.OTP.MainComponent.superclass.constructor.call(this, anElement, args); | 35 | Clipperz.PM.Components.OTP.MainComponent.superclass.constructor.call(this, anElement, args); |
38 | 36 | ||
39 | this._user = args.user; | 37 | this._user = args.user; |
40 | this._shouldRender = true; | 38 | this._shouldRender = true; |
41 | 39 | ||
42 | this._deleteButton = null; | 40 | this._deleteButton = null; |
43 | this._printButton = null; | 41 | this._printButton = null; |
44 | 42 | ||
45 | Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler'); | 43 | Clipperz.NotificationCenter.register(null, 'tabSelected', this, 'tabSelectedHandler'); |
46 | //Clipperz.NotificationCenter.register(null, 'oneTimePasswordAdded', this, 'render'); | 44 | //Clipperz.NotificationCenter.register(null, 'oneTimePasswordAdded', this, 'render'); |
47 | 45 | ||
48 | return this; | 46 | return this; |
49 | } | 47 | } |
50 | 48 | ||
51 | //============================================================================= | 49 | //============================================================================= |
52 | 50 | ||
53 | YAHOO.extendX(Clipperz.PM.Components.OTP.MainComponent, Clipperz.PM.Components.BaseComponent, { | 51 | YAHOO.extendX(Clipperz.PM.Components.OTP.MainComponent, Clipperz.PM.Components.BaseComponent, { |
54 | 52 | ||
55 | 'toString': function() { | 53 | 'toString': function() { |
56 | return "Clipperz.PM.Components.OTP.MainComponent component"; | 54 | return "Clipperz.PM.Components.OTP.MainComponent component"; |
57 | }, | 55 | }, |
58 | 56 | ||
59 | //------------------------------------------------------------------------- | 57 | //------------------------------------------------------------------------- |
60 | 58 | ||
61 | 'render': function() { | 59 | 'render': function() { |
62 | //MochiKit.Logging.logDebug("### OTP.MainComponent.render"); | 60 | //MochiKit.Logging.logDebug("### OTP.MainComponent.render"); |
63 | Clipperz.NotificationCenter.unregister(this); | 61 | Clipperz.NotificationCenter.unregister(this); |
64 | MochiKit.Signal.disconnectAllTo(this); | 62 | MochiKit.Signal.disconnectAllTo(this); |
65 | 63 | ||
66 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { | 64 | if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { |
67 | this.element().update(""); | 65 | this.element().update(""); |
68 | this.domHelper().append(this.element(), {tag:'div', cls:'oneTimePasswordReadOnlyMessage', htmlString:Clipperz.PM.Strings['oneTimePasswordReadOnlyMessage']}); | 66 | this.domHelper().append(this.element(), {tag:'div', cls:'oneTimePasswordReadOnlyMessage', htmlString:Clipperz.PM.Strings['oneTimePasswordReadOnlyMessage']}); |
69 | } else { | 67 | } else { |
70 | var deferredResult; | 68 | var deferredResult; |
71 | 69 | ||
72 | deferredResult = new MochiKit.Async.Deferred(); | 70 | deferredResult = new MochiKit.Async.Deferred(); |
73 | 71 | ||
74 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 1: " + res); return res;}); | 72 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 1: " + res); return res;}); |
75 | deferredResult.addCallback(MochiKit.Base.bind(function() { | 73 | deferredResult.addCallback(MochiKit.Base.bind(function() { |
76 | this.element().update(""); | 74 | this.element().update(""); |
77 | Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', htmlString:Clipperz.PM.Strings['oneTimePasswordLoadingMessage']}); | 75 | Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', htmlString:Clipperz.PM.Strings['oneTimePasswordLoadingMessage']}); |
78 | }, this)); | 76 | }, this)); |
79 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 2: " + res); return res;}); | 77 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 2: " + res); return res;}); |
80 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'loadOneTimePasswords')); | 78 | deferredResult.addCallback(MochiKit.Base.method(this.user(), 'loadOneTimePasswords')); |
81 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3: " + res); return res;}); | 79 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3: " + res); return res;}); |
82 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3.1: " + Clipperz.Base.serializeJSON(res.serializedData())); return res;}); | 80 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("OTP.MainComponent.render - 3.1: " + Clipperz.Base.serializeJSON(res.serializedData())); return res;}); |
83 | deferredResult.addCallback(MochiKit.Base.bind(function(aResult) { | 81 | deferredResult.addCallback(MochiKit.Base.bind(function(aResult) { |
84 | vartbodyElement; | 82 | vartbodyElement; |
85 | varoneTimePasswordReferenceKeys; | 83 | varoneTimePasswordReferenceKeys; |
86 | var imageExtension; | 84 | var imageExtension; |
87 | var isThereAnyActiveOneTimePassword; | 85 | var isThereAnyActiveOneTimePassword; |
88 | 86 | ||
89 | isThereAnyActiveOneTimePassword = false; | 87 | isThereAnyActiveOneTimePassword = false; |
90 | 88 | ||
91 | this.element().update(""); | 89 | this.element().update(""); |
92 | Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', id:'oneTimePasswordList', children:[ | 90 | Clipperz.YUI.DomHelper.append(this.element(), {tag:'div', id:'oneTimePasswordList', children:[ |
93 | {tag:'div', id:'oneTimePasswords_header', children:[ | 91 | {tag:'div', id:'oneTimePasswords_header', children:[ |
94 | {tag:'table', width:'100%', children:[ | 92 | {tag:'table', width:'100%', children:[ |
95 | {tag:'tbody', children:[ | 93 | {tag:'tbody', children:[ |
96 | {tag:'tr', children:[ | 94 | {tag:'tr', children:[ |
97 | {tag:'td', width:'10%', children:[ | 95 | {tag:'td', width:'10%', children:[ |
98 | {tag:'div', id:this.getId('createNewOneTimePasswordButton')} | 96 | {tag:'div', id:this.getId('createNewOneTimePasswordButton')} |
99 | ]}, | 97 | ]}, |
100 | {tag:'td', width:'40%', children:[ | 98 | {tag:'td', width:'40%', children:[ |
101 | {tag:'div', id:this.getId('deleteSelectedOneTimePasswordButton')} | 99 | {tag:'div', id:this.getId('deleteSelectedOneTimePasswordButton')} |
102 | ]}, | 100 | ]}, |
103 | {tag:'td', width:'50%', align:'right', children:[ | 101 | {tag:'td', width:'50%', align:'right', children:[ |
104 | {tag:'div', id:this.getId('printOneTimePasswordButton')} | 102 | {tag:'div', id:this.getId('printOneTimePasswordButton')} |
105 | ]} | 103 | ]} |
106 | ]} | 104 | ]} |
107 | ]} | 105 | ]} |
108 | ]}, | 106 | ]}, |
109 | {tag:'div', children:[ | 107 | {tag:'div', children:[ |
110 | {tag:'ul', children:[ | 108 | {tag:'ul', children:[ |
111 | {tag:'li', children:[ | 109 | {tag:'li', children:[ |
112 | {tag:'span', htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_selectLabel']} | 110 | {tag:'span', htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_selectLabel']} |
113 | ]}, | 111 | ]}, |
114 | {tag:'li', children:[ | 112 | {tag:'li', children:[ |
115 | {tag:'a', href:'#', id:this.getId('selectAllOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_all']} | 113 | {tag:'a', href:'#', id:this.getId('selectAllOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_all']} |
116 | ]}, | 114 | ]}, |
117 | {tag:'li', children:[ | 115 | {tag:'li', children:[ |
118 | {tag:'a', href:'#', id:this.getId('selectNoneOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_none']} | 116 | {tag:'a', href:'#', id:this.getId('selectNoneOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_none']} |
119 | ]}, | 117 | ]}, |
120 | {tag:'li', children:[ | 118 | {tag:'li', children:[ |
121 | {tag:'a', href:'#', id:this.getId('selectUsedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_used']} | 119 | {tag:'a', href:'#', id:this.getId('selectUsedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_used']} |
122 | ]}, | 120 | ]}, |
123 | {tag:'li', children:[ | 121 | {tag:'li', children:[ |
124 | {tag:'a', href:'#', id:this.getId('selectUnusedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_unused']} | 122 | {tag:'a', href:'#', id:this.getId('selectUnusedOneTimePasswords_link'), htmlString:Clipperz.PM.Strings['oneTimePasswordSelectionLink_unused']} |
125 | ]} | 123 | ]} |
126 | ]} | 124 | ]} |
127 | ]} | 125 | ]} |
128 | ]}, | 126 | ]}, |
129 | {tag:'form', id:this.getId('oneTimePasswords_form'), children:[ | 127 | {tag:'form', id:this.getId('oneTimePasswords_form'), children:[ |
130 | {tag:'table', cls:'oneTimePassword', cellspacing:'0', cellpadding:'2', children:[ | 128 | {tag:'table', cls:'oneTimePassword', cellspacing:'0', cellpadding:'2', children:[ |
131 | {tag:'tbody', id:this.getId('oneTimePasswords_tbody'), children:[ | 129 | {tag:'tbody', id:this.getId('oneTimePasswords_tbody'), children:[ |
132 | ]} | 130 | ]} |
133 | ]} | 131 | ]} |
134 | ]} | 132 | ]} |
135 | ]}); | 133 | ]}); |
136 | 134 | ||
137 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | 135 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; |
138 | 136 | ||
139 | tbodyElement = this.getElement('oneTimePasswords_tbody'); | 137 | tbodyElement = this.getElement('oneTimePasswords_tbody'); |
140 | oneTimePasswordReferenceKeys = MochiKit.Base.keys(this.user().oneTimePasswordManager().oneTimePasswords()).reverse(); | 138 | oneTimePasswordReferenceKeys = MochiKit.Base.keys(this.user().oneTimePasswordManager().oneTimePasswords()).reverse(); |
141 | c = oneTimePasswordReferenceKeys.length; | 139 | c = oneTimePasswordReferenceKeys.length; |
142 | if (c>0) { | 140 | if (c>0) { |
143 | for (i=0; i<c; i++) { | 141 | for (i=0; i<c; i++) { |
144 | var otpReference; | 142 | var otpReference; |
145 | var currentOTP; | 143 | var currentOTP; |
146 | var loginSessionInfoConfig; | 144 | var loginSessionInfoConfig; |
147 | 145 | ||
148 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; | 146 | imageExtension = (Clipperz_IEisBroken == true) ? 'gif': 'png'; |
149 | 147 | ||
150 | otpReference = oneTimePasswordReferenceKeys[i]; | 148 | otpReference = oneTimePasswordReferenceKeys[i]; |