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.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js
index 24dc785..f58d913 100644
--- a/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js
@@ -1,214 +1,212 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer 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
26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
28if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } 26if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; }
29if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; } 27if (typeof(Clipperz.PM.Components.Import) == 'undefined') { Clipperz.PM.Components.Import = {}; }
30 28
31//############################################################################# 29//#############################################################################
32 30
33Clipperz.PM.Components.Import.PasswordPlusImportComponent = function(anElement, args) { 31Clipperz.PM.Components.Import.PasswordPlusImportComponent = function(anElement, args) {
34 args = args || {}; 32 args = args || {};
35 33
36 Clipperz.PM.Components.Import.PasswordPlusImportComponent.superclass.constructor.call(this, anElement, args); 34 Clipperz.PM.Components.Import.PasswordPlusImportComponent.superclass.constructor.call(this, anElement, args);
37 35
38 this.render(); 36 this.render();
39 37
40 return this; 38 return this;
41} 39}
42 40
43//============================================================================= 41//=============================================================================
44 42
45YAHOO.extendX(Clipperz.PM.Components.Import.PasswordPlusImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, { 43YAHOO.extendX(Clipperz.PM.Components.Import.PasswordPlusImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, {
46 44
47 'toString': function() { 45 'toString': function() {
48 return "Clipperz.PM.Components.Import.PasswordPlusImportComponent component"; 46 return "Clipperz.PM.Components.Import.PasswordPlusImportComponent component";
49 }, 47 },
50 48
51 //------------------------------------------------------------------------- 49 //-------------------------------------------------------------------------
52 50
53 'render': function() { 51 'render': function() {
54//MochiKit.Logging.logDebug(">>> Import.PasswordPlusImportComponent.render"); 52//MochiKit.Logging.logDebug(">>> Import.PasswordPlusImportComponent.render");
55 this.domHelper().append(this.element(), {tag:'div', cls:'passwordPlusImportWizard', children:[ 53 this.domHelper().append(this.element(), {tag:'div', cls:'passwordPlusImportWizard', children:[
56 {tag:'h3', htmlString:Clipperz.PM.Strings['PasswordPlus_ImportWizard_Title']}, 54 {tag:'h3', htmlString:Clipperz.PM.Strings['PasswordPlus_ImportWizard_Title']},
57 {tag:'div', cls:'importSteps', id:this.getId('importSteps')}, 55 {tag:'div', cls:'importSteps', id:this.getId('importSteps')},
58 {tag:'div', cls:'importStepBlocks', children:[ 56 {tag:'div', cls:'importStepBlocks', children:[
59 {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[ 57 {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[
60 {tag:'div', children:[ 58 {tag:'div', children:[
61 {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_passwordPlus_description']}, 59 {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_passwordPlus_description']},
62 {tag:'div', cls:'importOptionsParameters', children:[]}, 60 {tag:'div', cls:'importOptionsParameters', children:[]},
63 this.textAreaConfig() 61 this.textAreaConfig()
64 ]} 62 ]}
65 ]}, 63 ]},
66 {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[ 64 {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[
67 {tag:'div', children:[ 65 {tag:'div', children:[
68 {tag:'div', id:this.getId('previewDiv'), html:"preview"} 66 {tag:'div', id:this.getId('previewDiv'), html:"preview"}
69 ]} 67 ]}
70 ]}, 68 ]},
71 {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[ 69 {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[
72 {tag:'div', children:[ 70 {tag:'div', children:[
73 {tag:'h4', html:"done"} 71 {tag:'h4', html:"done"}
74 ]} 72 ]}
75 ]} 73 ]}
76 ]}, 74 ]},
77 {tag:'div', cls:'importOptionsButtons', children:[ 75 {tag:'div', cls:'importOptionsButtons', children:[
78 {tag:'table', children:[ 76 {tag:'table', children:[
79 {tag:'tbody', children:[ 77 {tag:'tbody', children:[
80 {tag:'tr', children:[ 78 {tag:'tr', children:[
81 {tag:'td', html:'&nbsp;'}, 79 {tag:'td', html:'&nbsp;'},
82 {tag:'td', children:[ 80 {tag:'td', children:[
83 {tag:'div', id:this.getId('backActionButton')} 81 {tag:'div', id:this.getId('backActionButton')}
84 ]}, 82 ]},
85 {tag:'td', html:'&nbsp;'}, 83 {tag:'td', html:'&nbsp;'},
86 {tag:'td', children:[ 84 {tag:'td', children:[
87 {tag:'div', id:this.getId('nextActionButton')} 85 {tag:'div', id:this.getId('nextActionButton')}
88 ]}, 86 ]},
89 {tag:'td', html:'&nbsp;'} 87 {tag:'td', html:'&nbsp;'}
90 ]} 88 ]}
91 ]} 89 ]}
92 ]} 90 ]}
93 ]} 91 ]}
94 ]}); 92 ]});
95 93
96 this.updateSteps(); 94 this.updateSteps();
97 95
98 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this})); 96 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this}));
99 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this})); 97 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this}));
100 98
101 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show() 99 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show()
102 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 100 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
103 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); 101 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
104//MochiKit.Logging.logDebug("<<< Import.PasswordPlusImportComponent.render"); 102//MochiKit.Logging.logDebug("<<< Import.PasswordPlusImportComponent.render");
105 }, 103 },
106 104
107 //------------------------------------------------------------------------- 105 //-------------------------------------------------------------------------
108/* 106/*
109 'backAction': function() { 107 'backAction': function() {
110 switch (this.currentStep()) { 108 switch (this.currentStep()) {
111 case 1: //-> 0 109 case 1: //-> 0
112 this.backButton().disable(); 110 this.backButton().disable();
113 this.getElement('step_1').hide(); 111 this.getElement('step_1').hide();
114 this.setCurrentStep(0); 112 this.setCurrentStep(0);
115 this.getElement('step_0').show(); 113 this.getElement('step_0').show();
116 break; 114 break;
117 } 115 }
118 }, 116 },
119*/ 117*/
120 //------------------------------------------------------------------------- 118 //-------------------------------------------------------------------------
121 119
122 'nextAction': function() { 120 'nextAction': function() {
123 switch (this.currentStep()) { 121 switch (this.currentStep()) {
124 case 0: //-> 1 122 case 0: //-> 1
125 this.previewValues(); 123 this.previewValues();
126 break; 124 break;
127 case 1: //-> 2 125 case 1: //-> 2
128 this.importValues(); 126 this.importValues();
129 break; 127 break;
130 } 128 }
131 }, 129 },
132 130
133 //------------------------------------------------------------------------- 131 //-------------------------------------------------------------------------
134 132
135 'deferredPreviewValues': function() { 133 'deferredPreviewValues': function() {
136 var deferredResult; 134 var deferredResult;
137 135
138 // this.setFormValues(MochiKit.DOM.formContents(this.getDom('dataForm'))); 136 // this.setFormValues(MochiKit.DOM.formContents(this.getDom('dataForm')));
139 137
140 deferredResult = new MochiKit.Async.Deferred(); 138 deferredResult = new MochiKit.Async.Deferred();
141 deferredResult.addCallback(MochiKit.Base.bind(function(res) { 139 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
142 this.startProcessing(); 140 this.startProcessing();
143 141
144 return res; 142 return res;
145 }, this)); 143 }, this));
146 deferredResult.addCallback(MochiKit.Base.method(this, 'processPasswordPlusValues')); 144 deferredResult.addCallback(MochiKit.Base.method(this, 'processPasswordPlusValues'));
147 deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues')); 145 deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues'));
148 deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues')); 146 deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues'));
149 deferredResult.addCallback(MochiKit.Base.bind(function(res) { 147 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
150 this.processingDone(); 148 this.processingDone();
151 this.getElement('step_0').hide(); 149 this.getElement('step_0').hide();
152 this.getElement('step_1').show(); 150 this.getElement('step_1').show();
153 this.backButton().enable(); 151 this.backButton().enable();
154 152
155 return res; 153 return res;
156 }, this)); 154 }, this));
157 // deferredResult.addErrback(MochiKit.Base.bind(function() { 155 // deferredResult.addErrback(MochiKit.Base.bind(function() {
158 // this.processingAborted(); 156 // this.processingAborted();
159 // }, this)) 157 // }, this))
160 deferredResult.callback(this.textAreaContent()); 158 deferredResult.callback(this.textAreaContent());
161 159
162 return deferredResult; 160 return deferredResult;
163 }, 161 },
164 162
165 //------------------------------------------------------------------------- 163 //-------------------------------------------------------------------------
166 164
167 'processPasswordPlusValues': function(someData) { 165 'processPasswordPlusValues': function(someData) {
168 var deferredResult; 166 var deferredResult;
169 var csvProcessor; 167 var csvProcessor;
170 168
171 csvProcessor = new Clipperz.CSVProcessor({binary:true}); 169 csvProcessor = new Clipperz.CSVProcessor({binary:true});
172 170
173 deferredResult = new MochiKit.Async.Deferred(); 171 deferredResult = new MochiKit.Async.Deferred();
174 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData'); 172 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
175 deferredResult.addCallback(function(res) { 173 deferredResult.addCallback(function(res) {
176 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2)}, res); 174 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2)}, res);
177 }) 175 })
178 deferredResult.addCallback(MochiKit.Base.method(csvProcessor, 'deferredParse')); 176 deferredResult.addCallback(MochiKit.Base.method(csvProcessor, 'deferredParse'));
179 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData'); 177 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData');
180 deferredResult.addCallback(function(res) { 178 deferredResult.addCallback(function(res) {
181 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2), step:res.length}, res); 179 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length * 2), step:res.length}, res);
182 }) 180 })
183 deferredResult.addCallback(MochiKit.Base.bind(function(someCSVValues) { 181 deferredResult.addCallback(MochiKit.Base.bind(function(someCSVValues) {
184 var innerDeferredResult; 182 var innerDeferredResult;
185 var records; 183 var records;
186 var i,c; 184 var i,c;
187 185
188 innerDeferredResult = new MochiKit.Async.Deferred(); 186 innerDeferredResult = new MochiKit.Async.Deferred();
189 records = []; 187 records = [];
190 188
191 c = someCSVValues.length; 189 c = someCSVValues.length;
192 i=0; 190 i=0;
193 i++; //Dataviz Passwords Plus Export, Version,1, Minimum Version To Read,1 191 i++; //Dataviz Passwords Plus Export, Version,1, Minimum Version To Read,1
194 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 192 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
195 193
196 for( ; i<c; i++) { 194 for( ; i<c; i++) {
197 innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2); 195 innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2);
198 innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {}); 196 innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {});
199 innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) { 197 innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) {
200 if (someData[0] == '0') { 198 if (someData[0] == '0') {
201 var record; 199 var record;
202 var recordVersion; 200 var recordVersion;
203 var ii, cc; 201 var ii, cc;
204 202
205 record = new Clipperz.PM.DataModel.Record({user:this.user()}); 203 record = new Clipperz.PM.DataModel.Record({user:this.user()});
206 if (someData[1] != "") { 204 if (someData[1] != "") {
207 record.setLabel(someData[1]); 205 record.setLabel(someData[1]);
208 } else { 206 } else {
209 record.setLabel("imported record [" + (i+1) + "]"); 207 record.setLabel("imported record [" + (i+1) + "]");
210 } 208 }
211 record.setNotes(someData[33]); 209 record.setNotes(someData[33]);
212 recordVersion = record.currentVersion() 210 recordVersion = record.currentVersion()
213 211
214 cc = 10; 212 cc = 10;