Diffstat (limited to 'frontend/beta/js/Bookmarklet.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Bookmarklet.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Bookmarklet.js b/frontend/beta/js/Bookmarklet.js index b8a0c0e..59f4fef 100644 --- a/frontend/beta/js/Bookmarklet.js +++ b/frontend/beta/js/Bookmarklet.js | |||
@@ -1,216 +1,213 @@ | |||
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 | _cble = null; | 26 | _cble = null; |
30 | 27 | ||
31 | //----------------------------------------------------------------------------- | 28 | //----------------------------------------------------------------------------- |
32 | 29 | ||
33 | isLoginForm = function(aForm) { | 30 | isLoginForm = function(aForm) { |
34 | var inputFields; | 31 | var inputFields; |
35 | var passwordFieldsFound; | 32 | var passwordFieldsFound; |
36 | var i,c; | 33 | var i,c; |
37 | 34 | ||
38 | //console.log('is login form: ' + aForm.name + ' (' + aForm.id + ')'); | 35 | //console.log('is login form: ' + aForm.name + ' (' + aForm.id + ')'); |
39 | passwordFieldsFound = 0; | 36 | passwordFieldsFound = 0; |
40 | inputFields = aForm.elements; | 37 | inputFields = aForm.elements; |
41 | c = inputFields.length; | 38 | c = inputFields.length; |
42 | for (i=0; i<c; i++) { | 39 | for (i=0; i<c; i++) { |
43 | if (inputFields[i].type == 'password') { | 40 | if (inputFields[i].type == 'password') { |
44 | passwordFieldsFound ++; | 41 | passwordFieldsFound ++; |
45 | } | 42 | } |
46 | } | 43 | } |
47 | //console.log('number of password fields found: ' + passwordFieldsFound); | 44 | //console.log('number of password fields found: ' + passwordFieldsFound); |
48 | return (passwordFieldsFound == 1); | 45 | return (passwordFieldsFound == 1); |
49 | }; | 46 | }; |
50 | 47 | ||
51 | //----------------------------------------------------------------------------- | 48 | //----------------------------------------------------------------------------- |
52 | 49 | ||
53 | findLoginForm = function(aDocument, aLevel) { | 50 | findLoginForm = function(aDocument, aLevel) { |
54 | varresult; | 51 | varresult; |
55 | vardocumentForms; | 52 | vardocumentForms; |
56 | var i,c; | 53 | var i,c; |
57 | 54 | ||
58 | result = null; | 55 | result = null; |
59 | 56 | ||
60 | try { | 57 | try { |
61 | documentForms = aDocument.getElementsByTagName('form'); | 58 | documentForms = aDocument.getElementsByTagName('form'); |
62 | 59 | ||
63 | c = documentForms.length; | 60 | c = documentForms.length; |
64 | for (i=0; (i<c) && (result == null); i++) { | 61 | for (i=0; (i<c) && (result == null); i++) { |
65 | if (isLoginForm(documentForms[i])) { | 62 | if (isLoginForm(documentForms[i])) { |
66 | result = documentForms[i]; | 63 | result = documentForms[i]; |
67 | } | 64 | } |
68 | } | 65 | } |
69 | 66 | ||
70 | if ((result == null) && (aLevel == 0)) { | 67 | if ((result == null) && (aLevel == 0)) { |
71 | var iFrames; | 68 | var iFrames; |
72 | 69 | ||
73 | iFrames = aDocument.getElementsByTagName('iframe'); | 70 | iFrames = aDocument.getElementsByTagName('iframe'); |
74 | c = iFrames.length; | 71 | c = iFrames.length; |
75 | for (i=0; (i<c) && (result == null); i++) { | 72 | for (i=0; (i<c) && (result == null); i++) { |
76 | result = findLoginForm(iFrames[i].contentDocument, (aLevel + 1)); | 73 | result = findLoginForm(iFrames[i].contentDocument, (aLevel + 1)); |
77 | } | 74 | } |
78 | } | 75 | } |
79 | } catch (e) { | 76 | } catch (e) { |
80 | _cble = e; | 77 | _cble = e; |
81 | } | 78 | } |
82 | 79 | ||
83 | return result; | 80 | return result; |
84 | }; | 81 | }; |
85 | 82 | ||
86 | //----------------------------------------------------------------------------- | 83 | //----------------------------------------------------------------------------- |
87 | 84 | ||
88 | inputElementValues = function(anInputElement) { | 85 | inputElementValues = function(anInputElement) { |
89 | varresult; | 86 | varresult; |
90 | 87 | ||
91 | //if ((anInputElement instanceof HTMLInputElement) && (anInputElement.getAttribute('name') != null)) { | 88 | //if ((anInputElement instanceof HTMLInputElement) && (anInputElement.getAttribute('name') != null)) { |
92 | if ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('name') != null)) { | 89 | if ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('name') != null)) { |
93 | result = {}; | 90 | result = {}; |
94 | result.type = anInputElement.getAttribute('type') || 'text'; | 91 | result.type = anInputElement.getAttribute('type') || 'text'; |
95 | result.name = anInputElement.getAttribute('name'); | 92 | result.name = anInputElement.getAttribute('name'); |
96 | // result.value = anInputElement.getAttribute('value'); | 93 | // result.value = anInputElement.getAttribute('value'); |
97 | result.value = anInputElement.value; | 94 | result.value = anInputElement.value; |
98 | if (anInputElement.type.toLowerCase() == 'radio') { | 95 | if (anInputElement.type.toLowerCase() == 'radio') { |
99 | result.checked = anInputElement.checked; | 96 | result.checked = anInputElement.checked; |
100 | } | 97 | } |
101 | //} else if ((anInputElement instanceof HTMLSelectElement) && (anInputElement.getAttribute('name') != null)) { | 98 | //} else if ((anInputElement instanceof HTMLSelectElement) && (anInputElement.getAttribute('name') != null)) { |
102 | } else if ((anInputElement.tagName.toLowerCase() == 'select') && (anInputElement.getAttribute('name') != null)) { | 99 | } else if ((anInputElement.tagName.toLowerCase() == 'select') && (anInputElement.getAttribute('name') != null)) { |
103 | varoptions; | 100 | varoptions; |
104 | var c,i; | 101 | var c,i; |
105 | 102 | ||
106 | //console.log('input element values: %o', anInputElement); | 103 | //console.log('input element values: %o', anInputElement); |
107 | result = {}; | 104 | result = {}; |
108 | result.type = 'select'; | 105 | result.type = 'select'; |
109 | result.name = anInputElement.getAttribute('name'); | 106 | result.name = anInputElement.getAttribute('name'); |
110 | 107 | ||
111 | result.options = []; | 108 | result.options = []; |
112 | options = anInputElement.options; | 109 | options = anInputElement.options; |
113 | c = options.length; | 110 | c = options.length; |
114 | for (i=0; i<c; i++) { | 111 | for (i=0; i<c; i++) { |
115 | varoption; | 112 | varoption; |
116 | 113 | ||
117 | option = {}; | 114 | option = {}; |
118 | option.selected = options[i].selected; | 115 | option.selected = options[i].selected; |
119 | option.label = options[i].label || options[i].innerHTML; | 116 | option.label = options[i].label || options[i].innerHTML; |
120 | option.value = options[i].value; | 117 | option.value = options[i].value; |
121 | result.options.push(option); | 118 | result.options.push(option); |
122 | } | 119 | } |
123 | } else { | 120 | } else { |
124 | result = null; | 121 | result = null; |
125 | } | 122 | } |
126 | 123 | ||
127 | return result; | 124 | return result; |
128 | }; | 125 | }; |
129 | 126 | ||
130 | //----------------------------------------------------------------------------- | 127 | //----------------------------------------------------------------------------- |
131 | 128 | ||
132 | formParameters = function(aLoginForm) { | 129 | formParameters = function(aLoginForm) { |
133 | varresult; | 130 | varresult; |
134 | vari, c; | 131 | vari, c; |
135 | varaction; | 132 | varaction; |
136 | 133 | ||
137 | if (aLoginForm == null) { | 134 | if (aLoginForm == null) { |
138 | result = null; | 135 | result = null; |
139 | } else { | 136 | } else { |
140 | varradioValues; | 137 | varradioValues; |
141 | varradioValueName; | 138 | varradioValueName; |
142 | 139 | ||
143 | result = {}; | 140 | result = {}; |
144 | radioValues = {}; | 141 | radioValues = {}; |
145 | 142 | ||
146 | action = aLoginForm.action; | 143 | action = aLoginForm.action; |
147 | if (action.constructor != String) { | 144 | if (action.constructor != String) { |
148 | action = aLoginForm.getAttribute('action'); | 145 | action = aLoginForm.getAttribute('action'); |
149 | } | 146 | } |
150 | 147 | ||
151 | if (/^https?\:\/\/.*/.test(action)) { | 148 | if (/^https?\:\/\/.*/.test(action)) { |
152 | action = action; | 149 | action = action; |
153 | } else if (/^\/.*/.test(action)) { | 150 | } else if (/^\/.*/.test(action)) { |
154 | action = window.location.protocol + '/' + '/' + window.location.hostname + action; | 151 | action = window.location.protocol + '/' + '/' + window.location.hostname + action; |
155 | } else { | 152 | } else { |
156 | action = window.location.href.replace(/\/[^\/]*$/, '/' + action); | 153 | action = window.location.href.replace(/\/[^\/]*$/, '/' + action); |
157 | } | 154 | } |
158 | 155 | ||
159 | result.attributes = {}; | 156 | result.attributes = {}; |
160 | result.attributes.action = action; | 157 | result.attributes.action = action; |
161 | result.attributes.method = aLoginForm.getAttribute('method'); | 158 | result.attributes.method = aLoginForm.getAttribute('method'); |
162 | 159 | ||
163 | result.inputs = []; | 160 | result.inputs = []; |
164 | c = aLoginForm.elements.length; | 161 | c = aLoginForm.elements.length; |
165 | for (i=0; i<c; i++) { | 162 | for (i=0; i<c; i++) { |
166 | varinputElement; | 163 | varinputElement; |
167 | varelementValues; | 164 | varelementValues; |
168 | 165 | ||
169 | inputElement = aLoginForm.elements[i]; | 166 | inputElement = aLoginForm.elements[i]; |
170 | elementValues = inputElementValues(inputElement); | 167 | elementValues = inputElementValues(inputElement); |
171 | if (elementValues != null) { | 168 | if (elementValues != null) { |
172 | if (elementValues.type != 'radio') { | 169 | if (elementValues.type != 'radio') { |
173 | result.inputs.push(elementValues); | 170 | result.inputs.push(elementValues); |
174 | } else { | 171 | } else { |
175 | varradioValue; | 172 | varradioValue; |
176 | varvalues; | 173 | varvalues; |
177 | 174 | ||
178 | radioValue = radioValues[elementValues.name]; | 175 | radioValue = radioValues[elementValues.name]; |
179 | if (radioValue == null) { | 176 | if (radioValue == null) { |
180 | radioValue = {}; | 177 | radioValue = {}; |
181 | radioValue.name = elementValues.name; | 178 | radioValue.name = elementValues.name; |
182 | radioValue.type = 'radio'; | 179 | radioValue.type = 'radio'; |
183 | radioValue.options = []; | 180 | radioValue.options = []; |
184 | 181 | ||
185 | radioValues[elementValues.name] = radioValue; | 182 | radioValues[elementValues.name] = radioValue; |
186 | } | 183 | } |
187 | 184 | ||
188 | values = {}; | 185 | values = {}; |
189 | values.value = elementValues.value; | 186 | values.value = elementValues.value; |
190 | values.checked = elementValues.checked; | 187 | values.checked = elementValues.checked; |
191 | 188 | ||
192 | radioValue.options.push(values); | 189 | radioValue.options.push(values); |
193 | } | 190 | } |
194 | } | 191 | } |
195 | } | 192 | } |
196 | 193 | ||
197 | for (radioValueName in radioValues) { | 194 | for (radioValueName in radioValues) { |
198 | if (typeof(radioValues[radioValueName]) != 'function') { | 195 | if (typeof(radioValues[radioValueName]) != 'function') { |
199 | result.inputs.push(radioValues[radioValueName]); | 196 | result.inputs.push(radioValues[radioValueName]); |
200 | } | 197 | } |
201 | } | 198 | } |
202 | } | 199 | } |
203 | 200 | ||
204 | return result; | 201 | return result; |
205 | }; | 202 | }; |
206 | 203 | ||
207 | //----------------------------------------------------------------------------- | 204 | //----------------------------------------------------------------------------- |
208 | 205 | ||
209 | pageParameters = function() { | 206 | pageParameters = function() { |
210 | var result; | 207 | var result; |
211 | 208 | ||
212 | result = {}; | 209 | result = {}; |
213 | result['title'] = document.title; | 210 | result['title'] = document.title; |
214 | //<link rel='icon' href='http://example.com/favicon.ico' type='image/x-icon'> | 211 | //<link rel='icon' href='http://example.com/favicon.ico' type='image/x-icon'> |
215 | 212 | ||
216 | return result; | 213 | return result; |