summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/Components/Import
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Import') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js174
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js247
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js240
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js212
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js189
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js548
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js212
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/ExcelImportComponent.js134
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/GenericImportComponent.js523
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/KeePassImportComponent.js450
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js332
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/PasswordPlusImportComponent.js315
-rw-r--r--frontend/beta/js/Clipperz/PM/Components/Import/RoboFormImportComponent.js392
13 files changed, 3968 insertions, 0 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js
new file mode 100644
index 0000000..18b36da
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js
@@ -0,0 +1,174 @@
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 = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34
35//#############################################################################
36
37Clipperz.PM.Components.Import.CSVImport.CSVImportColumns = function(anElement, args) {
38 args = args || {};
39
40 Clipperz.PM.Components.Import.CSVImport.CSVImportColumns.superclass.constructor.call(this, anElement, args);
41 this._mainComponent = args.mainComponent;
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportColumns, Clipperz.PM.Components.BaseComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.CSVImport.CSVImportColumns component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'mainComponent': function() {
57 return this._mainComponent;
58 },
59
60 //-------------------------------------------------------------------------
61
62 'render': function() {
63 var i,c;
64 var columnSelectorCheckboxCells;
65 var checkboxes;
66 var data;
67
68//MochiKit.Logging.logDebug(">>> CSVImportColumns.render");
69 Clipperz.NotificationCenter.unregister(this);
70 MochiKit.Signal.disconnectAllTo(this);
71
72 this.element().update("");
73
74 data = this.mainComponent().parsedValues();
75 columnSelectorCheckboxCells = [];
76
77 c =data[0].length;
78 for (i=0; i<c; i++) {
79 columnSelectorCheckboxCells.push({tag:'th', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), children:[
80 {tag:'input', type:'checkbox', id:this.getId('columnCheckbox_' + i), value:i}
81 ]})
82 }
83
84 this.domHelper().append(this.element(), {tag:'div', children:[
85 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Columns']},
86 {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[
87 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview columns', cellspacing:'0', children:[
88 {tag:'thead', id:this.getId('previewData_thead'), children:[
89 {tag:'tr', children:columnSelectorCheckboxCells}
90 ]},
91 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]}
92 ]}
93 ]}
94 ]});
95
96 c =data[0].length;
97 for (i=0; i<c; i++) {
98 if (this.mainComponent().isColumnSelected(i)) {
99 this.getDom('columnCheckbox_' + i).checked = true;
100 }
101 }
102
103 this.renderData(this.getElement('previewData_tbody'), data);
104
105 checkboxes = MochiKit.DOM.getElementsByTagAndClassName('input', null, this.getDom('previewData_thead'));
106 c = checkboxes.length;
107 for (i=0; i<c; i++) {
108 MochiKit.Signal.connect(checkboxes[i], 'onclick', this, 'renderDataHandler');
109 }
110//MochiKit.Logging.logDebug("<<< CSVImportColumns.render");
111 },
112
113 //-------------------------------------------------------------------------
114
115 'renderData': function(anElement, someData) {
116 var config;
117 var i,c;
118
119//MochiKit.Logging.logDebug(">>> CSVImportColumns.renderData");
120 // anElement.update("");
121 MochiKit.DOM.replaceChildNodes(anElement.dom);
122
123 config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) {
124 var result;
125 var i,c;
126
127 result = {tag:'tr', children:[]};
128 c = aRowData.length;
129 for (i=0; i<c; i++) {
130 var field;
131
132 field = aRowData[i];
133 result.children.push({tag:'td', valign:'top', cls:(this.mainComponent().isColumnSelected(i) ? 'selectedColumn': 'skippedColumn'), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : '&nbsp;')});
134 }
135
136 return result;
137 }, this), someData);
138
139 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config);
140
141 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
142//MochiKit.Logging.logDebug("<<< CSVImportColumns.renderData");
143 },
144
145 //-------------------------------------------------------------------------
146
147 'renderDataHandler': function(anEvent) {
148 var thElement;
149
150 thElement = YAHOO.ext.Element.get(anEvent.src().parentNode);
151
152 if (anEvent.src().checked == true) {
153 this.mainComponent().skippedColumns().remove(anEvent.src().value);
154 thElement.addClass('selectedColumn');
155 thElement.removeClass('skippedColumn');
156 } else {
157 this.mainComponent().skippedColumns().add(anEvent.src().value);
158 thElement.removeClass('selectedColumn');
159 thElement.addClass('skippedColumn');
160 }
161
162 if (this.mainComponent().skippedColumns().allItems().length == this.mainComponent().parsedValues()[0].length) {
163 this.mainComponent().nextButton().disable();
164 } else {
165 this.mainComponent().nextButton().enable();
166 }
167
168 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
169 },
170
171 //-------------------------------------------------------------------------
172 __syntaxFix__: "syntax fix"
173});
174
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js
new file mode 100644
index 0000000..a368747
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js
@@ -0,0 +1,247 @@
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 = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34
35//#############################################################################
36
37Clipperz.PM.Components.Import.CSVImport.CSVImportFields = function(anElement, args) {
38 args = args || {};
39
40 Clipperz.PM.Components.Import.CSVImport.CSVImportFields.superclass.constructor.call(this, anElement, args);
41 this._mainComponent = args.mainComponent;
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportFields, Clipperz.PM.Components.BaseComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.CSVImport.CSVImportFields component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'mainComponent': function() {
57 return this._mainComponent;
58 },
59
60 //-------------------------------------------------------------------------
61
62 'render': function() {
63 varfieldsHeaderCells;
64 var titleColumnIndex;
65 var notesColumnIndex;
66 var i,c;
67
68 Clipperz.NotificationCenter.unregister(this);
69 MochiKit.Signal.disconnectAllTo(this);
70
71 this.element().update("");
72
73 titleColumnIndex = this.mainComponent().titleColumnIndex()
74 notesColumnIndex = this.mainComponent().notesColumnIndex()
75
76 fieldsHeaderCells = [];
77 fieldsHeaderCells.push({tag:'td', valign:'top', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)});
78
79 c =this.mainComponent().parsedValues()[0].length;
80 for (i=0; i<c; i++) {
81 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
82 var trimmedLabel;
83
84 trimmedLabel = Clipperz.Base.trim(this.mainComponent().labelForColumn(i));
85 fieldsHeaderCells.push({tag:'td', valign:'top', id:this.getId('fieldHeaderTD_' + i), cls:((trimmedLabel == "") ? 'missingLabelWarning' : (this.isColumnSetup(i) ? 'configuredColumn': 'unconfiguredColumn')), children:[
86 {tag:'span', html:((trimmedLabel == "") ? Clipperz.PM.Strings['CSV_ImportWizard_Fields_MissingLabelWarning'] : trimmedLabel)/*, cls:((trimmedLabel == "") ? 'missingLabelWarning' : '')*/},
87 {tag:'select', id:this.getId('select_' + i), name:i, children:[
88 {tag:'option', value:'UNDEFINED', html:"select data type", cls:'disabledOption'},
89 {tag:'option', value:'TXT', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['TXT']['shortDescription']},
90 {tag:'option', value:'PWD', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['PWD']['shortDescription']},
91 {tag:'option', value:'URL', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['URL']['shortDescription']},
92 {tag:'option', value:'DATE', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['DATE']['shortDescription']},
93 {tag:'option', value:'ADDR', htmlString:Clipperz.PM.Strings['recordFieldTypologies']['ADDR']['shortDescription']}
94 ]}
95 ]})
96 }
97 }
98
99 if (notesColumnIndex != -1) {
100 fieldsHeaderCells.push({tag:'td', valign:'top', cls:'notes', html:this.mainComponent().labelForColumn(notesColumnIndex)});
101 }
102
103 this.domHelper().append(this.element(), {tag:'div', children:[
104 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Fields']},
105 {tag:'div', id:this.getId('dataDiv'), children:[
106 {tag:'div', children:[
107 ]},
108 {tag:'div', cls:'csvImportPreview', children:[
109 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[
110 {tag:'thead', id:this.getId('previewData_thead'), children:[
111 {tag:'tr', cls:'CSV_previewData_header', children:fieldsHeaderCells}
112 ]},
113 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]}
114 ]}
115 ]}
116 ]}
117 ]});
118
119 for (i=0; i<c; i++) {
120 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
121 Clipperz.DOM.selectOptionMatchingValue(this.getDom('select_' + i), this.mainComponent().typeForColumn(i));
122 MochiKit.Signal.connect(this.getDom('select_' + i), 'onchange', this, 'renderDataRowsHandler');
123 }
124 }
125
126 this.renderDataRows(this.getElement('previewData_tbody'));
127 // Clipperz.NotificationCenter.register(null, 'updatedCSVImportColumnHeader', this, 'renderDataRowsHandler');
128 },
129
130 //-------------------------------------------------------------------------
131
132 'isColumnSetup': function(aColumnIndex) {
133 return ((Clipperz.Base.trim(this.mainComponent().labelForColumn(aColumnIndex)) != "") && (this.mainComponent().typeForColumn(aColumnIndex) != 'UNDEFINED'));
134 },
135
136 //-------------------------------------------------------------------------
137
138 'renderDataRowsHandler': function(anEvent) {
139 var columnIndex;
140 var tdElement;
141
142//MochiKit.Logging.logDebug(">>> renderDataRowsHandler")
143 columnIndex = anEvent.src().name;
144 this.mainComponent().setTypeForColumn(anEvent.src().value, columnIndex);
145
146 tdElement = this.getElement('fieldHeaderTD_' + columnIndex);
147
148 if (this.isColumnSetup(columnIndex)) {
149 tdElement.removeClass('unconfiguredColumn');
150 tdElement.addClass('configuredColumn');
151 } else {
152 tdElement.addClass('unconfiguredColumn');
153 tdElement.removeClass('configuredColumn');
154 }
155
156 this.renderDataRows(this.getElement('previewData_tbody'));
157 },
158
159 //-------------------------------------------------------------------------
160
161 'renderDataRows': function(anElement) {
162 var titleColumnIndex;
163 var notesColumnIndex;
164 var data
165 var i,c;
166
167//MochiKit.Logging.logDebug("#### >> renderDataRows");
168 // anElement.update("");
169 MochiKit.DOM.replaceChildNodes(anElement.dom);
170
171 if (this.mainComponent().isFirstRowHeader()) {
172 data = this.mainComponent().parsedValues().slice(1);
173 } else {
174 data = this.mainComponent().parsedValues();
175 }
176
177
178 titleColumnIndex = this.mainComponent().titleColumnIndex();
179 notesColumnIndex = this.mainComponent().notesColumnIndex();
180
181 c = data.length;
182 for (i=0; i<c; i++) {
183 var rowData;
184 var rowConfig;
185 var ii, cc;
186
187 rowData = data[i];
188
189 rowConfig = {tag:'tr', children:[
190 {tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(rowData[titleColumnIndex]) ? rowData[titleColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')}
191 ]};
192
193 cc = rowData.length;
194 for (ii=0; ii<cc; ii++) {
195 // if ((ii != titleColumnIndex) && (ii != notesColumnIndex)) {
196 if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.mainComponent().isColumnSelected(ii))) {
197 rowConfig.children.push({
198 tag:'td',
199 valign:'top',
200 cls:(this.isColumnSetup(ii) ? 'configuredColumn' : 'unconfiguredColumn'),
201 html:(MochiKit.Base.isNotEmpty(rowData[ii]) ? rowData[ii].replace(/\n/g, '<br>') : '&nbsp;')
202 });
203 }
204 }
205 if (notesColumnIndex != -1) {
206 rowConfig.children.push({tag:'td', valign:'top', cls:'notes', html:(MochiKit.Base.isNotEmpty(rowData[notesColumnIndex]) ? rowData[notesColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')});
207 }
208
209 this.domHelper().append(anElement, rowConfig);
210 }
211
212 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
213
214 this.checkWetherToEnableNextButton();
215//MochiKit.Logging.logDebug("#### << renderDataRows");
216 },
217
218 //-------------------------------------------------------------------------
219
220 'checkWetherToEnableNextButton': function() {
221 var result;
222 var titleColumnIndex;
223 var notesColumnIndex;
224 var i,c;
225
226 titleColumnIndex = this.mainComponent().titleColumnIndex()
227 notesColumnIndex = this.mainComponent().notesColumnIndex()
228
229 result = true;
230 c =this.mainComponent().parsedValues()[0].length;
231 for (i=0; i<c; i++) {
232 if ((i != titleColumnIndex) && (i != notesColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
233 result = result && this.isColumnSetup(i);
234 }
235 }
236
237 if (result) {
238 this.mainComponent().nextButton().enable();
239 } else {
240 this.mainComponent().nextButton().disable();
241 }
242 },
243
244 //-------------------------------------------------------------------------
245 __syntaxFix__: "syntax fix"
246});
247
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js
new file mode 100644
index 0000000..ebd243a
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js
@@ -0,0 +1,240 @@
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 = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34
35//#############################################################################
36
37Clipperz.PM.Components.Import.CSVImport.CSVImportHeader = function(anElement, args) {
38 args = args || {};
39
40 Clipperz.PM.Components.Import.CSVImport.CSVImportHeader.superclass.constructor.call(this, anElement, args);
41 this._mainComponent = args.mainComponent;
42
43 this._pendingDeferredLabelFieldHandlerEvents = 0;
44
45 return this;
46}
47
48//=============================================================================
49
50YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportHeader, Clipperz.PM.Components.BaseComponent, {
51
52 'toString': function() {
53 return "Clipperz.PM.Components.Import.CSVImport.CSVImportHeader component";
54 },
55
56 //-------------------------------------------------------------------------
57
58 'mainComponent': function() {
59 return this._mainComponent;
60 },
61
62 //-------------------------------------------------------------------------
63
64 'render': function() {
65 var thConfigs;
66 var i,c;
67
68//MochiKit.Logging.logDebug(">>> CSVImportHeader.render");
69 Clipperz.NotificationCenter.unregister(this);
70 MochiKit.Signal.disconnectAllTo(this);
71
72 thConfigs = [];
73 c = this.mainComponent().parsedValues()[0].length;
74 for (i=0; i<c; i++) {
75 if (this.mainComponent().isColumnSelected(i)) {
76 // thConfigs.push({tag:'th', children:[{tag:'input', type:'text', id:this.getId('headerTextField_' + i), value:this.mainComponent().labelForColumn(i)}]});
77 thConfigs.push({tag:'th', children:[{tag:'input', type:'text', id:this.getId('headerTextField_' + i), value:""}]});
78 }
79 }
80
81 this.element().update("");
82 this.domHelper().append(this.element(), {tag:'div', children:[
83 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Header']},
84 {tag:'div', cls:'importStepParameters', children:[
85 {tag:'input', type:'checkbox', name:'isFistRowHeader', id:this.getId('isFirstRowHeader_checkbox')},
86 {tag:'span', id:this.getId('isFirstRowHeader_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Header_Settings_firstRowHeaderLabel']}
87 ]},
88 {tag:'div', id:this.getId('dataDiv'), children:[
89 {tag:'div', cls:'csvImportPreview', children:[
90 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview header', cellspacing:'0', children:[
91 {tag:'thead', children:[{tag:'tr', children:thConfigs}]},
92 {tag:'tbody', id:this.getId('previewData_tbody')}
93 ]}
94 ]}
95 ]}
96 ]});
97
98 for (i=0; i<c; i++) {
99 if (this.mainComponent().isColumnSelected(i)) {
100 this.getElement('headerTextField_' + i).dom.value = this.mainComponent().labelForColumn(i);
101 }
102 }
103
104 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
105
106 if (this.mainComponent().isFirstRowHeader()) {
107 this.getDom('isFirstRowHeader_checkbox').click();
108 }
109
110 c = this.mainComponent().parsedValues()[0].length;
111 for (i=0; i<c; i++) {
112 if (this.mainComponent().isColumnSelected(i)) {
113 MochiKit.Signal.connect(this.getDom('headerTextField_' + i), 'onchange', MochiKit.Base.partial(MochiKit.Base.method(this, 'labelFieldHandler'), i));
114 MochiKit.Signal.connect(this.getDom('headerTextField_' + i), 'onkeypress', MochiKit.Base.partial(MochiKit.Base.method(this, 'deferredLabelFieldHandler'), i));
115 }
116 }
117
118 MochiKit.Signal.connect(this.getDom('isFirstRowHeader_checkbox'), 'onclick', this, 'toggleFirstRowHeaderCheckboxHandler');
119 if (Clipperz_IEisBroken != true) {
120 MochiKit.Signal.connect(this.getDom('isFirstRowHeader_span'), 'onclick', this.getDom('isFirstRowHeader_checkbox'), 'click');
121 }
122//MochiKit.Logging.logDebug("<<< CSVImportHeader.render");
123 },
124
125 //-------------------------------------------------------------------------
126
127 'renderData': function(anElement, someData) {
128 var trConfigs;
129 var data;
130 var i,c;
131
132 // anElement.update("");
133 MochiKit.DOM.replaceChildNodes(anElement.dom);
134
135 if (this.mainComponent().isFirstRowHeader()) {
136 data = someData.slice(1);
137 } else {
138 data = someData;
139 }
140
141 trConfigs = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) {
142 var result;
143 var i,c;
144
145 result = {tag:'tr', children:[]};
146 c = aRowData.length;
147 for (i=0; i<c; i++) {
148 if (this.mainComponent().isColumnSelected(i)) {
149 result.children.push({tag:'td', valign:'top', html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : '&nbsp;')});
150 }
151 }
152
153 return result;
154 }, this), data);
155
156 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, trConfigs);
157
158 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
159 },
160
161 //-------------------------------------------------------------------------
162
163 'toggleFirstRowHeaderCheckboxHandler': function() {
164 var firstRowData;
165 var i,c;
166
167//MochiKit.Logging.logDebug(">>> toggleFirstRowHeaderCheckboxHandler");
168 this.mainComponent().setIsFirstRowHeader(this.getDom('isFirstRowHeader_checkbox').checked);
169
170 firstRowData = this.mainComponent().parsedValues()[0];
171
172 c = firstRowData.length;
173 for (i=0; i<c; i++) {
174 if (this.mainComponent().isColumnSelected(i)) {
175 var label;
176
177 if (this.mainComponent().isFirstRowHeader()) {
178 label = firstRowData[i];
179 } else {
180 label = null;
181 }
182
183 this.mainComponent().setLabelForColumn(label, i);
184 }
185 };
186
187 this.updateInputFieldValues();
188 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
189//MochiKit.Logging.logDebug("<<< toggleFirstRowHeaderCheckboxHandler");
190 },
191
192 //-------------------------------------------------------------------------
193
194 'updateInputFieldValues': function() {
195 var i,c;
196
197//MochiKit.Logging.logDebug(">>> updateInputFieldValues");
198 c = this.mainComponent().parsedValues()[0].length;
199 for (i=0; i<c; i++) {
200 if (this.mainComponent().isColumnSelected(i)) {
201 this.getDom('headerTextField_' + i).value = this.mainComponent().labelForColumn(i);
202 }
203 }
204//console.log('[1] fieldSettings', fieldSettings);
205//MochiKit.Logging.logDebug("<<< updateInputFieldValues");
206 },
207
208 //-------------------------------------------------------------------------
209
210 'labelFieldHandler': function(aColumnIndex, anEvent) {
211 var inputField;
212
213//MochiKit.Logging.logDebug(">>> labelFieldHandler");
214 inputField = anEvent.src();
215
216 this.mainComponent().setLabelForColumn(inputField.value, aColumnIndex);
217//MochiKit.Logging.logDebug("##### [" + anEvent.src().id + "] -> label[" + aColumnIndex + "]: '" + inputField.value + "'");
218//MochiKit.Logging.logDebug("<<< labelFieldHandler");
219 },
220
221 'deferredLabelFieldHandler': function(aColumnIndex, anEvent) {
222//MochiKit.Logging.logDebug(">>> deferredLabelFieldHandler");
223 this._pendingDeferredLabelFieldHandlerEvents ++;
224 MochiKit.Async.callLater(1, MochiKit.Base.partial(MochiKit.Base.method(this, 'deferredLabelFieldHandlerCatcher'), aColumnIndex, anEvent));
225//MochiKit.Logging.logDebug("<<< deferredLabelFieldHandler");
226 },
227
228 'deferredLabelFieldHandlerCatcher': function(aColumnIndex, anEvent) {
229//MochiKit.Logging.logDebug(">>> deferredLabelFieldHandlerCatcher");
230 this._pendingDeferredLabelFieldHandlerEvents --;
231 if (this._pendingDeferredLabelFieldHandlerEvents == 0) {
232 this.labelFieldHandler(aColumnIndex, anEvent);
233 }
234//MochiKit.Logging.logDebug("<<< deferredLabelFieldHandlerCatcher");
235 },
236
237 //-------------------------------------------------------------------------
238 __syntaxFix__: "syntax fix"
239});
240
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js
new file mode 100644
index 0000000..a53c531
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js
@@ -0,0 +1,212 @@
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 = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34
35//#############################################################################
36
37Clipperz.PM.Components.Import.CSVImport.CSVImportNotes = function(anElement, args) {
38 args = args || {};
39
40 Clipperz.PM.Components.Import.CSVImport.CSVImportNotes.superclass.constructor.call(this, anElement, args);
41 this._mainComponent = args.mainComponent;
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportNotes, Clipperz.PM.Components.BaseComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.CSVImport.CSVImportNotes component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'mainComponent': function() {
57 return this._mainComponent;
58 },
59
60 //-------------------------------------------------------------------------
61
62 'render': function() {
63 varnotesSelectorCheckboxCells;
64 var totalNumberOfColumns;
65 var titleColumnIndex;
66 var notesColumnIndex;
67 var i,c;
68
69 Clipperz.NotificationCenter.unregister(this);
70 MochiKit.Signal.disconnectAllTo(this);
71
72 this.element().update("");
73
74 titleColumnIndex = this.mainComponent().titleColumnIndex()
75 notesColumnIndex = this.mainComponent().notesColumnIndex()
76
77 totalNumberOfColumns = this.mainComponent().parsedValues()[0].length;
78
79 notesSelectorCheckboxCells = [{tag:'th', cls:'title', html:this.mainComponent().labelForColumn(titleColumnIndex)}];
80 c =totalNumberOfColumns;
81 for (i=0; i<c; i++) {
82 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
83 notesSelectorCheckboxCells.push({tag:'th', id:this.getId('th_' + i), valign:'top', children:[
84 {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportNotesColumn', value:i},
85 {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)}
86 ]})
87 }
88 }
89
90 this.domHelper().append(this.element(), {tag:'div', children:[
91 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes']},
92 {tag:'div', id:this.getId('dataDiv'), children:[
93 {tag:'div', cls:'importStepParameters', children:[
94 {tag:'input', id:this.getId('doNotSetNotes_radio'), type:'radio', name:'CSVImportNotesColumn', value:-1},
95 {tag:'span', id:this.getId('doNotSetNotes_span'), cls:'clickableSpan', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Notes_Settings_noSelectionLabel']}
96 ]},
97 {tag:'div', cls:'csvImportPreview', children:[
98 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[
99 {tag:'thead', id:this.getId('previewData_thead'), children:[
100 {tag:'tr', children:notesSelectorCheckboxCells}
101 ]},
102 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]}
103 ]}
104 ]}
105 ]}
106 ]});
107
108 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
109
110 if ((notesColumnIndex >= totalNumberOfColumns) || (notesColumnIndex == titleColumnIndex) || !(this.mainComponent().isColumnSelected(notesColumnIndex))) {
111 this.mainComponent().setNotesColumnIndex(-1);
112 notesColumnIndex = -1;
113 }
114
115 c =totalNumberOfColumns;
116 for (i=0; i<c; i++) {
117 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
118 MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler');
119 if (Clipperz_IEisBroken != true) {
120 MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click');
121 }
122 }
123 }
124
125 MochiKit.Signal.connect(this.getDom('doNotSetNotes_radio'), 'onclick', this, 'renderDataHandler');
126 if (Clipperz_IEisBroken != true) {
127 MochiKit.Signal.connect(this.getDom('doNotSetNotes_span'), 'onclick', this.getDom('doNotSetNotes_radio'), 'click');
128 }
129
130 if (notesColumnIndex == -1) {
131 this.getDom('doNotSetNotes_radio').click();
132 } else {
133 this.getDom('radio_' + notesColumnIndex).click();
134 }
135 },
136
137 //-------------------------------------------------------------------------
138
139 'renderData': function(anElement, someData) {
140 var data;
141 var config;
142 var titleColumnIndex;
143 var notesColumnIndex;
144 var i,c;
145
146 // anElement.update("");
147 MochiKit.DOM.replaceChildNodes(anElement.dom);
148
149 titleColumnIndex = this.mainComponent().titleColumnIndex();
150 notesColumnIndex = this.mainComponent().notesColumnIndex();
151
152 if (this.mainComponent().isFirstRowHeader()) {
153 data = someData.slice(1);
154 } else {
155 data = someData;
156 }
157
158
159 // config = [{tag:'tr', cls:'CSV_previewData_header', children:[{tag:'td', valign:'top', html:header[titleColumnIndex], cls:'title'}]}];
160 // c = header.length;
161 // for (i=0; i<c; i++) {
162 // if (i != titleColumnIndex) {
163 // config[0].children.push({tag:'td', valign:'top', html:header[i], cls:((notesColumnIndex == i) ? 'notesColumn': '')})
164 // }
165 // }
166
167 config = MochiKit.Base.map(MochiKit.Base.bind(function(aTitleColumnIndex, aRowData) {
168 var result;
169 var i,c;
170
171 result = {tag:'tr', children:[{tag:'td', valign:'top', cls:'title', html:(MochiKit.Base.isNotEmpty(aRowData[aTitleColumnIndex]) ? aRowData[aTitleColumnIndex].replace(/\n/g, '<br>') : '&nbsp;')}]};
172 c = aRowData.length;
173 for (i=0; i<c; i++) {
174 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
175 result.children.push({tag:'td', valign:'top', cls:((notesColumnIndex == i) ? 'notesColumn': ''), html:(MochiKit.Base.isNotEmpty(aRowData[i]) ? aRowData[i].replace(/\n/g, '<br>') : '&nbsp;')});
176 }
177 }
178
179 return result;
180 }, this, titleColumnIndex), data);
181
182 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config);
183
184 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
185 },
186
187 //-------------------------------------------------------------------------
188
189 'renderDataHandler': function(anEvent) {
190 var titleColumnIndex;
191 var i,c;
192
193 this.mainComponent().setNotesColumnIndex(anEvent.src().value);
194 titleColumnIndex = this.mainComponent().titleColumnIndex();
195
196 c = this.mainComponent().parsedValues()[0].length;
197 for (i=0; i<c; i++) {
198 if ((i != titleColumnIndex) && (this.mainComponent().isColumnSelected(i))) {
199 this.getElement('th_' + i).removeClass('notesColumn');
200 }
201 }
202 if (anEvent.src().value != -1) {
203 this.getElement('th_' + anEvent.src().value).addClass('notesColumn');
204 }
205
206 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
207 },
208
209 //-------------------------------------------------------------------------
210 __syntaxFix__: "syntax fix"
211});
212
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js
new file mode 100644
index 0000000..9162867
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js
@@ -0,0 +1,189 @@
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 = {}; }
33if (typeof(Clipperz.PM.Components.Import.CSVImport) == 'undefined') { Clipperz.PM.Components.Import.CSVImport = {}; }
34
35//#############################################################################
36
37Clipperz.PM.Components.Import.CSVImport.CSVImportTitle = function(anElement, args) {
38 args = args || {};
39
40 Clipperz.PM.Components.Import.CSVImport.CSVImportTitle.superclass.constructor.call(this, anElement, args);
41 this._mainComponent = args.mainComponent;
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.CSVImport.CSVImportTitle, Clipperz.PM.Components.BaseComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.CSVImport.CSVImportTitle component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'mainComponent': function() {
57 return this._mainComponent;
58 },
59
60 //-------------------------------------------------------------------------
61
62 'render': function() {
63 vartitleSelectorCheckboxCells;
64 var titleColumnIndex;
65 var i,c;
66
67 Clipperz.NotificationCenter.unregister(this);
68 MochiKit.Signal.disconnectAllTo(this);
69
70 this.element().update("");
71
72 titleColumnIndex = this.mainComponent().titleColumnIndex()
73 titleSelectorCheckboxCells = [];
74 c =this.mainComponent().parsedValues()[0].length;
75 for (i=0; i<c; i++) {
76 if (this.mainComponent().isColumnSelected(i)) {
77 titleSelectorCheckboxCells.push({tag:'th', valign:'top', id:this.getId('th_' + i), children:[
78 {tag:'input', type:'radio', id:this.getId('radio_' + i), name:'CSVImportTitleColumn', value:i},
79 {tag:'span', cls:'clickableSpan', id:this.getId('columnLabel_' + i), html:this.mainComponent().labelForColumn(i)}
80 ]})
81 }
82 }
83
84 if (titleColumnIndex >= titleSelectorCheckboxCells.length) {
85 this.mainComponent().setTitleColumnIndex(-1);
86 }
87
88 this.domHelper().append(this.element(), {tag:'div', children:[
89 {tag:'div', cls:'importStepDescription', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']},
90 {tag:'div', id:this.getId('dataDiv'), cls:'csvImportPreview', children:[
91 {tag:'table', id:this.getId('previewDada'), cls:'csvImportPreview', cellspacing:'0', children:[
92 {tag:'thead', id:this.getId('previewData_thead'), children:[
93 {tag:'tr', children:titleSelectorCheckboxCells}
94 ]},
95 {tag:'tbody', id:this.getId('previewData_tbody'), children:[]}
96 ]}
97 ]}
98 ]});
99
100 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
101
102 c =this.mainComponent().parsedValues()[0].length;
103 for (i=0; i<c; i++) {
104 if (this.mainComponent().isColumnSelected(i)) {
105 MochiKit.Signal.connect(this.getDom('radio_' + i), 'onclick', this, 'renderDataHandler');
106 if (Clipperz_IEisBroken != true) {
107 MochiKit.Signal.connect(this.getDom('columnLabel_' + i), 'onclick', this.getDom('radio_' + i), 'click');
108 }
109 }
110 }
111
112 if (titleColumnIndex != -1) {
113 this.getDom('radio_' + titleColumnIndex).click();
114 } else {
115 this.mainComponent().nextButton().disable();
116 }
117
118 },
119
120 //-------------------------------------------------------------------------
121
122 'renderData': function(anElement, someData) {
123 var data;
124 var config;
125 var titleColumnIndex;
126 var i,c;
127
128 // anElement.update("");
129 MochiKit.DOM.replaceChildNodes(anElement.dom);
130
131 titleColumnIndex = this.mainComponent().titleColumnIndex()
132
133 if (this.mainComponent().isFirstRowHeader()) {
134 data = someData.slice(1);
135 } else {
136 data = someData;
137 }
138
139 config = MochiKit.Base.map(MochiKit.Base.bind(function(aRowData) {
140 var result;
141 var i,c;
142
143 result = {tag:'tr', children:[]};
144 c = aRowData.length;
145 for (i=0; i<c; i++) {
146 if (this.mainComponent().isColumnSelected(i)) {
147 var field;
148
149 field = aRowData[i];
150 result.children.push({tag:'td', valign:'top', cls:((titleColumnIndex == i) ? 'titleColumn': ''), html:(MochiKit.Base.isNotEmpty(field) ? field.replace(/\n/g, '<br>') : '&nbsp;')});
151 }
152 }
153
154 return result;
155 }, this), data);
156
157 MochiKit.Base.map(function(aRowConfig) {Clipperz.YUI.DomHelper.append(anElement, aRowConfig);}, config);
158
159 Clipperz.Style.applyZebraStylesToTable(this.getId('previewDada'));
160 },
161
162 //-------------------------------------------------------------------------
163
164 'renderDataHandler': function(anEvent) {
165 var i,c;
166
167 this.mainComponent().setTitleColumnIndex(anEvent.src().value);
168
169 c = this.mainComponent().parsedValues()[0].length;
170 for (i=0; i<c; i++) {
171 if (this.mainComponent().isColumnSelected(i)) {
172 this.getElement('th_' + i).removeClass('titleColumn');
173 }
174 }
175 this.getElement('th_' + anEvent.src().value).addClass('titleColumn');
176
177 if (anEvent.src().value != -1) {
178 this.mainComponent().nextButton().enable();
179 } else {
180 this.mainComponent().nextButton().disable();
181 }
182
183 this.renderData(this.getElement('previewData_tbody'), this.mainComponent().parsedValues());
184 },
185
186 //-------------------------------------------------------------------------
187 __syntaxFix__: "syntax fix"
188});
189
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js
new file mode 100644
index 0000000..707a3d2
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/CSVImportComponent.js
@@ -0,0 +1,548 @@
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.CSVImportComponent = function(anElement, args) {
37 args = args || {};
38
39 this._steps = this._steps || ['CSV_EDIT', 'CSV_COLUMNS', 'CSV_HEADER', 'CSV_TITLE', 'CSV_NOTES', 'CSV_FIELDS', 'PREVIEW', 'IMPORT'];
40
41 Clipperz.PM.Components.Import.CSVImportComponent.superclass.constructor.call(this, anElement, args);
42
43 this._step1Component = null;
44 this._step2Component = null;
45 this._step3Component = null;
46 this._step4Component = null;
47 this._step5Component = null;
48
49 this._isFirstRowHeader = false;
50 this._titleColumnIndex = -1;
51 this._notesColumnIndex = -1;
52 this._fieldSettings = {};
53 this._skippedColumns = new Clipperz.Set();
54
55 this.render();
56
57 return this;
58}
59
60//=============================================================================
61
62YAHOO.extendX(Clipperz.PM.Components.Import.CSVImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, {
63
64 'toString': function() {
65 return "Clipperz.PM.Components.Import.CSVImportComponent component";
66 },
67
68 //-------------------------------------------------------------------------
69
70 'render': function() {
71 this.domHelper().append(this.element(), {tag:'div', cls:'csvImportWizard', children:[
72 {tag:'h3', htmlString:Clipperz.PM.Strings['CSV_ImportWizard_Title']},
73 {tag:'div', cls:'importSteps', id:this.getId('importSteps')},
74 {tag:'div', cls:'importStepBlocks', children:[
75 {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[
76 {tag:'div', children:[
77 {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_csv_description']},
78 {tag:'div', cls:'importOptionsParameters', children:[
79 {tag:'div', cls:'CSVImportOptionsParameters', children:[
80 {tag:'ul', children:[
81 {tag:'li', children:[
82 {tag:'label', 'for':this.getId('CSV_inputOptions_separator'), html:"separator"},
83 {tag:'select', name:this.getId('CSV_inputOptions_separator'), id:this.getId('CSV_inputOptions_separator'), children:[
84 {tag:'option', name:'comma', value:',', html:"comma (,)", selected:true},
85 {tag:'option', name:'tab', value:'\t', html:"tab"}
86 ]}
87 ]},
88
89 {tag:'li', children:[
90 {tag:'label', 'for':this.getId('CSV_inputOptions_quote'), html:"quote"},
91 {tag:'select', name:this.getId('CSV_inputOptions_quote'), id:this.getId('CSV_inputOptions_quote'), children:[
92 {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true},
93 {tag:'option', name:'singleQuote', value:'\'', html:"single quote (\')"}
94 ]}
95 ]},
96
97 {tag:'li', children:[
98 {tag:'label', 'for':this.getId('CSV_inputOptions_escape'), html:"escape"},
99 {tag:'select', name:this.getId('CSV_inputOptions_escape'), id:this.getId('CSV_inputOptions_escape'), children:[
100 {tag:'option', name:'doubleQuote', value:'\"', html:"double quote (\")", selected:true},
101 {tag:'option', name:'slash', value:'\/', html:"slash (\/)"},
102 {tag:'option', name:'backslash', value:'\\', html:"backslash (\\)"}
103 ]}
104 ]}
105 ]}
106 ]}
107 ]},
108 this.textAreaConfig()
109 ]}
110 ]},
111 {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[]},
112 {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[]},
113 {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[]},
114 {tag:'div', cls:'step_4', id:this.getId('step_4'), children:[]},
115 {tag:'div', cls:'step_5', id:this.getId('step_5'), children:[]},
116 {tag:'div', cls:'step_6', id:this.getId('step_6'), children:[
117 {tag:'div', children:[
118 {tag:'div', id:this.getId('previewDiv'), html:"preview"}
119 ]}
120 ]},
121 {tag:'div', cls:'step_7', id:this.getId('step_7'), children:[
122 {tag:'div', children:[
123 {tag:'h4', html:"done"}
124 ]}
125 ]}
126 ]},
127 {tag:'div', cls:'importOptionsButtons', children:[
128 {tag:'table', children:[
129 {tag:'tbody', children:[
130 {tag:'tr', children:[
131 {tag:'td', html:'&nbsp;'},
132 {tag:'td', children:[
133 {tag:'div', id:this.getId('backActionButton')}
134 ]},
135 {tag:'td', html:'&nbsp;'},
136 {tag:'td', children:[
137 {tag:'div', id:this.getId('nextActionButton')}
138 ]},
139 {tag:'td', html:'&nbsp;'}
140 ]}
141 ]}
142 ]}
143 ]}
144 ]});
145
146 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this}));
147 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this}));
148
149 this.updateSteps();
150
151 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show()
152 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
153 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
154 this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
155 this.getElement('step_4').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
156 this.getElement('step_5').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
157 this.getElement('step_6').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
158 this.getElement('step_7').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
159
160 // this.backButton().disable();
161 },
162
163 //-------------------------------------------------------------------------
164
165 'nextAction': function() {
166 switch (this.currentStep()) {
167 case 0: //-> 1
168 Clipperz.PM.Components.MessageBox.showProgressPanel(
169 MochiKit.Base.method(this, 'deferredParseValues'),
170 MochiKit.Base.method(this, 'handleParseError'),
171 this.getDom('nextActionButton')
172 );
173 break;
174 case 1: //-> 2
175 this.getElement('step_1').hide();
176 this.step2Component().render();
177 this.setCurrentStep(2);
178 this.getElement('step_2').show();
179 break;
180 case 2: //-> 3
181 this.getElement('step_2').hide();
182 this.step3Component().render();
183 this.setCurrentStep(3);
184 this.getElement('step_3').show();
185 break;
186 case 3: //-> 4
187 this.getElement('step_3').hide();
188 this.step4Component().render();
189 this.setCurrentStep(4);
190 this.getElement('step_4').show();
191 break;
192 case 4: //-> 5
193 this.getElement('step_4').hide();
194 this.step5Component().render();
195 this.setCurrentStep(5);
196 this.getElement('step_5').show();
197 break;
198 case 5: //-> 6
199 this.previewValues();
200 break;
201 case 6: //-> 7
202 this.importValues();
203 break;
204 }
205 },
206
207 //-------------------------------------------------------------------------
208
209 'deferredParseValues': function() {
210 var deferredResult;
211
212 deferredResult = new MochiKit.Async.Deferred();
213//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 1 " + res.substring(0,50)); return res;});
214 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
215//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 2 " + res.substring(0,50)); return res;});
216 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
217 this.startProcessing();
218
219 return res;
220 }, this));
221//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 3 " + res.substring(0,50)); return res;});
222 deferredResult.addCallback(MochiKit.Base.method(this, 'parseCSVValues'));
223//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 4 " + res); return res;});
224 deferredResult.addCallback(MochiKit.Base.method(this, 'setParsedValues'));
225//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 5 " + res); return res;});
226 deferredResult.addCallback(MochiKit.Base.method(this.step1Component(), 'render'));
227//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 6 " + res); return res;});
228 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
229 this.processingDone();
230 this.getElement('step_0').hide();
231 this.getElement('step_1').show();
232 this.backButton().enable();
233
234 return res;
235 }, this));
236//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("CSVImportComponent.deferredParseValues - 7 " + res); return res;});
237 deferredResult.callback(this.textAreaContent());
238
239 return deferredResult;
240 },
241
242 //-------------------------------------------------------------------------
243
244 'deferredPreviewValues': function() {
245 var deferredResult;
246
247//MochiKit.Logging.logDebug(">>> CSVImportComponent.deferredPreviewValues");
248 deferredResult = new MochiKit.Async.Deferred();
249//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 1 " + res); return res;});
250 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData');
251//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 2 " + res); return res;});
252 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
253 this.startProcessing();
254
255 return res;
256 }, this));
257//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 3 " + res); return res;});
258 deferredResult.addCallback(MochiKit.Base.method(this, 'processCSVParsedValues'));
259//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 4 " + res); return res;});
260 deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues'));
261//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 5 " + res); return res;});
262 deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues'));
263//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 6 " + res); return res;});
264 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
265 this.processingDone();
266 this.getElement('step_5').hide();
267 this.getElement('step_6').show();
268 this.backButton().enable();
269
270 return res;
271 }, this));
272 deferredResult.callback(this.parsedValues());
273//MochiKit.Logging.logDebug("<<< CSVImportComponent.deferredPreviewValues");
274
275 return deferredResult;
276 },
277
278 //-------------------------------------------------------------------------
279
280 'csvProcessor': function() {
281 return new Clipperz.CSVProcessor({
282 quoteChar: this.getDom('CSV_inputOptions_quote').value,
283 escapeChar: this.getDom('CSV_inputOptions_escape').value,
284 separatorChar:this.getDom('CSV_inputOptions_separator').value,
285 binary:true
286 });
287 },
288
289 //-------------------------------------------------------------------------
290
291 'parseCSVValues': function(someData) {
292 var deferredResult;
293 var csvProcessor;
294
295 csvProcessor = this.csvProcessor();
296 deferredResult = new MochiKit.Async.Deferred();
297//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 1 " + res.substring(0,50)); return res;});
298 deferredResult.addCallback(function(res) {
299 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res);
300 })
301//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 2 " + res.substring(0,50)); return res;});
302 deferredResult.addCallback(MochiKit.Base.method(csvProcessor, 'deferredParse'));
303//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 3 " + res); return res;});
304 deferredResult.callback(someData);
305
306 return deferredResult;
307 },
308
309 //-------------------------------------------------------------------------
310
311 'processCSVParsedValues': function (someValues) {
312 var deferredResult;
313 var records;
314 var titleColumnIndex;
315 var notesColumnIndex;
316 var i,c;
317
318 deferredResult = new MochiKit.Async.Deferred();
319 records = [];
320
321 titleColumnIndex = this.titleColumnIndex();
322 notesColumnIndex = this.notesColumnIndex();
323
324 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {steps:(someValues.length)});
325
326 c = someValues.length;
327 if (this.isFirstRowHeader()) {
328 i = 1;
329 } else {
330 i = 0;
331 }
332
333 for( ; i<c; i++) {
334 deferredResult.addCallback(MochiKit.Async.wait, 0.2);
335 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {});
336 deferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) {
337 var record;
338 var recordVersion;
339 var ii;
340
341 record = new Clipperz.PM.DataModel.Record({user:this.user()});
342 record.setLabel(someData[titleColumnIndex]);
343 if (notesColumnIndex != -1) {
344 record.setNotes(someData[notesColumnIndex]);
345 }
346 recordVersion = record.currentVersion()
347
348 for (ii in someData) {
349 // if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (typeof(this.fieldSettings()[ii]) != 'undefined')) {
350 if ((ii != titleColumnIndex) && (ii != notesColumnIndex) && (this.isColumnSelected(ii))) {
351 var recordField;
352
353 recordField = new Clipperz.PM.DataModel.RecordField({
354 recordVersion:recordVersion,
355 label: this.labelForColumn(ii),
356 value: someData[ii],
357 type: this.typeForColumn(ii)
358 });
359 recordVersion.addField(recordField);
360 }
361 }
362
363 someRecords.push(record);
364
365 return someRecords;
366 }, this), records, someValues[i]);
367 }
368 deferredResult.addCallback(MochiKit.Async.succeed, records);
369 deferredResult.callback();
370
371 return deferredResult;
372 },
373
374 //-------------------------------------------------------------------------
375
376 'step1Component': function() {
377 if (this._step1Component == null) {
378 this._step1Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportColumns(this.getElement('step_1'), {mainComponent:this});
379 }
380
381 return this._step1Component;
382 },
383
384 'step2Component': function() {
385 if (this._step2Component == null) {
386 this._step2Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportHeader(this.getElement('step_2'), {mainComponent:this});
387 }
388
389 return this._step2Component;
390 },
391
392 'step3Component': function() {
393 if (this._step3Component == null) {
394 this._step3Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportTitle(this.getElement('step_3'), {mainComponent:this});
395 }
396
397 return this._step3Component;
398 },
399
400 'step4Component': function() {
401 if (this._step4Component == null) {
402 this._step4Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportNotes(this.getElement('step_4'), {mainComponent:this});
403 }
404
405 return this._step4Component;
406 },
407
408 'step5Component': function() {
409 if (this._step5Component == null) {
410 this._step5Component = new Clipperz.PM.Components.Import.CSVImport.CSVImportFields(this.getElement('step_5'), {mainComponent:this});
411 }
412
413 return this._step5Component;
414 },
415
416 //-------------------------------------------------------------------------
417
418 'isFirstRowHeader': function() {
419 return this._isFirstRowHeader;
420 },
421
422 'setIsFirstRowHeader': function(aValue) {
423 this._isFirstRowHeader = aValue;
424 },
425
426 //-------------------------------------------------------------------------
427
428 'titleColumnIndex': function() {
429 return this._titleColumnIndex;
430 },
431
432 'setTitleColumnIndex': function(aValue) {
433 this._titleColumnIndex = aValue;
434 },
435
436 //-------------------------------------------------------------------------
437
438 'notesColumnIndex': function() {
439 return this._notesColumnIndex;
440 },
441
442 'setNotesColumnIndex': function(aValue) {
443 this._notesColumnIndex = aValue;
444 },
445
446 //-------------------------------------------------------------------------
447
448 'fieldSettings': function() {
449 return this._fieldSettings;
450 },
451
452 //-------------------------------------------------------------------------
453
454 'skippedColumns': function() {
455 return this._skippedColumns;
456 },
457
458 //-------------------------------------------------------------------------
459
460 'isColumnSelected': function(aColumnIndex) {
461 return !this.skippedColumns().contains("" + aColumnIndex);
462 },
463
464 //=========================================================================
465
466 'labelForColumn': function(aColumnIndex) {
467 var result;
468
469 if ((typeof(this.fieldSettings()) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]) != 'undefined')) {
470 if (this.isFirstRowHeader()) {
471 result = this.fieldSettings()[aColumnIndex]['_firstRowLabel'];
472//MochiKit.Logging.logDebug("--- updateInputFieldValues - [" + aColumnIndex + "] _firstRowLabel: " + label);
473 } else {
474 result = this.fieldSettings()[aColumnIndex]['_emptyLabel'];
475//MochiKit.Logging.logDebug("--- updateInputFieldValues - [" + aColumnIndex + "] _emptyLabel: " + label);
476 }
477 } else {
478 result = "";
479 }
480
481 return result;
482 },
483
484 //-------------------------------------------------------------------------
485
486 'setLabelForColumn': function(aLabel, aColumnIndex) {
487 var fieldSettings;
488
489//MochiKit.Logging.logDebug(">>> setLabelForColumn[" + aColumnIndex + "]: " + aLabel);
490 fieldSettings = this.fieldSettings();
491
492 if (typeof(fieldSettings[aColumnIndex]) == 'undefined') {
493 fieldSettings[aColumnIndex] = {}
494 }
495
496 if (this.isFirstRowHeader()) {
497//MochiKit.Logging.logDebug("--- setLabelForColumn -> _firstRowLabel");
498 fieldSettings[aColumnIndex]['_firstRowLabel'] = aLabel;
499 } else {
500 if (typeof(fieldSettings[aColumnIndex]['_emptyLabel']) == 'undefined') {
501 if (aLabel == null) {
502//MochiKit.Logging.logDebug("--- setLabelForColumn -> _emptyLabel = \"\"");
503 fieldSettings[aColumnIndex]['_emptyLabel'] = "";
504 } else {
505 fieldSettings[aColumnIndex]['_emptyLabel'] = aLabel;
506 }
507 } else {
508//MochiKit.Logging.logDebug("--- setLabelForColumn -> _emptyLabel = " + aLabel);
509 if (aLabel != null) {
510 fieldSettings[aColumnIndex]['_emptyLabel'] = aLabel;
511 }
512 }
513 }
514//MochiKit.Logging.logDebug("<<< setLabelForColumn[" + aColumnIndex + "]: " + aLabel);
515 },
516
517 //=========================================================================
518
519 'typeForColumn': function(aColumnIndex) {
520 var result;
521
522 if ((typeof(this.fieldSettings()) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]) != 'undefined') && (typeof(this.fieldSettings()[aColumnIndex]['type']) != 'undefined')) {
523 result = this.fieldSettings()[aColumnIndex]['type'];
524 } else {
525 result = 'UNDEFINED';
526 }
527
528 return result;
529 },
530
531 //-------------------------------------------------------------------------
532
533 'setTypeForColumn': function(aType, aColumnIndex) {
534 var fieldSettings;
535
536 fieldSettings = this.fieldSettings();
537
538 if (typeof(fieldSettings[aColumnIndex]) == 'undefined') {
539 fieldSettings[aColumnIndex] = {}
540 }
541
542 fieldSettings[aColumnIndex]['type'] = aType;
543 },
544
545 //=========================================================================
546 __syntaxFix__: "syntax fix"
547});
548
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js
new file mode 100644
index 0000000..50dcb93
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/ClipperzImportComponent.js
@@ -0,0 +1,212 @@
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.ClipperzImportComponent = function(anElement, args) {
37 args = args || {};
38
39 Clipperz.PM.Components.Import.ClipperzImportComponent.superclass.constructor.call(this, anElement, args);
40
41 this.render();
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.ClipperzImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.ClipperzImportComponent component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'render': function() {
57//MochiKit.Logging.logDebug(">>> Import.ClipperzImportComponent.render");
58 this.domHelper().append(this.element(), {tag:'div', cls:'clipperzImportWizard', children:[
59 {tag:'h3', htmlString:Clipperz.PM.Strings['Clipperz_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_clipperz_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.ClipperzImportComponent.render");
108 },
109
110 //-------------------------------------------------------------------------
111
112 'nextAction': function() {
113 switch (this.currentStep()) {
114 case 0: //-> 1
115 this.previewValues();
116 break;
117 case 1: //-> 2
118 this.importValues();
119 break;
120 }
121 },
122
123 //-------------------------------------------------------------------------
124
125 'deferredPreviewValues': function() {
126 var deferredResult;
127
128 deferredResult = new MochiKit.Async.Deferred();
129 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
130 this.startProcessing();
131
132 return res;
133 }, this));
134 deferredResult.addCallback(MochiKit.Base.method(this, 'processClipperzValues'));
135 deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues'));
136 deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues'));
137 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
138 this.processingDone();
139 this.getElement('step_0').hide();
140 this.getElement('step_1').show();
141 this.backButton().enable();
142
143 return res;
144 }, this));
145 // deferredResult.addErrback(MochiKit.Base.bind(function() {
146 // this.processingAborted();
147 // }, this))
148 deferredResult.callback(this.textAreaContent());
149
150 return deferredResult;
151 },
152
153 //-------------------------------------------------------------------------
154
155 'processClipperzValues': function(someData) {
156 var deferredResult;
157
158 deferredResult = new MochiKit.Async.Deferred();
159//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 1: " + res); return res;});
160 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
161//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 2: " + res); return res;});
162 deferredResult.addCallback(Clipperz.Base.evalJSON);
163//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 3: " + res); return res;});
164 deferredResult.addCallback(function(res) {
165 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res);
166 })
167//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 4: " + res); return res;});
168 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData');
169//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 5: " + res); return res;});
170 deferredResult.addCallback(MochiKit.Base.bind(function(someClipperzValues) {
171 var innerDeferredResult;
172 var records;
173 var i,c;
174
175 innerDeferredResult = new MochiKit.Async.Deferred();
176 records = [];
177
178 c = someClipperzValues.length;
179 for(i=0; i<c; i++) {
180 innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2);
181 innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {});
182 innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) {
183 var record;
184 var recordVersion;
185
186//MochiKit.Logging.logDebug("=== someData: " + Clipperz.Base.serializeJSON(someData));
187 record = new Clipperz.PM.DataModel.Record({user:this.user()});
188 record.setLabel(someData['label']);
189 record.setShouldProcessData(true);
190 record.processData(someData);
191
192 someRecords.push(record);
193
194 return someRecords;
195 }, this), records, someClipperzValues[i]);
196 }
197 innerDeferredResult.addCallback(MochiKit.Async.succeed, records);
198 innerDeferredResult.callback();
199
200 return innerDeferredResult;
201 }, this));
202//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Record.processClipperzValues - 6: " + res); return res;});
203 deferredResult.callback(someData);
204
205 return deferredResult;
206 },
207
208
209 //-------------------------------------------------------------------------
210 __syntaxFix__: "syntax fix"
211});
212
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/ExcelImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/ExcelImportComponent.js
new file mode 100644
index 0000000..ecdf509
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/ExcelImportComponent.js
@@ -0,0 +1,134 @@
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.ExcelImportComponent = function(anElement, args) {
37 args = args || {};
38
39 this._steps = ['EXCEL_EDIT', 'CSV_COLUMNS', 'CSV_HEADER', 'CSV_TITLE', 'CSV_NOTES', 'CSV_FIELDS', 'PREVIEW', 'IMPORT'];
40
41 Clipperz.PM.Components.Import.ExcelImportComponent.superclass.constructor.call(this, anElement, args);
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.ExcelImportComponent, Clipperz.PM.Components.Import.CSVImportComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.ExcelImportComponent component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'render': function() {
57//MochiKit.Logging.logDebug(">>> Import.ExcelImportComponent.render");
58 this.domHelper().append(this.element(), {tag:'div', cls:'excelImportWizard', children:[
59 {tag:'h3', htmlString:Clipperz.PM.Strings['Excel_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_excel_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', cls:'step_2', id:this.getId('step_2'), children:[]},
71 {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[]},
72 {tag:'div', cls:'step_4', id:this.getId('step_4'), children:[]},
73 {tag:'div', cls:'step_5', id:this.getId('step_5'), children:[]},
74 {tag:'div', cls:'step_6', id:this.getId('step_6'), children:[
75 {tag:'div', children:[
76 {tag:'div', id:this.getId('previewDiv'), html:"preview"}
77 ]}
78 ]},
79 {tag:'div', cls:'step_7', id:this.getId('step_7'), children:[
80 {tag:'div', children:[
81 {tag:'h4', html:"done"}
82 ]}
83 ]}
84 ]},
85 {tag:'div', cls:'importOptionsButtons', children:[
86 {tag:'table', children:[
87 {tag:'tbody', children:[
88 {tag:'tr', children:[
89 {tag:'td', html:'&nbsp;'},
90 {tag:'td', children:[
91 {tag:'div', id:this.getId('backActionButton')}
92 ]},
93 {tag:'td', html:'&nbsp;'},
94 {tag:'td', children:[
95 {tag:'div', id:this.getId('nextActionButton')}
96 ]},
97 {tag:'td', html:'&nbsp;'}
98 ]}
99 ]}
100 ]}
101 ]}
102 ]});
103
104 this.updateSteps();
105
106 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this}));
107 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this}));
108
109 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show()
110 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
111 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
112 this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
113 this.getElement('step_4').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
114 this.getElement('step_5').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
115 this.getElement('step_6').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
116 this.getElement('step_7').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
117//MochiKit.Logging.logDebug("<<< Import.ExcelImportComponent.render");
118 },
119
120 //-------------------------------------------------------------------------
121
122 'csvProcessor': function() {
123 return new Clipperz.CSVProcessor({
124 // quoteChar: this.getDom('CSV_inputOptions_quote').value,
125 // escapeChar: this.getDom('CSV_inputOptions_escape').value,
126 separatorChar:'\t',
127 binary:true
128 });
129 },
130
131 //-------------------------------------------------------------------------
132 __syntaxFix__: "syntax fix"
133});
134
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/GenericImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/GenericImportComponent.js
new file mode 100644
index 0000000..4f6b1e4
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/GenericImportComponent.js
@@ -0,0 +1,523 @@
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.GenericImportComponent = function(anElement, args) {
37 args = args || {};
38
39 this._steps = this._steps || ['EDIT', 'PREVIEW', 'IMPORT'];
40
41 Clipperz.PM.Components.Import.GenericImportComponent.superclass.constructor.call(this, anElement, args);
42
43 this._user = args['user'];
44
45 this._currentStep = 0;
46 this._currentStatus = 'IDLE'; //'PROCESSING'
47
48 this._parsedValues = null;
49 this._processedValues = null;
50
51 this._backButton = null;
52 this._nextButton = null;
53
54 Clipperz.NotificationCenter.register(null, 'importProcessorProgressUpdate', this, 'updateProgressDialogStatus');
55
56 return this;
57}
58
59//=============================================================================
60
61YAHOO.extendX(Clipperz.PM.Components.Import.GenericImportComponent, Clipperz.PM.Components.BaseComponent, {
62
63 'toString': function() {
64 return "Clipperz.PM.Components.Import.GenericImportComponent component";
65 },
66
67 //-------------------------------------------------------------------------
68
69 'user': function() {
70 return this._user;
71 },
72
73 //-------------------------------------------------------------------------
74
75 'textAreaConfig': function() {
76 return {tag:'textarea', name:this.getId('importTextArea'), cls:'importTextArea', id:this.getId('importTextArea'), cols:60, rows:15, html:""};
77 },
78
79 'textAreaContent': function() {
80 return this.getDom('importTextArea').value
81 },
82
83 //-------------------------------------------------------------------------
84
85 'steps': function() {
86 return this._steps;
87 },
88
89 'currentStep': function() {
90 return this._currentStep;
91 },
92
93 'setCurrentStep': function(aValue) {
94 this._currentStep = aValue;
95 this.updateSteps();
96 },
97
98 //-------------------------------------------------------------------------
99
100 'currentStatus': function() {
101 return this._currentStatus;
102 },
103
104 'startProcessing': function() {
105 this._currentStatus = 'PROCESSING';
106 this.updateSteps();
107 },
108
109 'processingDone': function() {
110 this._currentStatus = 'IDLE';
111 this.setCurrentStep(this.currentStep() + 1);
112 },
113
114 'processingAborted': function() {
115 this._currentStatus = 'IDLE';
116 this.updateSteps();
117 },
118
119 //-------------------------------------------------------------------------
120
121 'stepsConfig': function() {
122 var result;
123 var i,c;
124
125 result = [];
126 c = this.steps().length;
127 for (i=0; i<c; i++) {
128 var cls;
129
130 if (this.currentStep() == i) {
131 if (this.currentStatus() == 'IDLE') {
132 cls = 'current';
133 } else {
134 cls = 'currentProcessing';
135 }
136 } else {
137 cls = "";
138 }
139
140 result.push({tag:'td', cls:cls, children:[
141 {tag:'div', children:[{tag:'span', htmlString:Clipperz.PM.Strings['ImportWizard'][this.steps()[i]]}]}
142 ]})
143 if (i < (c-1)) {
144 if ((this.currentStep() == i) && (this.currentStatus() == 'PROCESSING')) {
145 cls = 'stepSeparatorProcessing';
146 } else {
147 cls = 'stepSeparator';
148 }
149
150 result.push({tag:'td', cls:cls, children:[
151 {tag:'div', children:[{tag:'span', html:">"}]}
152 ]});
153 }
154 }
155
156 result = [{tag:'div', cls:'importWizardStepsBox', children:[
157 {tag:'div', cls:'importWizardStepsInnerBox', children:[
158 {tag:'table', cls:'importWizardSteps', children:[
159 {tag:'tbody', children:[
160 {tag:'tr', children:result}
161 ]}
162 ]}
163 ]},
164 {tag:'div', cls:'importWizardStepsBoxFooter'}
165 ]}];
166
167 return result;
168 },
169
170 'updateSteps': function() {
171 this.getElement('importSteps').update("");
172 Clipperz.YUI.DomHelper.append(this.getDom('importSteps'), {tag:'div', children:this.stepsConfig()});
173 },
174
175 //-------------------------------------------------------------------------
176
177 'backAction': function() {
178//MochiKit.Logging.logDebug(">>> backAction");
179 if (this.currentStep() == 0) {
180 Clipperz.NotificationCenter.notify(this, 'importCancelled');
181 } else {
182 this.getElement('step_' + this.currentStep()).hide();
183 this.setCurrentStep(this.currentStep() - 1);
184 this.getElement('step_' + this.currentStep()).show();
185
186 this.nextButton().enable();
187 }
188//MochiKit.Logging.logDebug("<<< backAction");
189 },
190
191 //-------------------------------------------------------------------------
192
193 'backButton': function() {
194 return this._backButton;
195 },
196
197 'setBackButton': function(aValue) {
198 this._backButton = aValue;
199 },
200
201 'nextButton': function() {
202 return this._nextButton;
203 },
204
205 'setNextButton': function(aValue) {
206 this._nextButton = aValue;
207 },
208
209 //-------------------------------------------------------------------------
210
211 'render': function() {
212//MochiKit.Logging.logDebug(">>> Import.GenericImportComponent.render");
213 this.domHelper().append(this.element(), {tag:'div', children:[
214 {tag:'h2', html:this.toString()}
215 ]});
216//MochiKit.Logging.logDebug("<<< Import.GenericImportComponent.render");
217 },
218
219 //-------------------------------------------------------------------------
220
221 'previewValues': function() {
222 Clipperz.PM.Components.MessageBox.showProgressPanel(
223 MochiKit.Base.method(this, 'deferredPreviewValues'),
224 MochiKit.Base.method(this, 'handlePreviewError'),
225 this.getDom('nextActionButton')
226 );
227 },
228
229 'deferredPreviewValues': function() {
230 throw Clipperz.Base.exception.AbstractMethod;
231 },
232
233 'handlePreviewError': function(anError) {
234console.log("anError", anError);
235 MochiKit.Logging.logError("An error occurred while previewing the data: " + anError);
236 alert("An error occurred while previewing the data");
237 Clipperz.PM.Components.MessageBox().hide();
238 },
239
240 //-------------------------------------------------------------------------
241
242 'previewRecordValues': function(someProcessedRecords) {
243//MochiKit.Logging.logDebug(">>> previewRecordValues");
244 this.getElement('previewDiv').update("");
245//MochiKit.Logging.logDebug("--- previewRecordValues - 1");
246 this.domHelper().append(this.getElement('previewDiv'), {tag:'div', cls:'importPreviewDiv', children:[{tag:'table', id:'importPreview', cellspacing:'0', children:[
247 {tag:'tbody', children:
248 MochiKit.Base.map(MochiKit.Base.bind(function(aRecord) {
249 var result;
250//MochiKit.Logging.logDebug("--- previewRecordValues - 1.1");
251//console.log("fields", aRecord.currentVersion().fields());
252 result = {tag:'tr', children:[{tag:'td', children:[
253 {tag:'table', cls:'importPreview_record', children:[
254 {tag:'tbody', children:[
255 {tag:'tr', children:[
256 {tag:'td', rowspan:'2', valign:'top', children:[
257 {tag:'input', type:'checkbox', id:this.getId(aRecord.reference()), value:"aRecord.reference()", checked:true}
258 ]},
259 {tag:'td', colspan:'2', children:[
260 {tag:'span', cls:'importPreview_title', html:aRecord.label()}
261 ]}
262 ]},
263 {tag:'tr', children:[
264 {tag:'td', valign:'top', children:[
265 {tag:'span', cls:'importPreview_notes', html:(MochiKit.Base.isNotEmpty(aRecord.notes()) ? aRecord.notes().replace(/\n/g, '<br>') : '&nbsp;')}
266 ]},
267 {tag:'td', valign:'top', cls:'importPreview_fieds', children:[
268 {tag:'table', cls:'importPreview_fields', children:[
269 {tag:'tbody', children:MochiKit.Base.map(function(aField) {
270 var result;
271//MochiKit.Logging.logDebug("--- previewRecordValues - 1.1.1");
272 result = {tag:'tr', children:[
273 {tag:'td', valign:'top', children:[
274 {tag:'span', cls:'importPreview_fields_label', html:aField.label()}
275 ]},
276 {tag:'td', valign:'top', children:[
277 {tag:'span', cls:'importPreview_fields_value', html:aField.value()}
278 ]}
279 ]};
280//MochiKit.Logging.logDebug("--- previewRecordValues - 1.1.2");
281 return result;
282 }, MochiKit.Base.values(aRecord.currentVersion().fields()))}
283 ]}
284 ]}
285 ]}
286 ]}
287 ]}
288 ]}]};
289//MochiKit.Logging.logDebug("--- previewRecordValues - 1.2");
290 return result;
291 }, this), someProcessedRecords)
292 }
293 ]}]});
294//MochiKit.Logging.logDebug("--- previewRecordValues - 2");
295
296 MochiKit.Base.map(MochiKit.Base.bind(function(aRecord) {
297 this.getElement(aRecord.reference()).dom.value = aRecord.reference();
298 }, this), someProcessedRecords);
299
300 Clipperz.Style.applyZebraStylesToTable('importPreview');
301//MochiKit.Logging.logDebug("<<< previewRecordValues");
302 },
303
304 //-------------------------------------------------------------------------
305
306 'updateProgressDialogStatus': function(anEvent) {
307 Clipperz.PM.Components.MessageBox().update({step:anEvent.parameters().progress});
308 },
309
310 //-------------------------------------------------------------------------
311
312 'parsedValues': function() {
313 return this._parsedValues;
314 },
315
316 'setParsedValues': function(aValue) {
317 this._parsedValues = aValue;
318
319 return this._parsedValues;
320 },
321
322 //-------------------------------------------------------------------------
323
324 'processedValues': function() {
325 return this._processedValues;
326 },
327
328 'setProcessedValues': function(aValue) {
329 this._processedValues = aValue;
330 return this._processedValues;
331 },
332
333 //-------------------------------------------------------------------------
334
335 'importValues': function() {
336 var deferredResult;
337
338 deferredResult = new MochiKit.Async.Deferred();
339
340 deferredResult.addCallback(MochiKit.Base.bind(function() {
341 this.nextButton().disable();
342 this.startProcessing();
343 },this));
344 deferredResult.addCallback(MochiKit.Base.method(this, 'importProcessedValues'));
345 deferredResult.addCallback(MochiKit.Base.method(this, 'processingDone'));
346 deferredResult.addErrback (MochiKit.Base.method(this, 'processingAborted'));
347 deferredResult.callback();
348
349 return deferredResult;
350 },
351
352 //-------------------------------------------------------------------------
353
354 'importProcessedValues': function() {
355 var deferredResult;
356 var processedValues;
357 var selectedRecords;
358 var i,c;
359
360//MochiKit.Logging.logDebug(">>> GenericImportComponent.importProcessedValues");
361 processedValues = this.processedValues();
362 selectedRecords = [];
363
364 c = processedValues.length;
365 for (i=0; i<c; i++) {
366 var currentRecord;
367
368 currentRecord = processedValues[i];
369 if (this.getDom(currentRecord.reference()).checked == true) {
370 selectedRecords.push(currentRecord);
371 }
372 }
373
374 deferredResult = new MochiKit.Async.Deferred();
375//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 1: " + res); return res;});
376 deferredResult.addCallback(function(someRecords) {
377 var innerDeferredResult;
378 var text;
379
380 text = Clipperz.PM.Strings['importData_importConfirmation_text'];
381 text = text.replace(/__numberOfRecords__/, someRecords.length);
382
383 innerDeferredResult = new MochiKit.Async.Deferred();
384//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 1.1: " + res); return res;});
385 innerDeferredResult.addCallback(MochiKit.Async.succeed, someRecords);
386//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 1.2: " + res); return res;});
387
388 Clipperz.PM.Components.MessageBox().deferredShow({
389 title:Clipperz.PM.Strings['importData_importConfirmation_title'],
390 text:text,
391 width:240,
392 showProgressBar:false,
393 showCloseButton:false,
394 buttons:{
395 'yes':"yes", //Clipperz.PM.Strings['mainPanelDeleteRecordPanelConfirmButtonLabel'],
396 'no':"no" //Clipperz.PM.Strings['mainPanelDeleteRecordPanelDenyButtonLabel']
397 },
398 fn:MochiKit.Base.partial(function(aDeferred, aResult) {
399 if (aResult == 'yes') {
400 aDeferred.callback(aResult);
401 } else {
402 aDeferred.errback(aResult);
403 }
404 }, innerDeferredResult)
405 }/*, this.getId('nextActionButton')*/);
406
407 return innerDeferredResult;
408 });
409
410//-------------------
411 // deferredResult.addCallback(MochiKit.Base.bind(function(someRecords) {
412 // Clipperz.PM.Components.MessageBox.showProgressPanel(
413 // MochiKit.Base.method(this, 'importProcessedValues_core', someRecords),
414 // MochiKit.Base.method(this, 'handleProcessError'),
415 // this.getDom('mainDiv')
416 // );
417 // }, this));
418
419//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 2: " + res); return res;});
420 deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'deferredShow'),
421 {
422 // title:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressTitle'],
423 // text:Clipperz.PM.Strings['accountPanelDeletingAccountPanelProgressText'],
424 width:240,
425 showProgressBar:true,
426 showCloseButton:false
427 }
428 );
429//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3: " + res); return res;});
430
431 deferredResult.addCallback(MochiKit.Base.bind(function(someRecords) {
432 var innerDeferredResult;
433
434//MochiKit.Logging.logDebug(">>> inner deferred");
435 innerDeferredResult = new MochiKit.Async.Deferred();
436
437//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3.1: " + res); return res;});
438 innerDeferredResult.addCallback(MochiKit.Base.method(this, 'importProcessedValues_core', someRecords));
439//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3.2: " + res); return res;});
440 innerDeferredResult.addErrback(MochiKit.Base.method(this, 'handleProcessError'));
441//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 3.3: " + res); return res;});
442 innerDeferredResult.callback(someRecords);
443//MochiKit.Logging.logDebug("<<< inner deferred");
444
445 return innerDeferredResult;
446 }, this), selectedRecords);
447//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 4: " + res); return res;});
448
449 deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Components.MessageBox(), 'hide'), 'mainDiv');
450
451 deferredResult.addErrback(MochiKit.Base.bind(function() {
452 this.nextButton().enable();
453 this.setCurrentStep(this.currentStep() -1);
454 }, this));
455//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("GenericImportComponent - 5: " + res); return res;});
456
457 deferredResult.callback(selectedRecords);
458//MochiKit.Logging.logDebug("<<< GenericImportComponent.importProcessedValues");
459
460 return deferredResult;
461 },
462
463 //-------------------------------------------------------------------------
464
465 'importProcessedValues_core': function(someRecords) {
466 var deferredResult;
467
468 deferredResult = new MochiKit.Async.Deferred();
469
470 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'processingImportData');
471 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {steps:(someRecords.length + 6 + 1)});
472 deferredResult.addCallback(MochiKit.Async.wait, 0.5);
473//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 3: " + res); return res;});
474 deferredResult.addCallback(MochiKit.Base.bind(function(someRecords) {
475 var i,c;
476
477 c = someRecords.length;
478 for (i=0; i<c; i++) {
479 this.user().addRecord(someRecords[i], true);
480 }
481
482 return someRecords;
483 }, this));
484 deferredResult.addCallback(MochiKit.Async.wait, 0.5);
485//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 4: " + res); return res;});
486 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'recordAdded', null);
487//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 5: " + res); return res;});
488 deferredResult.addCallback(MochiKit.Base.method(this.user(), 'saveRecords'));
489//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 6: " + res); return res;});
490 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'selectTab', 'mainTabPanel.recordsTab');
491//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("importProcessedValues_core - 7: " + res); return res;});
492
493 if (this.user().preferences().shouldShowDonationPanel()) {
494 deferredResult.addCallback(Clipperz.PM.showDonationSplashScreen, this.user(), 'mainDiv');
495 }
496
497 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'importCompleted', null);
498
499 deferredResult.callback(someRecords);
500
501 return deferredResult;
502 },
503
504 //-------------------------------------------------------------------------
505
506 'handleParseError': function(res) {
507 this.processingAborted();
508 MochiKit.Logging.logError("An error occurred while parsing the values: " + res);
509 alert("An error occurred while parsing the values: " + res);
510 Clipperz.PM.Components.MessageBox().hide();
511 },
512
513 'handleProcessError': function(res) {
514 this.processingAborted();
515 MochiKit.Logging.logError("An error occurred while processing the values: " + res);
516 alert("An error occurred while processing the values: " + res);
517 Clipperz.PM.Components.MessageBox().hide();
518 },
519
520 //-------------------------------------------------------------------------
521 __syntaxFix__: "syntax fix"
522});
523
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/KeePassImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/KeePassImportComponent.js
new file mode 100644
index 0000000..0657520
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/KeePassImportComponent.js
@@ -0,0 +1,450 @@
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.KeePassImportComponent = function(anElement, args) {
37 args = args || {};
38
39 Clipperz.PM.Components.Import.KeePassImportComponent.superclass.constructor.call(this, anElement, args);
40
41 this._steps = ['EDIT', 'KEEPASS_SETTINGS', 'PREVIEW', 'IMPORT'];
42 this._definedFields = ['Group', 'Group Tree', 'UserName', 'URL', 'Password', 'Notes', 'UUID', 'Icon', 'Creation Time', 'Last Access', 'Last Modification', 'Expires', 'Attachment Description', 'Attachment'];
43
44 this.render();
45
46 return this;
47}
48
49//=============================================================================
50
51YAHOO.extendX(Clipperz.PM.Components.Import.KeePassImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, {
52
53 'toString': function() {
54 return "Clipperz.PM.Components.Import.KeePassImportComponent component";
55 },
56
57 //-------------------------------------------------------------------------
58
59 'render': function() {
60//MochiKit.Logging.logDebug(">>> Import.KeePassImportComponent.render");
61 this.domHelper().append(this.element(), {tag:'div', cls:'keePassImportWizard', children:[
62 {tag:'h3', htmlString:Clipperz.PM.Strings['KeePass_ImportWizard_Title']},
63 {tag:'div', cls:'importSteps', id:this.getId('importSteps')},
64 {tag:'div', cls:'importStepBlocks', children:[
65 {tag:'div', cls:'step_0', id:this.getId('step_0'), children:[
66 {tag:'div', children:[
67 {tag:'div', cls:'importOptionsDescription', htmlString:Clipperz.PM.Strings['importOptions_keePass_description']},
68 {tag:'div', cls:'importOptionsParameters', children:[]},
69 this.textAreaConfig()
70 ]}
71 ]},
72 {tag:'div', cls:'step_1', id:this.getId('step_1'), children:[
73 {tag:'div', children:[
74 {tag:'div', id:this.getId('settingsDiv'), children:[
75 {tag:'table', id:'KeePassSettings', children:[
76 {tag:'tbody', children:[
77 {tag:'tr', children:[
78 {tag:'td', width:'50%', valign:'top', children:[
79 {tag:'table', children:[
80 {tag:'tbody', children:[
81 {tag:'tr', children:[
82 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Group_checkbox'), name:'Group'/*, checked:true*/}]},
83 {tag:'td', width:'150', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Group_label'), html:"Group"}]}
84 ]},
85 {tag:'tr', children:[
86 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Group Tree_checkbox'), name:'Group Tree'/*, checked:true*/}]},
87 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Group Tree_label'), html:"Group Tree"}]}
88 ]},
89 {tag:'tr', children:[
90 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('UserName_checkbox'), name:'UserName', checked:true}]},
91 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('UserName_label'), html:"UserName"}]}
92 ]},
93 {tag:'tr', children:[
94 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('URL_checkbox'), name:'URL', checked:true}]},
95 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('URL_label'), html:"URL"}]}
96 ]},
97 {tag:'tr', children:[
98 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Password_checkbox'), name:'Password', checked:true}]},
99 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Password_label'), html:"Password"}]}
100 ]},
101 {tag:'tr', children:[
102 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Notes_checkbox'), name:'Notes', checked:true}]},
103 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Notes_label'), html:"Notes"}]}
104 ]},
105 {tag:'tr', children:[
106 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('UUID_checkbox'), name:'UUID'/*, checked:true*/}]},
107 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('UUID_label'), html:"UUID"}]}
108 ]}
109 ]}
110 ]}
111 ]},
112 {tag:'td', width:'50%', valign:'top', children:[
113 {tag:'table', children:[
114 {tag:'tbody', children:[
115 {tag:'tr', children:[
116 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Icon_checkbox'), name:'Icon'/*, checked:true*/}]},
117 {tag:'td', width:'150', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Icon_label'), html:"Icon"}]}
118 ]},
119 {tag:'tr', children:[
120 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Creation Time_checkbox'), name:'Creation Time'/*, checked:true*/}]},
121 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Creation Time_label'), html:"Creation Time"}]}
122 ]},
123 {tag:'tr', children:[
124 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Last Access_checkbox'), name:'Last Access'/*, checked:true*/}]},
125 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Last Access_label'), html:"Last Access"}]}
126 ]},
127 {tag:'tr', children:[
128 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Last Modification_checkbox'), name:'Last Modification'/*, checked:true*/}]},
129 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Last Modification_label'), html:"Last Modification"}]}
130 ]},
131 {tag:'tr', children:[
132 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Expires_checkbox'), name:'Expires'/*, checked:true*/}]},
133 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Expires_label'), html:"Expires"}]}
134 ]},
135 {tag:'tr', children:[
136 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Attachment Description_checkbox'), name:'Attachment Description', checked:true}]},
137 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Attachment Description_label'), html:"Attachment Description"}]}
138 ]},
139 {tag:'tr', children:[
140 {tag:'td', valign:'top', children:[{tag:'input', type:'checkbox', id:this.getId('Attachment_checkbox'), name:'Attachment', checked:true}]},
141 {tag:'td', valign:'top', children:[{tag:'span', cls:'keePassFieldLabel', id:this.getId('Attachment_label'), html:"Attachment"}]}
142 ]}
143 ]}
144 ]}
145 ]}
146 ]}
147 ]}
148 ]}
149 ]}
150 ]}
151 ]},
152 {tag:'div', cls:'step_2', id:this.getId('step_2'), children:[
153 {tag:'div', children:[
154 {tag:'div', id:this.getId('previewDiv'), html:"preview"}
155 ]}
156 ]},
157 {tag:'div', cls:'step_3', id:this.getId('step_3'), children:[
158 {tag:'div', children:[
159 {tag:'h4', html:"done"}
160 ]}
161 ]}
162 ]},
163 {tag:'div', cls:'importOptionsButtons', children:[
164 {tag:'table', children:[
165 {tag:'tbody', children:[
166 {tag:'tr', children:[
167 {tag:'td', html:'&nbsp;'},
168 {tag:'td', children:[
169 {tag:'div', id:this.getId('backActionButton')}
170 ]},
171 {tag:'td', html:'&nbsp;'},
172 {tag:'td', children:[
173 {tag:'div', id:this.getId('nextActionButton')}
174 ]},
175 {tag:'td', html:'&nbsp;'}
176 ]}
177 ]}
178 ]}
179 ]}
180 ]});
181
182 this.updateSteps();
183
184 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this}));
185 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this}));
186
187 this.getElement('step_0').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show()
188 this.getElement('step_1').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
189 this.getElement('step_2').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
190 this.getElement('step_3').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
191//MochiKit.Logging.logDebug("<<< Import.KeePassImportComponent.render");
192 },
193
194 //-------------------------------------------------------------------------
195
196 'nextAction': function() {
197 switch (this.currentStep()) {
198 case 0: //-> 1
199 Clipperz.PM.Components.MessageBox.showProgressPanel(
200 MochiKit.Base.method(this, 'deferredParseValues'),
201 MochiKit.Base.method(this, 'handleParseError'),
202 this.getDom('nextActionButton')
203 );
204 break;
205 case 1: //-> 2
206 this.previewValues();
207 break;
208 case 2: //-> 3
209 this.importValues();
210 break;
211 }
212 },
213
214 //-------------------------------------------------------------------------
215
216 'deferredParseValues': function() {
217 var deferredResult;
218
219 deferredResult = new MochiKit.Async.Deferred();
220//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 1 " + res.substring(0,50)); return res;});
221 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
222//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 2 " + res.substring(0,50)); return res;});
223 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
224 this.startProcessing();
225
226 return res;
227 }, this));
228//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 3 " + res.substring(0,50)); return res;});
229 deferredResult.addCallback(MochiKit.Base.method(this, 'parseKeePassValues')); //processPasswordPlusValues
230//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 4 " + res); return res;});
231 deferredResult.addCallback(MochiKit.Base.method(this, 'setParsedValues')); //setProcessedValues
232//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 5 " + res); return res;});
233 deferredResult.addCallback(MochiKit.Base.method(this, 'showSettings')); //previewRecordValues
234//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 6 " + res); return res;});
235 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
236 this.processingDone();
237 this.getElement('step_0').hide();
238 this.getElement('step_1').show();
239 this.backButton().enable();
240
241 return res;
242 }, this));
243//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredParseValues - 7 " + res); return res;});
244 deferredResult.callback(this.textAreaContent());
245
246 return deferredResult;
247 },
248
249 //-------------------------------------------------------------------------
250
251 'deferredPreviewValues': function() {
252 var deferredResult;
253
254//MochiKit.Logging.logDebug(">>> KeePassImportComonent.deferredPreviewValues");
255 deferredResult = new MochiKit.Async.Deferred();
256//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 1 " + res); return res;});
257 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'previewImportData');
258//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 2 " + res); return res;});
259 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
260 this.startProcessing();
261
262 return res;
263 }, this));
264//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 3 " + res); return res;});
265 deferredResult.addCallback(MochiKit.Base.method(this, 'processKeePassParsedValues'));
266//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 4 " + res); return res;});
267 deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues'));
268//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 5 " + res); return res;});
269 deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues'));
270//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 6 " + res); return res;});
271 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
272 this.processingDone();
273 this.getElement('step_1').hide();
274 this.getElement('step_2').show();
275 this.backButton().enable();
276
277 return res;
278 }, this));
279//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 7 " + res); return res;});
280 // deferredResult.addErrback(MochiKit.Base.bind(function() {
281 // this.processingAborted();
282 // }, this))
283//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.deferredPreviewValues - 8 " + res); return res;});
284 deferredResult.callback(this.parsedValues());
285//MochiKit.Logging.logDebug("<<< KeePassImportComonent.deferredPreviewValues");
286
287 return deferredResult;
288 },
289
290 //-------------------------------------------------------------------------
291
292 'definedFields': function() {
293 return this._definedFields;
294 },
295
296 //-------------------------------------------------------------------------
297
298 'parseKeePassValues': function(someData) {
299 var deferredResult;
300 var keePassProcessor;
301
302 keePassProcessor = new Clipperz.KeePassExportProcessor();
303
304 deferredResult = new MochiKit.Async.Deferred();
305//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 1 " + res.substring(0,50)); return res;});
306 deferredResult.addCallback(function(res) {
307 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res);
308 })
309//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 2 " + res.substring(0,50)); return res;});
310 deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse'));
311//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassImportComponent.parseKeePassValues - 3 " + res); return res;});
312 deferredResult.callback(someData);
313
314 return deferredResult;
315 },
316
317 //-------------------------------------------------------------------------
318
319 'showSettings': function(someValues) {
320 var availableFields;
321 var i,c;
322
323//MochiKit.Logging.logDebug(">>> KeePassImportCOmponent.showSettings");
324 availableFields = new Clipperz.Set();
325 c = this.parsedValues().length;
326 for (i=0; i<c; i++) {
327 var fieldLabel;
328
329 for (fieldLabel in this.parsedValues()[i]) {
330 availableFields.add(fieldLabel);
331 }
332 }
333
334 c = this.definedFields().length;
335 for (i=0; i<c; i++) {
336 var definedField;
337
338 definedField = this.definedFields()[i];
339 if (availableFields.contains(definedField)) {
340//MochiKit.Logging.logDebug("enabling field " + definedField);
341 this.getDom(definedField + '_checkbox').disabled = false;
342 this.getElement(definedField + '_label').removeClass('disabled');
343 } else {
344//MochiKit.Logging.logDebug("disabling field " + definedField);
345 this.getDom(definedField + '_checkbox').disabled = true;
346 this.getDom(definedField + '_checkbox').checked = false; //????
347 this.getElement(definedField + '_label').addClass('disabled');
348 }
349 }
350//MochiKit.Logging.logDebug("<<< KeePassImportCOmponent.showSettings");
351
352 return MochiKit.Async.succeed(someValues);
353 },
354
355 //-------------------------------------------------------------------------
356
357 'shouldImportField': function(aFieldName) {
358 var fieldCheckbox;
359 var result;
360
361//MochiKit.Logging.logDebug(">>> shouldImportField: " + aFieldName);
362 // fieldCheckbox = this.getDom(aFieldName + '_checkbox');
363 fieldCheckbox = MochiKit.DOM.getElement(this.getId(aFieldName + '_checkbox'));
364 if (fieldCheckbox != null) {
365 result = fieldCheckbox.checked;
366 } else {
367 result = false;
368 }
369//MochiKit.Logging.logDebug("<<< shouldImportField: " + result);
370
371 return result;
372 },
373
374 //-------------------------------------------------------------------------
375
376 'processKeePassParsedValues': function(someValues) {
377 var deferredResult;
378 var records;
379 var i,c;
380
381//MochiKit.Logging.logDebug(">>> processKeePassParsedValues");
382 deferredResult = new MochiKit.Async.Deferred();
383 records = [];
384
385//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("processKeePassParsedValues - 1: " + res); return res;});
386 c = someValues.length;
387 deferredResult.addCallback(function(res) {
388 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:c}, res);
389 })
390 for(i=0; i<c; i++) {
391//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.1: " + res); return res;});
392 deferredResult.addCallback(MochiKit.Async.wait, 0.2);
393//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.2: " + res); return res;});
394 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {});
395//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.3: " + res); return res;});
396 deferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) {
397 var record;
398 var recordVersion;
399 var ii;
400
401 record = new Clipperz.PM.DataModel.Record({user:this.user()});
402 record.setLabel(someData['Title']);
403 if (this.shouldImportField('Notes')) {
404 record.setNotes(someData['Notes']);
405 }
406 recordVersion = record.currentVersion()
407
408 for (ii in someData) {
409 if ((ii != 'Title') && (ii != 'Notes') && (typeof(someData[ii]) != "undefined") && (this.shouldImportField(ii))) {
410 var recordField;
411 var recordFieldType;
412
413 recordFieldType = 'TXT';
414 if (ii == 'Password') {
415 recordFieldType = 'PWD';
416 } else if (ii == 'URL') {
417 recordFieldType = 'URL';
418 } else if ((ii == 'Creation Time') || (ii == 'Last Access') || (ii == 'Last Modification') || (ii == 'Expires')) {
419 recordFieldType = 'Date';
420 }
421
422 recordField = new Clipperz.PM.DataModel.RecordField({
423 recordVersion:recordVersion,
424 label: ii,
425 value: someData[ii],
426 type: recordFieldType
427 });
428 recordVersion.addField(recordField);
429 }
430 }
431
432 someRecords.push(record);
433
434 return someRecords;
435 }, this), records, someValues[i]);
436//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("[" + i + "] processKeePassParsedValues - 1.4: " + res); return res;});
437 }
438//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("processKeePassParsedValues - 2: " + res); return res;});
439 deferredResult.addCallback(MochiKit.Async.succeed, records);
440//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("processKeePassParsedValues - 3: " + res); return res;});
441 deferredResult.callback();
442//MochiKit.Logging.logDebug("<<< processKeePassParsedValues");
443
444 return deferredResult;
445 },
446
447 //-------------------------------------------------------------------------
448 __syntaxFix__: "syntax fix"
449});
450
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js
new file mode 100644
index 0000000..54813bc
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/MainComponent.js
@@ -0,0 +1,332 @@
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.MainComponent = function(anElement, args) {
37 args = args || {};
38
39 Clipperz.PM.Components.Import.MainComponent.superclass.constructor.call(this, anElement, args);
40
41 this._user = args.user;
42 this._wizardComponent = null;
43
44 this._backButton = null;
45 this._nextButton = null;
46
47 this._selectedComponent = null;
48
49 this.render();
50
51 return this;
52}
53
54//=============================================================================
55
56YAHOO.extendX(Clipperz.PM.Components.Import.MainComponent, Clipperz.PM.Components.BaseComponent, {
57
58 'toString': function() {
59 return "Clipperz.PM.Components.Import.MainComponent component";
60 },
61
62 //-------------------------------------------------------------------------
63
64 'user': function() {
65 return this._user;
66 },
67
68 //-------------------------------------------------------------------------
69
70 'wizardComponent': function() {
71 return this._wizardComponent;
72 },
73
74 'setWizardComponent': function(aValue) {
75 if (this._wizardComponent != null) {
76 this._wizardComponent.remove();
77 }
78
79 if (aValue != null) {
80 this.getElement('importCover').hide();
81 this.getElement('importWizard').show();
82 }
83 this._wizardComponent = aValue;
84 },
85
86 'resetImportComponent': function() {
87//MochiKit.Logging.logDebug(">>> resetImportComponent");
88 this.setWizardComponent(null);
89 this.getElement('wizardComponent').update("");
90
91 this.getElement('importCover').show();
92 this.getElement('importWizard').hide();
93//MochiKit.Logging.logDebug("<<< resetImportComponent");
94 },
95
96 //-------------------------------------------------------------------------
97
98 'backButton': function() {
99 return this._backButton;
100 },
101
102 'setBackButton': function(aValue) {
103 this._backButton = aValue;
104 },
105
106 'nextButton': function() {
107 return this._nextButton;
108 },
109
110 'setNextButton': function(aValue) {
111 this._nextButton = aValue;
112 },
113
114 //-------------------------------------------------------------------------
115
116 'render': function() {
117//MochiKit.Logging.logDebug(">>> Import.MainComponent.render");
118 Clipperz.NotificationCenter.unregister(this);
119 MochiKit.Signal.disconnectAllTo(this);
120
121 this.element().update("");
122 this.domHelper().append(this.element(), {tag:'div', id:this.getId('mainDiv'), children:[
123 {tag:'div', id:this.getId('importCover'), children:[
124 {tag:'h5', htmlString:Clipperz.PM.Strings['importTabTitle']},
125 {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['importTabDescription']},
126 {tag:'div', cls:'importFormats', children:[
127 {tag:'ul', cls:'radioList', children:[
128 {tag:'li', children:[
129 {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[
130 {tag:'td', valign:'top', children:[
131 {tag:'input', id:this.getId('CSV_radio'), type:'radio', name:'importFormat', value:'CSV'}
132 ]},
133 {tag:'td', valign:'top', children:[
134 {tag:'h4', id:this.getId('CSV_title'), htmlString:Clipperz.PM.Strings['importFormats']['CSV']['label']},
135 {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['CSV']['description']}
136 ]}
137 ]}]}]}
138 ]},
139 {tag:'li', children:[
140 {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[
141 {tag:'td', valign:'top', children:[
142 {tag:'input', id:this.getId('Excel_radio'), type:'radio', name:'importFormat', value:'EXCEL'}
143 ]},
144 {tag:'td', valign:'top', children:[
145 {tag:'h4', id:this.getId('Excel_title'), htmlString:Clipperz.PM.Strings['importFormats']['Excel']['label']},
146 {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['Excel']['description']}
147 ]}
148 ]}]}]}
149 ]},
150 {tag:'li', children:[
151 {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[
152 {tag:'td', valign:'top', children:[
153 {tag:'input', id:this.getId('KeePass_radio'), type:'radio', name:'importFormat', value:'KEEPASS'}
154 ]},
155 {tag:'td', valign:'top', children:[
156 {tag:'h4', id:this.getId('KeePass_title'), htmlString:Clipperz.PM.Strings['importFormats']['KeePass']['label']},
157 {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['KeePass']['description']}
158 ]}
159 ]}]}]}
160 ]},
161 {tag:'li', children:[
162 {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[
163 {tag:'td', valign:'top', children:[
164 {tag:'input', id:this.getId('Roboform_radio'), type:'radio', name:'importFormat', value:'ROBOFORM'}
165 ]},
166 {tag:'td', valign:'top', children:[
167 {tag:'h4', id:this.getId('Roboform_title'), htmlString:Clipperz.PM.Strings['importFormats']['Roboform']['label']},
168 {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['Roboform']['description']}
169 ]}
170 ]}]}]}
171 ]},
172 {tag:'li', children:[
173 {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[
174 {tag:'td', valign:'top', children:[
175 {tag:'input', id:this.getId('PasswordPlus_radio'), type:'radio', name:'importFormat', value:'PASSWORD_PLUS'}
176 ]},
177 {tag:'td', valign:'top', children:[
178 {tag:'h4', id:this.getId('PasswordPlus_title'), htmlString:Clipperz.PM.Strings['importFormats']['PasswordPlus']['label']},
179 {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['PasswordPlus']['description']}
180 ]}
181 ]}]}]}
182 ]},
183 {tag:'li', children:[
184 {tag:'table', children:[{tag:'tbody', children:[{tag:'tr', children:[
185 {tag:'td', valign:'top', children:[
186 {tag:'input', id:this.getId('ClipperzExport_radio'), type:'radio', name:'importFormat', value:'CLIPPERZ_EXPORT'}
187 ]},
188 {tag:'td', valign:'top', children:[
189 {tag:'h4', id:this.getId('ClipperzExport_title'), htmlString:Clipperz.PM.Strings['importFormats']['ClipperzExport']['label']},
190 {tag:'div', cls:'templateDescription', htmlString:Clipperz.PM.Strings['importFormats']['ClipperzExport']['description']}
191 ]}
192 ]}]}]}
193 ]}
194 ]},
195
196 {tag:'div', cls:'importOptionsButtons', children:[
197 {tag:'table', children:[
198 {tag:'tbody', children:[
199 {tag:'tr', children:[
200 {tag:'td', html:'&nbsp;'},
201 {tag:'td', children:[
202 {tag:'div', id:this.getId('backActionButton')}
203 ]},
204 {tag:'td', html:'&nbsp;'},
205 {tag:'td', children:[
206 {tag:'div', id:this.getId('nextActionButton')}
207 ]},
208 {tag:'td', html:'&nbsp;'}
209 ]}
210 ]}
211 ]}
212 ]}
213 ]}
214 ]},
215 {tag:'div', id:this.getId('importWizard'), children:[
216 {tag:'form', id:this.getId('importWizardForm'), children:[
217 {tag:'div', cls:'wizardComponent', id:this.getId('wizardComponent'), children:[]}
218 ]}
219 ]}
220 ]});
221
222 this.setBackButton(new YAHOO.ext.Button(this.getDom('backActionButton'), {text:"back", handler:this.backAction, scope:this}));
223 this.setNextButton(new YAHOO.ext.Button(this.getDom('nextActionButton'), {text:"next", handler:this.nextAction, scope:this}));
224
225 this.backButton().disable();
226 this.nextButton().disable();
227
228 this.getElement('importCover').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show();
229 this.getElement('importWizard').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide();
230
231 if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) {
232 this.getElement('mainDiv').addClass('read-only');
233
234 this.getDom('ClipperzExport_radio').disabled = true;
235 this.getDom('CSV_radio').disabled = true;
236 this.getDom('Excel_radio').disabled = true;
237 this.getDom('PasswordPlus_radio').disabled = true;
238 this.getDom('Roboform_radio').disabled = true;
239 this.getDom('KeePass_radio').disabled = true;
240 } else {
241 MochiKit.Signal.connect(this.getId('ClipperzExport_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent'));
242 MochiKit.Signal.connect(this.getId('CSV_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent'));
243 MochiKit.Signal.connect(this.getId('Excel_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent'));
244 MochiKit.Signal.connect(this.getId('PasswordPlus_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent'));
245 MochiKit.Signal.connect(this.getId('Roboform_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent'));
246 MochiKit.Signal.connect(this.getId('KeePass_radio'), 'onclick', MochiKit.Base.method(this, 'selectComponent'));
247
248 if (Clipperz_IEisBroken != true) {
249 MochiKit.Signal.connect(this.getId('ClipperzExport_title'), 'onclick', this.getDom('ClipperzExport_radio'), 'click');
250 MochiKit.Signal.connect(this.getId('CSV_title'), 'onclick', this.getDom('CSV_radio'), 'click');
251 MochiKit.Signal.connect(this.getId('Excel_title'), 'onclick', this.getDom('Excel_radio'), 'click');
252 MochiKit.Signal.connect(this.getId('PasswordPlus_title'), 'onclick', this.getDom('PasswordPlus_radio'), 'click');
253 MochiKit.Signal.connect(this.getId('Roboform_title'), 'onclick', this.getDom('Roboform_radio'), 'click');
254 MochiKit.Signal.connect(this.getId('KeePass_title'), 'onclick', this.getDom('KeePass_radio'), 'click');
255 }
256
257 Clipperz.NotificationCenter.register(null, 'importCompleted', this, 'resetImportComponent');
258 Clipperz.NotificationCenter.register(null, 'importCancelled', this, 'resetImportComponent');
259 }
260
261//MochiKit.Logging.logDebug("<<< Import.MainComponent.render");
262 },
263
264 //-------------------------------------------------------------------------
265/*
266 'selectedFormat': function() {
267 return this.getDom('importSelectionOptions').value;
268 },
269*/
270 //-------------------------------------------------------------------------
271
272 'updateSelectedImportWizardComponent': function(aComponent) {
273 var newWizardComponent;
274
275//MochiKit.Logging.logDebug(">>> Import.MainComponent.updateSelectedImportWizardComponent");
276 this.getElement('wizardComponent').update("");
277
278 switch(aComponent) {
279 case 'CLIPPERZ_EXPORT':
280 newWizardComponent = new Clipperz.PM.Components.Import.ClipperzImportComponent(this.getElement('wizardComponent'), {user:this.user()});
281 break;
282 case 'CSV':
283 newWizardComponent = new Clipperz.PM.Components.Import.CSVImportComponent(this.getElement('wizardComponent'), {user:this.user()});
284 break;
285 case 'EXCEL':
286 newWizardComponent = new Clipperz.PM.Components.Import.ExcelImportComponent(this.getElement('wizardComponent'), {user:this.user()});
287 break;
288 case 'PASSWORD_PLUS':
289 newWizardComponent = new Clipperz.PM.Components.Import.PasswordPlusImportComponent(this.getElement('wizardComponent'), {user:this.user()});
290 break;
291 case 'ROBOFORM':
292 newWizardComponent = new Clipperz.PM.Components.Import.RoboFormImportComponent(this.getElement('wizardComponent'), {user:this.user()});;
293 break;
294 case 'KEEPASS':
295 newWizardComponent = new Clipperz.PM.Components.Import.KeePassImportComponent(this.getElement('wizardComponent'), {user:this.user()});
296 break;
297 }
298
299 this.setWizardComponent(newWizardComponent);
300//MochiKit.Logging.logDebug("<<< Import.MainComponent.updateSelectedWizardComponent");
301 },
302
303 //-------------------------------------------------------------------------
304
305 'selectComponent': function(anEvent) {
306 this.setSelectedComponent(anEvent.src().value);
307 this.nextButton().enable();
308 },
309
310 'selectedComponent': function() {
311 return this._selectedComponent;
312 },
313
314 'setSelectedComponent': function(aValue) {
315 this._selectedComponent = aValue;
316 },
317
318 //-------------------------------------------------------------------------
319
320 'backAction': function() {
321 },
322
323 //-------------------------------------------------------------------------
324
325 'nextAction': function() {
326 this.updateSelectedImportWizardComponent(this.selectedComponent());
327 },
328
329 //-------------------------------------------------------------------------
330 __syntaxFix__: "syntax fix"
331});
332
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
diff --git a/frontend/beta/js/Clipperz/PM/Components/Import/RoboFormImportComponent.js b/frontend/beta/js/Clipperz/PM/Components/Import/RoboFormImportComponent.js
new file mode 100644
index 0000000..d35bdc6
--- a/dev/null
+++ b/frontend/beta/js/Clipperz/PM/Components/Import/RoboFormImportComponent.js
@@ -0,0 +1,392 @@
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.RoboFormImportComponent = function(anElement, args) {
37 args = args || {};
38
39 Clipperz.PM.Components.Import.RoboFormImportComponent.superclass.constructor.call(this, anElement, args);
40
41 this.render();
42
43 return this;
44}
45
46//=============================================================================
47
48YAHOO.extendX(Clipperz.PM.Components.Import.RoboFormImportComponent, Clipperz.PM.Components.Import.GenericImportComponent, {
49
50 'toString': function() {
51 return "Clipperz.PM.Components.Import.RoboFormImportComponent component";
52 },
53
54 //-------------------------------------------------------------------------
55
56 'render': function() {
57//MochiKit.Logging.logDebug(">>> Import.RoboFormImportComponent.render");
58 this.domHelper().append(this.element(), {tag:'div', cls:'roboFormImportWizard', children:[
59 {tag:'h3', htmlString:Clipperz.PM.Strings['RoboForm_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_roboForm_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.RoboFormImportComponent.render");
108 },
109
110 //-------------------------------------------------------------------------
111
112 'nextAction': function() {
113 switch (this.currentStep()) {
114 case 0: //-> 1
115 this.previewValues();
116 break;
117 case 1: //-> 2
118 this.importValues();
119 break;
120 }
121 },
122
123 //-------------------------------------------------------------------------
124
125 'deferredPreviewValues': function() {
126 var deferredResult;
127
128 // this.setFormValues(MochiKit.DOM.formContents(this.getDom('dataForm')));
129
130 deferredResult = new MochiKit.Async.Deferred();
131 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
132 this.startProcessing();
133
134 return res;
135 }, this));
136 deferredResult.addCallback(MochiKit.Base.method(this, 'processRoboFormValues'));
137 deferredResult.addCallback(MochiKit.Base.method(this, 'setProcessedValues'));
138 deferredResult.addCallback(MochiKit.Base.method(this, 'previewRecordValues'));
139 deferredResult.addCallback(MochiKit.Base.bind(function(res) {
140 this.processingDone();
141 this.getElement('step_0').hide();
142 this.getElement('step_1').show();
143 this.backButton().enable();
144
145 return res;
146 }, this));
147 // deferredResult.addErrback(MochiKit.Base.bind(function() {
148 // this.processingAborted();
149 // }, this))
150 deferredResult.callback(this.textAreaContent());
151
152 return deferredResult;
153 },
154
155 //-------------------------------------------------------------------------
156
157 'processRoboFormValues': function(someData) {
158 var result;
159
160 if (someData.match(/^\<HTML\>\<HEAD\>\<TITLE\>RoboForm Passcards List /g)) {
161 result = this.processRoboFormPasscardsValues(someData);
162 } else if (someData.match(/\<HTML\>\<HEAD\>\<TITLE\>RoboForm Safenotes List /g)) {
163 result = this.processRoboFormSafenotesValues(someData);
164 }
165
166 return result;
167 },
168
169 //.........................................................................
170
171 'processRoboFormPasscardsValues': function(someData) {
172 var deferredResult;
173
174 deferredResult = new MochiKit.Async.Deferred();
175//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 1: "/* + res*/); return res;});
176 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
177//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 2: "/* + res*/); return res;});
178 deferredResult.addCallback(function(someData) {
179 var result;
180 var data;
181
182 data = someData.replace(/\r?\n/g, "");
183 result = data.match(/\<TABLE width\=\"100\%\"\>.*?\<\/TABLE\>/g);
184
185 return result;
186 });
187//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3: "/* + res*/); return res;});
188//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3.1: " + res.length); return res;});
189 deferredResult.addCallback(function(res) {
190 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res);
191 })
192//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 4: "/* + res*/); return res;});
193 deferredResult.addCallback(MochiKit.Base.bind(function(someRecordValues) {
194 var innerDeferredResult;
195 var records;
196 var i,c;
197
198 innerDeferredResult = new MochiKit.Async.Deferred();
199 records = [];
200
201 c = someRecordValues.length;
202 for(i=0; i<c; i++) {
203//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 1: " + res); return res;});
204 innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2);
205//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 2: " + res); return res;});
206 innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {});
207//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 3: " + res); return res;});
208 innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) {
209 var data;
210 var record;
211 var recordVersion;
212 var fields;
213 var ii, cc;
214 var hasNotes;
215
216 var caption;
217 var subcaption;
218
219//MochiKit.Logging.logDebug("data: " + someData);
220 data = someData.replace(/\<WBR\>/g, "");
221 hasNotes = false;
222
223 /\<TD class\=caption colSpan\=3\>(.*?)\<\/TD\>/.test(data); //<TD class=caption colSpan=3>110mb</TD>
224 caption = RegExp.$1;
225//MochiKit.Logging.logDebug("caption: " + caption);
226
227 /\<TD class\=subcaption colSpan\=3\>(.*?)\<\/TD\>/.test(data); //<TD class=subcaption colSpan=3>110<WBR>mb.com</TD>
228 subcaption = RegExp.$1;
229//MochiKit.Logging.logDebug("subcaption: " + subcaption);
230
231 record = new Clipperz.PM.DataModel.Record({user:this.user()});
232 recordVersion = record.currentVersion()
233
234 record.setLabel(caption);
235 // record.setNotes(subcaption);
236 if (subcaption != null) {
237 var recordField;
238
239 recordField = new Clipperz.PM.DataModel.RecordField({
240 recordVersion:recordVersion,
241 label: "url",
242 value: subcaption,
243 type: 'URL'
244 });
245 recordVersion.addField(recordField);
246 }
247
248 fields = data.match(/\<TR\>.*?\<\/TR\>/g) || [];
249 cc = fields.length;
250//MochiKit.Logging.logDebug("fields.length: " + cc);
251 for (ii=0; ii<cc; ii++) {
252 var recordField;
253 var fieldString;
254 var fieldName;
255 var fieldValue;
256
257//MochiKit.Logging.logDebug("fieldString: " + fields[ii]);
258 fieldString = fields[ii];
259//MochiKit.Logging.logDebug("fieldString (cleaned): " + fieldString);
260 /\<TD class\=field vAlign\=top align\=left width\=\"40\%\"\>(.*?)\<\/TD\>/.test(fieldString);
261 fieldName = RegExp.$1;
262
263 /\<TD class\=wordbreakfield vAlign\=top align\=left width\=\"55\%\"\>(.*?)\<\/TD\>/.test(fieldString);
264 fieldValue = RegExp.$1;
265
266 if (fieldName == "Note$") {
267 record.setNotes(fieldValue);
268 hasNotes = true;
269 } else {
270 var fieldType;
271
272 if (((ii == 1) && (hasNotes == false)) || ((ii == 2) && (hasNotes == true))) {
273 fieldType = 'PWD';
274 } else {
275 fieldType = 'TXT';
276 }
277
278 recordField = new Clipperz.PM.DataModel.RecordField({
279 recordVersion:recordVersion,
280 label: fieldName,
281 value: fieldValue,
282 type: fieldType
283 });
284 recordVersion.addField(recordField);
285 }
286 }
287
288 someRecords.push(record);
289
290 return someRecords;
291 }, this), records, someRecordValues[i]);
292 }
293//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 4: " + res); return res;});
294 innerDeferredResult.addCallback(MochiKit.Async.succeed, records);
295//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 5: " + res); return res;});
296 innerDeferredResult.callback();
297
298 return innerDeferredResult;
299 }, this));
300 deferredResult.callback(someData);
301
302 return deferredResult;
303 },
304
305
306 //.........................................................................
307
308 'processRoboFormSafenotesValues': function(someData) {
309 var deferredResult;
310
311 deferredResult = new MochiKit.Async.Deferred();
312//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 1: "/* + res*/); return res;});
313 deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'parseImportData');
314//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 2: "/* + res*/); return res;});
315 deferredResult.addCallback(function(someData) {
316 var result;
317 var data;
318
319 data = someData.replace(/\r?\n/g, "");
320 result = data.match(/\<TABLE width\=\"100\%\"\>.*?\<\/TABLE\>/g);
321
322 return result;
323 });
324//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3: "/* + res*/); return res;});
325//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 3.1: " + res.length); return res;});
326 deferredResult.addCallback(function(res) {
327 return Clipperz.NotificationCenter.deferredNotification(this, 'updatedProgressState', {steps:(res.length)}, res);
328 })
329//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues - 4: "/* + res*/); return res;});
330 deferredResult.addCallback(MochiKit.Base.bind(function(someRecordValues) {
331 var innerDeferredResult;
332 var records;
333 var i,c;
334
335 innerDeferredResult = new MochiKit.Async.Deferred();
336 records = [];
337
338 c = someRecordValues.length;
339 for(i=0; i<c; i++) {
340//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 1: " + res); return res;});
341 innerDeferredResult.addCallback(MochiKit.Async.wait, 0.2);
342//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 2: " + res); return res;});
343 innerDeferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {});
344//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 3: " + res); return res;});
345 innerDeferredResult.addCallback(MochiKit.Base.bind(function(someRecords, someData) {
346 var data;
347 var record;
348 var recordVersion;
349
350 var caption;
351 var wordbreakfield;
352
353//MochiKit.Logging.logDebug("data: " + someData);
354 data = someData.replace(/\<WBR\>/g, "");
355 hasNotes = false;
356
357 /\<TD class\=caption colSpan\=3\>(.*?)\<\/TD\>/.test(data); //<TD class=caption colSpan=3>110mb</TD>
358 caption = RegExp.$1;
359//MochiKit.Logging.logDebug("caption: " + caption);
360
361 /\<TD class\=wordbreakfield vAlign=top align\=left width\=\"\1\0\0\%\"\>(.*?)\<\/TD\>/.test(data); //<TD class=wordbreakfield vAlign=top align=left width="100%">7759500</TD>
362 wordbreakfield = RegExp.$1;
363//MochiKit.Logging.logDebug("subcaption: " + subcaption);
364
365 record = new Clipperz.PM.DataModel.Record({user:this.user()});
366 recordVersion = record.currentVersion()
367
368 record.setLabel(caption);
369 record.setNotes(wordbreakfield);
370
371 someRecords.push(record);
372
373 return someRecords;
374 }, this), records, someRecordValues[i]);
375 }
376//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 4: " + res); return res;});
377 innerDeferredResult.addCallback(MochiKit.Async.succeed, records);
378//innerDeferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("RoboFormImportComponent.processRoboFormValues __inner loop__ - 5: " + res); return res;});
379 innerDeferredResult.callback();
380
381 return innerDeferredResult;
382 }, this));
383 deferredResult.callback(someData);
384
385 return deferredResult;
386 },
387
388
389 //-------------------------------------------------------------------------
390 __syntaxFix__: "syntax fix"
391});
392