Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js index 8188389..d9995fc 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLoginInput.js | |||
@@ -1,200 +1,192 @@ | |||
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 | Clipperz.PM.DataModel.DirectLoginInput = function(args) { | 30 | Clipperz.PM.DataModel.DirectLoginInput = function(args) { |
33 | this._args = args; | 31 | this._args = args; |
34 | 32 | ||
35 | return this; | 33 | return this; |
36 | } | 34 | } |
37 | 35 | ||
38 | Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, { | 36 | Clipperz.PM.DataModel.DirectLoginInput.prototype = MochiKit.Base.update(null, { |
39 | 37 | ||
40 | 'args': function() { | 38 | 'args': function() { |
41 | return this._args; | 39 | return this._args; |
42 | }, | 40 | }, |
43 | 41 | ||
44 | //------------------------------------------------------------------------- | 42 | //------------------------------------------------------------------------- |
45 | 43 | ||
46 | 'name': function() { | 44 | 'name': function() { |
47 | return this.args()['name']; | 45 | return this.args()['name']; |
48 | }, | 46 | }, |
49 | 47 | ||
50 | //------------------------------------------------------------------------- | 48 | //------------------------------------------------------------------------- |
51 | 49 | ||
52 | 'type': function() { | 50 | 'type': function() { |
53 | var result; | 51 | var result; |
54 | 52 | ||
55 | result = this.args()['type']; | 53 | result = this.args()['type']; |
56 | 54 | ||
57 | if (result != null) { | 55 | if (result != null) { |
58 | result = result.toLowerCase(); | 56 | result = result.toLowerCase(); |
59 | } | 57 | } |
60 | return result; | 58 | return result; |
61 | }, | 59 | }, |
62 | 60 | ||
63 | //------------------------------------------------------------------------- | 61 | //------------------------------------------------------------------------- |
64 | 62 | ||
65 | 'options': function() { | 63 | 'options': function() { |
66 | return this.args()['options']; | 64 | return this.args()['options']; |
67 | }, | 65 | }, |
68 | 66 | ||
69 | //------------------------------------------------------------------------- | 67 | //------------------------------------------------------------------------- |
70 | 68 | ||
71 | 'value': function() { | 69 | 'value': function() { |
72 | return this.args()['value']; | 70 | return this.args()['value']; |
73 | }, | 71 | }, |
74 | 72 | ||
75 | //------------------------------------------------------------------------- | 73 | //------------------------------------------------------------------------- |
76 | /* | 74 | /* |
77 | 'formConfiguration': function(someFormValues, someBindings, someFields) { | 75 | 'formConfiguration': function(someFormValues, someBindings, someFields) { |
78 | var result; | 76 | var result; |
79 | //console.log("### DirectLoginInput.formConfiguration", someFields); | 77 | |
80 | if (this.shouldSetValue()) { | 78 | if (this.shouldSetValue()) { |
81 | switch (this.type()) { | 79 | switch (this.type()) { |
82 | case 'select': | 80 | case 'select': |
83 | var currentValue; | 81 | var currentValue; |
84 | var options; | 82 | var options; |
85 | 83 | ||
86 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; | 84 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; |
87 | currentValue = someFormValues[this.name()]; | 85 | currentValue = someFormValues[this.name()]; |
88 | options = this.args()['options']; | 86 | options = this.args()['options']; |
89 | 87 | ||
90 | result = MochiKit.DOM.SELECT({name:this.name()}, | 88 | result = MochiKit.DOM.SELECT({name:this.name()}, |
91 | MochiKit.Base.map(function(anOption) { | 89 | MochiKit.Base.map(function(anOption) { |
92 | var options; | 90 | var options; |
93 | 91 | ||
94 | options = {value:anOption['value']}; | 92 | options = {value:anOption['value']}; |
95 | if (currentValue == anOption['value']) { | 93 | if (currentValue == anOption['value']) { |
96 | options.selected = true; | 94 | options.selected = true; |
97 | } | 95 | } |
98 | 96 | ||
99 | return MochiKit.DOM.OPTION(options, anOption['label']) | 97 | return MochiKit.DOM.OPTION(options, anOption['label']) |
100 | }, options) | 98 | }, options) |
101 | ) | 99 | ) |
102 | break; | 100 | break; |
103 | case 'checkbox': | 101 | case 'checkbox': |
104 | var options; | 102 | var options; |
105 | 103 | ||
106 | options = {type:'checkbox', name: this.name()}; | 104 | options = {type:'checkbox', name: this.name()}; |
107 | // if (this.directLogin()._configuration['formValues'][this.name()] == true) { | 105 | // if (this.directLogin()._configuration['formValues'][this.name()] == true) { |
108 | if (someFormValues[this.name()] == true) { | 106 | if (someFormValues[this.name()] == true) { |
109 | options['checked'] = true; | 107 | options['checked'] = true; |
110 | }; | 108 | }; |
111 | 109 | ||
112 | result = MochiKit.DOM.INPUT(options, null); | 110 | result = MochiKit.DOM.INPUT(options, null); |
113 | break; | 111 | break; |
114 | case 'radio': | 112 | case 'radio': |
115 | var currentName; | 113 | var currentName; |
116 | var currentValue; | 114 | var currentValue; |
117 | var options; | 115 | var options; |
118 | 116 | ||
119 | currentName = this.name(); | 117 | currentName = this.name(); |
120 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; | 118 | // currentValue = this.directLogin()._configuration['formValues'][this.name()]; |
121 | currentValue = someFormValues[this.name()]; | 119 | currentValue = someFormValues[this.name()]; |
122 | options = this.args()['options']; | 120 | options = this.args()['options']; |
123 | 121 | ||
124 | result = MochiKit.DOM.DIV(null, | 122 | result = MochiKit.DOM.DIV(null, |
125 | MochiKit.Base.map(function(anOption) { | 123 | MochiKit.Base.map(function(anOption) { |
126 | var options; | 124 | var options; |
127 | var isChecked; | 125 | var isChecked; |
128 | var inputNode; | 126 | var inputNode; |
129 | var divNode; | 127 | var divNode; |
130 | 128 | ||
131 | options = {type:'radio', name:currentName, value:anOption['value']} | 129 | options = {type:'radio', name:currentName, value:anOption['value']} |
132 | isChecked = (currentValue == anOption['value']); | 130 | isChecked = (currentValue == anOption['value']); |
133 | if (isChecked) { | 131 | if (isChecked) { |
134 | options.checked = true; | 132 | options.checked = true; |
135 | } | 133 | } |
136 | 134 | ||
137 | if (Clipperz_IEisBroken == true) { | 135 | if (Clipperz_IEisBroken == true) { |
138 | var checkedValue; | 136 | var checkedValue; |
139 | 137 | ||
140 | checkedValue = (isChecked ? " CHECKED" : ""); | 138 | checkedValue = (isChecked ? " CHECKED" : ""); |
141 | inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">"); | 139 | inputNode = MochiKit.DOM.currentDocument().createElement("<INPUT TYPE='RADIO' NAME='" + currentName + "' VALUE='" + anOption['value'] + "'" + checkedValue + ">"); |
142 | } else { | 140 | } else { |
143 | inputNode = MochiKit.DOM.INPUT(options, anOption['value']); | 141 | inputNode = MochiKit.DOM.INPUT(options, anOption['value']); |
144 | } | 142 | } |
145 | divNode = MochiKit.DOM.DIV(null, inputNode); | 143 | divNode = MochiKit.DOM.DIV(null, inputNode); |
146 | 144 | ||
147 | return divNode; | 145 | return divNode; |
148 | }, options) | 146 | }, options) |
149 | ); | 147 | ); |
150 | break; | 148 | break; |
151 | } | 149 | } |
152 | } else { | 150 | } else { |
153 | var binding; | 151 | var binding; |
154 | // binding = this.directLogin().bindings()[this.name()]; | 152 | // binding = this.directLogin().bindings()[this.name()]; |
155 | binding = someBindings[this.name()]; | 153 | binding = someBindings[this.name()]; |
156 | 154 | ||
157 | //console.log("### binding", binding); | ||
158 | //if (binding != null) { | ||
159 | ///console.log(" binding.field()", binding.field()); | ||
160 | ///console.log(" binding.field().value()", binding.field().value()); | ||
161 | //console.log(" someFields[binding.fieldKey()].value()", someFields[binding.fieldKey()].value()); | ||
162 | //} | ||
163 | result = MochiKit.DOM.INPUT({ | 155 | result = MochiKit.DOM.INPUT({ |
164 | type:((this.type() != 'password') ? this.type() : 'text'), | 156 | type:((this.type() != 'password') ? this.type() : 'text'), |
165 | name:this.name(), | 157 | name:this.name(), |
166 | // value:((binding != null)? binding.field().value() : this.value()) | 158 | // value:((binding != null)? binding.field().value() : this.value()) |
167 | value:((binding != null)? someFields[binding.fieldKey()]['value'] : this.value()) | 159 | value:((binding != null)? someFields[binding.fieldKey()]['value'] : this.value()) |
168 | // value:((binding != null)? someFields[binding.fieldKey()].value() : this.value()) | 160 | // value:((binding != null)? someFields[binding.fieldKey()].value() : this.value()) |
169 | }, null); | 161 | }, null); |
170 | } | 162 | } |
171 | 163 | ||
172 | return result; | 164 | return result; |
173 | }, | 165 | }, |
174 | */ | 166 | */ |
175 | //------------------------------------------------------------------------- | 167 | //------------------------------------------------------------------------- |
176 | 168 | ||
177 | 'needsFormValue': function() { | 169 | 'needsFormValue': function() { |
178 | var type; | 170 | var type; |
179 | var result; | 171 | var result; |
180 | 172 | ||
181 | type = this.type(); | 173 | type = this.type(); |
182 | result = ((type == 'checkbox') || (type == 'radio') || (type == 'select')); | 174 | result = ((type == 'checkbox') || (type == 'radio') || (type == 'select')); |
183 | 175 | ||
184 | return result; | 176 | return result; |
185 | }, | 177 | }, |
186 | 178 | ||
187 | 'needsBinding': function() { | 179 | 'needsBinding': function() { |
188 | var type; | 180 | var type; |
189 | var result; | 181 | var result; |
190 | 182 | ||
191 | type = this.type(); | 183 | type = this.type(); |
192 | result = ((type == 'text') || (type == 'password')); | 184 | result = ((type == 'text') || (type == 'password')); |
193 | 185 | ||
194 | return result; | 186 | return result; |
195 | }, | 187 | }, |
196 | 188 | ||
197 | //------------------------------------------------------------------------- | 189 | //------------------------------------------------------------------------- |
198 | __syntaxFix__: "syntax fix" | 190 | __syntaxFix__: "syntax fix" |
199 | }); | 191 | }); |
200 | 192 | ||