Diffstat (limited to 'frontend/gamma/js/Clipperz/DOM.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/DOM.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/DOM.js b/frontend/gamma/js/Clipperz/DOM.js index 40720d8..8f24653 100644 --- a/frontend/gamma/js/Clipperz/DOM.js +++ b/frontend/gamma/js/Clipperz/DOM.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 | if (typeof(Clipperz.DOM) == 'undefined') { Clipperz.DOM = {}; } | 27 | if (typeof(Clipperz.DOM) == 'undefined') { Clipperz.DOM = {}; } |
31 | 28 | ||
32 | Clipperz.DOM.VERSION = "0.1"; | 29 | Clipperz.DOM.VERSION = "0.1"; |
33 | Clipperz.DOM.NAME = "Clipperz.DOM"; | 30 | Clipperz.DOM.NAME = "Clipperz.DOM"; |
34 | 31 | ||
35 | MochiKit.Base.update(Clipperz.DOM, { | 32 | MochiKit.Base.update(Clipperz.DOM, { |
36 | 33 | ||
37 | //------------------------------------------------------------------------- | 34 | //------------------------------------------------------------------------- |
38 | 35 | ||
39 | '__repr__': function () { | 36 | '__repr__': function () { |
40 | return "[" + this.NAME + " " + this.VERSION + "]"; | 37 | return "[" + this.NAME + " " + this.VERSION + "]"; |
41 | }, | 38 | }, |
42 | 39 | ||
43 | //------------------------------------------------------------------------- | 40 | //------------------------------------------------------------------------- |
44 | 41 | ||
45 | 'toString': function () { | 42 | 'toString': function () { |
46 | return this.__repr__(); | 43 | return this.__repr__(); |
47 | }, | 44 | }, |
48 | 45 | ||
49 | //------------------------------------------------------------------------- | 46 | //------------------------------------------------------------------------- |
50 | 47 | ||
51 | 'selectOptionMatchingValue': function (aSelectElement, aValue, shouldUseCaseInsensitiveTest) { | 48 | 'selectOptionMatchingValue': function (aSelectElement, aValue, shouldUseCaseInsensitiveTest) { |
52 | var selectedOptionIndex; | 49 | var selectedOptionIndex; |
53 | var i, c; | 50 | var i, c; |
54 | 51 | ||
55 | selectedOptionIndex = -1; | 52 | selectedOptionIndex = -1; |
56 | 53 | ||
57 | c = aSelectElement.options.length; | 54 | c = aSelectElement.options.length; |
58 | for (i=0; (i<c) && (selectedOptionIndex == -1); i++) { | 55 | for (i=0; (i<c) && (selectedOptionIndex == -1); i++) { |
59 | if (shouldUseCaseInsensitiveTest == true) { | 56 | if (shouldUseCaseInsensitiveTest == true) { |
60 | if (aSelectElement.options[i].value.toLowerCase() == aValue.toLowerCase()) { | 57 | if (aSelectElement.options[i].value.toLowerCase() == aValue.toLowerCase()) { |
61 | selectedOptionIndex = i; | 58 | selectedOptionIndex = i; |
62 | } | 59 | } |
63 | } else { | 60 | } else { |
64 | if (aSelectElement.options[i].value == aValue) { | 61 | if (aSelectElement.options[i].value == aValue) { |
65 | selectedOptionIndex = i; | 62 | selectedOptionIndex = i; |
66 | } | 63 | } |
67 | } | 64 | } |
68 | } | 65 | } |
69 | 66 | ||
70 | if (selectedOptionIndex != -1) { | 67 | if (selectedOptionIndex != -1) { |
71 | aSelectElement.selectedIndex = selectedOptionIndex; | 68 | aSelectElement.selectedIndex = selectedOptionIndex; |
72 | } | 69 | } |
73 | }, | 70 | }, |
74 | 71 | ||
75 | //------------------------------------------------------------------------- | 72 | //------------------------------------------------------------------------- |
76 | 73 | ||
77 | 'setFormContents': function(aNode, someValues) { | 74 | 'setFormContents': function(aNode, someValues) { |
78 | var node; | 75 | var node; |
79 | var values; | 76 | var values; |
80 | var i, c; | 77 | var i, c; |
81 | 78 | ||
82 | values = {}; | 79 | values = {}; |
83 | c = someValues[0].length; | 80 | c = someValues[0].length; |
84 | for (i=0; i<c; i++) { | 81 | for (i=0; i<c; i++) { |
85 | values[someValues[0][i]] = someValues[1][i]; | 82 | values[someValues[0][i]] = someValues[1][i]; |
86 | } | 83 | } |
87 | 84 | ||
88 | // var m = MochiKit.Base; | 85 | // var m = MochiKit.Base; |
89 | // var self = MochiKit.DOM; | 86 | // var self = MochiKit.DOM; |
90 | if (typeof(aNode) == "undefined" || aNode === null) { | 87 | if (typeof(aNode) == "undefined" || aNode === null) { |
91 | node = MochiKit.DOM._document.body; | 88 | node = MochiKit.DOM._document.body; |
92 | } else { | 89 | } else { |
93 | node = MochiKit.DOM.getElement(aNode); | 90 | node = MochiKit.DOM.getElement(aNode); |
94 | } | 91 | } |
95 | 92 | ||
96 | MochiKit.Base.nodeWalk(node, function(aNode) { | 93 | MochiKit.Base.nodeWalk(node, function(aNode) { |
97 | var result; | 94 | var result; |
98 | var name; | 95 | var name; |
99 | 96 | ||
100 | result = null; | 97 | result = null; |
101 | name = aNode.name; | 98 | name = aNode.name; |
102 | if (MochiKit.Base.isNotEmpty(name) && (typeof(values[name]) != 'undefined')) { | 99 | if (MochiKit.Base.isNotEmpty(name) && (typeof(values[name]) != 'undefined')) { |
103 | var tagName; | 100 | var tagName; |
104 | 101 | ||
105 | tagName = aNode.tagName.toUpperCase(); | 102 | tagName = aNode.tagName.toUpperCase(); |
106 | if (tagName === "INPUT" && (aNode.type == "radio" || aNode.type == "checkbox")) { | 103 | if (tagName === "INPUT" && (aNode.type == "radio" || aNode.type == "checkbox")) { |
107 | aNode.checked = values[name]; | 104 | aNode.checked = values[name]; |
108 | } else if (tagName === "SELECT") { | 105 | } else if (tagName === "SELECT") { |
109 | if (aNode.type == "select-one") { | 106 | if (aNode.type == "select-one") { |
110 | Clipperz.DOM.selectOptionMatchingValue(aNode, values[name]); | 107 | Clipperz.DOM.selectOptionMatchingValue(aNode, values[name]); |
111 | } else { //aNode.type == "select-multiple" | 108 | } else { //aNode.type == "select-multiple" |
112 | MochiKit.Logging.logWarning("### unhandled Select.type = 'select-multiple' condition"); | 109 | MochiKit.Logging.logWarning("### unhandled Select.type = 'select-multiple' condition"); |
113 | } | 110 | } |
114 | } else if (tagName === "FORM" || tagName === "P" || tagName === "SPAN" || tagName === "DIV") { | 111 | } else if (tagName === "FORM" || tagName === "P" || tagName === "SPAN" || tagName === "DIV") { |
115 | result = aNode.childNodes; | 112 | result = aNode.childNodes; |
116 | } else { | 113 | } else { |
117 | aNode.value = values[name] | 114 | aNode.value = values[name] |
118 | } | 115 | } |
119 | } else { | 116 | } else { |
120 | result = aNode.childNodes; | 117 | result = aNode.childNodes; |