summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js315
1 files changed, 315 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js
new file mode 100644
index 0000000..f476ac2
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js
@@ -0,0 +1,315 @@
1/*
2
3Copyright 2008-2011 Clipperz Srl
4
5This file is part of Clipperz's Javascript Crypto Library.
6Javascript Crypto Library provides web developers with an extensive
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please
11refer to http://www.clipperz.com
12
13* Javascript Crypto Library is free software: you can redistribute
14 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
16 3 of the License, or (at your option) any later version.
17
18* Javascript Crypto Library is distributed in the hope that it will
19 be useful, but WITHOUT ANY WARRANTY; without even the implied
20 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 See the GNU Affero General Public License for more details.
22
23* You should have received a copy of the GNU Affero General Public
24 License along with Javascript Crypto Library. If not, see
25 <http://www.gnu.org/licenses/>.
26
27*/
28
29if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
30if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
31if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
32if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; }
33
34//#############################################################################
35
36Clipperz.PM.Components.Import.PasswordPlusImportComponent = function(anElement, args) {
37 args = args || {};
38
39 Clipperz.PM.Components.Import.PasswordPlusImportComponent.superclass.constructor.call(this, anElement, args);
40
41 this.render();
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.PasswordPlusImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.PasswordPlusImportComponent component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'render': function() {
57//MochiKit.Logging.logDebug(">>> Import.PasswordPlusImportComponent.render");
58 this.domHelper().append(this.element(), {tag:'div', cls:'passwordPlusImportWizard', children:[
59 {tag:'h3', htmlString:Clipperz.PM.Strings['PasswordPlus_ImportWizard_Title']},
60 {tag:'div', cls:'importSteps', id:this.getId('importSteps')},
61 {tag:'div', cls:'importStepBlocks', children:[
62 {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[
63 {tag:'div', children:[
64 {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_passwordPlus_description']},
65 {tag:'div', cls:'importOptionsParameters', children:[]},
66 this.textAreaConfig()
67 ]}
68 ]},
69 {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[
70 {tag:'div', children:[
71 {tag:'div', id:this.getId('previewDiv'), html:"preview"}
72 ]}
73 ]},
74 {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[
75 {tag:'div', children:[
76 {tag:'h4', html:"done"}
77 ]}
78 ]}
79 ]},
80 {tag:'div', cls:'importOptionsButtons', children:[
81 {tag:'table', children:[
82 {tag:'tbody', children:[
83 {tag:'tr', children:[
84 {tag:'td', html:'&nbsp;'},
85 {tag:'td', children:[
86 {tag:'div', id:this.getId('backActionButton')}
87 ]},
88 {tag:'td', html:'&nbsp;'},
89 {tag:'td', children:[
90 {tag:'div', id:this.getId('nextActionButton')}
91 ]},
92 {tag:'td', html:'&nbsp;'}
93 ]}
94 ]}
95 ]}
96 ]}
97 ]});
98
99 this.updateSteps();
100
101 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this}));
102 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this}));
103
104 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show()
105 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
106 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
107//MochiKit.Logging.logDebug("<<< Import.PasswordPlusImportComponent.render");
108 },
109
110 //-------------------------------------------------------------------------
111/*
112 'backAction': function() {
113 switch (this.currentStep()) {
114 case 1: //-> 0
115 this.backButton().disable();
116 this.getElement('step_1').hide();
117 this.setCurrentStep(0);
118 this.getElement('step_0').show();
119 break;
120 }
121 },
122*/
123 //-------------------------------------------------------------------------
124
125 'nextAction': function() {
126 switch (this.currentStep()) {
127 case 0: //-> 1
128 this.previewValues();
129 break;
130 case 1: //-> 2
131 this.importValues();
132 break;
133 }
134 },
135
136 //-------------------------------------------------------------------------
137
138 'deferredPreviewValues': function() {
139 var deferredResult;
140
141 // this.setFormValues(MochiKit.DOM.formContents(this.getDom('dataForm')));
142
143 deferredResult = new MochiKit.Async.Deferred();
144 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
145 this.startProcessing();
146
147 return res;
148 }, this));
149 deferredResult.addCallback(MochiKit.Base.method(this, 'processPasswordPlusValues'));
150 deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues'));
151 deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues'));
152 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
153 this.processingDone();
154 this.getElement('step_0').hide();
155 this.getElement('step_1').show();
156 this.backButton().enable();
157
158 return res;
159 }, this));
160 // deferredResult.addErrback(MochiKit.Base.bind(function() {
161 // this.processingAborted();
162 // }, this))
163 deferredResult.callback(this.textAreaContent());
164
165 return deferredResult;
166 },
167
168 //-------------------------------------------------------------------------
169
170 'processPasswordPlusValues': function(someData) {
171 var deferredResult;
172 var csvProcessor;
173
174 csvProcessor = new Clipperz.CSVProcessor({binary:true});
175
176 deferredResult = new MochiKit.Async.Deferred();
177 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
178 deferredResult.addCallback(function(res) {
179 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2)}, res);
180 })
181 deferredResult.addCallback(MochiKit.Base.method(csvProcessor, 'deferredParse'));
182 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData');
183 deferredResult.addCallback(function(res) {
184 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2), step:res.length}, res);
185 })
186 deferredResult.addCallback(MochiKit.Base.bind(function(someCSVValues) {
187 var innerDeferredResult;
188 var records;
189 var i,c;
190
191 innerDeferredResult = new MochiKit.Async.Deferred();
192 records = [];
193
194 c = someCSVValues.length;
195 i=0;
196 i++; //Dataviz Passwords Plus Export, Version,1, Minimum Version To Read,1
197 i++; //Is Template,Title,Category,Field 1 Label,Field 1 Value,Field 1 Hidden,Field 2 Label,Field 2 Value,Field 2 Hidden,Field 3 Label,Field 3 Value,Field 3 Hidden,Field 4 Label,Field 4 Value,Field 4 Hidden,Field 5 Label,Field 5 Value,Field 5 Hidden,Field 6 Label,Field 6 Value,Field 6 Hidden,Field 7 Label,Field 7 Value,Field 7 Hidden,Field 8 Label,Field 8 Value,Field 8 Hidden,Field 9 Label,Field 9 Value,Field 9 Hidden,Field 10 Label,Field 10 Value,Field 10 Hidden,Note
198
199 for( ; i<c; i++) {
200 innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2);
201 innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {});
202 innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) {
203 if (someData[0] == '0') {
204 var record;
205 var recordVersion;
206 var ii, cc;
207
208 record = new Clipperz.PM.DataModel.Record({user:this.user()});
209 if (someData[1] != "") {
210 record.setLabel(someData[1]);
211 } else {
212 record.setLabel("imported record [" + (i+1) + "]");
213 }
214 record.setNotes(someData[33]);
215 recordVersion = record.currentVersion()
216
217 cc = 10;
218 for (ii=0; ii<cc; ii++) {
219 var currentFieldValueIndex;
220 var currentType;
221
222 currentFieldValueIndex = (ii * 3) + 4;
223
224 if (someData[currentFieldValueIndex] != "") {
225 var recordField;
226 var recordFieldType;
227
228 recordFieldType = 'TXT';
229 if (someData[currentFieldValueIndex + 1] == 1) {
230 recordFieldType = 'PWD';
231 } else if (/^http/.test(someData[currentFieldValueIndex])) {
232 recordFieldType = 'URL';
233 }
234
235 recordField = new Clipperz.PM.DataModel.RecordField({
236 recordVersion:recordVersion,
237 label: someData[currentFieldValueIndex - 1],
238 value: someData[currentFieldValueIndex],
239 type: recordFieldType
240 });
241 recordVersion.addField(recordField);
242 }
243 }
244
245 // this.user().addRecord(record, true);
246
247 someRecords.push(record);
248 }
249
250 return someRecords;
251 }, this), records, someCSVValues[i]);
252 }
253 innerDeferredResult.addCallback(MochiKit.Async.succeed, records);
254 innerDeferredResult.callback();
255
256 return innerDeferredResult;
257 }, this));
258 deferredResult.callback(someData);
259
260 return deferredResult;
261
262/*
263 0Is Template
264 1Title
265 2Category
266
267 3Field 1 Label
268 4Field 1 Value
269 5Field 1 Hidden
270
271 6Field 2 Label
272 7Field 2 Value
273 8Field 2 Hidden
274
275 9Field 3 Label
276 10Field 3 Value
277 11Field 3 Hidden
278
279 12Field 4 Label
280 13Field 4 Value
281 14Field 4 Hidden
282
283 15Field 5 Label
284 16Field 5 Value
285 17Field 5 Hidden
286
287 18Field 6 Label
288 19Field 6 Value
289 20Field 6 Hidden
290
291 21Field 7 Label
292 22Field 7 Value
293 23Field 7 Hidden
294
295 24Field 8 Label
296 25Field 8 Value
297 26Field 8 Hidden
298
299 27Field 9 Label
300 28Field 9 Value
301 29Field 9 Hidden
302
303 30Field 10 Label
304 31Field 10 Value
305 32Field 10 Hidden
306
307 33Note
308*/
309 },
310
311
312 //-------------------------------------------------------------------------
313 __syntaxFix__: "syntax fix"
314});
315