Diffstat (limited to 'frontend/beta/js/Clipperz/PM/BookmarkletProcessor.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/BookmarkletProcessor.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/frontend/beta/js/Clipperz/PM/BookmarkletProcessor.js b/frontend/beta/js/Clipperz/PM/BookmarkletProcessor.js index 2295d3f..369b9ce 100644 --- a/frontend/beta/js/Clipperz/PM/BookmarkletProcessor.js +++ b/frontend/beta/js/Clipperz/PM/BookmarkletProcessor.js | |||
@@ -45,193 +45,193 @@ Clipperz.PM.BookmarkletProcessor.versions['abstract'].prototype = MochiKit.Base. | |||
45 | return "BookmarkletProcessor - " + this.user(); | 45 | return "BookmarkletProcessor - " + this.user(); |
46 | }, | 46 | }, |
47 | 47 | ||
48 | //------------------------------------------------------------------------- | 48 | //------------------------------------------------------------------------- |
49 | 49 | ||
50 | 'user': function() { | 50 | 'user': function() { |
51 | return this._user; | 51 | return this._user; |
52 | }, | 52 | }, |
53 | 53 | ||
54 | //------------------------------------------------------------------------- | 54 | //------------------------------------------------------------------------- |
55 | 55 | ||
56 | 'configuration': function() { | 56 | 'configuration': function() { |
57 | return this._configuration; | 57 | return this._configuration; |
58 | }, | 58 | }, |
59 | 59 | ||
60 | //------------------------------------------------------------------------- | 60 | //------------------------------------------------------------------------- |
61 | 61 | ||
62 | 'record': function() { | 62 | 'record': function() { |
63 | throw Clipperz.Base.exception.AbstractMethod; | 63 | throw Clipperz.Base.exception.AbstractMethod; |
64 | }, | 64 | }, |
65 | 65 | ||
66 | //------------------------------------------------------------------------- | 66 | //------------------------------------------------------------------------- |
67 | __syntaxFix__: "syntax fix" | 67 | __syntaxFix__: "syntax fix" |
68 | }); | 68 | }); |
69 | */ | 69 | */ |
70 | 70 | ||
71 | Clipperz.PM.BookmarkletProcessor = function(anUser, aConfiguration) { | 71 | Clipperz.PM.BookmarkletProcessor = function(anUser, aConfiguration) { |
72 | this._user = anUser; | 72 | this._user = anUser; |
73 | this._configuration = aConfiguration; | 73 | this._configuration = aConfiguration; |
74 | 74 | ||
75 | this._recordTitle = null; | 75 | this._recordTitle = null; |
76 | this._record = null; | 76 | this._record = null; |
77 | this._editableFields = null; | 77 | this._editableFields = null; |
78 | this._favicon = null; | 78 | this._favicon = null; |
79 | 79 | ||
80 | return this; | 80 | return this; |
81 | } | 81 | } |
82 | 82 | ||
83 | Clipperz.PM.BookmarkletProcessor.prototype = MochiKit.Base.update(null, { | 83 | Clipperz.PM.BookmarkletProcessor.prototype = MochiKit.Base.update(null, { |
84 | 84 | ||
85 | 'toString': function() { | 85 | 'toString': function() { |
86 | return "BookmarkletProcessor - " + this.user(); | 86 | return "BookmarkletProcessor - " + this.user(); |
87 | }, | 87 | }, |
88 | 88 | ||
89 | //------------------------------------------------------------------------- | 89 | //------------------------------------------------------------------------- |
90 | 90 | ||
91 | 'user': function() { | 91 | 'user': function() { |
92 | return this._user; | 92 | return this._user; |
93 | }, | 93 | }, |
94 | 94 | ||
95 | //------------------------------------------------------------------------- | 95 | //------------------------------------------------------------------------- |
96 | 96 | ||
97 | 'configuration': function() { | 97 | 'configuration': function() { |
98 | return this._configuration; | 98 | return this._configuration; |
99 | }, | 99 | }, |
100 | 100 | ||
101 | //------------------------------------------------------------------------- | 101 | //------------------------------------------------------------------------- |
102 | 102 | ||
103 | 'recordTitle': function() { | 103 | 'recordTitle': function() { |
104 | if (this._recordTitle == null) { | 104 | if (this._recordTitle == null) { |
105 | this._recordTitle = this.configuration().page.title; | 105 | this._recordTitle = this.configuration().page.title; |
106 | } | 106 | } |
107 | 107 | ||
108 | return this._recordTitle; | 108 | return this._recordTitle; |
109 | }, | 109 | }, |
110 | 110 | ||
111 | //------------------------------------------------------------------------- | 111 | //------------------------------------------------------------------------- |
112 | 112 | ||
113 | 'fields': function() { | 113 | 'fields': function() { |
114 | return this.configuration().form.inputs; | 114 | return this.configuration().form.inputs; |
115 | }, | 115 | }, |
116 | 116 | ||
117 | //------------------------------------------------------------------------- | 117 | //------------------------------------------------------------------------- |
118 | 118 | ||
119 | 'editableFields': function() { | 119 | 'editableFields': function() { |
120 | if (this._editableFields == null) { | 120 | if (this._editableFields == null) { |
121 | this._editableFields = MochiKit.Base.filter(function(aField) { | 121 | this._editableFields = MochiKit.Base.filter(function(aField) { |
122 | var result; | 122 | var result; |
123 | var type; | 123 | var type; |
124 | 124 | ||
125 | type = aField['type'].toLowerCase(); | 125 | type = aField['type'].toLowerCase(); |
126 | result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); | 126 | result = ((type != 'hidden') && (type != 'submit') && (type != 'checkbox') && (type != 'radio') && (type != 'select')); |
127 | 127 | ||
128 | return result; | 128 | return result; |
129 | }, this.fields()) | 129 | }, this.fields()) |
130 | } | 130 | } |
131 | 131 | ||
132 | return this._editableFields; | 132 | return this._editableFields; |
133 | }, | 133 | }, |
134 | 134 | ||
135 | //------------------------------------------------------------------------- | 135 | //------------------------------------------------------------------------- |
136 | 136 | ||
137 | 'hostname': function() { | 137 | 'hostname': function() { |
138 | if (this._hostname == null) { | 138 | if (this._hostname == null) { |
139 | var actionUrl; | 139 | var actionUrl; |
140 | 140 | ||
141 | actionUrl = this.configuration()['form']['attributes']['action']; | 141 | actionUrl = Clipperz.Base.sanitizeUrl(this.configuration()['form']['attributes']['action']); |
142 | //MochiKit.Logging.logDebug("+++ actionUrl: " + actionUrl); | 142 | //MochiKit.Logging.logDebug("+++ actionUrl: " + actionUrl); |
143 | this._hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); | 143 | this._hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1'); |
144 | } | 144 | } |
145 | 145 | ||
146 | return this._hostname; | 146 | return this._hostname; |
147 | }, | 147 | }, |
148 | 148 | ||
149 | 'favicon': function() { | 149 | 'favicon': function() { |
150 | if (this._favicon == null) { | 150 | if (this._favicon == null) { |
151 | this._favicon = "http://" + this.hostname() + "/favicon.ico"; | 151 | this._favicon = "http://" + this.hostname() + "/favicon.ico"; |
152 | //MochiKit.Logging.logDebug("+++ favicon: " + this._favicon); | 152 | //MochiKit.Logging.logDebug("+++ favicon: " + this._favicon); |
153 | } | 153 | } |
154 | 154 | ||
155 | return this._favicon; | 155 | return this._favicon; |
156 | }, | 156 | }, |
157 | 157 | ||
158 | //------------------------------------------------------------------------- | 158 | //------------------------------------------------------------------------- |
159 | 159 | ||
160 | 'record': function() { | 160 | 'record': function() { |
161 | if (this._record == null) { | 161 | if (this._record == null) { |
162 | var record; | 162 | var record; |
163 | var recordVersion; | 163 | var recordVersion; |
164 | var directLogin; | 164 | var directLogin; |
165 | var bindings; | 165 | var bindings; |
166 | var i,c; | 166 | var i,c; |
167 | 167 | ||
168 | record = new Clipperz.PM.DataModel.Record({ | 168 | record = new Clipperz.PM.DataModel.Record({ |
169 | label:this.recordTitle(), | 169 | label:this.recordTitle(), |
170 | notes:"", | 170 | notes:"", |
171 | user:this.user() | 171 | user:this.user() |
172 | }); | 172 | }); |
173 | recordVersion = new Clipperz.PM.DataModel.RecordVersion(record, {}) | 173 | recordVersion = new Clipperz.PM.DataModel.RecordVersion(record, {}) |
174 | record.setCurrentVersion(recordVersion); | 174 | record.setCurrentVersion(recordVersion); |
175 | 175 | ||
176 | bindings = {}; | 176 | bindings = {}; |
177 | 177 | ||
178 | c = this.editableFields().length; | 178 | c = this.editableFields().length; |
179 | for (i=0; i<c; i++) { | 179 | for (i=0; i<c; i++) { |
180 | var formField; | 180 | var formField; |
181 | var recordField; | 181 | var recordField; |
182 | 182 | ||
183 | //MochiKit.Logging.logDebug(">>> adding a field"); | 183 | //MochiKit.Logging.logDebug(">>> adding a field"); |
184 | formField = this.editableFields()[i]; | 184 | formField = this.editableFields()[i]; |
185 | recordField = new Clipperz.PM.DataModel.RecordField({ | 185 | recordField = new Clipperz.PM.DataModel.RecordField({ |
186 | recordVersion:recordVersion, | 186 | recordVersion:recordVersion, |
187 | label:formField['name'], | 187 | label:formField['name'], |
188 | value:formField['value'], | 188 | value:formField['value'], |
189 | type:Clipperz.PM.Strings.inputTypeToRecordFieldType[formField['type']], | 189 | type:Clipperz.PM.Strings.inputTypeToRecordFieldType[formField['type']], |
190 | hidden:false | 190 | hidden:false |
191 | }); | 191 | }); |
192 | recordVersion.addField(recordField); | 192 | recordVersion.addField(recordField); |
193 | 193 | ||
194 | bindings[formField['name']] = recordField.key(); | 194 | bindings[formField['name']] = recordField.key(); |
195 | //MochiKit.Logging.logDebug("<<< adding a field"); | 195 | //MochiKit.Logging.logDebug("<<< adding a field"); |
196 | } | 196 | } |
197 | 197 | ||
198 | directLogin = new Clipperz.PM.DataModel.DirectLogin({ | 198 | directLogin = new Clipperz.PM.DataModel.DirectLogin({ |
199 | record:record, | 199 | record:record, |
200 | label:this.recordTitle() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], | 200 | label:this.recordTitle() + Clipperz.PM.Strings['newDirectLoginLabelSuffix'], |
201 | // bookmarkletVersion:this.version(), | 201 | // bookmarkletVersion:this.version(), |
202 | bookmarkletVersion:'0.2', | 202 | bookmarkletVersion:'0.2', |
203 | favicon:this.favicon(), | 203 | favicon:this.favicon(), |
204 | formData:this.configuration()['form'], | 204 | formData:this.configuration()['form'], |
205 | bindingData:bindings | 205 | bindingData:bindings |
206 | }); | 206 | }); |
207 | record.addDirectLogin(directLogin); | 207 | record.addDirectLogin(directLogin); |
208 | 208 | ||
209 | this.user().addRecord(record); | 209 | this.user().addRecord(record); |
210 | 210 | ||
211 | this._record = record; | 211 | this._record = record; |
212 | } | 212 | } |
213 | 213 | ||
214 | return this._record; | 214 | return this._record; |
215 | }, | 215 | }, |
216 | 216 | ||
217 | //------------------------------------------------------------------------- | 217 | //------------------------------------------------------------------------- |
218 | __syntaxFix__: "syntax fix" | 218 | __syntaxFix__: "syntax fix" |
219 | }); | 219 | }); |
220 | 220 | ||
221 | //############################################################################# | 221 | //############################################################################# |
222 | 222 | ||
223 | Clipperz.PM.BookmarkletProcessor.createRecordFromBookmarkletConfiguration = function(anUser, aConfiguration) { | 223 | Clipperz.PM.BookmarkletProcessor.createRecordFromBookmarkletConfiguration = function(anUser, aConfiguration) { |
224 | var processor; | 224 | var processor; |
225 | 225 | ||
226 | processor = new Clipperz.PM.BookmarkletProcessor(anUser, aConfiguration); | 226 | processor = new Clipperz.PM.BookmarkletProcessor(anUser, aConfiguration); |
227 | 227 | ||
228 | return processor.record(); | 228 | return processor.record(); |
229 | }; | 229 | }; |
230 | 230 | ||
231 | //----------------------------------------------------------------------------- | 231 | //----------------------------------------------------------------------------- |
232 | 232 | ||
233 | Clipperz.PM.BookmarkletProcessor.sanitizeBookmarkletConfiguration = function(aConfiguration) { | 233 | Clipperz.PM.BookmarkletProcessor.sanitizeBookmarkletConfiguration = function(aConfiguration) { |
234 | var result; | 234 | var result; |
235 | 235 | ||
236 | //throw "XSS Bookmarklet attempt"; | 236 | //throw "XSS Bookmarklet attempt"; |
237 | 237 | ||