Diffstat (limited to 'frontend/beta/js/Clipperz/KeePassExportProcessor.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/KeePassExportProcessor.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/KeePassExportProcessor.js b/frontend/beta/js/Clipperz/KeePassExportProcessor.js index ba56b8e..74d36ca 100644 --- a/frontend/beta/js/Clipperz/KeePassExportProcessor.js +++ b/frontend/beta/js/Clipperz/KeePassExportProcessor.js | |||
@@ -1,120 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | 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 | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
30 | 27 | ||
31 | 28 | ||
32 | Clipperz.KeePassExportProcessor = function(args) { | 29 | Clipperz.KeePassExportProcessor = function(args) { |
33 | args = args || {}; | 30 | args = args || {}; |
34 | 31 | ||
35 | return this; | 32 | return this; |
36 | } | 33 | } |
37 | 34 | ||
38 | //============================================================================= | 35 | //============================================================================= |
39 | 36 | ||
40 | Clipperz.KeePassExportProcessor.prototype = MochiKit.Base.update(null, { | 37 | Clipperz.KeePassExportProcessor.prototype = MochiKit.Base.update(null, { |
41 | 38 | ||
42 | //------------------------------------------------------------------------- | 39 | //------------------------------------------------------------------------- |
43 | /* | 40 | /* |
44 | 'parse': function(aValue) { | 41 | 'parse': function(aValue) { |
45 | var result; | 42 | var result; |
46 | 43 | ||
47 | //MochiKit.Logging.logDebug(">>> KeePassExportProcessor.parse"); | 44 | //MochiKit.Logging.logDebug(">>> KeePassExportProcessor.parse"); |
48 | result = []; | 45 | result = []; |
49 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.parse - result: " + Clipperz.Base.serializeJSON(result)); | 46 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.parse - result: " + Clipperz.Base.serializeJSON(result)); |
50 | //MochiKit.Logging.logDebug("<<< KeePassExportProcessor.parse"); | 47 | //MochiKit.Logging.logDebug("<<< KeePassExportProcessor.parse"); |
51 | 48 | ||
52 | return result; | 49 | return result; |
53 | }, | 50 | }, |
54 | */ | 51 | */ |
55 | //------------------------------------------------------------------------- | 52 | //------------------------------------------------------------------------- |
56 | 53 | ||
57 | 'deferredParse_core': function(aContext) { | 54 | 'deferredParse_core': function(aContext) { |
58 | var deferredResult; | 55 | var deferredResult; |
59 | 56 | ||
60 | //MochiKit.Logging.logDebug(">>> KeePassExportProcessor.deferredParse_core"); | 57 | //MochiKit.Logging.logDebug(">>> KeePassExportProcessor.deferredParse_core"); |
61 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - (1) aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); | 58 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - (1) aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); |
62 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - aContext: " + Clipperz.Base.serializeJSON(aContext).substring(0,50)); | 59 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - aContext: " + Clipperz.Base.serializeJSON(aContext).substring(0,50)); |
63 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - (2) aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); | 60 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - (2) aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); |
64 | //console.log("deferredParse_core - aContext", aContext); | 61 | //console.log("deferredParse_core - aContext", aContext); |
65 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - (3) aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); | 62 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse_core - (3) aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); |
66 | if (aContext.line == "") { | 63 | if (aContext.line == "") { |
67 | deferredResult = MochiKit.Async.succeed(aContext.result); | 64 | deferredResult = MochiKit.Async.succeed(aContext.result); |
68 | } else { | 65 | } else { |
69 | var record; | 66 | var record; |
70 | 67 | ||
71 | record = this.parseRecord(aContext); | 68 | record = this.parseRecord(aContext); |
72 | if (record != null) { | 69 | if (record != null) { |
73 | aContext.result.push(record); | 70 | aContext.result.push(record); |
74 | } | 71 | } |
75 | 72 | ||
76 | //MochiKit.Logging.logDebug("--> KeePassExportProcessor.deferredParse_core - aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); | 73 | //MochiKit.Logging.logDebug("--> KeePassExportProcessor.deferredParse_core - aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); |
77 | aContext.line = aContext.line.replace(/^\n*/g, "").replace(/\n$/g, ""); | 74 | aContext.line = aContext.line.replace(/^\n*/g, "").replace(/\n$/g, ""); |
78 | //MochiKit.Logging.logDebug("<-- KeePassExportProcessor.deferredParse_core - aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); | 75 | //MochiKit.Logging.logDebug("<-- KeePassExportProcessor.deferredParse_core - aContext.line: " + aContext.line.replace(/\n/g, "\\n").substring(0,50)); |
79 | 76 | ||
80 | deferredResult = new MochiKit.Async.Deferred(); | 77 | deferredResult = new MochiKit.Async.Deferred(); |
81 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.1 " + res); return res;}); | 78 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.1 " + res); return res;}); |
82 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)}); | 79 | deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)}); |
83 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.2 " + res); return res;}); | 80 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.2 " + res); return res;}); |
84 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); | 81 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); |
85 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.3 " + res); return res;}); | 82 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.3 " + res); return res;}); |
86 | //deferredResult.addBoth(function(res) {console.log("KeePassExportProcessor.deferredParse_core - 1.3 ", res); return res;}); | 83 | //deferredResult.addBoth(function(res) {console.log("KeePassExportProcessor.deferredParse_core - 1.3 ", res); return res;}); |
87 | deferredResult.addCallback(MochiKit.Base.method(this, 'deferredParse_core')) | 84 | deferredResult.addCallback(MochiKit.Base.method(this, 'deferredParse_core')) |
88 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.4 " + res); return res;}); | 85 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse_core - 1.4 " + res); return res;}); |
89 | deferredResult.callback(aContext); | 86 | deferredResult.callback(aContext); |
90 | } | 87 | } |
91 | //MochiKit.Logging.logDebug("<<< KeePassExportProcessor.deferredParse_core"); | 88 | //MochiKit.Logging.logDebug("<<< KeePassExportProcessor.deferredParse_core"); |
92 | 89 | ||
93 | return deferredResult; | 90 | return deferredResult; |
94 | }, | 91 | }, |
95 | 92 | ||
96 | //......................................................................... | 93 | //......................................................................... |
97 | 94 | ||
98 | 'deferredParse': function(aValue) { | 95 | 'deferredParse': function(aValue) { |
99 | var deferredResult; | 96 | var deferredResult; |
100 | var lines; | 97 | var lines; |
101 | var context; | 98 | var context; |
102 | 99 | ||
103 | //MochiKit.Logging.logDebug(">>> KeePassExportProcessor.deferredParse"); | 100 | //MochiKit.Logging.logDebug(">>> KeePassExportProcessor.deferredParse"); |
104 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse - aValue: " + aValue.length); | 101 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse - aValue: " + aValue.length); |
105 | lines = aValue.replace(/\r?\n/g, "\n"); | 102 | lines = aValue.replace(/\r?\n/g, "\n"); |
106 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse - lines: " + lines.length); | 103 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse - lines: " + lines.length); |
107 | context = { | 104 | context = { |
108 | line: lines, | 105 | line: lines, |
109 | size: lines.length, | 106 | size: lines.length, |
110 | result: [] | 107 | result: [] |
111 | } | 108 | } |
112 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse - context: " + Clipperz.Base.serializeJSON(context).substring(0,50)); | 109 | //MochiKit.Logging.logDebug("--- KeePassExportProcessor.deferredParse - context: " + Clipperz.Base.serializeJSON(context).substring(0,50)); |
113 | //console.log("--- KeePassExportProcessor.deferredParse - context: ", context); | 110 | //console.log("--- KeePassExportProcessor.deferredParse - context: ", context); |
114 | 111 | ||
115 | deferredResult = new MochiKit.Async.Deferred(); | 112 | deferredResult = new MochiKit.Async.Deferred(); |
116 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse - 1 " + res); return res;}); | 113 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse - 1 " + res); return res;}); |
117 | //deferredResult.addBoth(function(res) {console.log("KeePassExportProcessor.deferredParse - 1 ", res); return res;}); | 114 | //deferredResult.addBoth(function(res) {console.log("KeePassExportProcessor.deferredParse - 1 ", res); return res;}); |
118 | deferredResult.addCallback(MochiKit.Base.method(this, 'deferredParse_core')); | 115 | deferredResult.addCallback(MochiKit.Base.method(this, 'deferredParse_core')); |
119 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse - 2 " + res); return res;}); | 116 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("KeePassExportProcessor.deferredParse - 2 " + res); return res;}); |
120 | deferredResult.callback(context); | 117 | deferredResult.callback(context); |