Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js b/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js index 2be7d58..236d7c9 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/DirectLoginReference.js | |||
@@ -1,189 +1,187 @@ | |||
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.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } | 26 | if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } |
29 | 27 | ||
30 | 28 | ||
31 | //############################################################################# | 29 | //############################################################################# |
32 | 30 | ||
33 | Clipperz.PM.DataModel.DirectLoginReference = function(args) { | 31 | Clipperz.PM.DataModel.DirectLoginReference = function(args) { |
34 | args = args || {}; | 32 | args = args || {}; |
35 | 33 | ||
36 | //MochiKit.Logging.logDebug(">>> new DirectLoginReference: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(args))); | 34 | //MochiKit.Logging.logDebug(">>> new DirectLoginReference: " + Clipperz.Base.serializeJSON(MochiKit.Base.keys(args))); |
37 | //MochiKit.Logging.logDebug(">>> new DirectLoginReference - record: " + args.record); | 35 | //MochiKit.Logging.logDebug(">>> new DirectLoginReference - record: " + args.record); |
38 | this._user = args.user; | 36 | this._user = args.user; |
39 | 37 | ||
40 | if (args.directLogin != null) { | 38 | if (args.directLogin != null) { |
41 | this._reference = args.directLogin.reference(); | 39 | this._reference = args.directLogin.reference(); |
42 | this._recordReference = args.directLogin.record().reference(); | 40 | this._recordReference = args.directLogin.record().reference(); |
43 | this._label = args.directLogin.label(); | 41 | this._label = args.directLogin.label(); |
44 | this._favicon = args.directLogin.favicon() || null; | 42 | this._favicon = args.directLogin.favicon() || null; |
45 | 43 | ||
46 | this._directLogin = args.directLogin; | 44 | this._directLogin = args.directLogin; |
47 | this._record = args.directLogin.record(); | 45 | this._record = args.directLogin.record(); |
48 | } else { | 46 | } else { |
49 | this._reference = args.reference; | 47 | this._reference = args.reference; |
50 | this._recordReference = args.record; | 48 | this._recordReference = args.record; |
51 | this._label = args.label; | 49 | this._label = args.label; |
52 | this._favicon = args.favicon || null; | 50 | this._favicon = args.favicon || null; |
53 | 51 | ||
54 | this._directLogin = null; | 52 | this._directLogin = null; |
55 | this._record = null; | 53 | this._record = null; |
56 | } | 54 | } |
57 | 55 | ||
58 | this._fixedFavicon = null; | 56 | this._fixedFavicon = null; |
59 | 57 | ||
60 | return this; | 58 | return this; |
61 | } | 59 | } |
62 | 60 | ||
63 | Clipperz.PM.DataModel.DirectLoginReference.prototype = MochiKit.Base.update(null, { | 61 | Clipperz.PM.DataModel.DirectLoginReference.prototype = MochiKit.Base.update(null, { |
64 | 62 | ||
65 | 'user': function() { | 63 | 'user': function() { |
66 | return this._user; | 64 | return this._user; |
67 | }, | 65 | }, |
68 | 66 | ||
69 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
70 | 68 | ||
71 | 'reference': function() { | 69 | 'reference': function() { |
72 | return this._reference; | 70 | return this._reference; |
73 | }, | 71 | }, |
74 | 72 | ||
75 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
76 | 74 | ||
77 | 'synchronizeValues': function(aDirectLogin) { | 75 | 'synchronizeValues': function(aDirectLogin) { |
78 | this._label = aDirectLogin.label(); | 76 | this._label = aDirectLogin.label(); |
79 | this._favicon = aDirectLogin.favicon(); | 77 | this._favicon = aDirectLogin.favicon(); |
80 | }, | 78 | }, |
81 | 79 | ||
82 | //------------------------------------------------------------------------- | 80 | //------------------------------------------------------------------------- |
83 | 81 | ||
84 | 'label': function() { | 82 | 'label': function() { |
85 | return this._label; | 83 | return this._label; |
86 | }, | 84 | }, |
87 | 85 | ||
88 | //------------------------------------------------------------------------- | 86 | //------------------------------------------------------------------------- |
89 | 87 | ||
90 | 'recordReference': function() { | 88 | 'recordReference': function() { |
91 | return this._recordReference; | 89 | return this._recordReference; |
92 | }, | 90 | }, |
93 | 91 | ||
94 | //------------------------------------------------------------------------- | 92 | //------------------------------------------------------------------------- |
95 | 93 | ||
96 | 'record': function() { | 94 | 'record': function() { |
97 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.record"); | 95 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.record"); |
98 | if (this._record == null) { | 96 | if (this._record == null) { |
99 | this._record = this.user().records()[this.recordReference()]; | 97 | this._record = this.user().records()[this.recordReference()]; |
100 | } | 98 | } |
101 | 99 | ||
102 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.record"); | 100 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.record"); |
103 | return this._record; | 101 | return this._record; |
104 | }, | 102 | }, |
105 | 103 | ||
106 | //------------------------------------------------------------------------- | 104 | //------------------------------------------------------------------------- |
107 | 105 | ||
108 | 'favicon': function() { | 106 | 'favicon': function() { |
109 | return this._favicon; | 107 | return this._favicon; |
110 | }, | 108 | }, |
111 | 109 | ||
112 | //------------------------------------------------------------------------- | 110 | //------------------------------------------------------------------------- |
113 | 111 | ||
114 | 'fixedFavicon': function() { | 112 | 'fixedFavicon': function() { |
115 | var result; | 113 | var result; |
116 | 114 | ||
117 | if (this._fixedFavicon == null) { | 115 | if (this._fixedFavicon == null) { |
118 | result = this.favicon(); | 116 | result = this.favicon(); |
119 | 117 | ||
120 | if (Clipperz_IEisBroken && (this.user().preferences().disableUnsecureFaviconLoadingForIE()) && (result.indexOf('https://') != 0)) { | 118 | if (Clipperz_IEisBroken && (this.user().preferences().disableUnsecureFaviconLoadingForIE()) && (result.indexOf('https://') != 0)) { |
121 | result = Clipperz.PM.Strings['defaultFaviconUrl_IE']; | 119 | result = Clipperz.PM.Strings['defaultFaviconUrl_IE']; |
122 | this.setFixedFavicon(result); | 120 | this.setFixedFavicon(result); |
123 | } | 121 | } |
124 | } else { | 122 | } else { |
125 | result = this._fixedFavicon; | 123 | result = this._fixedFavicon; |
126 | } | 124 | } |
127 | 125 | ||
128 | return result; | 126 | return result; |
129 | }, | 127 | }, |
130 | 128 | ||
131 | 'setFixedFavicon': function(aValue) { | 129 | 'setFixedFavicon': function(aValue) { |
132 | this._fixedFavicon = aValue; | 130 | this._fixedFavicon = aValue; |
133 | }, | 131 | }, |
134 | 132 | ||
135 | //------------------------------------------------------------------------- | 133 | //------------------------------------------------------------------------- |
136 | 134 | ||
137 | 'setupJumpPageWindow': function(aWindow) { | 135 | 'setupJumpPageWindow': function(aWindow) { |
138 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.setupJumpPageWindow - " + aWindow); | 136 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.setupJumpPageWindow - " + aWindow); |
139 | try { | 137 | try { |
140 | MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() { | 138 | MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function() { |
141 | MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, | 139 | MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, |
142 | MochiKit.DOM.H1(null, "Loading " + this.label()) | 140 | MochiKit.DOM.H1(null, "Loading " + this.label()) |
143 | ); | 141 | ); |
144 | }, this)); | 142 | }, this)); |
145 | } catch(e) { | 143 | } catch(e) { |
146 | MochiKit.Logging.logDebug("EXCEPTION: " + e); | 144 | MochiKit.Logging.logDebug("EXCEPTION: " + e); |
147 | } | 145 | } |
148 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.setupJumpPageWindow"); | 146 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.setupJumpPageWindow"); |
149 | }, | 147 | }, |
150 | 148 | ||
151 | //------------------------------------------------------------------------- | 149 | //------------------------------------------------------------------------- |
152 | 150 | ||
153 | 'deferredDirectLogin': function() { | 151 | 'deferredDirectLogin': function() { |
154 | var deferredResult; | 152 | var deferredResult; |
155 | 153 | ||
156 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.deferredDirectLogin - " + this); | 154 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.deferredDirectLogin - " + this); |
157 | deferredResult = new MochiKit.Async.Deferred(); | 155 | deferredResult = new MochiKit.Async.Deferred(); |
158 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 1"); | 156 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 1"); |
159 | deferredResult.addCallback(MochiKit.Base.method(this.record(), 'deferredData')); | 157 | deferredResult.addCallback(MochiKit.Base.method(this.record(), 'deferredData')); |
160 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 2"); | 158 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 2"); |
161 | deferredResult.addCallback(function(aRecord, aDirectLoginReference) { | 159 | deferredResult.addCallback(function(aRecord, aDirectLoginReference) { |
162 | return aRecord.directLogins()[aDirectLoginReference]; | 160 | return aRecord.directLogins()[aDirectLoginReference]; |
163 | }, this.record(), this.reference()); | 161 | }, this.record(), this.reference()); |
164 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 3"); | 162 | //MochiKit.Logging.logDebug("--- DirectLoginReference.deferredDirectLogin - 3"); |
165 | deferredResult.callback(); | 163 | deferredResult.callback(); |
166 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.deferredDirectLogin"); | 164 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.deferredDirectLogin"); |
167 | 165 | ||
168 | return deferredResult; | 166 | return deferredResult; |
169 | }, | 167 | }, |
170 | 168 | ||
171 | //------------------------------------------------------------------------- | 169 | //------------------------------------------------------------------------- |
172 | 170 | ||
173 | 'handleMissingFaviconImage': function(anEvent) { | 171 | 'handleMissingFaviconImage': function(anEvent) { |
174 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.handleMissingFaviconImage"); | 172 | //MochiKit.Logging.logDebug(">>> DirectLoginReference.handleMissingFaviconImage"); |
175 | anEvent.stop(); | 173 | anEvent.stop(); |
176 | MochiKit.Signal.disconnectAll(anEvent.src()); | 174 | MochiKit.Signal.disconnectAll(anEvent.src()); |
177 | this.setFixedFavicon(Clipperz.PM.Strings['defaultFaviconUrl']); | 175 | this.setFixedFavicon(Clipperz.PM.Strings['defaultFaviconUrl']); |
178 | //MochiKit.Logging.logDebug("--- DirectLoginReference.handleMissingFaviconImage - fixedFavicon: " + this.fixedFavicon()); | 176 | //MochiKit.Logging.logDebug("--- DirectLoginReference.handleMissingFaviconImage - fixedFavicon: " + this.fixedFavicon()); |
179 | //MochiKit.Logging.logDebug("--- DirectLoginReference.handleMissingFaviconImage - anEvent.src().src: " + anEvent.src().src); | 177 | //MochiKit.Logging.logDebug("--- DirectLoginReference.handleMissingFaviconImage - anEvent.src().src: " + anEvent.src().src); |
180 | // MochiKit.DOM.swapDOM(anEvent.src(), MochiKit.DOM.IMG({src:'this.fixedFavicon()'})); | 178 | // MochiKit.DOM.swapDOM(anEvent.src(), MochiKit.DOM.IMG({src:'this.fixedFavicon()'})); |
181 | anEvent.src().src = this.fixedFavicon(); | 179 | anEvent.src().src = this.fixedFavicon(); |
182 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.handleMissingFaviconImage"); | 180 | //MochiKit.Logging.logDebug("<<< DirectLoginReference.handleMissingFaviconImage"); |
183 | }, | 181 | }, |
184 | 182 | ||
185 | //------------------------------------------------------------------------- | 183 | //------------------------------------------------------------------------- |
186 | __syntaxFix__: "syntax fix" | 184 | __syntaxFix__: "syntax fix" |
187 | 185 | ||
188 | }); | 186 | }); |
189 | 187 | ||