Diffstat (limited to 'frontend/beta/js/Bookmarklet.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Bookmarklet.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Bookmarklet.js b/frontend/beta/js/Bookmarklet.js index 59f4fef..67e93f0 100644 --- a/frontend/beta/js/Bookmarklet.js +++ b/frontend/beta/js/Bookmarklet.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 | _cble = null; | 24 | _cble = null; |
27 | 25 | ||
28 | //----------------------------------------------------------------------------- | 26 | //----------------------------------------------------------------------------- |
29 | 27 | ||
30 | isLoginForm = function(aForm) { | 28 | isLoginForm = function(aForm) { |
31 | var inputFields; | 29 | var inputFields; |
32 | var passwordFieldsFound; | 30 | var passwordFieldsFound; |
33 | var i,c; | 31 | var i,c; |
34 | 32 | ||
35 | //console.log('is login form: ' + aForm.name + ' (' + aForm.id + ')'); | 33 | //console.log('is login form: ' + aForm.name + ' (' + aForm.id + ')'); |
36 | passwordFieldsFound = 0; | 34 | passwordFieldsFound = 0; |
37 | inputFields = aForm.elements; | 35 | inputFields = aForm.elements; |
38 | c = inputFields.length; | 36 | c = inputFields.length; |
39 | for (i=0; i<c; i++) { | 37 | for (i=0; i<c; i++) { |
40 | if (inputFields[i].type == 'password') { | 38 | if (inputFields[i].type == 'password') { |
41 | passwordFieldsFound ++; | 39 | passwordFieldsFound ++; |
42 | } | 40 | } |
43 | } | 41 | } |
44 | //console.log('number of password fields found: ' + passwordFieldsFound); | 42 | //console.log('number of password fields found: ' + passwordFieldsFound); |
45 | return (passwordFieldsFound == 1); | 43 | return (passwordFieldsFound == 1); |
46 | }; | 44 | }; |
47 | 45 | ||
48 | //----------------------------------------------------------------------------- | 46 | //----------------------------------------------------------------------------- |
49 | 47 | ||
50 | findLoginForm = function(aDocument, aLevel) { | 48 | findLoginForm = function(aDocument, aLevel) { |
51 | varresult; | 49 | varresult; |
52 | vardocumentForms; | 50 | vardocumentForms; |
53 | var i,c; | 51 | var i,c; |
54 | 52 | ||
55 | result = null; | 53 | result = null; |
56 | 54 | ||
57 | try { | 55 | try { |
58 | documentForms = aDocument.getElementsByTagName('form'); | 56 | documentForms = aDocument.getElementsByTagName('form'); |
59 | 57 | ||
60 | c = documentForms.length; | 58 | c = documentForms.length; |
61 | for (i=0; (i<c) && (result == null); i++) { | 59 | for (i=0; (i<c) && (result == null); i++) { |
62 | if (isLoginForm(documentForms[i])) { | 60 | if (isLoginForm(documentForms[i])) { |
63 | result = documentForms[i]; | 61 | result = documentForms[i]; |
64 | } | 62 | } |
65 | } | 63 | } |
66 | 64 | ||
67 | if ((result == null) && (aLevel == 0)) { | 65 | if ((result == null) && (aLevel == 0)) { |
68 | var iFrames; | 66 | var iFrames; |
69 | 67 | ||
70 | iFrames = aDocument.getElementsByTagName('iframe'); | 68 | iFrames = aDocument.getElementsByTagName('iframe'); |
71 | c = iFrames.length; | 69 | c = iFrames.length; |
72 | for (i=0; (i<c) && (result == null); i++) { | 70 | for (i=0; (i<c) && (result == null); i++) { |
73 | result = findLoginForm(iFrames[i].contentDocument, (aLevel + 1)); | 71 | result = findLoginForm(iFrames[i].contentDocument, (aLevel + 1)); |
74 | } | 72 | } |
75 | } | 73 | } |
76 | } catch (e) { | 74 | } catch (e) { |
77 | _cble = e; | 75 | _cble = e; |
78 | } | 76 | } |
79 | 77 | ||
80 | return result; | 78 | return result; |
81 | }; | 79 | }; |
82 | 80 | ||
83 | //----------------------------------------------------------------------------- | 81 | //----------------------------------------------------------------------------- |
84 | 82 | ||
85 | inputElementValues = function(anInputElement) { | 83 | inputElementValues = function(anInputElement) { |
86 | varresult; | 84 | varresult; |
87 | 85 | ||
88 | //if ((anInputElement instanceof HTMLInputElement) && (anInputElement.getAttribute('name') != null)) { | 86 | //if ((anInputElement instanceof HTMLInputElement) && (anInputElement.getAttribute('name') != null)) { |
89 | if ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('name') != null)) { | 87 | if ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('name') != null)) { |
90 | result = {}; | 88 | result = {}; |
91 | result.type = anInputElement.getAttribute('type') || 'text'; | 89 | result.type = anInputElement.getAttribute('type') || 'text'; |
92 | result.name = anInputElement.getAttribute('name'); | 90 | result.name = anInputElement.getAttribute('name'); |
93 | // result.value = anInputElement.getAttribute('value'); | 91 | // result.value = anInputElement.getAttribute('value'); |
94 | result.value = anInputElement.value; | 92 | result.value = anInputElement.value; |
95 | if (anInputElement.type.toLowerCase() == 'radio') { | 93 | if (anInputElement.type.toLowerCase() == 'radio') { |
96 | result.checked = anInputElement.checked; | 94 | result.checked = anInputElement.checked; |
97 | } | 95 | } |
98 | //} else if ((anInputElement instanceof HTMLSelectElement) && (anInputElement.getAttribute('name') != null)) { | 96 | //} else if ((anInputElement instanceof HTMLSelectElement) && (anInputElement.getAttribute('name') != null)) { |
99 | } else if ((anInputElement.tagName.toLowerCase() == 'select') && (anInputElement.getAttribute('name') != null)) { | 97 | } else if ((anInputElement.tagName.toLowerCase() == 'select') && (anInputElement.getAttribute('name') != null)) { |
100 | varoptions; | 98 | varoptions; |
101 | var c,i; | 99 | var c,i; |
102 | 100 | ||
103 | //console.log('input element values: %o', anInputElement); | 101 | //console.log('input element values: %o', anInputElement); |
104 | result = {}; | 102 | result = {}; |
105 | result.type = 'select'; | 103 | result.type = 'select'; |
106 | result.name = anInputElement.getAttribute('name'); | 104 | result.name = anInputElement.getAttribute('name'); |
107 | 105 | ||
108 | result.options = []; | 106 | result.options = []; |
109 | options = anInputElement.options; | 107 | options = anInputElement.options; |
110 | c = options.length; | 108 | c = options.length; |
111 | for (i=0; i<c; i++) { | 109 | for (i=0; i<c; i++) { |
112 | varoption; | 110 | varoption; |
113 | 111 | ||
114 | option = {}; | 112 | option = {}; |
115 | option.selected = options[i].selected; | 113 | option.selected = options[i].selected; |
116 | option.label = options[i].label || options[i].innerHTML; | 114 | option.label = options[i].label || options[i].innerHTML; |
117 | option.value = options[i].value; | 115 | option.value = options[i].value; |
118 | result.options.push(option); | 116 | result.options.push(option); |