Diffstat (limited to 'frontend/gamma/js/Clipperz/KeePassExportProcessor.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/KeePassExportProcessor.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/gamma/js/Clipperz/KeePassExportProcessor.js b/frontend/gamma/js/Clipperz/KeePassExportProcessor.js index a3c10c8..e35d729 100644 --- a/frontend/gamma/js/Clipperz/KeePassExportProcessor.js +++ b/frontend/gamma/js/Clipperz/KeePassExportProcessor.js | |||
@@ -1,118 +1,116 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | 25 | ||
28 | 26 | ||
29 | Clipperz.KeePassExportProcessor = function(args) { | 27 | Clipperz.KeePassExportProcessor = function(args) { |
30 | args = args || {}; | 28 | args = args || {}; |
31 | 29 | ||
32 | return this; | 30 | return this; |
33 | } | 31 | } |
34 | 32 | ||
35 | //============================================================================= | 33 | //============================================================================= |
36 | 34 | ||
37 | Clipperz.KeePassExportProcessor.prototype = MochiKit.Base.update(null, { | 35 | Clipperz.KeePassExportProcessor.prototype = MochiKit.Base.update(null, { |
38 | 36 | ||
39 | //------------------------------------------------------------------------- | 37 | //------------------------------------------------------------------------- |
40 | 38 | ||
41 | 'deferredParse_core': function(aContext) { | 39 | 'deferredParse_core': function(aContext) { |
42 | var deferredResult; | 40 | var deferredResult; |
43 | 41 | ||
44 | if (aContext.line == "") { | 42 | if (aContext.line == "") { |
45 | deferredResult = MochiKit.Async.succeed(aContext.result); | 43 | deferredResult = MochiKit.Async.succeed(aContext.result); |
46 | } else { | 44 | } else { |
47 | var record; | 45 | var record; |
48 | 46 | ||
49 | record = this.parseRecord(aContext); | 47 | record = this.parseRecord(aContext); |
50 | if (record != null) { | 48 | if (record != null) { |
51 | aContext.result.push(record); | 49 | aContext.result.push(record); |
52 | } | 50 | } |
53 | 51 | ||
54 | aContext.line = aContext.line.replace(/^\n*/g, "").replace(/\n$/g, ""); | 52 | aContext.line = aContext.line.replace(/^\n*/g, "").replace(/\n$/g, ""); |
55 | 53 | ||
56 | deferredResult = new Clipperz.Async.Deferred("KeePassExportProcessor.deferredParse_core"); | 54 | deferredResult = new Clipperz.Async.Deferred("KeePassExportProcessor.deferredParse_core"); |
57 | deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)}); | 55 | deferredResult.addCallbackPass(MochiKit.Signal.signal, this, 'importProcessorProgressUpdate', {status:'processing', size:aContext.size, progress:(aContext.size - aContext.line.length)}); |
58 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); | 56 | deferredResult.addCallback(MochiKit.Async.wait, 0.2); |
59 | deferredResult.addMethod(this, 'deferredParse_core'); | 57 | deferredResult.addMethod(this, 'deferredParse_core'); |
60 | deferredResult.callback(aContext); | 58 | deferredResult.callback(aContext); |
61 | } | 59 | } |
62 | 60 | ||
63 | return deferredResult; | 61 | return deferredResult; |
64 | }, | 62 | }, |
65 | 63 | ||
66 | //......................................................................... | 64 | //......................................................................... |
67 | 65 | ||
68 | 'deferredParse': function(aValue) { | 66 | 'deferredParse': function(aValue) { |
69 | var deferredResult; | 67 | var deferredResult; |
70 | var lines; | 68 | var lines; |
71 | var context; | 69 | var context; |
72 | 70 | ||
73 | lines = aValue.replace(/\r?\n/g, "\n"); | 71 | lines = aValue.replace(/\r?\n/g, "\n"); |
74 | context = { | 72 | context = { |
75 | line: lines, | 73 | line: lines, |
76 | size: lines.length, | 74 | size: lines.length, |
77 | result: [] | 75 | result: [] |
78 | } | 76 | } |
79 | 77 | ||
80 | deferredResult = new Clipperz.Async.Deferred("KeePassExportProcessor.deferredResult"); | 78 | deferredResult = new Clipperz.Async.Deferred("KeePassExportProcessor.deferredResult"); |
81 | deferredResult.addMethod(this, 'deferredParse_core'); | 79 | deferredResult.addMethod(this, 'deferredParse_core'); |
82 | deferredResult.callback(context); | 80 | deferredResult.callback(context); |
83 | 81 | ||
84 | return deferredResult; | 82 | return deferredResult; |
85 | }, | 83 | }, |
86 | 84 | ||
87 | //------------------------------------------------------------------------- | 85 | //------------------------------------------------------------------------- |
88 | 86 | ||
89 | 'parseRecord': function(aContext) { | 87 | 'parseRecord': function(aContext) { |
90 | var result; | 88 | var result; |
91 | var recordLabelRegexp; | 89 | var recordLabelRegexp; |
92 | varfieldLabelRegexp; | 90 | varfieldLabelRegexp; |
93 | var fieldValueRegexp; | 91 | var fieldValueRegexp; |
94 | var fullLineRegexp; | 92 | var fullLineRegexp; |
95 | /* | 93 | /* |
96 | [Record name] | 94 | [Record name] |
97 | Group Tree: | 95 | Group Tree: |
98 | UserName: | 96 | UserName: |
99 | URL: | 97 | URL: |
100 | Password: | 98 | Password: |
101 | Notes: test | 99 | Notes: test |
102 | UUID: 525f62430079bae48b79ed2961924b05 | 100 | UUID: 525f62430079bae48b79ed2961924b05 |
103 | Icon: 0 | 101 | Icon: 0 |
104 | Creation Time: 2007-06-26 17:56:03 | 102 | Creation Time: 2007-06-26 17:56:03 |
105 | Last Access: 2007-10-25 16:23:51 | 103 | Last Access: 2007-10-25 16:23:51 |
106 | Last Modification: 2007-10-25 16:23:51 | 104 | Last Modification: 2007-10-25 16:23:51 |
107 | Expires: 2999-12-28 23:59:59 | 105 | Expires: 2999-12-28 23:59:59 |
108 | 106 | ||
109 | [Record name] ==> Title | 107 | [Record name] ==> Title |
110 | Group: General ==> Group | 108 | Group: General ==> Group |
111 | Group Tree: ==> Group Tree | 109 | Group Tree: ==> Group Tree |
112 | UserName: ==> UserName | 110 | UserName: ==> UserName |
113 | URL: ==>URL | 111 | URL: ==>URL |
114 | Password: ==>Password | 112 | Password: ==>Password |
115 | Notes: test ==>Notes | 113 | Notes: test ==>Notes |
116 | UUID: 525f62430079bae48b79ed2961924b05 ==>UUID | 114 | UUID: 525f62430079bae48b79ed2961924b05 ==>UUID |
117 | Icon: 0 ==>Icon | 115 | Icon: 0 ==>Icon |
118 | Creation Time: 2007-06-26 17:56:03 ==>Creation Time | 116 | Creation Time: 2007-06-26 17:56:03 ==>Creation Time |