summaryrefslogtreecommitdiff
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2012-03-17 21:08:23 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2012-03-17 21:08:23 (UTC)
commit928f3f3ed3981f7f81b69ed94f2a315205db39fa (patch) (unidiff)
tree8a47229b56e4c906de8512baf0c5ca100bc03dfb
parentbf7d8191a3a6dbd092a88911098a3e7f6cf30cf7 (diff)
downloadclipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.zip
clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.gz
clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.bz2
Fixed frontend properties and updated MochiKit version
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/properties/beta.properties.json3
-rw-r--r--frontend/gamma/js/MochiKit/Async.js120
-rw-r--r--frontend/gamma/js/MochiKit/Base.js156
-rw-r--r--frontend/gamma/js/MochiKit/Color.js17
-rw-r--r--frontend/gamma/js/MochiKit/DOM.js165
-rw-r--r--frontend/gamma/js/MochiKit/DateTime.js49
-rw-r--r--frontend/gamma/js/MochiKit/DragAndDrop.js14
-rw-r--r--frontend/gamma/js/MochiKit/Format.js16
-rw-r--r--frontend/gamma/js/MochiKit/Iter.js16
-rw-r--r--frontend/gamma/js/MochiKit/Logging.js4
-rw-r--r--frontend/gamma/js/MochiKit/LoggingPane.js13
-rw-r--r--frontend/gamma/js/MochiKit/MochiKit.js11
-rw-r--r--frontend/gamma/js/MochiKit/MockDOM.js9
-rw-r--r--frontend/gamma/js/MochiKit/Position.js2
-rw-r--r--frontend/gamma/js/MochiKit/Selector.js16
-rw-r--r--frontend/gamma/js/MochiKit/Signal.js47
-rw-r--r--frontend/gamma/js/MochiKit/Sortable.js12
-rw-r--r--frontend/gamma/js/MochiKit/Style.js19
-rw-r--r--frontend/gamma/js/MochiKit/Test.js2
-rw-r--r--frontend/gamma/js/MochiKit/Text.js359
-rw-r--r--frontend/gamma/js/MochiKit/Visual.js39
-rw-r--r--frontend/gamma/js/MochiKit/__package__.js18
-rw-r--r--frontend/gamma/js/main.js10
-rw-r--r--frontend/gamma/properties/gamma.properties.json7
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/AES.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/AES.performance.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/Base.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/BigInt.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.B283.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.Value.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/PRNG.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/SHA.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/Usage.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/Date.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/Proxy.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/Toll.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/PM/UI/Web/Controllers/MainController.html1
-rw-r--r--frontend/gamma/tests/tests/Clipperz/RoboFormExportProcessor.html1
-rw-r--r--frontend/gamma/tests/tests/Components/CardDialogNew/index.html4
-rw-r--r--frontend/gamma/tests/tests/Components/Tooltips/index.html4
43 files changed, 623 insertions, 526 deletions
diff --git a/frontend/beta/properties/beta.properties.json b/frontend/beta/properties/beta.properties.json
index 7b0c1f9..476becd 100644
--- a/frontend/beta/properties/beta.properties.json
+++ b/frontend/beta/properties/beta.properties.json
@@ -1,184 +1,187 @@
1{ 1{
2 "copyright.values": { 2 "copyright.values": {
3 "mochikit.repository": "http://svn.mochikit.com/mochikit/trunk/", 3 "mochikit.repository": "http://svn.mochikit.com/mochikit/trunk/",
4 "mochikit.version": "1249" 4 "mochikit.version": "1249"
5 }, 5 },
6
7 "html.template": "index_template.html",
8
6 "js": [ 9 "js": [
7 "MochiKit/Base.js", 10 "MochiKit/Base.js",
8 "MochiKit/Iter.js", 11 "MochiKit/Iter.js",
9 "MochiKit/DOM.js", 12 "MochiKit/DOM.js",
10 "MochiKit/Style.js", 13 "MochiKit/Style.js",
11 "MochiKit/Signal.js", 14 "MochiKit/Signal.js",
12 "MochiKit/Format.js", 15 "MochiKit/Format.js",
13 "MochiKit/Async.js", 16 "MochiKit/Async.js",
14 "MochiKit/Selector.js", 17 "MochiKit/Selector.js",
15 "MochiKit/Logging.js", 18 "MochiKit/Logging.js",
16 "MochiKit/LoggingPane.js", 19 "MochiKit/LoggingPane.js",
17 20
18 "YUI/yahoo.js", 21 "YUI/yahoo.js",
19 "YUI/animation.js", 22 "YUI/animation.js",
20 "YUI/event.js", 23 "YUI/event.js",
21 "YUI/dom.js", 24 "YUI/dom.js",
22 "YUI/dragdrop.js", 25 "YUI/dragdrop.js",
23 "YUI/logger.js", 26 "YUI/logger.js",
24 27
25 "YUI-extensions/yutil.js", 28 "YUI-extensions/yutil.js",
26 "YUI-extensions/Bench.js", 29 "YUI-extensions/Bench.js",
27 "YUI-extensions/Date.js", 30 "YUI-extensions/Date.js",
28 "YUI-extensions/DomHelper.js", 31 "YUI-extensions/DomHelper.js",
29 "YUI-extensions/Element.js", 32 "YUI-extensions/Element.js",
30 "YUI-extensions/CompositeElement.js", 33 "YUI-extensions/CompositeElement.js",
31 "YUI-extensions/State.js", 34 "YUI-extensions/State.js",
32 "YUI-extensions/EventManager.js", 35 "YUI-extensions/EventManager.js",
33 "YUI-extensions/KeyMap.js", 36 "YUI-extensions/KeyMap.js",
34 "YUI-extensions/Layer.js", 37 "YUI-extensions/Layer.js",
35 "YUI-extensions/MixedCollection.js", 38 "YUI-extensions/MixedCollection.js",
36 "YUI-extensions/State.js", 39 "YUI-extensions/State.js",
37 "YUI-extensions/UpdateManager.js", 40 "YUI-extensions/UpdateManager.js",
38 "YUI-extensions/anim/Actor.js", 41 "YUI-extensions/anim/Actor.js",
39 "YUI-extensions/anim/Animator.js", 42 "YUI-extensions/anim/Animator.js",
40 "YUI-extensions/dd/Registry.js", 43 "YUI-extensions/dd/Registry.js",
41 "YUI-extensions/dd/ScrollManager.js", 44 "YUI-extensions/dd/ScrollManager.js",
42 "YUI-extensions/dd/StatusProxy.js", 45 "YUI-extensions/dd/StatusProxy.js",
43 "YUI-extensions/layout/ContentPanels.js", 46 "YUI-extensions/layout/ContentPanels.js",
44 "YUI-extensions/layout/LayoutManager.js", 47 "YUI-extensions/layout/LayoutManager.js",
45 "YUI-extensions/layout/BorderLayout.js", 48 "YUI-extensions/layout/BorderLayout.js",
46 "YUI-extensions/layout/BasicLayoutRegion.js", 49 "YUI-extensions/layout/BasicLayoutRegion.js",
47 "YUI-extensions/layout/LayoutRegion.js", 50 "YUI-extensions/layout/LayoutRegion.js",
48 "YUI-extensions/layout/LayoutStateManager.js", 51 "YUI-extensions/layout/LayoutStateManager.js",
49 "YUI-extensions/layout/SplitLayoutRegion.js", 52 "YUI-extensions/layout/SplitLayoutRegion.js",
50 "YUI-extensions/layout/BorderLayoutRegions.js", 53 "YUI-extensions/layout/BorderLayoutRegions.js",
51 "YUI-extensions/widgets/BasicDialog.js", 54 "YUI-extensions/widgets/BasicDialog.js",
52 "YUI-extensions/widgets/Button.js", 55 "YUI-extensions/widgets/Button.js",
53 "YUI-extensions/widgets/MessageBox.js", 56 "YUI-extensions/widgets/MessageBox.js",
54 "YUI-extensions/widgets/Resizable.js", 57 "YUI-extensions/widgets/Resizable.js",
55 "YUI-extensions/widgets/SplitBar.js", 58 "YUI-extensions/widgets/SplitBar.js",
56 "YUI-extensions/widgets/TabPanel.js", 59 "YUI-extensions/widgets/TabPanel.js",
57 "YUI-extensions/widgets/TemplateView.js", 60 "YUI-extensions/widgets/TemplateView.js",
58 "YUI-extensions/widgets/Toolbar.js", 61 "YUI-extensions/widgets/Toolbar.js",
59 "YUI-extensions/widgets/InlineEditor.js", 62 "YUI-extensions/widgets/InlineEditor.js",
60 "YUI-extensions/widgets/QuickTips.js", 63 "YUI-extensions/widgets/QuickTips.js",
61 "YUI-extensions/CSS.js", 64 "YUI-extensions/CSS.js",
62 65
63 "JSON/json2.js", 66 "JSON/json2.js",
64 67
65 "Clipperz/ByteArray.js", 68 "Clipperz/ByteArray.js",
66 "Clipperz/Base.js", 69 "Clipperz/Base.js",
67 "Clipperz/CSVProcessor.js", 70 "Clipperz/CSVProcessor.js",
68 "Clipperz/KeePassExportProcessor.js", 71 "Clipperz/KeePassExportProcessor.js",
69 "Clipperz/Date.js", 72 "Clipperz/Date.js",
70 "Clipperz/DOM.js", 73 "Clipperz/DOM.js",
71 "Clipperz/Signal.js", 74 "Clipperz/Signal.js",
72 "Clipperz/Style.js", 75 "Clipperz/Style.js",
73 "Clipperz/Set.js", 76 "Clipperz/Set.js",
74 "Clipperz/NotificationCenter.js", 77 "Clipperz/NotificationCenter.js",
75 "Clipperz/Crypto/SHA.js", 78 "Clipperz/Crypto/SHA.js",
76 "Clipperz/Crypto/AES.js", 79 "Clipperz/Crypto/AES.js",
77 "Clipperz/Crypto/PRNG.js", 80 "Clipperz/Crypto/PRNG.js",
78 "Clipperz/Crypto/BigInt.js", 81 "Clipperz/Crypto/BigInt.js",
79 "Clipperz/Crypto/Base.js", 82 "Clipperz/Crypto/Base.js",
80 "Clipperz/Crypto/SRP.js", 83 "Clipperz/Crypto/SRP.js",
81 "Clipperz/Crypto/RSA.js", 84 "Clipperz/Crypto/RSA.js",
82 "Clipperz/PM/Strings/Strings_en-US.js", 85 "Clipperz/PM/Strings/Strings_en-US.js",
83 "Clipperz/PM/Strings/Strings_it-IT.js", 86 "Clipperz/PM/Strings/Strings_it-IT.js",
84 "Clipperz/PM/Strings/Strings_pt-BR.js", 87 "Clipperz/PM/Strings/Strings_pt-BR.js",
85 "Clipperz/PM/Strings/Strings_ja-JP.js", 88 "Clipperz/PM/Strings/Strings_ja-JP.js",
86 "Clipperz/PM/Strings/Strings_zh-CN.js", 89 "Clipperz/PM/Strings/Strings_zh-CN.js",
87 "Clipperz/PM/Strings/Strings_es-ES.js", 90 "Clipperz/PM/Strings/Strings_es-ES.js",
88 "Clipperz/PM/Strings/Strings_fr-FR.js", 91 "Clipperz/PM/Strings/Strings_fr-FR.js",
89 "Clipperz/PM/Strings/Strings_ru-RU.js", 92 "Clipperz/PM/Strings/Strings_ru-RU.js",
90 "Clipperz/PM/Strings.js", 93 "Clipperz/PM/Strings.js",
91 "Clipperz/PM/Strings/MessagePanelConfigurations.js", 94 "Clipperz/PM/Strings/MessagePanelConfigurations.js",
92 "Clipperz/PM/Date.js", 95 "Clipperz/PM/Date.js",
93 "Clipperz/PM/Components/BaseComponent.js", 96 "Clipperz/PM/Components/BaseComponent.js",
94 "Clipperz/PM/Components/MessageBox.js", 97 "Clipperz/PM/Components/MessageBox.js",
95 "Clipperz/PM/Components/TextFormField.js", 98 "Clipperz/PM/Components/TextFormField.js",
96 "Clipperz/PM/Components/PasswordEntropyDisplay.js", 99 "Clipperz/PM/Components/PasswordEntropyDisplay.js",
97 "Clipperz/PM/Components/PasswordGenerator.js", 100 "Clipperz/PM/Components/PasswordGenerator.js",
98 "Clipperz/PM/Components/Panels/BasePanel.js", 101 "Clipperz/PM/Components/Panels/BasePanel.js",
99 "Clipperz/PM/Components/Panels/LoginPanel.js", 102 "Clipperz/PM/Components/Panels/LoginPanel.js",
100 "Clipperz/PM/Components/Panels/MainPanel.js", 103 "Clipperz/PM/Components/Panels/MainPanel.js",
101 "Clipperz/PM/Components/Panels/AccountPanel.js", 104 "Clipperz/PM/Components/Panels/AccountPanel.js",
102 "Clipperz/PM/Components/Panels/DataPanel.js", 105 "Clipperz/PM/Components/Panels/DataPanel.js",
103 "Clipperz/PM/Components/Panels/ContactsPanel.js", 106 "Clipperz/PM/Components/Panels/ContactsPanel.js",
104 "Clipperz/PM/Components/Panels/ToolsPanel.js", 107 "Clipperz/PM/Components/Panels/ToolsPanel.js",
105 "Clipperz/PM/Components/Panels/LogoutPanel.js", 108 "Clipperz/PM/Components/Panels/LogoutPanel.js",
106 "Clipperz/PM/Components/RecordDetail/MainComponent.js", 109 "Clipperz/PM/Components/RecordDetail/MainComponent.js",
107 "Clipperz/PM/Components/RecordDetail/AbstractComponent.js", 110 "Clipperz/PM/Components/RecordDetail/AbstractComponent.js",
108 "Clipperz/PM/Components/RecordDetail/HeaderComponent.js", 111 "Clipperz/PM/Components/RecordDetail/HeaderComponent.js",
109 "Clipperz/PM/Components/RecordDetail/TitleComponent.js", 112 "Clipperz/PM/Components/RecordDetail/TitleComponent.js",
110 "Clipperz/PM/Components/RecordDetail/NotesComponent.js", 113 "Clipperz/PM/Components/RecordDetail/NotesComponent.js",
111 "Clipperz/PM/Components/RecordDetail/FieldComponent.js", 114 "Clipperz/PM/Components/RecordDetail/FieldComponent.js",
112 "Clipperz/PM/Components/RecordDetail/AbstractFieldSubComponent.js", 115 "Clipperz/PM/Components/RecordDetail/AbstractFieldSubComponent.js",
113 "Clipperz/PM/Components/RecordDetail/FieldButtonComponent.js", 116 "Clipperz/PM/Components/RecordDetail/FieldButtonComponent.js",
114 "Clipperz/PM/Components/RecordDetail/FieldLabelComponent.js", 117 "Clipperz/PM/Components/RecordDetail/FieldLabelComponent.js",
115 "Clipperz/PM/Components/RecordDetail/FieldDragHandler.js", 118 "Clipperz/PM/Components/RecordDetail/FieldDragHandler.js",
116 "Clipperz/PM/Components/RecordDetail/FieldValueComponent.js", 119 "Clipperz/PM/Components/RecordDetail/FieldValueComponent.js",
117 "Clipperz/PM/Components/RecordDetail/FieldTypeComponent.js", 120 "Clipperz/PM/Components/RecordDetail/FieldTypeComponent.js",
118 "Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js", 121 "Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js",
119 "Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js", 122 "Clipperz/PM/Components/RecordDetail/DirectLoginComponent.js",
120 "Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js", 123 "Clipperz/PM/Components/RecordDetail/DirectLoginBindingComponent.js",
121 "Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js", 124 "Clipperz/PM/Components/RecordDetail/DirectLoginValueComponent.js",
122 "Clipperz/PM/Components/RecordDetail/CreationWizard.js", 125 "Clipperz/PM/Components/RecordDetail/CreationWizard.js",
123 "Clipperz/PM/Components/TabPanel/TabPanelController.js", 126 "Clipperz/PM/Components/TabPanel/TabPanelController.js",
124 "Clipperz/PM/Components/Import/MainComponent.js", 127 "Clipperz/PM/Components/Import/MainComponent.js",
125 "Clipperz/PM/Components/Import/GenericImportComponent.js", 128 "Clipperz/PM/Components/Import/GenericImportComponent.js",
126 "Clipperz/PM/Components/Import/CSVImportComponent.js", 129 "Clipperz/PM/Components/Import/CSVImportComponent.js",
127 "Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js", 130 "Clipperz/PM/Components/Import/CSVImport/CSVImportColumns.js",
128 "Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js", 131 "Clipperz/PM/Components/Import/CSVImport/CSVImportHeader.js",
129 "Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js", 132 "Clipperz/PM/Components/Import/CSVImport/CSVImportTitle.js",
130 "Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js", 133 "Clipperz/PM/Components/Import/CSVImport/CSVImportNotes.js",
131 "Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js", 134 "Clipperz/PM/Components/Import/CSVImport/CSVImportFields.js",
132 "Clipperz/PM/Components/Import/ExcelImportComponent.js", 135 "Clipperz/PM/Components/Import/ExcelImportComponent.js",
133 "Clipperz/PM/Components/Import/PasswordPlusImportComponent.js", 136 "Clipperz/PM/Components/Import/PasswordPlusImportComponent.js",
134 "Clipperz/PM/Components/Import/ClipperzImportComponent.js", 137 "Clipperz/PM/Components/Import/ClipperzImportComponent.js",
135 "Clipperz/PM/Components/Import/RoboFormImportComponent.js", 138 "Clipperz/PM/Components/Import/RoboFormImportComponent.js",
136 "Clipperz/PM/Components/Import/KeePassImportComponent.js", 139 "Clipperz/PM/Components/Import/KeePassImportComponent.js",
137 "Clipperz/PM/Components/Printing/Header.js", 140 "Clipperz/PM/Components/Printing/Header.js",
138 "Clipperz/PM/Components/Printing/Record.js", 141 "Clipperz/PM/Components/Printing/Record.js",
139 "Clipperz/PM/Components/Printing/Footer.js", 142 "Clipperz/PM/Components/Printing/Footer.js",
140 "Clipperz/PM/Components/OTP/MainComponent.js", 143 "Clipperz/PM/Components/OTP/MainComponent.js",
141 "Clipperz/PM/Components/Compact/CompactHeader.js", 144 "Clipperz/PM/Components/Compact/CompactHeader.js",
142 "Clipperz/PM/Components/Compact/LoginForm.js", 145 "Clipperz/PM/Components/Compact/LoginForm.js",
143 "Clipperz/PM/Components/Compact/CompactInterface.js", 146 "Clipperz/PM/Components/Compact/CompactInterface.js",
144 "Clipperz/PM/Toll.js", 147 "Clipperz/PM/Toll.js",
145 "Clipperz/PM/Proxy.js", 148 "Clipperz/PM/Proxy.js",
146 "Clipperz/PM/Proxy/Proxy.JSON.js", 149 "Clipperz/PM/Proxy/Proxy.JSON.js",
147 "Clipperz/PM/Proxy/Proxy.Offline.js", 150 "Clipperz/PM/Proxy/Proxy.Offline.js",
148 "Clipperz/PM/Proxy/Proxy.Offline.DataStore.js", 151 "Clipperz/PM/Proxy/Proxy.Offline.DataStore.js",
149 "Clipperz/PM/Connection.js", 152 "Clipperz/PM/Connection.js",
150 "Clipperz/PM/Crypto.js", 153 "Clipperz/PM/Crypto.js",
151 "Clipperz/PM/BookmarkletProcessor.js", 154 "Clipperz/PM/BookmarkletProcessor.js",
152 "Clipperz/PM/DataModel/User.js", 155 "Clipperz/PM/DataModel/User.js",
153 "Clipperz/PM/DataModel/UserPreferences.js", 156 "Clipperz/PM/DataModel/UserPreferences.js",
154 "Clipperz/PM/DataModel/Header.js", 157 "Clipperz/PM/DataModel/Header.js",
155 "Clipperz/PM/DataModel/Statistics.js", 158 "Clipperz/PM/DataModel/Statistics.js",
156 "Clipperz/PM/DataModel/Record.js", 159 "Clipperz/PM/DataModel/Record.js",
157 "Clipperz/PM/DataModel/RecordField.js", 160 "Clipperz/PM/DataModel/RecordField.js",
158 "Clipperz/PM/DataModel/RecordVersion.js", 161 "Clipperz/PM/DataModel/RecordVersion.js",
159 "Clipperz/PM/DataModel/DirectLogin.js", 162 "Clipperz/PM/DataModel/DirectLogin.js",
160 "Clipperz/PM/DataModel/DirectLoginReference.js", 163 "Clipperz/PM/DataModel/DirectLoginReference.js",
161 "Clipperz/PM/DataModel/DirectLoginInput.js", 164 "Clipperz/PM/DataModel/DirectLoginInput.js",
162 "Clipperz/PM/DataModel/DirectLoginBinding.js", 165 "Clipperz/PM/DataModel/DirectLoginBinding.js",
163 "Clipperz/PM/DataModel/OneTimePasswordManager.js", 166 "Clipperz/PM/DataModel/OneTimePasswordManager.js",
164 "Clipperz/PM/DataModel/OneTimePassword.js", 167 "Clipperz/PM/DataModel/OneTimePassword.js",
165 "Clipperz/YUI/IBLayoutManager.js", 168 "Clipperz/YUI/IBLayoutManager.js",
166 "Clipperz/YUI/IBLayoutRegion.js", 169 "Clipperz/YUI/IBLayoutRegion.js",
167 "Clipperz/YUI/Drawer.js", 170 "Clipperz/YUI/Drawer.js",
168 "Clipperz/YUI/Collapser.js", 171 "Clipperz/YUI/Collapser.js",
169 "Clipperz/YUI/MessageBox.js", 172 "Clipperz/YUI/MessageBox.js",
170 "Clipperz/YUI/DomHelper.js", 173 "Clipperz/YUI/DomHelper.js",
171 174
172 "Clipperz/PM/Main.js" 175 "Clipperz/PM/Main.js"
173 ], 176 ],
174 177
175 "css": [ 178 "css": [
176 "yui-extensions/reset-min.css", 179 "yui-extensions/reset-min.css",
177 "yui-extensions/core.css", 180 "yui-extensions/core.css",
178 "yui-extensions/basic-dialog.css", 181 "yui-extensions/basic-dialog.css",
179 "yui-extensions/button.css", 182 "yui-extensions/button.css",
180 "clipperz/clipperz.css", 183 "clipperz/clipperz.css",
181 "clipperz/compact.css", 184 "clipperz/compact.css",
182 "clipperz/ytheme-clipperz.css" 185 "clipperz/ytheme-clipperz.css"
183 ] 186 ]
184} 187}
diff --git a/frontend/gamma/js/MochiKit/Async.js b/frontend/gamma/js/MochiKit/Async.js
index c7408e7..cc43835 100644
--- a/frontend/gamma/js/MochiKit/Async.js
+++ b/frontend/gamma/js/MochiKit/Async.js
@@ -1,640 +1,706 @@
1/*** 1/***
2 2
3MochiKit.Async 1.5 3MochiKit.Async 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Async', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'Async', '1.5', ['Base']);
12 12
13/** @id MochiKit.Async.Deferred */ 13/** @id MochiKit.Async.Deferred */
14MochiKit.Async.Deferred = function (/* optional */ canceller) { 14MochiKit.Async.Deferred = function (/* optional */ canceller) {
15 this.chain = []; 15 this.chain = [];
16 this.id = this._nextId(); 16 this.id = this._nextId();
17 this.fired = -1; 17 this.fired = -1;
18 this.paused = 0; 18 this.paused = 0;
19 this.results = [null, null]; 19 this.results = [null, null];
20 this.canceller = canceller; 20 this.canceller = canceller;
21 this.silentlyCancelled = false; 21 this.silentlyCancelled = false;
22 this.chained = false; 22 this.chained = false;
23 this.finalized = false;
23}; 24};
24 25
25MochiKit.Async.Deferred.prototype = { 26MochiKit.Async.Deferred.prototype = {
26 /** @id MochiKit.Async.Deferred.prototype.repr */ 27 /** @id MochiKit.Async.Deferred.prototype.repr */
27 repr: function () { 28 repr: function () {
28 var state; 29 return 'Deferred(' + this.id + ', ' + this.state() + ')';
29 if (this.fired == -1) {
30 state = 'unfired';
31 } else if (this.fired === 0) {
32 state = 'success';
33 } else {
34 state = 'error';
35 }
36 return 'Deferred(' + this.id + ', ' + state + ')';
37 }, 30 },
38 31
39 toString: MochiKit.Base.forwardCall("repr"), 32 toString: MochiKit.Base.forwardCall("repr"),
40 33
41 _nextId: MochiKit.Base.counter(), 34 _nextId: MochiKit.Base.counter(),
42 35
36 /** @id MochiKit.Async.Deferred.prototype.state */
37 state: function () {
38 if (this.fired == -1) {
39 return 'unfired';
40 } else if (this.fired === 0) {
41 return 'success';
42 } else {
43 return 'error';
44 }
45 },
46
43 /** @id MochiKit.Async.Deferred.prototype.cancel */ 47 /** @id MochiKit.Async.Deferred.prototype.cancel */
44 cancel: function () { 48 cancel: function (e) {
45 var self = MochiKit.Async; 49 var self = MochiKit.Async;
46 if (this.fired == -1) { 50 if (this.fired == -1) {
47 if (this.canceller) { 51 if (this.canceller) {
48 this.canceller(this); 52 this.canceller(this);
49 } else { 53 } else {
50 this.silentlyCancelled = true; 54 this.silentlyCancelled = true;
51 } 55 }
52 if (this.fired == -1) { 56 if (this.fired == -1) {
53 this.errback(new self.CancelledError(this)); 57 if (typeof(e) === 'string') {
58 e = new self.GenericError(e);
59 } else if (!(e instanceof Error)) {
60 e = new self.CancelledError(this);
61 }
62 this.errback(e);
54 } 63 }
55 } else if ((this.fired === 0) && (this.results[0] instanceof self.Deferred)) { 64 } else if ((this.fired === 0) && (this.results[0] instanceof self.Deferred)) {
56 this.results[0].cancel(); 65 this.results[0].cancel(e);
57 } 66 }
58 }, 67 },
59 68
60 _resback: function (res) { 69 _resback: function (res) {
61 /*** 70 /***
62 71
63 The primitive that means either callback or errback 72 The primitive that means either callback or errback
64 73
65 ***/ 74 ***/
66 this.fired = ((res instanceof Error) ? 1 : 0); 75 this.fired = ((res instanceof Error) ? 1 : 0);
67 this.results[this.fired] = res; 76 this.results[this.fired] = res;
68 this._fire(); 77 if (this.paused === 0) {
78 this._fire();
79 }
69 }, 80 },
70 81
71 _check: function () { 82 _check: function () {
72 if (this.fired != -1) { 83 if (this.fired != -1) {
73 if (!this.silentlyCancelled) { 84 if (!this.silentlyCancelled) {
74 throw new MochiKit.Async.AlreadyCalledError(this); 85 throw new MochiKit.Async.AlreadyCalledError(this);
75 } 86 }
76 this.silentlyCancelled = false; 87 this.silentlyCancelled = false;
77 return; 88 return;
78 } 89 }
79 }, 90 },
80 91
81 /** @id MochiKit.Async.Deferred.prototype.callback */ 92 /** @id MochiKit.Async.Deferred.prototype.callback */
82 callback: function (res) { 93 callback: function (res) {
83 this._check(); 94 this._check();
84 if (res instanceof MochiKit.Async.Deferred) { 95 if (res instanceof MochiKit.Async.Deferred) {
85 throw new Error("Deferred instances can only be chained if they are the result of a callback"); 96 throw new Error("Deferred instances can only be chained if they are the result of a callback");
86 } 97 }
87 this._resback(res); 98 this._resback(res);
88 }, 99 },
89 100
90 /** @id MochiKit.Async.Deferred.prototype.errback */ 101 /** @id MochiKit.Async.Deferred.prototype.errback */
91 errback: function (res) { 102 errback: function (res) {
92 this._check(); 103 this._check();
93 var self = MochiKit.Async; 104 var self = MochiKit.Async;
94 if (res instanceof self.Deferred) { 105 if (res instanceof self.Deferred) {
95 throw new Error("Deferred instances can only be chained if they are the result of a callback"); 106 throw new Error("Deferred instances can only be chained if they are the result of a callback");
96 } 107 }
97 if (!(res instanceof Error)) { 108 if (!(res instanceof Error)) {
98 res = new self.GenericError(res); 109 res = new self.GenericError(res);
99 } 110 }
100 this._resback(res); 111 this._resback(res);
101 }, 112 },
102 113
103 /** @id MochiKit.Async.Deferred.prototype.addBoth */ 114 /** @id MochiKit.Async.Deferred.prototype.addBoth */
104 addBoth: function (fn) { 115 addBoth: function (fn) {
105 if (arguments.length > 1) { 116 if (arguments.length > 1) {
106 fn = MochiKit.Base.partial.apply(null, arguments); 117 fn = MochiKit.Base.partial.apply(null, arguments);
107 } 118 }
108 return this.addCallbacks(fn, fn); 119 return this.addCallbacks(fn, fn);
109 }, 120 },
110 121
111 /** @id MochiKit.Async.Deferred.prototype.addCallback */ 122 /** @id MochiKit.Async.Deferred.prototype.addCallback */
112 addCallback: function (fn) { 123 addCallback: function (fn) {
113 if (arguments.length > 1) { 124 if (arguments.length > 1) {
114 fn = MochiKit.Base.partial.apply(null, arguments); 125 fn = MochiKit.Base.partial.apply(null, arguments);
115 } 126 }
116 return this.addCallbacks(fn, null); 127 return this.addCallbacks(fn, null);
117 }, 128 },
118 129
119 /** @id MochiKit.Async.Deferred.prototype.addErrback */ 130 /** @id MochiKit.Async.Deferred.prototype.addErrback */
120 addErrback: function (fn) { 131 addErrback: function (fn) {
121 if (arguments.length > 1) { 132 if (arguments.length > 1) {
122 fn = MochiKit.Base.partial.apply(null, arguments); 133 fn = MochiKit.Base.partial.apply(null, arguments);
123 } 134 }
124 return this.addCallbacks(null, fn); 135 return this.addCallbacks(null, fn);
125 }, 136 },
126 137
127 /** @id MochiKit.Async.Deferred.prototype.addCallbacks */ 138 /** @id MochiKit.Async.Deferred.prototype.addCallbacks */
128 addCallbacks: function (cb, eb) { 139 addCallbacks: function (cb, eb) {
129 if (this.chained) { 140 if (this.chained) {
130 throw new Error("Chained Deferreds can not be re-used"); 141 throw new Error("Chained Deferreds can not be re-used");
131 } 142 }
143 if (this.finalized) {
144 throw new Error("Finalized Deferreds can not be re-used");
145 }
132 this.chain.push([cb, eb]); 146 this.chain.push([cb, eb]);
133 if (this.fired >= 0) { 147 if (this.fired >= 0) {
134 this._fire(); 148 this._fire();
135 } 149 }
136 return this; 150 return this;
137 }, 151 },
138 152
153 /** @id MochiKit.Async.Deferred.prototype.setFinalizer */
154 setFinalizer: function (fn) {
155 if (this.chained) {
156 throw new Error("Chained Deferreds can not be re-used");
157 }
158 if (this.finalized) {
159 throw new Error("Finalized Deferreds can not be re-used");
160 }
161 if (arguments.length > 1) {
162 fn = MochiKit.Base.partial.apply(null, arguments);
163 }
164 this._finalizer = fn;
165 if (this.fired >= 0) {
166 this._fire();
167 }
168 return this;
169 },
170
139 _fire: function () { 171 _fire: function () {
140 /*** 172 /***
141 173
142 Used internally to exhaust the callback sequence when a result 174 Used internally to exhaust the callback sequence when a result
143 is available. 175 is available.
144 176
145 ***/ 177 ***/
146 var chain = this.chain; 178 var chain = this.chain;
147 var fired = this.fired; 179 var fired = this.fired;
148 var res = this.results[fired]; 180 var res = this.results[fired];
149 var self = this; 181 var self = this;
150 var cb = null; 182 var cb = null;
151 while (chain.length > 0 && this.paused === 0) { 183 while (chain.length > 0 && this.paused === 0) {
152 // Array 184 // Array
153 var pair = chain.shift(); 185 var pair = chain.shift();
154 var f = pair[fired]; 186 var f = pair[fired];
155 if (f === null) { 187 if (f === null) {
156 continue; 188 continue;
157 } 189 }
158 try { 190 try {
159 res = f(res); 191 res = f(res);
160 fired = ((res instanceof Error) ? 1 : 0); 192 fired = ((res instanceof Error) ? 1 : 0);
161 if (res instanceof MochiKit.Async.Deferred) { 193 if (res instanceof MochiKit.Async.Deferred) {
162 cb = function (res) { 194 cb = function (res) {
163 self._resback(res);
164 self.paused--; 195 self.paused--;
165 if ((self.paused === 0) && (self.fired >= 0)) { 196 self._resback(res);
166 self._fire();
167 }
168 }; 197 };
169 this.paused++; 198 this.paused++;
170 } 199 }
171 } catch (err) { 200 } catch (err) {
172 fired = 1; 201 fired = 1;
173 if (!(err instanceof Error)) { 202 if (!(err instanceof Error)) {
174 err = new MochiKit.Async.GenericError(err); 203 err = new MochiKit.Async.GenericError(err);
175 } 204 }
176 res = err; 205 res = err;
177 } 206 }
178 } 207 }
179 this.fired = fired; 208 this.fired = fired;
180 this.results[fired] = res; 209 this.results[fired] = res;
210 if (this.chain.length == 0 && this.paused === 0 && this._finalizer) {
211 this.finalized = true;
212 this._finalizer(res);
213 }
181 if (cb && this.paused) { 214 if (cb && this.paused) {
182 // this is for "tail recursion" in case the dependent deferred 215 // this is for "tail recursion" in case the dependent deferred
183 // is already fired 216 // is already fired
184 res.addBoth(cb); 217 res.addBoth(cb);
185 res.chained = true; 218 res.chained = true;
186 } 219 }
187 } 220 }
188}; 221};
189 222
190MochiKit.Base.update(MochiKit.Async, { 223MochiKit.Base.update(MochiKit.Async, {
191 /** @id MochiKit.Async.evalJSONRequest */ 224 /** @id MochiKit.Async.evalJSONRequest */
192 evalJSONRequest: function (req) { 225 evalJSONRequest: function (req) {
193 return MochiKit.Base.evalJSON(req.responseText); 226 return MochiKit.Base.evalJSON(req.responseText);
194 }, 227 },
195 228
196 /** @id MochiKit.Async.succeed */ 229 /** @id MochiKit.Async.succeed */
197 succeed: function (/* optional */result) { 230 succeed: function (/* optional */result) {
198 var d = new MochiKit.Async.Deferred(); 231 var d = new MochiKit.Async.Deferred();
199 d.callback.apply(d, arguments); 232 d.callback.apply(d, arguments);
200 return d; 233 return d;
201 }, 234 },
202 235
203 /** @id MochiKit.Async.fail */ 236 /** @id MochiKit.Async.fail */
204 fail: function (/* optional */result) { 237 fail: function (/* optional */result) {
205 var d = new MochiKit.Async.Deferred(); 238 var d = new MochiKit.Async.Deferred();
206 d.errback.apply(d, arguments); 239 d.errback.apply(d, arguments);
207 return d; 240 return d;
208 }, 241 },
209 242
210 /** @id MochiKit.Async.getXMLHttpRequest */ 243 /** @id MochiKit.Async.getXMLHttpRequest */
211 getXMLHttpRequest: function () { 244 getXMLHttpRequest: function () {
212 var self = arguments.callee; 245 var self = arguments.callee;
213 if (!self.XMLHttpRequest) { 246 if (!self.XMLHttpRequest) {
214 var tryThese = [ 247 var tryThese = [
215 function () { return new XMLHttpRequest(); }, 248 function () { return new XMLHttpRequest(); },
216 function () { return new ActiveXObject('Msxml2.XMLHTTP'); }, 249 function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
217 function () { return new ActiveXObject('Microsoft.XMLHTTP'); }, 250 function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
218 function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); }, 251 function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
219 function () { 252 function () {
220 throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest"); 253 throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest");
221 } 254 }
222 ]; 255 ];
223 for (var i = 0; i < tryThese.length; i++) { 256 for (var i = 0; i < tryThese.length; i++) {
224 var func = tryThese[i]; 257 var func = tryThese[i];
225 try { 258 try {
226 self.XMLHttpRequest = func; 259 self.XMLHttpRequest = func;
227 return func(); 260 return func();
228 } catch (e) { 261 } catch (e) {
229 // pass 262 // pass
230 } 263 }
231 } 264 }
232 } 265 }
233 return self.XMLHttpRequest(); 266 return self.XMLHttpRequest();
234 }, 267 },
235 268
236 _xhr_onreadystatechange: function (d) { 269 _xhr_onreadystatechange: function (d) {
237 // MochiKit.Logging.logDebug('this.readyState', this.readyState); 270 // MochiKit.Logging.logDebug('this.readyState', this.readyState);
238 var m = MochiKit.Base; 271 var m = MochiKit.Base;
239 if (this.readyState == 4) { 272 if (this.readyState == 4) {
240 // IE SUCKS 273 // IE SUCKS
241 try { 274 try {
242 this.onreadystatechange = null; 275 this.onreadystatechange = null;
243 } catch (e) { 276 } catch (e) {
244 try { 277 try {
245 this.onreadystatechange = m.noop; 278 this.onreadystatechange = m.noop;
246 } catch (e) { 279 } catch (e) {
247 } 280 }
248 } 281 }
249 var status = null; 282 var status = null;
250 try { 283 try {
251 status = this.status; 284 status = this.status;
252 if (!status && m.isNotEmpty(this.responseText)) { 285 if (!status && (this.response || m.isNotEmpty(this.responseText))) {
253 // 0 or undefined seems to mean cached or local 286 // 0 or undefined seems to mean cached or local
254 status = 304; 287 status = 304;
255 } 288 }
256 } catch (e) { 289 } catch (e) {
257 // pass 290 // pass
258 // MochiKit.Logging.logDebug('error getting status?', repr(items(e))); 291 // MochiKit.Logging.logDebug('error getting status?', repr(items(e)));
259 } 292 }
260 // 200 is OK, 201 is CREATED, 204 is NO CONTENT 293 // 200 is OK, 201 is CREATED, 204 is NO CONTENT
261 // 304 is NOT MODIFIED, 1223 is apparently a bug in IE 294 // 304 is NOT MODIFIED, 1223 is apparently a bug in IE
262 if (status == 200 || status == 201 || status == 204 || 295 if (status == 200 || status == 201 || status == 204 ||
263 status == 304 || status == 1223) { 296 status == 304 || status == 1223) {
264 d.callback(this); 297 d.callback(this);
265 } else { 298 } else {
266 var err = new MochiKit.Async.XMLHttpRequestError(this, "Request failed"); 299 var err = new MochiKit.Async.XMLHttpRequestError(this, "Request failed");
267 if (err.number) { 300 if (err.number) {
268 // XXX: This seems to happen on page change 301 // XXX: This seems to happen on page change
269 d.errback(err); 302 d.errback(err);
270 } else { 303 } else {
271 // XXX: this seems to happen when the server is unreachable 304 // XXX: this seems to happen when the server is unreachable
272 d.errback(err); 305 d.errback(err);
273 } 306 }
274 } 307 }
275 } 308 }
276 }, 309 },
277 310
278 _xhr_canceller: function (req) { 311 _xhr_canceller: function (req) {
279 // IE SUCKS 312 // IE SUCKS
280 try { 313 try {
281 req.onreadystatechange = null; 314 req.onreadystatechange = null;
282 } catch (e) { 315 } catch (e) {
283 try { 316 try {
284 req.onreadystatechange = MochiKit.Base.noop; 317 req.onreadystatechange = MochiKit.Base.noop;
285 } catch (e) { 318 } catch (e) {
286 } 319 }
287 } 320 }
288 req.abort(); 321 req.abort();
289 }, 322 },
290 323
291 324
292 /** @id MochiKit.Async.sendXMLHttpRequest */ 325 /** @id MochiKit.Async.sendXMLHttpRequest */
293 sendXMLHttpRequest: function (req, /* optional */ sendContent) { 326 sendXMLHttpRequest: function (req, /* optional */ sendContent) {
294 if (typeof(sendContent) == "undefined" || sendContent === null) { 327 if (typeof(sendContent) == "undefined" || sendContent === null) {
295 sendContent = ""; 328 sendContent = "";
296 } 329 }
297 330
298 var m = MochiKit.Base; 331 var m = MochiKit.Base;
299 var self = MochiKit.Async; 332 var self = MochiKit.Async;
300 var d = new self.Deferred(m.partial(self._xhr_canceller, req)); 333 var d = new self.Deferred(m.partial(self._xhr_canceller, req));
301 334
302 try { 335 try {
303 req.onreadystatechange = m.bind(self._xhr_onreadystatechange, 336 req.onreadystatechange = m.bind(self._xhr_onreadystatechange,
304 req, d); 337 req, d);
305 req.send(sendContent); 338 req.send(sendContent);
306 } catch (e) { 339 } catch (e) {
307 try { 340 try {
308 req.onreadystatechange = null; 341 req.onreadystatechange = null;
309 } catch (ignore) { 342 } catch (ignore) {
310 // pass 343 // pass
311 } 344 }
312 d.errback(e); 345 d.errback(e);
313 } 346 }
314 347
315 return d; 348 return d;
316 349
317 }, 350 },
318 351
319 /** @id MochiKit.Async.doXHR */ 352 /** @id MochiKit.Async.doXHR */
320 doXHR: function (url, opts) { 353 doXHR: function (url, opts) {
321 /* 354 /*
322 Work around a Firefox bug by dealing with XHR during 355 Work around a Firefox bug by dealing with XHR during
323 the next event loop iteration. Maybe it's this one: 356 the next event loop iteration. Maybe it's this one:
324 https://bugzilla.mozilla.org/show_bug.cgi?id=249843 357 https://bugzilla.mozilla.org/show_bug.cgi?id=249843
325 */ 358 */
326 var self = MochiKit.Async; 359 var self = MochiKit.Async;
327 return self.callLater(0, self._doXHR, url, opts); 360 return self.callLater(0, self._doXHR, url, opts);
328 }, 361 },
329 362
330 _doXHR: function (url, opts) { 363 _doXHR: function (url, opts) {
331 var m = MochiKit.Base; 364 var m = MochiKit.Base;
332 opts = m.update({ 365 opts = m.update({
333 method: 'GET', 366 method: 'GET',
334 sendContent: '' 367 sendContent: ''
335 /* 368 /*
336 queryString: undefined, 369 queryString: undefined,
337 username: undefined, 370 username: undefined,
338 password: undefined, 371 password: undefined,
339 headers: undefined, 372 headers: undefined,
340 mimeType: undefined 373 mimeType: undefined,
374 responseType: undefined
341 */ 375 */
342 }, opts); 376 }, opts);
343 var self = MochiKit.Async; 377 var self = MochiKit.Async;
344 var req = self.getXMLHttpRequest(); 378 var req = self.getXMLHttpRequest();
345 if (opts.queryString) { 379 if (opts.queryString) {
346 var qs = m.queryString(opts.queryString); 380 var qs = m.queryString(opts.queryString);
347 if (qs) { 381 if (qs) {
348 url += "?" + qs; 382 url += "?" + qs;
349 } 383 }
350 } 384 }
351 // Safari will send undefined:undefined, so we have to check. 385 // Safari will send undefined:undefined, so we have to check.
352 // We can't use apply, since the function is native. 386 // We can't use apply, since the function is native.
353 if ('username' in opts) { 387 if ('username' in opts) {
354 req.open(opts.method, url, true, opts.username, opts.password); 388 req.open(opts.method, url, true, opts.username, opts.password);
355 } else { 389 } else {
356 req.open(opts.method, url, true); 390 req.open(opts.method, url, true);
357 } 391 }
358 if (req.overrideMimeType && opts.mimeType) { 392 if (req.overrideMimeType && opts.mimeType) {
359 req.overrideMimeType(opts.mimeType); 393 req.overrideMimeType(opts.mimeType);
360 } 394 }
361 req.setRequestHeader("X-Requested-With", "XMLHttpRequest"); 395 req.setRequestHeader("X-Requested-With", "XMLHttpRequest");
362 if (opts.headers) { 396 if (opts.headers) {
363 var headers = opts.headers; 397 var headers = opts.headers;
364 if (!m.isArrayLike(headers)) { 398 if (!m.isArrayLike(headers)) {
365 headers = m.items(headers); 399 headers = m.items(headers);
366 } 400 }
367 for (var i = 0; i < headers.length; i++) { 401 for (var i = 0; i < headers.length; i++) {
368 var header = headers[i]; 402 var header = headers[i];
369 var name = header[0]; 403 var name = header[0];
370 var value = header[1]; 404 var value = header[1];
371 req.setRequestHeader(name, value); 405 req.setRequestHeader(name, value);
372 } 406 }
373 } 407 }
408 if ("responseType" in opts && "responseType" in req) {
409 req.responseType = opts.responseType;
410 }
374 return self.sendXMLHttpRequest(req, opts.sendContent); 411 return self.sendXMLHttpRequest(req, opts.sendContent);
375 }, 412 },
376 413
377 _buildURL: function (url/*, ...*/) { 414 _buildURL: function (url/*, ...*/) {
378 if (arguments.length > 1) { 415 if (arguments.length > 1) {
379 var m = MochiKit.Base; 416 var m = MochiKit.Base;
380 var qs = m.queryString.apply(null, m.extend(null, arguments, 1)); 417 var qs = m.queryString.apply(null, m.extend(null, arguments, 1));
381 if (qs) { 418 if (qs) {
382 return url + "?" + qs; 419 return url + "?" + qs;
383 } 420 }
384 } 421 }
385 return url; 422 return url;
386 }, 423 },
387 424
388 /** @id MochiKit.Async.doSimpleXMLHttpRequest */ 425 /** @id MochiKit.Async.doSimpleXMLHttpRequest */
389 doSimpleXMLHttpRequest: function (url/*, ...*/) { 426 doSimpleXMLHttpRequest: function (url/*, ...*/) {
390 var self = MochiKit.Async; 427 var self = MochiKit.Async;
391 url = self._buildURL.apply(self, arguments); 428 url = self._buildURL.apply(self, arguments);
392 return self.doXHR(url); 429 return self.doXHR(url);
393 }, 430 },
394 431
395 /** @id MochiKit.Async.loadJSONDoc */ 432 /** @id MochiKit.Async.loadJSONDoc */
396 loadJSONDoc: function (url/*, ...*/) { 433 loadJSONDoc: function (url/*, ...*/) {
397 var self = MochiKit.Async; 434 var self = MochiKit.Async;
398 url = self._buildURL.apply(self, arguments); 435 url = self._buildURL.apply(self, arguments);
399 var d = self.doXHR(url, { 436 var d = self.doXHR(url, {
400 'mimeType': 'text/plain', 437 'mimeType': 'text/plain',
401 'headers': [['Accept', 'application/json']] 438 'headers': [['Accept', 'application/json']]
402 }); 439 });
403 d = d.addCallback(self.evalJSONRequest); 440 d = d.addCallback(self.evalJSONRequest);
404 return d; 441 return d;
405 }, 442 },
406 443
444 /** @id MochiKit.Async.loadScript */
445 loadScript: function (url) {
446 var d = new MochiKit.Async.Deferred();
447 var script = document.createElement("script");
448 script.type = "text/javascript";
449 script.src = url;
450 script.onload = function () {
451 script.onload = null;
452 script.onerror = null;
453 script.onreadystatechange = null;
454 script = null;
455 d.callback();
456 };
457 script.onerror = function (msg) {
458 script.onload = null;
459 script.onerror = null;
460 script.onreadystatechange = null;
461 script = null;
462 msg = "Failed to load script at " + url + ": " + msg;
463 d.errback(new URIError(msg, url));
464 }
465 script.onreadystatechange = function () {
466 if (script.readyState == "loaded" || script.readyState == "complete") {
467 script.onload();
468 } else {
469 // IE doesn't bother to report errors...
470 MochiKit.Async.callLater(10, script.onerror, "Script loading timed out")
471 }
472 };
473 document.getElementsByTagName("head")[0].appendChild(script);
474 return d;
475 },
476
407 /** @id MochiKit.Async.wait */ 477 /** @id MochiKit.Async.wait */
408 wait: function (seconds, /* optional */value) { 478 wait: function (seconds, /* optional */value) {
409 var d = new MochiKit.Async.Deferred(); 479 var d = new MochiKit.Async.Deferred();
410 var m = MochiKit.Base; 480 var cb = MochiKit.Base.bind("callback", d, value);
411 if (typeof(value) != 'undefined') { 481 var timeout = setTimeout(cb, Math.floor(seconds * 1000));
412 d.addCallback(function () { return value; });
413 }
414 var timeout = setTimeout(
415 m.bind("callback", d),
416 Math.floor(seconds * 1000));
417 d.canceller = function () { 482 d.canceller = function () {
418 try { 483 try {
419 clearTimeout(timeout); 484 clearTimeout(timeout);
420 } catch (e) { 485 } catch (e) {
421 // pass 486 // pass
422 } 487 }
423 }; 488 };
424 return d; 489 return d;
425 }, 490 },
426 491
427 /** @id MochiKit.Async.callLater */ 492 /** @id MochiKit.Async.callLater */
428 callLater: function (seconds, func) { 493 callLater: function (seconds, func) {
429 var m = MochiKit.Base; 494 var m = MochiKit.Base;
430 var pfunc = m.partial.apply(m, m.extend(null, arguments, 1)); 495 var pfunc = m.partial.apply(m, m.extend(null, arguments, 1));
431 return MochiKit.Async.wait(seconds).addCallback( 496 return MochiKit.Async.wait(seconds).addCallback(
432 function (res) { return pfunc(); } 497 function (res) { return pfunc(); }
433 ); 498 );
434 } 499 }
435}); 500});
436 501
437 502
438/** @id MochiKit.Async.DeferredLock */ 503/** @id MochiKit.Async.DeferredLock */
439MochiKit.Async.DeferredLock = function () { 504MochiKit.Async.DeferredLock = function () {
440 this.waiting = []; 505 this.waiting = [];
441 this.locked = false; 506 this.locked = false;
442 this.id = this._nextId(); 507 this.id = this._nextId();
443}; 508};
444 509
445MochiKit.Async.DeferredLock.prototype = { 510MochiKit.Async.DeferredLock.prototype = {
446 __class__: MochiKit.Async.DeferredLock, 511 __class__: MochiKit.Async.DeferredLock,
447 /** @id MochiKit.Async.DeferredLock.prototype.acquire */ 512 /** @id MochiKit.Async.DeferredLock.prototype.acquire */
448 acquire: function () { 513 acquire: function () {
449 var d = new MochiKit.Async.Deferred(); 514 var d = new MochiKit.Async.Deferred();
450 if (this.locked) { 515 if (this.locked) {
451 this.waiting.push(d); 516 this.waiting.push(d);
452 } else { 517 } else {
453 this.locked = true; 518 this.locked = true;
454 d.callback(this); 519 d.callback(this);
455 } 520 }
456 return d; 521 return d;
457 }, 522 },
458 /** @id MochiKit.Async.DeferredLock.prototype.release */ 523 /** @id MochiKit.Async.DeferredLock.prototype.release */
459 release: function () { 524 release: function () {
460 if (!this.locked) { 525 if (!this.locked) {
461 throw TypeError("Tried to release an unlocked DeferredLock"); 526 throw TypeError("Tried to release an unlocked DeferredLock");
462 } 527 }
463 this.locked = false; 528 this.locked = false;
464 if (this.waiting.length > 0) { 529 if (this.waiting.length > 0) {
465 this.locked = true; 530 this.locked = true;
466 this.waiting.shift().callback(this); 531 this.waiting.shift().callback(this);
467 } 532 }
468 }, 533 },
469 _nextId: MochiKit.Base.counter(), 534 _nextId: MochiKit.Base.counter(),
470 repr: function () { 535 repr: function () {
471 var state; 536 var state;
472 if (this.locked) { 537 if (this.locked) {
473 state = 'locked, ' + this.waiting.length + ' waiting'; 538 state = 'locked, ' + this.waiting.length + ' waiting';
474 } else { 539 } else {
475 state = 'unlocked'; 540 state = 'unlocked';
476 } 541 }
477 return 'DeferredLock(' + this.id + ', ' + state + ')'; 542 return 'DeferredLock(' + this.id + ', ' + state + ')';
478 }, 543 },
479 toString: MochiKit.Base.forwardCall("repr") 544 toString: MochiKit.Base.forwardCall("repr")
480 545
481}; 546};
482 547
483/** @id MochiKit.Async.DeferredList */ 548/** @id MochiKit.Async.DeferredList */
484MochiKit.Async.DeferredList = function (list, /* optional */fireOnOneCallback, fireOnOneErrback, consumeErrors, canceller) { 549MochiKit.Async.DeferredList = function (list, /* optional */fireOnOneCallback, fireOnOneErrback, consumeErrors, canceller) {
485 550
486 // call parent constructor 551 // call parent constructor
487 MochiKit.Async.Deferred.apply(this, [canceller]); 552 MochiKit.Async.Deferred.apply(this, [canceller]);
488 553
489 this.list = list; 554 this.list = list;
490 var resultList = []; 555 var resultList = [];
491 this.resultList = resultList; 556 this.resultList = resultList;
492 557
493 this.finishedCount = 0; 558 this.finishedCount = 0;
494 this.fireOnOneCallback = fireOnOneCallback; 559 this.fireOnOneCallback = fireOnOneCallback;
495 this.fireOnOneErrback = fireOnOneErrback; 560 this.fireOnOneErrback = fireOnOneErrback;
496 this.consumeErrors = consumeErrors; 561 this.consumeErrors = consumeErrors;
497 562
498 var cb = MochiKit.Base.bind(this._cbDeferred, this); 563 var cb = MochiKit.Base.bind(this._cbDeferred, this);
499 for (var i = 0; i < list.length; i++) { 564 for (var i = 0; i < list.length; i++) {
500 var d = list[i]; 565 var d = list[i];
501 resultList.push(undefined); 566 resultList.push(undefined);
502 d.addCallback(cb, i, true); 567 d.addCallback(cb, i, true);
503 d.addErrback(cb, i, false); 568 d.addErrback(cb, i, false);
504 } 569 }
505 570
506 if (list.length === 0 && !fireOnOneCallback) { 571 if (list.length === 0 && !fireOnOneCallback) {
507 this.callback(this.resultList); 572 this.callback(this.resultList);
508 } 573 }
509 574
510}; 575};
511 576
512MochiKit.Async.DeferredList.prototype = new MochiKit.Async.Deferred(); 577MochiKit.Async.DeferredList.prototype = new MochiKit.Async.Deferred();
578MochiKit.Async.DeferredList.prototype.constructor = MochiKit.Async.DeferredList;
513 579
514MochiKit.Async.DeferredList.prototype._cbDeferred = function (index, succeeded, result) { 580MochiKit.Async.DeferredList.prototype._cbDeferred = function (index, succeeded, result) {
515 this.resultList[index] = [succeeded, result]; 581 this.resultList[index] = [succeeded, result];
516 this.finishedCount += 1; 582 this.finishedCount += 1;
517 if (this.fired == -1) { 583 if (this.fired == -1) {
518 if (succeeded && this.fireOnOneCallback) { 584 if (succeeded && this.fireOnOneCallback) {
519 this.callback([index, result]); 585 this.callback([index, result]);
520 } else if (!succeeded && this.fireOnOneErrback) { 586 } else if (!succeeded && this.fireOnOneErrback) {
521 this.errback(result); 587 this.errback(result);
522 } else if (this.finishedCount == this.list.length) { 588 } else if (this.finishedCount == this.list.length) {
523 this.callback(this.resultList); 589 this.callback(this.resultList);
524 } 590 }
525 } 591 }
526 if (!succeeded && this.consumeErrors) { 592 if (!succeeded && this.consumeErrors) {
527 result = null; 593 result = null;
528 } 594 }
529 return result; 595 return result;
530}; 596};
531 597
532/** @id MochiKit.Async.gatherResults */ 598/** @id MochiKit.Async.gatherResults */
533MochiKit.Async.gatherResults = function (deferredList) { 599MochiKit.Async.gatherResults = function (deferredList) {
534 var d = new MochiKit.Async.DeferredList(deferredList, false, true, false); 600 var d = new MochiKit.Async.DeferredList(deferredList, false, true, false);
535 d.addCallback(function (results) { 601 d.addCallback(function (results) {
536 var ret = []; 602 var ret = [];
537 for (var i = 0; i < results.length; i++) { 603 for (var i = 0; i < results.length; i++) {
538 ret.push(results[i][1]); 604 ret.push(results[i][1]);
539 } 605 }
540 return ret; 606 return ret;
541 }); 607 });
542 return d; 608 return d;
543}; 609};
544 610
545/** @id MochiKit.Async.maybeDeferred */ 611/** @id MochiKit.Async.maybeDeferred */
546MochiKit.Async.maybeDeferred = function (func) { 612MochiKit.Async.maybeDeferred = function (func) {
547 var self = MochiKit.Async; 613 var self = MochiKit.Async;
548 var result; 614 var result;
549 try { 615 try {
550 var r = func.apply(null, MochiKit.Base.extend([], arguments, 1)); 616 var r = func.apply(null, MochiKit.Base.extend([], arguments, 1));
551 if (r instanceof self.Deferred) { 617 if (r instanceof self.Deferred) {
552 result = r; 618 result = r;
553 } else if (r instanceof Error) { 619 } else if (r instanceof Error) {
554 result = self.fail(r); 620 result = self.fail(r);
555 } else { 621 } else {
556 result = self.succeed(r); 622 result = self.succeed(r);
557 } 623 }
558 } catch (e) { 624 } catch (e) {
559 result = self.fail(e); 625 result = self.fail(e);
560 } 626 }
561 return result; 627 return result;
562}; 628};
563 629
564 630
565MochiKit.Async.__new__ = function () { 631MochiKit.Async.__new__ = function () {
566 var m = MochiKit.Base; 632 var m = MochiKit.Base;
567 var ne = m.partial(m._newNamedError, this); 633 var ne = m.partial(m._newNamedError, this);
568 634
569 ne("AlreadyCalledError", 635 ne("AlreadyCalledError",
570 /** @id MochiKit.Async.AlreadyCalledError */ 636 /** @id MochiKit.Async.AlreadyCalledError */
571 function (deferred) { 637 function (deferred) {
572 /*** 638 /***
573 639
574 Raised by the Deferred if callback or errback happens 640 Raised by the Deferred if callback or errback happens
575 after it was already fired. 641 after it was already fired.
576 642
577 ***/ 643 ***/
578 this.deferred = deferred; 644 this.deferred = deferred;
579 } 645 }
580 ); 646 );
581 647
582 ne("CancelledError", 648 ne("CancelledError",
583 /** @id MochiKit.Async.CancelledError */ 649 /** @id MochiKit.Async.CancelledError */
584 function (deferred) { 650 function (deferred) {
585 /*** 651 /***
586 652
587 Raised by the Deferred cancellation mechanism. 653 Raised by the Deferred cancellation mechanism.
588 654
589 ***/ 655 ***/
590 this.deferred = deferred; 656 this.deferred = deferred;
591 } 657 }
592 ); 658 );
593 659
594 ne("BrowserComplianceError", 660 ne("BrowserComplianceError",
595 /** @id MochiKit.Async.BrowserComplianceError */ 661 /** @id MochiKit.Async.BrowserComplianceError */
596 function (msg) { 662 function (msg) {
597 /*** 663 /***
598 664
599 Raised when the JavaScript runtime is not capable of performing 665 Raised when the JavaScript runtime is not capable of performing
600 the given function. Technically, this should really never be 666 the given function. Technically, this should really never be
601 raised because a non-conforming JavaScript runtime probably 667 raised because a non-conforming JavaScript runtime probably
602 isn't going to support exceptions in the first place. 668 isn't going to support exceptions in the first place.
603 669
604 ***/ 670 ***/
605 this.message = msg; 671 this.message = msg;
606 } 672 }
607 ); 673 );
608 674
609 ne("GenericError", 675 ne("GenericError",
610 /** @id MochiKit.Async.GenericError */ 676 /** @id MochiKit.Async.GenericError */
611 function (msg) { 677 function (msg) {
612 this.message = msg; 678 this.message = msg;
613 } 679 }
614 ); 680 );
615 681
616 ne("XMLHttpRequestError", 682 ne("XMLHttpRequestError",
617 /** @id MochiKit.Async.XMLHttpRequestError */ 683 /** @id MochiKit.Async.XMLHttpRequestError */
618 function (req, msg) { 684 function (req, msg) {
619 /*** 685 /***
620 686
621 Raised when an XMLHttpRequest does not complete for any reason. 687 Raised when an XMLHttpRequest does not complete for any reason.
622 688
623 ***/ 689 ***/
624 this.req = req; 690 this.req = req;
625 this.message = msg; 691 this.message = msg;
626 try { 692 try {
627 // Strange but true that this can raise in some cases. 693 // Strange but true that this can raise in some cases.
628 this.number = req.status; 694 this.number = req.status;
629 } catch (e) { 695 } catch (e) {
630 // pass 696 // pass
631 } 697 }
632 } 698 }
633 ); 699 );
634 700
635 m.nameFunctions(this); 701 m.nameFunctions(this);
636}; 702};
637 703
638MochiKit.Async.__new__(); 704MochiKit.Async.__new__();
639 705
640MochiKit.Base._exportSymbols(this, MochiKit.Async); 706MochiKit.Base._exportSymbols(this, MochiKit.Async);
diff --git a/frontend/gamma/js/MochiKit/Base.js b/frontend/gamma/js/MochiKit/Base.js
index d33c269..ca1734c 100644
--- a/frontend/gamma/js/MochiKit/Base.js
+++ b/frontend/gamma/js/MochiKit/Base.js
@@ -1,1452 +1,1500 @@
1/*** 1/***
2 2
3MochiKit.Base 1.5 3MochiKit.Base 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11if (typeof(MochiKit) == 'undefined') { 11
12 MochiKit = {}; 12// MochiKit module (namespace)
13} 13var MochiKit = MochiKit || {};
14if (typeof(MochiKit.__export__) == "undefined") { 14if (typeof(MochiKit.__export__) == "undefined") {
15 MochiKit.__export__ = true; 15 MochiKit.__export__ = true;
16} 16}
17if (typeof(MochiKit.Base) == 'undefined') { 17MochiKit.NAME = "MochiKit";
18 MochiKit.Base = {}; 18MochiKit.VERSION = "1.5";
19} 19MochiKit.__repr__ = function () {
20 return "[" + this.NAME + " " + this.VERSION + "]";
21};
22MochiKit.toString = function () {
23 return this.__repr__();
24};
25
26
27// MochiKit.Base module
28MochiKit.Base = MochiKit.Base || {};
20 29
21/** 30/**
22 * Registers a new MochiKit module. This function will insert a new 31 * Creates a new module in a parent namespace. This function will
23 * property into the "MochiKit" object, making sure that all 32 * create a new empty module object with "NAME", "VERSION",
24 * dependency modules have already been inserted. It will also make 33 * "toString" and "__repr__" properties. This object will be inserted into the parent object
25 * sure that the appropriate properties and default module functions 34 * using the specified name (i.e. parent[name] = module). It will
26 * are defined. 35 * also verify that all the dependency modules are defined in the
36 * parent, or an error will be thrown.
27 * 37 *
38 * @param {Object} parent the parent module (use "this" or "window" for
39 * a global module)
28 * @param {String} name the module name, e.g. "Base" 40 * @param {String} name the module name, e.g. "Base"
29 * @param {String} version the module version, e.g. "1.5" 41 * @param {String} version the module version, e.g. "1.5"
30 * @param {Array} deps the array of module dependencies (as strings) 42 * @param {Array} [deps] the array of module dependencies (as strings)
31 */ 43 */
32MochiKit.Base._module = function (name, version, deps) { 44MochiKit.Base.module = function (parent, name, version, deps) {
33 if (!(name in MochiKit)) { 45 var module = parent[name] = parent[name] || {};
34 MochiKit[name] = {}; 46 var prefix = (parent.NAME ? parent.NAME + "." : "");
35 } 47 module.NAME = prefix + name;
36 var module = MochiKit[name];
37 module.NAME = "MochiKit." + name;
38 module.VERSION = version; 48 module.VERSION = version;
39 module.__repr__ = function () { 49 module.__repr__ = function () {
40 return "[" + this.NAME + " " + this.VERSION + "]"; 50 return "[" + this.NAME + " " + this.VERSION + "]";
41 }; 51 };
42 module.toString = function () { 52 module.toString = function () {
43 return this.__repr__(); 53 return this.__repr__();
44 }; 54 };
45 for (var i = 0; i < deps.length; i++) { 55 for (var i = 0; deps != null && i < deps.length; i++) {
46 if (!(deps[i] in MochiKit)) { 56 if (!(deps[i] in parent)) {
47 throw 'MochiKit.' + name + ' depends on MochiKit.' + deps[i] + '!'; 57 throw module.NAME + ' depends on ' + prefix + deps[i] + '!';
48 } 58 }
49 } 59 }
50} 60 return module;
61};
51 62
52MochiKit.Base._module("Base", "1.5", []); 63MochiKit.Base.module(MochiKit, "Base", "1.5", []);
53 64
54/** @id MochiKit.Base.update */ 65/** @id MochiKit.Base.update */
55MochiKit.Base.update = function (self, obj/*, ... */) { 66MochiKit.Base.update = function (self, obj/*, ... */) {
56 if (self === null || self === undefined) { 67 if (self === null || self === undefined) {
57 self = {}; 68 self = {};
58 } 69 }
59 for (var i = 1; i < arguments.length; i++) { 70 for (var i = 1; i < arguments.length; i++) {
60 var o = arguments[i]; 71 var o = arguments[i];
61 if (typeof(o) != 'undefined' && o !== null) { 72 if (typeof(o) != 'undefined' && o !== null) {
62 for (var k in o) { 73 for (var k in o) {
63 self[k] = o[k]; 74 self[k] = o[k];
64 } 75 }
65 } 76 }
66 } 77 }
67 return self; 78 return self;
68}; 79};
69 80
70MochiKit.Base.update(MochiKit.Base, { 81MochiKit.Base.update(MochiKit.Base, {
71 /** @id MochiKit.Base.camelize */ 82 /** @id MochiKit.Base.camelize */
72 camelize: function (selector) { 83 camelize: function (selector) {
73 /* from dojo.style.toCamelCase */ 84 /* from dojo.style.toCamelCase */
74 var arr = selector.split('-'); 85 var arr = selector.split('-');
75 var cc = arr[0]; 86 var cc = arr[0];
76 for (var i = 1; i < arr.length; i++) { 87 for (var i = 1; i < arr.length; i++) {
77 cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1); 88 cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1);
78 } 89 }
79 return cc; 90 return cc;
80 }, 91 },
81 92
82 /** @id MochiKit.Base.counter */ 93 /** @id MochiKit.Base.counter */
83 counter: function (n/* = 1 */) { 94 counter: function (n/* = 1 */) {
84 if (arguments.length === 0) { 95 if (arguments.length === 0) {
85 n = 1; 96 n = 1;
86 } 97 }
87 return function () { 98 return function () {
88 return n++; 99 return n++;
89 }; 100 };
90 }, 101 },
91 102
92 /** @id MochiKit.Base.clone */ 103 /** @id MochiKit.Base.clone */
93 clone: function (obj) { 104 clone: function (obj) {
94 var me = arguments.callee; 105 var me = arguments.callee;
95 if (arguments.length == 1) { 106 if (arguments.length == 1) {
96 me.prototype = obj; 107 me.prototype = obj;
97 return new me(); 108 return new me();
98 } 109 }
99 }, 110 },
100 111
101 _flattenArray: function (res, lst) { 112 _flattenArray: function (res, lst) {
102 for (var i = 0; i < lst.length; i++) { 113 for (var i = 0; i < lst.length; i++) {
103 var o = lst[i]; 114 var o = lst[i];
104 if (o instanceof Array) { 115 if (o instanceof Array) {
105 arguments.callee(res, o); 116 arguments.callee(res, o);
106 } else { 117 } else {
107 res.push(o); 118 res.push(o);
108 } 119 }
109 } 120 }
110 return res; 121 return res;
111 }, 122 },
112 123
113 /** @id MochiKit.Base.flattenArray */ 124 /** @id MochiKit.Base.flattenArray */
114 flattenArray: function (lst) { 125 flattenArray: function (lst) {
115 return MochiKit.Base._flattenArray([], lst); 126 return MochiKit.Base._flattenArray([], lst);
116 }, 127 },
117 128
118 /** @id MochiKit.Base.flattenArguments */ 129 /** @id MochiKit.Base.flattenArguments */
119 flattenArguments: function (lst/* ...*/) { 130 flattenArguments: function (lst/* ...*/) {
120 var res = []; 131 var res = [];
121 var m = MochiKit.Base; 132 var m = MochiKit.Base;
122 var args = m.extend(null, arguments); 133 var args = m.extend(null, arguments);
123 while (args.length) { 134 while (args.length) {
124 var o = args.shift(); 135 var o = args.shift();
125 if (o && typeof(o) == "object" && typeof(o.length) == "number") { 136 if (o && typeof(o) == "object" && typeof(o.length) == "number") {
126 for (var i = o.length - 1; i >= 0; i--) { 137 for (var i = o.length - 1; i >= 0; i--) {
127 args.unshift(o[i]); 138 args.unshift(o[i]);
128 } 139 }
129 } else { 140 } else {
130 res.push(o); 141 res.push(o);
131 } 142 }
132 } 143 }
133 return res; 144 return res;
134 }, 145 },
135 146
136 /** @id MochiKit.Base.extend */ 147 /** @id MochiKit.Base.extend */
137 extend: function (self, obj, /* optional */skip) { 148 extend: function (self, obj, /* optional */skip) {
138 // Extend an array with an array-like object starting 149 // Extend an array with an array-like object starting
139 // from the skip index 150 // from the skip index
140 if (!skip) { 151 if (!skip) {
141 skip = 0; 152 skip = 0;
142 } 153 }
143 if (obj) { 154 if (obj) {
144 // allow iterable fall-through, but skip the full isArrayLike 155 // allow iterable fall-through, but skip the full isArrayLike
145 // check for speed, this is called often. 156 // check for speed, this is called often.
146 var l = obj.length; 157 var l = obj.length;
147 if (typeof(l) != 'number' /* !isArrayLike(obj) */) { 158 if (typeof(l) != 'number' /* !isArrayLike(obj) */) {
148 if (typeof(MochiKit.Iter) != "undefined") { 159 if (typeof(MochiKit.Iter) != "undefined") {
149 obj = MochiKit.Iter.list(obj); 160 obj = MochiKit.Iter.list(obj);
150 l = obj.length; 161 l = obj.length;
151 } else { 162 } else {
152 throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); 163 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
153 } 164 }
154 } 165 }
155 if (!self) { 166 if (!self) {
156 self = []; 167 self = [];
157 } 168 }
158 for (var i = skip; i < l; i++) { 169 for (var i = skip; i < l; i++) {
159 self.push(obj[i]); 170 self.push(obj[i]);
160 } 171 }
161 } 172 }
162 // This mutates, but it's convenient to return because 173 // This mutates, but it's convenient to return because
163 // it's often used like a constructor when turning some 174 // it's often used like a constructor when turning some
164 // ghetto array-like to a real array 175 // ghetto array-like to a real array
165 return self; 176 return self;
166 }, 177 },
167 178
168 179
169 /** @id MochiKit.Base.updatetree */ 180 /** @id MochiKit.Base.updatetree */
170 updatetree: function (self, obj/*, ...*/) { 181 updatetree: function (self, obj/*, ...*/) {
171 if (self === null || self === undefined) { 182 if (self === null || self === undefined) {
172 self = {}; 183 self = {};
173 } 184 }
174 for (var i = 1; i < arguments.length; i++) { 185 for (var i = 1; i < arguments.length; i++) {
175 var o = arguments[i]; 186 var o = arguments[i];
176 if (typeof(o) != 'undefined' && o !== null) { 187 if (typeof(o) != 'undefined' && o !== null) {
177 for (var k in o) { 188 for (var k in o) {
178 var v = o[k]; 189 var v = o[k];
179 if (typeof(self[k]) == 'object' && typeof(v) == 'object') { 190 if (typeof(self[k]) == 'object' && typeof(v) == 'object') {
180 arguments.callee(self[k], v); 191 arguments.callee(self[k], v);
181 } else { 192 } else {
182 self[k] = v; 193 self[k] = v;
183 } 194 }
184 } 195 }
185 } 196 }
186 } 197 }
187 return self; 198 return self;
188 }, 199 },
189 200
190 /** @id MochiKit.Base.setdefault */ 201 /** @id MochiKit.Base.setdefault */
191 setdefault: function (self, obj/*, ...*/) { 202 setdefault: function (self, obj/*, ...*/) {
192 if (self === null || self === undefined) { 203 if (self === null || self === undefined) {
193 self = {}; 204 self = {};
194 } 205 }
195 for (var i = 1; i < arguments.length; i++) { 206 for (var i = 1; i < arguments.length; i++) {
196 var o = arguments[i]; 207 var o = arguments[i];
197 for (var k in o) { 208 for (var k in o) {
198 if (!(k in self)) { 209 if (!(k in self)) {
199 self[k] = o[k]; 210 self[k] = o[k];
200 } 211 }
201 } 212 }
202 } 213 }
203 return self; 214 return self;
204 }, 215 },
205 216
206 /** @id MochiKit.Base.keys */ 217 /** @id MochiKit.Base.keys */
207 keys: function (obj) { 218 keys: function (obj) {
208 var rval = []; 219 var rval = [];
209 for (var prop in obj) { 220 for (var prop in obj) {
210 rval.push(prop); 221 rval.push(prop);
211 } 222 }
212 return rval; 223 return rval;
213 }, 224 },
214 225
215 /** @id MochiKit.Base.values */ 226 /** @id MochiKit.Base.values */
216 values: function (obj) { 227 values: function (obj) {
217 var rval = []; 228 var rval = [];
218 for (var prop in obj) { 229 for (var prop in obj) {
219 rval.push(obj[prop]); 230 rval.push(obj[prop]);
220 } 231 }
221 return rval; 232 return rval;
222 }, 233 },
223 234
224 /** @id MochiKit.Base.items */ 235 /** @id MochiKit.Base.items */
225 items: function (obj) { 236 items: function (obj) {
226 var rval = []; 237 var rval = [];
227 var e; 238 var e;
228 for (var prop in obj) { 239 for (var prop in obj) {
229 var v; 240 var v;
230 try { 241 try {
231 v = obj[prop]; 242 v = obj[prop];
232 } catch (e) { 243 } catch (e) {
233 continue; 244 continue;
234 } 245 }
235 rval.push([prop, v]); 246 rval.push([prop, v]);
236 } 247 }
237 return rval; 248 return rval;
238 }, 249 },
239 250
240 251
241 _newNamedError: function (module, name, func) { 252 _newNamedError: function (module, name, func) {
242 func.prototype = new MochiKit.Base.NamedError(module.NAME + "." + name); 253 func.prototype = new MochiKit.Base.NamedError(module.NAME + "." + name);
254 func.prototype.constructor = func;
243 module[name] = func; 255 module[name] = func;
244 }, 256 },
245 257
246 258
247 /** @id MochiKit.Base.operator */ 259 /** @id MochiKit.Base.operator */
248 operator: { 260 operator: {
249 // unary logic operators 261 // unary logic operators
250 /** @id MochiKit.Base.truth */ 262 /** @id MochiKit.Base.truth */
251 truth: function (a) { return !!a; }, 263 truth: function (a) { return !!a; },
252 /** @id MochiKit.Base.lognot */ 264 /** @id MochiKit.Base.lognot */
253 lognot: function (a) { return !a; }, 265 lognot: function (a) { return !a; },
254 /** @id MochiKit.Base.identity */ 266 /** @id MochiKit.Base.identity */
255 identity: function (a) { return a; }, 267 identity: function (a) { return a; },
256 268
257 // bitwise unary operators 269 // bitwise unary operators
258 /** @id MochiKit.Base.not */ 270 /** @id MochiKit.Base.not */
259 not: function (a) { return ~a; }, 271 not: function (a) { return ~a; },
260 /** @id MochiKit.Base.neg */ 272 /** @id MochiKit.Base.neg */
261 neg: function (a) { return -a; }, 273 neg: function (a) { return -a; },
262 274
263 // binary operators 275 // binary operators
264 /** @id MochiKit.Base.add */ 276 /** @id MochiKit.Base.add */
265 add: function (a, b) { return a + b; }, 277 add: function (a, b) { return a + b; },
266 /** @id MochiKit.Base.sub */ 278 /** @id MochiKit.Base.sub */
267 sub: function (a, b) { return a - b; }, 279 sub: function (a, b) { return a - b; },
268 /** @id MochiKit.Base.div */ 280 /** @id MochiKit.Base.div */
269 div: function (a, b) { return a / b; }, 281 div: function (a, b) { return a / b; },
270 /** @id MochiKit.Base.mod */ 282 /** @id MochiKit.Base.mod */
271 mod: function (a, b) { return a % b; }, 283 mod: function (a, b) { return a % b; },
272 /** @id MochiKit.Base.mul */ 284 /** @id MochiKit.Base.mul */
273 mul: function (a, b) { return a * b; }, 285 mul: function (a, b) { return a * b; },
274 286
275 // bitwise binary operators 287 // bitwise binary operators
276 /** @id MochiKit.Base.and */ 288 /** @id MochiKit.Base.and */
277 and: function (a, b) { return a & b; }, 289 and: function (a, b) { return a & b; },
278 /** @id MochiKit.Base.or */ 290 /** @id MochiKit.Base.or */
279 or: function (a, b) { return a | b; }, 291 or: function (a, b) { return a | b; },
280 /** @id MochiKit.Base.xor */ 292 /** @id MochiKit.Base.xor */
281 xor: function (a, b) { return a ^ b; }, 293 xor: function (a, b) { return a ^ b; },
282 /** @id MochiKit.Base.lshift */ 294 /** @id MochiKit.Base.lshift */
283 lshift: function (a, b) { return a << b; }, 295 lshift: function (a, b) { return a << b; },
284 /** @id MochiKit.Base.rshift */ 296 /** @id MochiKit.Base.rshift */
285 rshift: function (a, b) { return a >> b; }, 297 rshift: function (a, b) { return a >> b; },
286 /** @id MochiKit.Base.zrshift */ 298 /** @id MochiKit.Base.zrshift */
287 zrshift: function (a, b) { return a >>> b; }, 299 zrshift: function (a, b) { return a >>> b; },
288 300
289 // near-worthless built-in comparators 301 // near-worthless built-in comparators
290 /** @id MochiKit.Base.eq */ 302 /** @id MochiKit.Base.eq */
291 eq: function (a, b) { return a == b; }, 303 eq: function (a, b) { return a == b; },
292 /** @id MochiKit.Base.ne */ 304 /** @id MochiKit.Base.ne */
293 ne: function (a, b) { return a != b; }, 305 ne: function (a, b) { return a != b; },
294 /** @id MochiKit.Base.gt */ 306 /** @id MochiKit.Base.gt */
295 gt: function (a, b) { return a > b; }, 307 gt: function (a, b) { return a > b; },
296 /** @id MochiKit.Base.ge */ 308 /** @id MochiKit.Base.ge */
297 ge: function (a, b) { return a >= b; }, 309 ge: function (a, b) { return a >= b; },
298 /** @id MochiKit.Base.lt */ 310 /** @id MochiKit.Base.lt */
299 lt: function (a, b) { return a < b; }, 311 lt: function (a, b) { return a < b; },
300 /** @id MochiKit.Base.le */ 312 /** @id MochiKit.Base.le */
301 le: function (a, b) { return a <= b; }, 313 le: function (a, b) { return a <= b; },
302 314
303 // strict built-in comparators 315 // strict built-in comparators
304 seq: function (a, b) { return a === b; }, 316 seq: function (a, b) { return a === b; },
305 sne: function (a, b) { return a !== b; }, 317 sne: function (a, b) { return a !== b; },
306 318
307 // compare comparators 319 // compare comparators
308 /** @id MochiKit.Base.ceq */ 320 /** @id MochiKit.Base.ceq */
309 ceq: function (a, b) { return MochiKit.Base.compare(a, b) === 0; }, 321 ceq: function (a, b) { return MochiKit.Base.compare(a, b) === 0; },
310 /** @id MochiKit.Base.cne */ 322 /** @id MochiKit.Base.cne */
311 cne: function (a, b) { return MochiKit.Base.compare(a, b) !== 0; }, 323 cne: function (a, b) { return MochiKit.Base.compare(a, b) !== 0; },
312 /** @id MochiKit.Base.cgt */ 324 /** @id MochiKit.Base.cgt */
313 cgt: function (a, b) { return MochiKit.Base.compare(a, b) == 1; }, 325 cgt: function (a, b) { return MochiKit.Base.compare(a, b) == 1; },
314 /** @id MochiKit.Base.cge */ 326 /** @id MochiKit.Base.cge */
315 cge: function (a, b) { return MochiKit.Base.compare(a, b) != -1; }, 327 cge: function (a, b) { return MochiKit.Base.compare(a, b) != -1; },
316 /** @id MochiKit.Base.clt */ 328 /** @id MochiKit.Base.clt */
317 clt: function (a, b) { return MochiKit.Base.compare(a, b) == -1; }, 329 clt: function (a, b) { return MochiKit.Base.compare(a, b) == -1; },
318 /** @id MochiKit.Base.cle */ 330 /** @id MochiKit.Base.cle */
319 cle: function (a, b) { return MochiKit.Base.compare(a, b) != 1; }, 331 cle: function (a, b) { return MochiKit.Base.compare(a, b) != 1; },
320 332
321 // binary logical operators 333 // binary logical operators
322 /** @id MochiKit.Base.logand */ 334 /** @id MochiKit.Base.logand */
323 logand: function (a, b) { return a && b; }, 335 logand: function (a, b) { return a && b; },
324 /** @id MochiKit.Base.logor */ 336 /** @id MochiKit.Base.logor */
325 logor: function (a, b) { return a || b; }, 337 logor: function (a, b) { return a || b; },
326 /** @id MochiKit.Base.contains */ 338 /** @id MochiKit.Base.contains */
327 contains: function (a, b) { return b in a; } 339 contains: function (a, b) { return b in a; }
328 }, 340 },
329 341
330 /** @id MochiKit.Base.forwardCall */ 342 /** @id MochiKit.Base.forwardCall */
331 forwardCall: function (func) { 343 forwardCall: function (func) {
332 return function () { 344 return function () {
333 return this[func].apply(this, arguments); 345 return this[func].apply(this, arguments);
334 }; 346 };
335 }, 347 },
336 348
337 /** @id MochiKit.Base.itemgetter */ 349 /** @id MochiKit.Base.itemgetter */
338 itemgetter: function (func) { 350 itemgetter: function (func) {
339 return function (arg) { 351 return function (arg) {
340 return arg[func]; 352 return arg[func];
341 }; 353 };
342 }, 354 },
343 355
344 /** @id MochiKit.Base.bool */ 356 /** @id MochiKit.Base.bool */
345 bool: function (value) { 357 bool: function (value) {
346 if (typeof(value) === "boolean" || value instanceof Boolean) { 358 if (typeof(value) === "boolean" || value instanceof Boolean) {
347 return value.valueOf(); 359 return value.valueOf();
348 } else if (typeof(value) === "string" || value instanceof String) { 360 } else if (typeof(value) === "string" || value instanceof String) {
349 return value.length > 0 && value != "false" && value != "null" && 361 return value.length > 0 && value != "false" && value != "null" &&
350 value != "undefined" && value != "0"; 362 value != "undefined" && value != "0";
351 } else if (typeof(value) === "number" || value instanceof Number) { 363 } else if (typeof(value) === "number" || value instanceof Number) {
352 return !isNaN(value) && value != 0; 364 return !isNaN(value) && value != 0;
353 } else if (value != null && typeof(value.length) === "number") { 365 } else if (value != null && typeof(value.length) === "number") {
354 return value.length !== 0 366 return value.length !== 0;
355 } else { 367 } else {
356 return value != null; 368 return value != null;
357 } 369 }
358 }, 370 },
359 371
360 /** @id MochiKit.Base.typeMatcher */ 372 /** @id MochiKit.Base.typeMatcher */
361 typeMatcher: function (/* typ */) { 373 typeMatcher: function (/* typ */) {
362 var types = {}; 374 var types = {};
363 for (var i = 0; i < arguments.length; i++) { 375 for (var i = 0; i < arguments.length; i++) {
364 var typ = arguments[i]; 376 var typ = arguments[i];
365 types[typ] = typ; 377 types[typ] = typ;
366 } 378 }
367 return function () { 379 return function () {
368 for (var i = 0; i < arguments.length; i++) { 380 for (var i = 0; i < arguments.length; i++) {
369 if (!(typeof(arguments[i]) in types)) { 381 if (!(typeof(arguments[i]) in types)) {
370 return false; 382 return false;
371 } 383 }
372 } 384 }
373 return true; 385 return true;
374 }; 386 };
375 }, 387 },
376 388
377 /** @id MochiKit.Base.isNull */ 389 /** @id MochiKit.Base.isNull */
378 isNull: function (/* ... */) { 390 isNull: function (/* ... */) {
379 for (var i = 0; i < arguments.length; i++) { 391 for (var i = 0; i < arguments.length; i++) {
380 if (arguments[i] !== null) { 392 if (arguments[i] !== null) {
381 return false; 393 return false;
382 } 394 }
383 } 395 }
384 return true; 396 return true;
385 }, 397 },
386 398
387 /** @id MochiKit.Base.isUndefinedOrNull */ 399 /** @id MochiKit.Base.isUndefinedOrNull */
388 isUndefinedOrNull: function (/* ... */) { 400 isUndefinedOrNull: function (/* ... */) {
389 for (var i = 0; i < arguments.length; i++) { 401 for (var i = 0; i < arguments.length; i++) {
390 var o = arguments[i]; 402 var o = arguments[i];
391 if (!(typeof(o) == 'undefined' || o === null)) { 403 if (!(typeof(o) == 'undefined' || o === null)) {
392 return false; 404 return false;
393 } 405 }
394 } 406 }
395 return true; 407 return true;
396 }, 408 },
397 409
398 /** @id MochiKit.Base.isEmpty */ 410 /** @id MochiKit.Base.isEmpty */
399 isEmpty: function (obj) { 411 isEmpty: function (obj) {
400 return !MochiKit.Base.isNotEmpty.apply(this, arguments); 412 return !MochiKit.Base.isNotEmpty.apply(this, arguments);
401 }, 413 },
402 414
403 /** @id MochiKit.Base.isNotEmpty */ 415 /** @id MochiKit.Base.isNotEmpty */
404 isNotEmpty: function (obj) { 416 isNotEmpty: function (obj) {
405 for (var i = 0; i < arguments.length; i++) { 417 for (var i = 0; i < arguments.length; i++) {
406 var o = arguments[i]; 418 var o = arguments[i];
407 if (!(o && o.length)) { 419 if (!(o && o.length)) {
408 return false; 420 return false;
409 } 421 }
410 } 422 }
411 return true; 423 return true;
412 }, 424 },
413 425
414 /** @id MochiKit.Base.isArrayLike */ 426 /** @id MochiKit.Base.isArrayLike */
415 isArrayLike: function () { 427 isArrayLike: function () {
416 for (var i = 0; i < arguments.length; i++) { 428 for (var i = 0; i < arguments.length; i++) {
417 var o = arguments[i]; 429 var o = arguments[i];
418 var typ = typeof(o); 430 var typ = typeof(o);
419 if ( 431 if (
420 (typ != 'object' && !(typ == 'function' && typeof(o.item) == 'function')) || 432 (typ != 'object' && !(typ == 'function' && typeof(o.item) == 'function')) ||
421 o === null || 433 o === null ||
422 typeof(o.length) != 'number' || 434 typeof(o.length) != 'number' ||
423 o.nodeType === 3 || 435 o.nodeType === 3 ||
424 o.nodeType === 4 436 o.nodeType === 4
425 ) { 437 ) {
426 return false; 438 return false;
427 } 439 }
428 } 440 }
429 return true; 441 return true;
430 }, 442 },
431 443
432 /** @id MochiKit.Base.isDateLike */ 444 /** @id MochiKit.Base.isDateLike */
433 isDateLike: function () { 445 isDateLike: function () {
434 for (var i = 0; i < arguments.length; i++) { 446 for (var i = 0; i < arguments.length; i++) {
435 var o = arguments[i]; 447 var o = arguments[i];
436 if (typeof(o) != "object" || o === null 448 if (typeof(o) != "object" || o === null
437 || typeof(o.getTime) != 'function') { 449 || typeof(o.getTime) != 'function') {
438 return false; 450 return false;
439 } 451 }
440 } 452 }
441 return true; 453 return true;
442 }, 454 },
443 455
444 456
445 /** @id MochiKit.Base.xmap */ 457 /** @id MochiKit.Base.xmap */
446 xmap: function (fn/*, obj... */) { 458 xmap: function (fn/*, obj... */) {
447 if (fn === null) { 459 if (fn === null) {
448 return MochiKit.Base.extend(null, arguments, 1); 460 return MochiKit.Base.extend(null, arguments, 1);
449 } 461 }
450 var rval = []; 462 var rval = [];
451 for (var i = 1; i < arguments.length; i++) { 463 for (var i = 1; i < arguments.length; i++) {
452 rval.push(fn(arguments[i])); 464 rval.push(fn(arguments[i]));
453 } 465 }
454 return rval; 466 return rval;
455 }, 467 },
456 468
457 /** @id MochiKit.Base.map */ 469 /** @id MochiKit.Base.map */
458 map: function (fn, lst/*, lst... */) { 470 map: function (fn, lst/*, lst... */) {
459 var m = MochiKit.Base; 471 var m = MochiKit.Base;
460 var itr = MochiKit.Iter; 472 var itr = MochiKit.Iter;
461 var isArrayLike = m.isArrayLike; 473 var isArrayLike = m.isArrayLike;
462 if (arguments.length <= 2) { 474 if (arguments.length <= 2) {
463 // allow an iterable to be passed 475 // allow an iterable to be passed
464 if (!isArrayLike(lst)) { 476 if (!isArrayLike(lst)) {
465 if (itr) { 477 if (itr) {
466 // fast path for map(null, iterable) 478 // fast path for map(null, iterable)
467 lst = itr.list(lst); 479 lst = itr.list(lst);
468 if (fn === null) { 480 if (fn === null) {
469 return lst; 481 return lst;
470 } 482 }
471 } else { 483 } else {
472 throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); 484 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
473 } 485 }
474 } 486 }
475 // fast path for map(null, lst) 487 // fast path for map(null, lst)
476 if (fn === null) { 488 if (fn === null) {
477 return m.extend(null, lst); 489 return m.extend(null, lst);
478 } 490 }
479 // disabled fast path for map(fn, lst) 491 // disabled fast path for map(fn, lst)
480 /* 492 /*
481 if (false && typeof(Array.prototype.map) == 'function') { 493 if (false && typeof(Array.prototype.map) == 'function') {
482 // Mozilla fast-path 494 // Mozilla fast-path
483 return Array.prototype.map.call(lst, fn); 495 return Array.prototype.map.call(lst, fn);
484 } 496 }
485 */ 497 */
486 var rval = []; 498 var rval = [];
487 for (var i = 0; i < lst.length; i++) { 499 for (var i = 0; i < lst.length; i++) {
488 rval.push(fn(lst[i])); 500 rval.push(fn(lst[i]));
489 } 501 }
490 return rval; 502 return rval;
491 } else { 503 } else {
492 // default for map(null, ...) is zip(...) 504 // default for map(null, ...) is zip(...)
493 if (fn === null) { 505 if (fn === null) {
494 fn = Array; 506 fn = Array;
495 } 507 }
496 var length = null; 508 var length = null;
497 for (var i = 1; i < arguments.length; i++) { 509 for (var i = 1; i < arguments.length; i++) {
498 // allow iterables to be passed 510 // allow iterables to be passed
499 if (!isArrayLike(arguments[i])) { 511 if (!isArrayLike(arguments[i])) {
500 if (itr) { 512 if (itr) {
501 return itr.list(itr.imap.apply(null, arguments)); 513 return itr.list(itr.imap.apply(null, arguments));
502 } else { 514 } else {
503 throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); 515 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
504 } 516 }
505 } 517 }
506 // find the minimum length 518 // find the minimum length
507 var l = arguments[i].length; 519 var l = arguments[i].length;
508 if (length === null || length > l) { 520 if (length === null || length > l) {
509 length = l; 521 length = l;
510 } 522 }
511 } 523 }
512 rval = []; 524 rval = [];
513 for (var i = 0; i < length; i++) { 525 for (var i = 0; i < length; i++) {
514 var args = []; 526 var args = [];
515 for (var j = 1; j < arguments.length; j++) { 527 for (var j = 1; j < arguments.length; j++) {
516 args.push(arguments[j][i]); 528 args.push(arguments[j][i]);
517 } 529 }
518 rval.push(fn.apply(this, args)); 530 rval.push(fn.apply(this, args));
519 } 531 }
520 return rval; 532 return rval;
521 } 533 }
522 }, 534 },
523 535
524 /** @id MochiKit.Base.xfilter */ 536 /** @id MochiKit.Base.xfilter */
525 xfilter: function (fn/*, obj... */) { 537 xfilter: function (fn/*, obj... */) {
526 var rval = []; 538 var rval = [];
527 if (fn === null) { 539 if (fn === null) {
528 fn = MochiKit.Base.operator.truth; 540 fn = MochiKit.Base.operator.truth;
529 } 541 }
530 for (var i = 1; i < arguments.length; i++) { 542 for (var i = 1; i < arguments.length; i++) {
531 var o = arguments[i]; 543 var o = arguments[i];
532 if (fn(o)) { 544 if (fn(o)) {
533 rval.push(o); 545 rval.push(o);
534 } 546 }
535 } 547 }
536 return rval; 548 return rval;
537 }, 549 },
538 550
539 /** @id MochiKit.Base.filter */ 551 /** @id MochiKit.Base.filter */
540 filter: function (fn, lst, self) { 552 filter: function (fn, lst, self) {
541 var rval = []; 553 var rval = [];
542 // allow an iterable to be passed 554 // allow an iterable to be passed
543 var m = MochiKit.Base; 555 var m = MochiKit.Base;
544 if (!m.isArrayLike(lst)) { 556 if (!m.isArrayLike(lst)) {
545 if (MochiKit.Iter) { 557 if (MochiKit.Iter) {
546 lst = MochiKit.Iter.list(lst); 558 lst = MochiKit.Iter.list(lst);
547 } else { 559 } else {
548 throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); 560 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
549 } 561 }
550 } 562 }
551 if (fn === null) { 563 if (fn === null) {
552 fn = m.operator.truth; 564 fn = m.operator.truth;
553 } 565 }
554 if (typeof(Array.prototype.filter) == 'function') { 566 if (typeof(Array.prototype.filter) == 'function') {
555 // Mozilla fast-path 567 // Mozilla fast-path
556 return Array.prototype.filter.call(lst, fn, self); 568 return Array.prototype.filter.call(lst, fn, self);
557 } else if (typeof(self) == 'undefined' || self === null) { 569 } else if (typeof(self) == 'undefined' || self === null) {
558 for (var i = 0; i < lst.length; i++) { 570 for (var i = 0; i < lst.length; i++) {
559 var o = lst[i]; 571 var o = lst[i];
560 if (fn(o)) { 572 if (fn(o)) {
561 rval.push(o); 573 rval.push(o);
562 } 574 }
563 } 575 }
564 } else { 576 } else {
565 for (var i = 0; i < lst.length; i++) { 577 for (var i = 0; i < lst.length; i++) {
566 o = lst[i]; 578 o = lst[i];
567 if (fn.call(self, o)) { 579 if (fn.call(self, o)) {
568 rval.push(o); 580 rval.push(o);
569 } 581 }
570 } 582 }
571 } 583 }
572 return rval; 584 return rval;
573 }, 585 },
574 586
575 587
576 _wrapDumbFunction: function (func) { 588 _wrapDumbFunction: function (func) {
577 return function () { 589 return function () {
578 // fast path! 590 // fast path!
579 switch (arguments.length) { 591 switch (arguments.length) {
580 case 0: return func(); 592 case 0: return func();
581 case 1: return func(arguments[0]); 593 case 1: return func(arguments[0]);
582 case 2: return func(arguments[0], arguments[1]); 594 case 2: return func(arguments[0], arguments[1]);
583 case 3: return func(arguments[0], arguments[1], arguments[2]); 595 case 3: return func(arguments[0], arguments[1], arguments[2]);
584 } 596 }
585 var args = []; 597 var args = [];
586 for (var i = 0; i < arguments.length; i++) { 598 for (var i = 0; i < arguments.length; i++) {
587 args.push("arguments[" + i + "]"); 599 args.push("arguments[" + i + "]");
588 } 600 }
589 return eval("(func(" + args.join(",") + "))"); 601 return eval("(func(" + args.join(",") + "))");
590 }; 602 };
591 }, 603 },
592 604
593 /** @id MochiKit.Base.methodcaller */ 605 /** @id MochiKit.Base.methodcaller */
594 methodcaller: function (func/*, args... */) { 606 methodcaller: function (func/*, args... */) {
595 var args = MochiKit.Base.extend(null, arguments, 1); 607 var args = MochiKit.Base.extend(null, arguments, 1);
596 if (typeof(func) == "function") { 608 if (typeof(func) == "function") {
597 return function (obj) { 609 return function (obj) {
598 return func.apply(obj, args); 610 return func.apply(obj, args);
599 }; 611 };
600 } else { 612 } else {
601 return function (obj) { 613 return function (obj) {
602 return obj[func].apply(obj, args); 614 return obj[func].apply(obj, args);
603 }; 615 };
604 } 616 }
605 }, 617 },
606 618
607 /** @id MochiKit.Base.method */ 619 /** @id MochiKit.Base.method */
608 method: function (self, func) { 620 method: function (self, func) {
609 var m = MochiKit.Base; 621 var m = MochiKit.Base;
610 return m.bind.apply(this, m.extend([func, self], arguments, 2)); 622 return m.bind.apply(this, m.extend([func, self], arguments, 2));
611 }, 623 },
612 624
613 /** @id MochiKit.Base.compose */ 625 /** @id MochiKit.Base.compose */
614 compose: function (f1, f2/*, f3, ... fN */) { 626 compose: function (f1, f2/*, f3, ... fN */) {
615 var fnlist = []; 627 var fnlist = [];
616 var m = MochiKit.Base; 628 var m = MochiKit.Base;
617 if (arguments.length === 0) { 629 if (arguments.length === 0) {
618 throw new TypeError("compose() requires at least one argument"); 630 throw new TypeError("compose() requires at least one argument");
619 } 631 }
620 for (var i = 0; i < arguments.length; i++) { 632 for (var i = 0; i < arguments.length; i++) {
621 var fn = arguments[i]; 633 var fn = arguments[i];
622 if (typeof(fn) != "function") { 634 if (typeof(fn) != "function") {
623 throw new TypeError(m.repr(fn) + " is not a function"); 635 throw new TypeError(m.repr(fn) + " is not a function");
624 } 636 }
625 fnlist.push(fn); 637 fnlist.push(fn);
626 } 638 }
627 return function () { 639 return function () {
628 var args = arguments; 640 var args = arguments;
629 for (var i = fnlist.length - 1; i >= 0; i--) { 641 for (var i = fnlist.length - 1; i >= 0; i--) {
630 args = [fnlist[i].apply(this, args)]; 642 args = [fnlist[i].apply(this, args)];
631 } 643 }
632 return args[0]; 644 return args[0];
633 }; 645 };
634 }, 646 },
635 647
636 /** @id MochiKit.Base.bind */ 648 /** @id MochiKit.Base.bind */
637 bind: function (func, self/* args... */) { 649 bind: function (func, self/* args... */) {
638 if (typeof(func) == "string") { 650 if (typeof(func) == "string") {
639 func = self[func]; 651 func = self[func];
640 } 652 }
641 var im_func = func.im_func; 653 var im_func = func.im_func;
642 var im_preargs = func.im_preargs; 654 var im_preargs = func.im_preargs;
643 var im_self = func.im_self; 655 var im_self = func.im_self;
644 var m = MochiKit.Base; 656 var m = MochiKit.Base;
645 if (typeof(func) == "function" && typeof(func.apply) == "undefined") { 657 if (typeof(func) == "function" && typeof(func.apply) == "undefined") {
646 // this is for cases where JavaScript sucks ass and gives you a 658 // this is for cases where JavaScript sucks ass and gives you a
647 // really dumb built-in function like alert() that doesn't have 659 // really dumb built-in function like alert() that doesn't have
648 // an apply 660 // an apply
649 func = m._wrapDumbFunction(func); 661 func = m._wrapDumbFunction(func);
650 } 662 }
651 if (typeof(im_func) != 'function') { 663 if (typeof(im_func) != 'function') {
652 im_func = func; 664 im_func = func;
653 } 665 }
654 if (typeof(self) != 'undefined') { 666 if (typeof(self) != 'undefined') {
655 im_self = self; 667 im_self = self;
656 } 668 }
657 if (typeof(im_preargs) == 'undefined') { 669 if (typeof(im_preargs) == 'undefined') {
658 im_preargs = []; 670 im_preargs = [];
659 } else { 671 } else {
660 im_preargs = im_preargs.slice(); 672 im_preargs = im_preargs.slice();
661 } 673 }
662 m.extend(im_preargs, arguments, 2); 674 m.extend(im_preargs, arguments, 2);
663 var newfunc = function () { 675 var newfunc = function () {
664 var args = arguments; 676 var args = arguments;
665 var me = arguments.callee; 677 var me = arguments.callee;
666 if (me.im_preargs.length > 0) { 678 if (me.im_preargs.length > 0) {
667 args = m.concat(me.im_preargs, args); 679 args = m.concat(me.im_preargs, args);
668 } 680 }
669 var self = me.im_self; 681 var self = me.im_self;
670 if (!self) { 682 if (!self) {
671 self = this; 683 self = this;
672 } 684 }
673 return me.im_func.apply(self, args); 685 return me.im_func.apply(self, args);
674 }; 686 };
675 newfunc.im_self = im_self; 687 newfunc.im_self = im_self;
676 newfunc.im_func = im_func; 688 newfunc.im_func = im_func;
677 newfunc.im_preargs = im_preargs; 689 newfunc.im_preargs = im_preargs;
690 if (typeof(im_func.NAME) == 'string') {
691 newfunc.NAME = "bind(" + im_func.NAME + ",...)";
692 }
678 return newfunc; 693 return newfunc;
679 }, 694 },
680 695
681 /** @id MochiKit.Base.bindLate */ 696 /** @id MochiKit.Base.bindLate */
682 bindLate: function (func, self/* args... */) { 697 bindLate: function (func, self/* args... */) {
683 var m = MochiKit.Base; 698 var m = MochiKit.Base;
684 var args = arguments; 699 var args = arguments;
685 if (typeof(func) === "string") { 700 if (typeof(func) === "string") {
686 args = m.extend([m.forwardCall(func)], arguments, 1); 701 args = m.extend([m.forwardCall(func)], arguments, 1);
687 return m.bind.apply(this, args); 702 return m.bind.apply(this, args);
688 } 703 }
689 return m.bind.apply(this, args); 704 return m.bind.apply(this, args);
690 }, 705 },
691 706
692 /** @id MochiKit.Base.bindMethods */ 707 /** @id MochiKit.Base.bindMethods */
693 bindMethods: function (self) { 708 bindMethods: function (self) {
694 var bind = MochiKit.Base.bind; 709 var bind = MochiKit.Base.bind;
695 for (var k in self) { 710 for (var k in self) {
696 var func = self[k]; 711 var func = self[k];
697 if (typeof(func) == 'function') { 712 if (typeof(func) == 'function') {
698 self[k] = bind(func, self); 713 self[k] = bind(func, self);
699 } 714 }
700 } 715 }
701 }, 716 },
702 717
703 /** @id MochiKit.Base.registerComparator */ 718 /** @id MochiKit.Base.registerComparator */
704 registerComparator: function (name, check, comparator, /* optional */ override) { 719 registerComparator: function (name, check, comparator, /* optional */ override) {
705 MochiKit.Base.comparatorRegistry.register(name, check, comparator, override); 720 MochiKit.Base.comparatorRegistry.register(name, check, comparator, override);
706 }, 721 },
707 722
708 _primitives: {'boolean': true, 'string': true, 'number': true}, 723 _primitives: {'boolean': true, 'string': true, 'number': true},
709 724
710 /** @id MochiKit.Base.compare */ 725 /** @id MochiKit.Base.compare */
711 compare: function (a, b) { 726 compare: function (a, b) {
712 if (a == b) { 727 if (a == b) {
713 return 0; 728 return 0;
714 } 729 }
715 var aIsNull = (typeof(a) == 'undefined' || a === null); 730 var aIsNull = (typeof(a) == 'undefined' || a === null);
716 var bIsNull = (typeof(b) == 'undefined' || b === null); 731 var bIsNull = (typeof(b) == 'undefined' || b === null);
717 if (aIsNull && bIsNull) { 732 if (aIsNull && bIsNull) {
718 return 0; 733 return 0;
719 } else if (aIsNull) { 734 } else if (aIsNull) {
720 return -1; 735 return -1;
721 } else if (bIsNull) { 736 } else if (bIsNull) {
722 return 1; 737 return 1;
723 } 738 }
724 var m = MochiKit.Base; 739 var m = MochiKit.Base;
725 // bool, number, string have meaningful comparisons 740 // bool, number, string have meaningful comparisons
726 var prim = m._primitives; 741 var prim = m._primitives;
727 if (!(typeof(a) in prim && typeof(b) in prim)) { 742 if (!(typeof(a) in prim && typeof(b) in prim)) {
728 try { 743 try {
729 return m.comparatorRegistry.match(a, b); 744 return m.comparatorRegistry.match(a, b);
730 } catch (e) { 745 } catch (e) {
731 if (e != m.NotFound) { 746 if (e != m.NotFound) {
732 throw e; 747 throw e;
733 } 748 }
734 } 749 }
735 } 750 }
736 if (a < b) { 751 if (a < b) {
737 return -1; 752 return -1;
738 } else if (a > b) { 753 } else if (a > b) {
739 return 1; 754 return 1;
740 } 755 }
741 // These types can't be compared 756 // These types can't be compared
742 var repr = m.repr; 757 var repr = m.repr;
743 throw new TypeError(repr(a) + " and " + repr(b) + " can not be compared"); 758 throw new TypeError(repr(a) + " and " + repr(b) + " can not be compared");
744 }, 759 },
745 760
746 /** @id MochiKit.Base.compareDateLike */ 761 /** @id MochiKit.Base.compareDateLike */
747 compareDateLike: function (a, b) { 762 compareDateLike: function (a, b) {
748 return MochiKit.Base.compare(a.getTime(), b.getTime()); 763 return MochiKit.Base.compare(a.getTime(), b.getTime());
749 }, 764 },
750 765
751 /** @id MochiKit.Base.compareArrayLike */ 766 /** @id MochiKit.Base.compareArrayLike */
752 compareArrayLike: function (a, b) { 767 compareArrayLike: function (a, b) {
753 var compare = MochiKit.Base.compare; 768 var compare = MochiKit.Base.compare;
754 var count = a.length; 769 var count = a.length;
755 var rval = 0; 770 var rval = 0;
756 if (count > b.length) { 771 if (count > b.length) {
757 rval = 1; 772 rval = 1;
758 count = b.length; 773 count = b.length;
759 } else if (count < b.length) { 774 } else if (count < b.length) {
760 rval = -1; 775 rval = -1;
761 } 776 }
762 for (var i = 0; i < count; i++) { 777 for (var i = 0; i < count; i++) {
763 var cmp = compare(a[i], b[i]); 778 var cmp = compare(a[i], b[i]);
764 if (cmp) { 779 if (cmp) {
765 return cmp; 780 return cmp;
766 } 781 }
767 } 782 }
768 return rval; 783 return rval;
769 }, 784 },
770 785
771 /** @id MochiKit.Base.registerRepr */ 786 /** @id MochiKit.Base.registerRepr */
772 registerRepr: function (name, check, wrap, /* optional */override) { 787 registerRepr: function (name, check, wrap, /* optional */override) {
773 MochiKit.Base.reprRegistry.register(name, check, wrap, override); 788 MochiKit.Base.reprRegistry.register(name, check, wrap, override);
774 }, 789 },
775 790
776 /** @id MochiKit.Base.repr */ 791 /** @id MochiKit.Base.repr */
777 repr: function (o) { 792 repr: function (o) {
778 if (typeof(o) == "undefined") { 793 if (typeof(o) == "undefined") {
779 return "undefined"; 794 return "undefined";
780 } else if (o === null) { 795 } else if (o === null) {
781 return "null"; 796 return "null";
782 } 797 }
783 try { 798 try {
784 if (typeof(o.__repr__) == 'function') { 799 if (typeof(o.__repr__) == 'function') {
785 return o.__repr__(); 800 return o.__repr__();
786 } else if (typeof(o.repr) == 'function' && o.repr != arguments.callee) { 801 } else if (typeof(o.repr) == 'function' && o.repr != arguments.callee) {
787 return o.repr(); 802 return o.repr();
788 } 803 }
789 return MochiKit.Base.reprRegistry.match(o); 804 return MochiKit.Base.reprRegistry.match(o);
790 } catch (e) { 805 } catch (e) {
791 if (typeof(o.NAME) == 'string' && ( 806 try {
792 o.toString == Function.prototype.toString || 807 if (typeof(o.NAME) == 'string' && (
793 o.toString == Object.prototype.toString 808 o.toString == Function.prototype.toString ||
794 )) { 809 o.toString == Object.prototype.toString
795 return o.NAME; 810 )) {
811 return o.NAME;
812 }
813 } catch (ignore) {
796 } 814 }
797 } 815 }
798 try { 816 try {
799 var ostring = (o + ""); 817 var ostring = (o + "");
800 } catch (e) { 818 } catch (e) {
801 return "[" + typeof(o) + "]"; 819 return "[" + typeof(o) + "]";
802 } 820 }
803 if (typeof(o) == "function") { 821 if (typeof(o) == "function") {
804 ostring = ostring.replace(/^\s+/, "").replace(/\s+/g, " "); 822 ostring = ostring.replace(/^\s+/, "").replace(/\s+/g, " ");
805 ostring = ostring.replace(/,(\S)/, ", $1"); 823 ostring = ostring.replace(/,(\S)/, ", $1");
806 var idx = ostring.indexOf("{"); 824 var idx = ostring.indexOf("{");
807 if (idx != -1) { 825 if (idx != -1) {
808 ostring = ostring.substr(0, idx) + "{...}"; 826 ostring = ostring.substr(0, idx) + "{...}";
809 } 827 }
810 } 828 }
811 return ostring; 829 return ostring;
812 }, 830 },
813 831
814 /** @id MochiKit.Base.reprArrayLike */ 832 /** @id MochiKit.Base.reprArrayLike */
815 reprArrayLike: function (o) { 833 reprArrayLike: function (o) {
816 var m = MochiKit.Base; 834 var m = MochiKit.Base;
817 return "[" + m.map(m.repr, o).join(", ") + "]"; 835 return "[" + m.map(m.repr, o).join(", ") + "]";
818 }, 836 },
819 837
820 /** @id MochiKit.Base.reprString */ 838 /** @id MochiKit.Base.reprString */
821 reprString: function (o) { 839 reprString: function (o) {
822 return ('"' + o.replace(/(["\\])/g, '\\$1') + '"' 840 return ('"' + o.replace(/(["\\])/g, '\\$1') + '"'
823 ).replace(/[\f]/g, "\\f" 841 ).replace(/[\f]/g, "\\f"
824 ).replace(/[\b]/g, "\\b" 842 ).replace(/[\b]/g, "\\b"
825 ).replace(/[\n]/g, "\\n" 843 ).replace(/[\n]/g, "\\n"
826 ).replace(/[\t]/g, "\\t" 844 ).replace(/[\t]/g, "\\t"
827 ).replace(/[\v]/g, "\\v" 845 ).replace(/[\v]/g, "\\v"
828 ).replace(/[\r]/g, "\\r"); 846 ).replace(/[\r]/g, "\\r");
829 }, 847 },
830 848
831 /** @id MochiKit.Base.reprNumber */ 849 /** @id MochiKit.Base.reprNumber */
832 reprNumber: function (o) { 850 reprNumber: function (o) {
833 return o + ""; 851 return o + "";
834 }, 852 },
835 853
836 /** @id MochiKit.Base.registerJSON */ 854 /** @id MochiKit.Base.registerJSON */
837 registerJSON: function (name, check, wrap, /* optional */override) { 855 registerJSON: function (name, check, wrap, /* optional */override) {
838 MochiKit.Base.jsonRegistry.register(name, check, wrap, override); 856 MochiKit.Base.jsonRegistry.register(name, check, wrap, override);
839 }, 857 },
840 858
841 859
842 /** @id MochiKit.Base.evalJSON */ 860 /** @id MochiKit.Base.evalJSON */
843 evalJSON: function () { 861 evalJSON: function (jsonText) {
844 return eval("(" + MochiKit.Base._filterJSON(arguments[0]) + ")"); 862 return eval("(" + MochiKit.Base._filterJSON(jsonText) + ")");
845 }, 863 },
846 864
847 _filterJSON: function (s) { 865 _filterJSON: function (s) {
848 var m = s.match(/^\s*\/\*(.*)\*\/\s*$/); 866 var m = s.match(/^\s*\/\*(.*)\*\/\s*$/);
849 if (m) { 867 return (m) ? m[1] : s;
850 return m[1];
851 }
852 return s;
853 }, 868 },
854 869
855 /** @id MochiKit.Base.serializeJSON */ 870 /** @id MochiKit.Base.serializeJSON */
856 serializeJSON: function (o) { 871 serializeJSON: function (o) {
857 var objtype = typeof(o); 872 var objtype = typeof(o);
858 if (objtype == "number" || objtype == "boolean") { 873 if (objtype == "number" || objtype == "boolean") {
859 return o + ""; 874 return o + "";
860 } else if (o === null) { 875 } else if (o === null) {
861 return "null"; 876 return "null";
862 } else if (objtype == "string") { 877 } else if (objtype == "string") {
863 var res = ""; 878 var res = "";
864 for (var i = 0; i < o.length; i++) { 879 for (var i = 0; i < o.length; i++) {
865 var c = o.charAt(i); 880 var c = o.charAt(i);
866 if (c == '\"') { 881 if (c == '\"') {
867 res += '\\"'; 882 res += '\\"';
868 } else if (c == '\\') { 883 } else if (c == '\\') {
869 res += '\\\\'; 884 res += '\\\\';
870 } else if (c == '\b') { 885 } else if (c == '\b') {
871 res += '\\b'; 886 res += '\\b';
872 } else if (c == '\f') { 887 } else if (c == '\f') {
873 res += '\\f'; 888 res += '\\f';
874 } else if (c == '\n') { 889 } else if (c == '\n') {
875 res += '\\n'; 890 res += '\\n';
876 } else if (c == '\r') { 891 } else if (c == '\r') {
877 res += '\\r'; 892 res += '\\r';
878 } else if (c == '\t') { 893 } else if (c == '\t') {
879 res += '\\t'; 894 res += '\\t';
880 } else if (o.charCodeAt(i) <= 0x1F) { 895 } else if (o.charCodeAt(i) <= 0x1F) {
881 var hex = o.charCodeAt(i).toString(16); 896 var hex = o.charCodeAt(i).toString(16);
882 if (hex.length < 2) { 897 if (hex.length < 2) {
883 hex = '0' + hex; 898 hex = '0' + hex;
884 } 899 }
885 res += '\\u00' + hex.toUpperCase(); 900 res += '\\u00' + hex.toUpperCase();
886 } else { 901 } else {
887 res += c; 902 res += c;
888 } 903 }
889 } 904 }
890 return '"' + res + '"'; 905 return '"' + res + '"';
891 } 906 }
892 // recurse 907 // recurse
893 var me = arguments.callee; 908 var me = arguments.callee;
894 // short-circuit for objects that support "json" serialization 909 // short-circuit for objects that support "json" serialization
895 // if they return "self" then just pass-through... 910 // if they return "self" then just pass-through...
896 var newObj; 911 var newObj;
912 if (typeof(o.toJSON) == "function") {
913 newObj = o.toJSON();
914 if (o !== newObj) {
915 return me(newObj);
916 }
917 }
897 if (typeof(o.__json__) == "function") { 918 if (typeof(o.__json__) == "function") {
898 newObj = o.__json__(); 919 newObj = o.__json__();
899 if (o !== newObj) { 920 if (o !== newObj) {
900 return me(newObj); 921 return me(newObj);
901 } 922 }
902 } 923 }
903 if (typeof(o.json) == "function") { 924 if (typeof(o.json) == "function") {
904 newObj = o.json(); 925 newObj = o.json();
905 if (o !== newObj) { 926 if (o !== newObj) {
906 return me(newObj); 927 return me(newObj);
907 } 928 }
908 } 929 }
909 // array 930 // array
910 if (objtype != "function" && typeof(o.length) == "number") { 931 if (objtype != "function" && typeof(o.length) == "number") {
911 var res = []; 932 var res = [];
912 for (var i = 0; i < o.length; i++) { 933 for (var i = 0; i < o.length; i++) {
913 var val = me(o[i]); 934 var val = me(o[i]);
914 if (typeof(val) != "string") { 935 if (typeof(val) != "string") {
915 // skip non-serializable values 936 // skip non-serializable values
916 continue; 937 continue;
917 } 938 }
918 res.push(val); 939 res.push(val);
919 } 940 }
920 return "[" + res.join(", ") + "]"; 941 return "[" + res.join(", ") + "]";
921 } 942 }
922 // look in the registry 943 // look in the registry
923 var m = MochiKit.Base; 944 var m = MochiKit.Base;
924 try { 945 try {
925 newObj = m.jsonRegistry.match(o); 946 newObj = m.jsonRegistry.match(o);
926 if (o !== newObj) { 947 if (o !== newObj) {
927 return me(newObj); 948 return me(newObj);
928 } 949 }
929 } catch (e) { 950 } catch (e) {
930 if (e != m.NotFound) { 951 if (e != m.NotFound) {
931 // something really bad happened 952 // something really bad happened
932 throw e; 953 throw e;
933 } 954 }
934 } 955 }
935 // undefined is outside of the spec 956 // undefined is outside of the spec
936 if (objtype == "undefined") { 957 if (objtype == "undefined") {
937 throw new TypeError("undefined can not be serialized as JSON"); 958 throw new TypeError("undefined can not be serialized as JSON");
938 } 959 }
939 // it's a function with no adapter, bad 960 // it's a function with no adapter, bad
940 if (objtype == "function") { 961 if (objtype == "function") {
941 return null; 962 return null;
942 } 963 }
943 // generic object code path 964 // generic object code path
944 res = []; 965 res = [];
945 for (var k in o) { 966 for (var k in o) {
946 var useKey; 967 var useKey;
947 if (typeof(k) == "number") { 968 if (typeof(k) == "number") {
948 useKey = '"' + k + '"'; 969 useKey = '"' + k + '"';
949 } else if (typeof(k) == "string") { 970 } else if (typeof(k) == "string") {
950 useKey = me(k); 971 useKey = me(k);
951 } else { 972 } else {
952 // skip non-string or number keys 973 // skip non-string or number keys
953 continue; 974 continue;
954 } 975 }
955 val = me(o[k]); 976 val = me(o[k]);
956 if (typeof(val) != "string") { 977 if (typeof(val) != "string") {
957 // skip non-serializable values 978 // skip non-serializable values
958 continue; 979 continue;
959 } 980 }
960 res.push(useKey + ":" + val); 981 res.push(useKey + ":" + val);
961 } 982 }
962 return "{" + res.join(", ") + "}"; 983 return "{" + res.join(", ") + "}";
963 }, 984 },
964 985
965 986
966 /** @id MochiKit.Base.objEqual */ 987 /** @id MochiKit.Base.objEqual */
967 objEqual: function (a, b) { 988 objEqual: function (a, b) {
968 return (MochiKit.Base.compare(a, b) === 0); 989 return (MochiKit.Base.compare(a, b) === 0);
969 }, 990 },
970 991
971 /** @id MochiKit.Base.arrayEqual */ 992 /** @id MochiKit.Base.arrayEqual */
972 arrayEqual: function (self, arr) { 993 arrayEqual: function (self, arr) {
973 if (self.length != arr.length) { 994 if (self.length != arr.length) {
974 return false; 995 return false;
975 } 996 }
976 return (MochiKit.Base.compare(self, arr) === 0); 997 return (MochiKit.Base.compare(self, arr) === 0);
977 }, 998 },
978 999
979 /** @id MochiKit.Base.concat */ 1000 /** @id MochiKit.Base.concat */
980 concat: function (/* lst... */) { 1001 concat: function (/* lst... */) {
981 var rval = []; 1002 var rval = [];
982 var extend = MochiKit.Base.extend; 1003 var extend = MochiKit.Base.extend;
983 for (var i = 0; i < arguments.length; i++) { 1004 for (var i = 0; i < arguments.length; i++) {
984 extend(rval, arguments[i]); 1005 extend(rval, arguments[i]);
985 } 1006 }
986 return rval; 1007 return rval;
987 }, 1008 },
988 1009
989 /** @id MochiKit.Base.keyComparator */ 1010 /** @id MochiKit.Base.keyComparator */
990 keyComparator: function (key/* ... */) { 1011 keyComparator: function (key/* ... */) {
991 // fast-path for single key comparisons 1012 // fast-path for single key comparisons
992 var m = MochiKit.Base; 1013 var m = MochiKit.Base;
993 var compare = m.compare; 1014 var compare = m.compare;
994 if (arguments.length == 1) { 1015 if (arguments.length == 1) {
995 return function (a, b) { 1016 return function (a, b) {
996 return compare(a[key], b[key]); 1017 return compare(a[key], b[key]);
997 }; 1018 };
998 } 1019 }
999 var compareKeys = m.extend(null, arguments); 1020 var compareKeys = m.extend(null, arguments);
1000 return function (a, b) { 1021 return function (a, b) {
1001 var rval = 0; 1022 var rval = 0;
1002 // keep comparing until something is inequal or we run out of 1023 // keep comparing until something is inequal or we run out of
1003 // keys to compare 1024 // keys to compare
1004 for (var i = 0; (rval === 0) && (i < compareKeys.length); i++) { 1025 for (var i = 0; (rval === 0) && (i < compareKeys.length); i++) {
1005 var key = compareKeys[i]; 1026 var key = compareKeys[i];
1006 rval = compare(a[key], b[key]); 1027 rval = compare(a[key], b[key]);
1007 } 1028 }
1008 return rval; 1029 return rval;
1009 }; 1030 };
1010 }, 1031 },
1011 1032
1012 /** @id MochiKit.Base.reverseKeyComparator */ 1033 /** @id MochiKit.Base.reverseKeyComparator */
1013 reverseKeyComparator: function (key) { 1034 reverseKeyComparator: function (key) {
1014 var comparator = MochiKit.Base.keyComparator.apply(this, arguments); 1035 var comparator = MochiKit.Base.keyComparator.apply(this, arguments);
1015 return function (a, b) { 1036 return function (a, b) {
1016 return comparator(b, a); 1037 return comparator(b, a);
1017 }; 1038 };
1018 }, 1039 },
1019 1040
1020 /** @id MochiKit.Base.partial */ 1041 /** @id MochiKit.Base.partial */
1021 partial: function (func) { 1042 partial: function (func) {
1022 var m = MochiKit.Base; 1043 var m = MochiKit.Base;
1023 return m.bind.apply(this, m.extend([func, undefined], arguments, 1)); 1044 return m.bind.apply(this, m.extend([func, undefined], arguments, 1));
1024 }, 1045 },
1025 1046
1026 /** @id MochiKit.Base.listMinMax */ 1047 /** @id MochiKit.Base.listMinMax */
1027 listMinMax: function (which, lst) { 1048 listMinMax: function (which, lst) {
1028 if (lst.length === 0) { 1049 if (lst.length === 0) {
1029 return null; 1050 return null;
1030 } 1051 }
1031 var cur = lst[0]; 1052 var cur = lst[0];
1032 var compare = MochiKit.Base.compare; 1053 var compare = MochiKit.Base.compare;
1033 for (var i = 1; i < lst.length; i++) { 1054 for (var i = 1; i < lst.length; i++) {
1034 var o = lst[i]; 1055 var o = lst[i];
1035 if (compare(o, cur) == which) { 1056 if (compare(o, cur) == which) {
1036 cur = o; 1057 cur = o;
1037 } 1058 }
1038 } 1059 }
1039 return cur; 1060 return cur;
1040 }, 1061 },
1041 1062
1042 /** @id MochiKit.Base.objMax */ 1063 /** @id MochiKit.Base.objMax */
1043 objMax: function (/* obj... */) { 1064 objMax: function (/* obj... */) {
1044 return MochiKit.Base.listMinMax(1, arguments); 1065 return MochiKit.Base.listMinMax(1, arguments);
1045 }, 1066 },
1046 1067
1047 /** @id MochiKit.Base.objMin */ 1068 /** @id MochiKit.Base.objMin */
1048 objMin: function (/* obj... */) { 1069 objMin: function (/* obj... */) {
1049 return MochiKit.Base.listMinMax(-1, arguments); 1070 return MochiKit.Base.listMinMax(-1, arguments);
1050 }, 1071 },
1051 1072
1052 /** @id MochiKit.Base.findIdentical */ 1073 /** @id MochiKit.Base.findIdentical */
1053 findIdentical: function (lst, value, start/* = 0 */, /* optional */end) { 1074 findIdentical: function (lst, value, start/* = 0 */, /* optional */end) {
1054 if (typeof(end) == "undefined" || end === null) { 1075 if (typeof(end) == "undefined" || end === null) {
1055 end = lst.length; 1076 end = lst.length;
1056 } 1077 }
1057 if (typeof(start) == "undefined" || start === null) { 1078 if (typeof(start) == "undefined" || start === null) {
1058 start = 0; 1079 start = 0;
1059 } 1080 }
1060 for (var i = start; i < end; i++) { 1081 for (var i = start; i < end; i++) {
1061 if (lst[i] === value) { 1082 if (lst[i] === value) {
1062 return i; 1083 return i;
1063 } 1084 }
1064 } 1085 }
1065 return -1; 1086 return -1;
1066 }, 1087 },
1067 1088
1068 /** @id MochiKit.Base.mean */ 1089 /** @id MochiKit.Base.mean */
1069 mean: function(/* lst... */) { 1090 mean: function(/* lst... */) {
1070 /* http://www.nist.gov/dads/HTML/mean.html */ 1091 /* http://www.nist.gov/dads/HTML/mean.html */
1071 var sum = 0; 1092 var sum = 0;
1072 1093
1073 var m = MochiKit.Base; 1094 var m = MochiKit.Base;
1074 var args = m.extend(null, arguments); 1095 var args = m.extend(null, arguments);
1075 var count = args.length; 1096 var count = args.length;
1076 1097
1077 while (args.length) { 1098 while (args.length) {
1078 var o = args.shift(); 1099 var o = args.shift();
1079 if (o && typeof(o) == "object" && typeof(o.length) == "number") { 1100 if (o && typeof(o) == "object" && typeof(o.length) == "number") {
1080 count += o.length - 1; 1101 count += o.length - 1;
1081 for (var i = o.length - 1; i >= 0; i--) { 1102 for (var i = o.length - 1; i >= 0; i--) {
1082 sum += o[i]; 1103 sum += o[i];
1083 } 1104 }
1084 } else { 1105 } else {
1085 sum += o; 1106 sum += o;
1086 } 1107 }
1087 } 1108 }
1088 1109
1089 if (count <= 0) { 1110 if (count <= 0) {
1090 throw new TypeError('mean() requires at least one argument'); 1111 throw new TypeError('mean() requires at least one argument');
1091 } 1112 }
1092 1113
1093 return sum/count; 1114 return sum/count;
1094 }, 1115 },
1095 1116
1096 /** @id MochiKit.Base.median */ 1117 /** @id MochiKit.Base.median */
1097 median: function(/* lst... */) { 1118 median: function(/* lst... */) {
1098 /* http://www.nist.gov/dads/HTML/median.html */ 1119 /* http://www.nist.gov/dads/HTML/median.html */
1099 var data = MochiKit.Base.flattenArguments(arguments); 1120 var data = MochiKit.Base.flattenArguments(arguments);
1100 if (data.length === 0) { 1121 if (data.length === 0) {
1101 throw new TypeError('median() requires at least one argument'); 1122 throw new TypeError('median() requires at least one argument');
1102 } 1123 }
1103 data.sort(compare); 1124 data.sort(MochiKit.Base.compare);
1104 if (data.length % 2 == 0) { 1125 if (data.length % 2 == 0) {
1105 var upper = data.length / 2; 1126 var upper = data.length / 2;
1106 return (data[upper] + data[upper - 1]) / 2; 1127 return (data[upper] + data[upper - 1]) / 2;
1107 } else { 1128 } else {
1108 return data[(data.length - 1) / 2]; 1129 return data[(data.length - 1) / 2];
1109 } 1130 }
1110 }, 1131 },
1111 1132
1112 /** @id MochiKit.Base.findValue */ 1133 /** @id MochiKit.Base.findValue */
1113 findValue: function (lst, value, start/* = 0 */, /* optional */end) { 1134 findValue: function (lst, value, start/* = 0 */, /* optional */end) {
1114 if (typeof(end) == "undefined" || end === null) { 1135 if (typeof(end) == "undefined" || end === null) {
1115 end = lst.length; 1136 end = lst.length;
1116 } 1137 }
1117 if (typeof(start) == "undefined" || start === null) { 1138 if (typeof(start) == "undefined" || start === null) {
1118 start = 0; 1139 start = 0;
1119 } 1140 }
1120 var cmp = MochiKit.Base.compare; 1141 var cmp = MochiKit.Base.compare;
1121 for (var i = start; i < end; i++) { 1142 for (var i = start; i < end; i++) {
1122 if (cmp(lst[i], value) === 0) { 1143 if (cmp(lst[i], value) === 0) {
1123 return i; 1144 return i;
1124 } 1145 }
1125 } 1146 }
1126 return -1; 1147 return -1;
1127 }, 1148 },
1128 1149
1129 /** @id MochiKit.Base.nodeWalk */ 1150 /** @id MochiKit.Base.nodeWalk */
1130 nodeWalk: function (node, visitor) { 1151 nodeWalk: function (node, visitor) {
1131 var nodes = [node]; 1152 var nodes = [node];
1132 var extend = MochiKit.Base.extend; 1153 var extend = MochiKit.Base.extend;
1133 while (nodes.length) { 1154 while (nodes.length) {
1134 var res = visitor(nodes.shift()); 1155 var res = visitor(nodes.shift());
1135 if (res) { 1156 if (res) {
1136 extend(nodes, res); 1157 extend(nodes, res);
1137 } 1158 }
1138 } 1159 }
1139 }, 1160 },
1140 1161
1141 1162
1142 /** @id MochiKit.Base.nameFunctions */ 1163 /** @id MochiKit.Base.nameFunctions */
1143 nameFunctions: function (namespace) { 1164 nameFunctions: function (namespace) {
1144 var base = namespace.NAME; 1165 var base = namespace.NAME;
1145 if (typeof(base) == 'undefined') { 1166 if (typeof(base) == 'undefined') {
1146 base = ''; 1167 base = '';
1147 } else { 1168 } else {
1148 base = base + '.'; 1169 base = base + '.';
1149 } 1170 }
1150 for (var name in namespace) { 1171 for (var name in namespace) {
1151 var o = namespace[name]; 1172 var o = namespace[name];
1152 if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') { 1173 if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') {
1153 try { 1174 try {
1154 o.NAME = base + name; 1175 o.NAME = base + name;
1155 } catch (e) { 1176 } catch (e) {
1156 // pass 1177 // pass
1157 } 1178 }
1158 } 1179 }
1159 } 1180 }
1160 }, 1181 },
1161 1182
1162 1183
1163 /** @id MochiKit.Base.queryString */ 1184 /** @id MochiKit.Base.queryString */
1164 queryString: function (names, values) { 1185 queryString: function (names, values) {
1165 // check to see if names is a string or a DOM element, and if 1186 // check to see if names is a string or a DOM element, and if
1166 // MochiKit.DOM is available. If so, drop it like it's a form 1187 // MochiKit.DOM is available. If so, drop it like it's a form
1167 // Ugliest conditional in MochiKit? Probably! 1188 // Ugliest conditional in MochiKit? Probably!
1168 if (typeof(MochiKit.DOM) != "undefined" && arguments.length == 1 1189 if (typeof(MochiKit.DOM) != "undefined" && arguments.length == 1
1169 && (typeof(names) == "string" || ( 1190 && (typeof(names) == "string" || (
1170 typeof(names.nodeType) != "undefined" && names.nodeType > 0 1191 typeof(names.nodeType) != "undefined" && names.nodeType > 0
1171 )) 1192 ))
1172 ) { 1193 ) {
1173 var kv = MochiKit.DOM.formContents(names); 1194 var kv = MochiKit.DOM.formContents(names);
1174 names = kv[0]; 1195 names = kv[0];
1175 values = kv[1]; 1196 values = kv[1];
1176 } else if (arguments.length == 1) { 1197 } else if (arguments.length == 1) {
1177 // Allow the return value of formContents to be passed directly 1198 // Allow the return value of formContents to be passed directly
1178 if (typeof(names.length) == "number" && names.length == 2) { 1199 if (typeof(names.length) == "number" && names.length == 2) {
1179 return arguments.callee(names[0], names[1]); 1200 return arguments.callee(names[0], names[1]);
1180 } 1201 }
1181 var o = names; 1202 var o = names;
1182 names = []; 1203 names = [];
1183 values = []; 1204 values = [];
1184 for (var k in o) { 1205 for (var k in o) {
1185 var v = o[k]; 1206 var v = o[k];
1186 if (typeof(v) == "function") { 1207 if (typeof(v) == "function") {
1187 continue; 1208 continue;
1188 } else if (MochiKit.Base.isArrayLike(v)){ 1209 } else if (MochiKit.Base.isArrayLike(v)){
1189 for (var i = 0; i < v.length; i++) { 1210 for (var i = 0; i < v.length; i++) {
1190 names.push(k); 1211 names.push(k);
1191 values.push(v[i]); 1212 values.push(v[i]);
1192 } 1213 }
1193 } else { 1214 } else {
1194 names.push(k); 1215 names.push(k);
1195 values.push(v); 1216 values.push(v);
1196 } 1217 }
1197 } 1218 }
1198 } 1219 }
1199 var rval = []; 1220 var rval = [];
1200 var len = Math.min(names.length, values.length); 1221 var len = Math.min(names.length, values.length);
1201 var urlEncode = MochiKit.Base.urlEncode; 1222 var urlEncode = MochiKit.Base.urlEncode;
1202 for (var i = 0; i < len; i++) { 1223 for (var i = 0; i < len; i++) {
1203 v = values[i]; 1224 v = values[i];
1204 if (typeof(v) != 'undefined' && v !== null) { 1225 if (typeof(v) != 'undefined' && v !== null) {
1205 rval.push(urlEncode(names[i]) + "=" + urlEncode(v)); 1226 rval.push(urlEncode(names[i]) + "=" + urlEncode(v));
1206 } 1227 }
1207 } 1228 }
1208 return rval.join("&"); 1229 return rval.join("&");
1209 }, 1230 },
1210 1231
1211 1232
1212 /** @id MochiKit.Base.parseQueryString */ 1233 /** @id MochiKit.Base.parseQueryString */
1213 parseQueryString: function (encodedString, useArrays) { 1234 parseQueryString: function (encodedString, useArrays) {
1214 // strip a leading '?' from the encoded string 1235 // strip a leading '?' from the encoded string
1215 var qstr = (encodedString.charAt(0) == "?") 1236 var qstr = (encodedString.charAt(0) == "?")
1216 ? encodedString.substring(1) 1237 ? encodedString.substring(1)
1217 : encodedString; 1238 : encodedString;
1218 var pairs = qstr.replace(/\+/g, "%20").split(/\&amp\;|\&\#38\;|\&#x26;|\&/); 1239 var pairs = qstr.replace(/\+/g, "%20").split(/\&amp\;|\&\#38\;|\&#x26;|\&/);
1219 var o = {}; 1240 var o = {};
1220 var decode; 1241 var decode;
1221 if (typeof(decodeURIComponent) != "undefined") { 1242 if (typeof(decodeURIComponent) != "undefined") {
1222 decode = decodeURIComponent; 1243 decode = decodeURIComponent;
1223 } else { 1244 } else {
1224 decode = unescape; 1245 decode = unescape;
1225 } 1246 }
1226 if (useArrays) { 1247 if (useArrays) {
1227 for (var i = 0; i < pairs.length; i++) { 1248 for (var i = 0; i < pairs.length; i++) {
1228 var pair = pairs[i].split("="); 1249 var pair = pairs[i].split("=");
1229 var name = decode(pair.shift()); 1250 var name = decode(pair.shift());
1230 if (!name) { 1251 if (!name) {
1231 continue; 1252 continue;
1232 } 1253 }
1233 var arr = o[name]; 1254 var arr = o[name];
1234 if (!(arr instanceof Array)) { 1255 if (!(arr instanceof Array)) {
1235 arr = []; 1256 arr = [];
1236 o[name] = arr; 1257 o[name] = arr;
1237 } 1258 }
1238 arr.push(decode(pair.join("="))); 1259 arr.push(decode(pair.join("=")));
1239 } 1260 }
1240 } else { 1261 } else {
1241 for (var i = 0; i < pairs.length; i++) { 1262 for (var i = 0; i < pairs.length; i++) {
1242 pair = pairs[i].split("="); 1263 pair = pairs[i].split("=");
1243 var name = pair.shift(); 1264 var name = pair.shift();
1244 if (!name) { 1265 if (!name) {
1245 continue; 1266 continue;
1246 } 1267 }
1247 o[decode(name)] = decode(pair.join("=")); 1268 o[decode(name)] = decode(pair.join("="));
1248 } 1269 }
1249 } 1270 }
1250 return o; 1271 return o;
1251 } 1272 }
1252}); 1273});
1253 1274
1254/** @id MochiKit.Base.AdapterRegistry */ 1275/** @id MochiKit.Base.AdapterRegistry */
1255MochiKit.Base.AdapterRegistry = function () { 1276MochiKit.Base.AdapterRegistry = function () {
1256 this.pairs = []; 1277 this.pairs = [];
1257}; 1278};
1258 1279
1259MochiKit.Base.AdapterRegistry.prototype = { 1280MochiKit.Base.AdapterRegistry.prototype = {
1260 /** @id MochiKit.Base.AdapterRegistry.prototype.register */ 1281 /** @id MochiKit.Base.AdapterRegistry.prototype.register */
1261 register: function (name, check, wrap, /* optional */ override) { 1282 register: function (name, check, wrap, /* optional */ override) {
1262 if (override) { 1283 if (override) {
1263 this.pairs.unshift([name, check, wrap]); 1284 this.pairs.unshift([name, check, wrap]);
1264 } else { 1285 } else {
1265 this.pairs.push([name, check, wrap]); 1286 this.pairs.push([name, check, wrap]);
1266 } 1287 }
1267 }, 1288 },
1268 1289
1269 /** @id MochiKit.Base.AdapterRegistry.prototype.match */ 1290 /** @id MochiKit.Base.AdapterRegistry.prototype.match */
1270 match: function (/* ... */) { 1291 match: function (/* ... */) {
1271 for (var i = 0; i < this.pairs.length; i++) { 1292 for (var i = 0; i < this.pairs.length; i++) {
1272 var pair = this.pairs[i]; 1293 var pair = this.pairs[i];
1273 if (pair[1].apply(this, arguments)) { 1294 if (pair[1].apply(this, arguments)) {
1274 return pair[2].apply(this, arguments); 1295 return pair[2].apply(this, arguments);
1275 } 1296 }
1276 } 1297 }
1277 throw MochiKit.Base.NotFound; 1298 throw MochiKit.Base.NotFound;
1278 }, 1299 },
1279 1300
1280 /** @id MochiKit.Base.AdapterRegistry.prototype.unregister */ 1301 /** @id MochiKit.Base.AdapterRegistry.prototype.unregister */
1281 unregister: function (name) { 1302 unregister: function (name) {
1282 for (var i = 0; i < this.pairs.length; i++) { 1303 for (var i = 0; i < this.pairs.length; i++) {
1283 var pair = this.pairs[i]; 1304 var pair = this.pairs[i];
1284 if (pair[0] == name) { 1305 if (pair[0] == name) {
1285 this.pairs.splice(i, 1); 1306 this.pairs.splice(i, 1);
1286 return true; 1307 return true;
1287 } 1308 }
1288 } 1309 }
1289 return false; 1310 return false;
1290 } 1311 }
1291}; 1312};
1292 1313
1293MochiKit.Base._exportSymbols = function (globals, module) { 1314/**
1294 if (MochiKit.__export__ === false || module.__export__ === false) { 1315 * Exports all symbols from one or more modules into the specified
1295 return; 1316 * namespace (or scope). This is similar to MochiKit.Base.update(),
1296 } 1317 * except for special handling of the "__export__" flag, contained
1297 for (var k in module) { 1318 * sub-modules (exported recursively), and names starting with "_".
1298 var v = module[k]; 1319 *
1299 if (v != null) { 1320 * @param {Object} namespace the object or scope to modify
1300 var okName = (k[0] !== "_" && k !== "toString"); 1321 * @param {Object} module the module to export
1301 if (v.__export__ === true || (v.__export__ !== false && okName)) { 1322 */
1302 globals[k] = module[k]; 1323MochiKit.Base.moduleExport = function (namespace, module/*, ...*/) {
1324 var SKIP = { toString: true, NAME: true, VERSION: true };
1325 var mods = MochiKit.Base.extend([], arguments, 1);
1326 while ((module = mods.shift()) != null) {
1327 for (var k in module) {
1328 var v = module[k];
1329 if (v != null) {
1330 var flagSet = (typeof(v.__export__) == 'boolean');
1331 var nameValid = (k[0] !== "_" && !SKIP[k]);
1332 if (flagSet ? v.__export__ : nameValid) {
1333 if (typeof(v) == 'object' && v.NAME && v.VERSION) {
1334 mods.push(v);
1335 } else {
1336 namespace[k] = module[k];
1337 }
1338 }
1303 } 1339 }
1304 } 1340 }
1305 } 1341 }
1342 return namespace;
1343};
1344
1345/**
1346 * Identical to moduleExport, but also considers the global and
1347 * module-specific "__export__" flag.
1348 */
1349MochiKit.Base._exportSymbols = function (namespace, module) {
1350 if (MochiKit.__export__ !== false && module.__export__ !== false) {
1351 MochiKit.Base.moduleExport(namespace, module);
1352 }
1306}; 1353};
1307 1354
1308/** 1355/**
1309 * Creates a deprecated function alias in the specified module. The 1356 * Creates a deprecated function alias in the specified module. The
1310 * deprecated function will forward all calls and arguments to a 1357 * deprecated function will forward all calls and arguments to a
1311 * target function, while also logging a debug message on the first 1358 * target function, while also logging a debug message on the first
1312 * call (if MochiKit.Logging is loaded). The destination function may 1359 * call (if MochiKit.Logging is loaded). The destination function may
1313 * be located in another module, which must be loaded, or an 1360 * be located in another module, which must be loaded, or an
1314 * exception will be thrown. 1361 * exception will be thrown.
1315 * 1362 *
1316 * @param {Object/String} module the source module or module name 1363 * @param {Object/String} module the source module or module name
1317 * (e.g. 'DOM' or 'MochiKit.DOM') 1364 * (e.g. 'DOM' or 'MochiKit.DOM')
1318 * @param {String} name the deprecated function name (e.g. 'getStyle') 1365 * @param {String} name the deprecated function name (e.g. 'getStyle')
1319 * @param {String} target the fully qualified name of the target 1366 * @param {String} target the fully qualified name of the target
1320 * function (e.g. 'MochiKit.Style.getStyle') 1367 * function (e.g. 'MochiKit.Style.getStyle')
1321 * @param {String} version the first version when the source function 1368 * @param {String} version the first version when the source function
1322 * was deprecated (e.g. '1.4') 1369 * was deprecated (e.g. '1.4')
1323 * @param {Boolean} [exportable] the exportable function flag, 1370 * @param {Boolean} [exportable] the exportable function flag,
1324 * defaults to true 1371 * defaults to false
1325 */ 1372 */
1326MochiKit.Base._deprecated = function (module, name, target, version, exportable) { 1373MochiKit.Base._deprecated = function (module, name, target, version, exportable) {
1327 if (typeof(module) === 'string') { 1374 if (typeof(module) === 'string') {
1328 if (module.indexOf('MochiKit.') === 0) { 1375 if (module.indexOf('MochiKit.') === 0) {
1329 module = module.substring(9); 1376 module = module.substring(9);
1330 } 1377 }
1331 module = MochiKit[module]; 1378 module = MochiKit[module];
1332 } 1379 }
1333 var targetModule = target.split('.')[1]; 1380 var targetModule = target.split('.')[1];
1334 var targetName = target.split('.')[2]; 1381 var targetName = target.split('.')[2];
1335 var func = function () { 1382 var func = function () {
1336 var self = arguments.callee; 1383 var self = arguments.callee;
1337 var msg = module.NAME + '.' + name + ' is deprecated since version ' + 1384 var msg = module.NAME + '.' + name + ' is deprecated since version ' +
1338 version + '. Use ' + target + ' instead.'; 1385 version + '. Use ' + target + ' instead.';
1339 if (self.logged !== true) { 1386 if (self.logged !== true) {
1340 self.logged = true; 1387 self.logged = true;
1341 if (MochiKit.Logging) { 1388 if (MochiKit.Logging) {
1342 MochiKit.Logging.logDebug(msg); 1389 MochiKit.Logging.logDebug(msg);
1343 } else if (console && console.log) { 1390 } else if (console && console.log) {
1344 console.log(msg); 1391 console.log(msg);
1345 } 1392 }
1346 } 1393 }
1347 if (!MochiKit[targetModule]) { 1394 if (!MochiKit[targetModule]) {
1348 throw new Error(msg); 1395 throw new Error(msg);
1349 } 1396 }
1350 return MochiKit[targetModule][targetName].apply(this, arguments); 1397 return MochiKit[targetModule][targetName].apply(this, arguments);
1351 }; 1398 };
1352 if (exportable === false) { 1399 func.__export__ = (exportable === true);
1353 func.__export__ = false;
1354 }
1355 module[name] = func; 1400 module[name] = func;
1356} 1401};
1357 1402
1358MochiKit.Base.__new__ = function () { 1403MochiKit.Base.__new__ = function () {
1359 var m = this; 1404 var m = this;
1360 1405
1361 /** @id MochiKit.Base.noop */ 1406 /** @id MochiKit.Base.noop */
1362 m.noop = m.operator.identity; 1407 m.noop = m.operator.identity;
1363 1408
1364 // Backwards compat 1409 // Backwards compat
1365 m._deprecated(m, 'forward', 'MochiKit.Base.forwardCall', '1.3', false); 1410 m._deprecated(m, 'forward', 'MochiKit.Base.forwardCall', '1.3');
1366 m._deprecated(m, 'find', 'MochiKit.Base.findValue', '1.3', false); 1411 m._deprecated(m, 'find', 'MochiKit.Base.findValue', '1.3');
1367 1412
1368 if (typeof(encodeURIComponent) != "undefined") { 1413 if (typeof(encodeURIComponent) != "undefined") {
1369 /** @id MochiKit.Base.urlEncode */ 1414 /** @id MochiKit.Base.urlEncode */
1370 m.urlEncode = function (unencoded) { 1415 m.urlEncode = function (unencoded) {
1371 return encodeURIComponent(unencoded).replace(/\'/g, '%27'); 1416 return encodeURIComponent(unencoded).replace(/\'/g, '%27');
1372 }; 1417 };
1373 } else { 1418 } else {
1374 m.urlEncode = function (unencoded) { 1419 m.urlEncode = function (unencoded) {
1375 return escape(unencoded 1420 return escape(unencoded
1376 ).replace(/\+/g, '%2B' 1421 ).replace(/\+/g, '%2B'
1377 ).replace(/\"/g,'%22' 1422 ).replace(/\"/g,'%22'
1378 ).rval.replace(/\'/g, '%27'); 1423 ).replace(/\'/g, '%27');
1379 }; 1424 };
1380 } 1425 }
1381 1426
1382 /** @id MochiKit.Base.NamedError */ 1427 /** @id MochiKit.Base.NamedError */
1383 m.NamedError = function (name) { 1428 m.NamedError = function (name) {
1384 this.message = name; 1429 this.message = name;
1385 this.name = name; 1430 this.name = name;
1386 }; 1431 };
1387 m.NamedError.prototype = new Error(); 1432 m.NamedError.prototype = new Error();
1433 m.NamedError.prototype.constructor = m.NamedError;
1388 m.update(m.NamedError.prototype, { 1434 m.update(m.NamedError.prototype, {
1389 repr: function () { 1435 repr: function () {
1390 if (this.message && this.message != this.name) { 1436 if (this.message && this.message != this.name) {
1391 return this.name + "(" + m.repr(this.message) + ")"; 1437 return this.name + "(" + m.repr(this.message) + ")";
1392 } else { 1438 } else {
1393 return this.name + "()"; 1439 return this.name + "()";
1394 } 1440 }
1395 }, 1441 },
1396 toString: m.forwardCall("repr") 1442 toString: m.forwardCall("repr")
1397 }); 1443 });
1398 1444
1399 /** @id MochiKit.Base.NotFound */ 1445 /** @id MochiKit.Base.NotFound */
1400 m.NotFound = new m.NamedError("MochiKit.Base.NotFound"); 1446 m.NotFound = new m.NamedError("MochiKit.Base.NotFound");
1401 1447
1402 1448
1403 /** @id MochiKit.Base.listMax */ 1449 /** @id MochiKit.Base.listMax */
1404 m.listMax = m.partial(m.listMinMax, 1); 1450 m.listMax = m.partial(m.listMinMax, 1);
1405 /** @id MochiKit.Base.listMin */ 1451 /** @id MochiKit.Base.listMin */
1406 m.listMin = m.partial(m.listMinMax, -1); 1452 m.listMin = m.partial(m.listMinMax, -1);
1407 1453
1408 /** @id MochiKit.Base.isCallable */ 1454 /** @id MochiKit.Base.isCallable */
1409 m.isCallable = m.typeMatcher('function'); 1455 m.isCallable = m.typeMatcher('function');
1410 /** @id MochiKit.Base.isUndefined */ 1456 /** @id MochiKit.Base.isUndefined */
1411 m.isUndefined = m.typeMatcher('undefined'); 1457 m.isUndefined = m.typeMatcher('undefined');
1458 /** @id MochiKit.Base.isValue */
1459 m.isValue = m.typeMatcher('boolean', 'number', 'string');
1412 1460
1413 /** @id MochiKit.Base.merge */ 1461 /** @id MochiKit.Base.merge */
1414 m.merge = m.partial(m.update, null); 1462 m.merge = m.partial(m.update, null);
1415 /** @id MochiKit.Base.zip */ 1463 /** @id MochiKit.Base.zip */
1416 m.zip = m.partial(m.map, null); 1464 m.zip = m.partial(m.map, null);
1417 1465
1418 /** @id MochiKit.Base.average */ 1466 /** @id MochiKit.Base.average */
1419 m.average = m.mean; 1467 m.average = m.mean;
1420 1468
1421 /** @id MochiKit.Base.comparatorRegistry */ 1469 /** @id MochiKit.Base.comparatorRegistry */
1422 m.comparatorRegistry = new m.AdapterRegistry(); 1470 m.comparatorRegistry = new m.AdapterRegistry();
1423 m.registerComparator("dateLike", m.isDateLike, m.compareDateLike); 1471 m.registerComparator("dateLike", m.isDateLike, m.compareDateLike);
1424 m.registerComparator("arrayLike", m.isArrayLike, m.compareArrayLike); 1472 m.registerComparator("arrayLike", m.isArrayLike, m.compareArrayLike);
1425 1473
1426 /** @id MochiKit.Base.reprRegistry */ 1474 /** @id MochiKit.Base.reprRegistry */
1427 m.reprRegistry = new m.AdapterRegistry(); 1475 m.reprRegistry = new m.AdapterRegistry();
1428 m.registerRepr("arrayLike", m.isArrayLike, m.reprArrayLike); 1476 m.registerRepr("arrayLike", m.isArrayLike, m.reprArrayLike);
1429 m.registerRepr("string", m.typeMatcher("string"), m.reprString); 1477 m.registerRepr("string", m.typeMatcher("string"), m.reprString);
1430 m.registerRepr("numbers", m.typeMatcher("number", "boolean"), m.reprNumber); 1478 m.registerRepr("numbers", m.typeMatcher("number", "boolean"), m.reprNumber);
1431 1479
1432 /** @id MochiKit.Base.jsonRegistry */ 1480 /** @id MochiKit.Base.jsonRegistry */
1433 m.jsonRegistry = new m.AdapterRegistry(); 1481 m.jsonRegistry = new m.AdapterRegistry();
1434 1482
1435 m.nameFunctions(this); 1483 m.nameFunctions(this);
1436 1484
1437}; 1485};
1438 1486
1439MochiKit.Base.__new__(); 1487MochiKit.Base.__new__();
1440 1488
1441// 1489//
1442// XXX: Internet Explorer blows 1490// XXX: Internet Explorer blows
1443// 1491//
1444if (MochiKit.__export__) { 1492if (MochiKit.__export__) {
1445 compare = MochiKit.Base.compare; 1493 compare = MochiKit.Base.compare;
1446 compose = MochiKit.Base.compose; 1494 compose = MochiKit.Base.compose;
1447 serializeJSON = MochiKit.Base.serializeJSON; 1495 serializeJSON = MochiKit.Base.serializeJSON;
1448 mean = MochiKit.Base.mean; 1496 mean = MochiKit.Base.mean;
1449 median = MochiKit.Base.median; 1497 median = MochiKit.Base.median;
1450} 1498}
1451 1499
1452MochiKit.Base._exportSymbols(this, MochiKit.Base); 1500MochiKit.Base._exportSymbols(this, MochiKit.Base);
diff --git a/frontend/gamma/js/MochiKit/Color.js b/frontend/gamma/js/MochiKit/Color.js
index 27dc2d0..f2a0f67 100644
--- a/frontend/gamma/js/MochiKit/Color.js
+++ b/frontend/gamma/js/MochiKit/Color.js
@@ -1,371 +1,371 @@
1/*** 1/***
2 2
3MochiKit.Color 1.5 3MochiKit.Color 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito and others. All rights Reserved. 7(c) 2005 Bob Ippolito and others. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Color', '1.5', ['Base', 'DOM', 'Style']); 11MochiKit.Base.module(MochiKit, 'Color', '1.5', ['Base', 'DOM', 'Style']);
12 12
13/** @id MochiKit.Color.Color */ 13/** @id MochiKit.Color.Color */
14MochiKit.Color.Color = function (red, green, blue, alpha) { 14MochiKit.Color.Color = function (red, green, blue, alpha) {
15 if (typeof(alpha) == 'undefined' || alpha === null) { 15 if (typeof(alpha) == 'undefined' || alpha === null) {
16 alpha = 1.0; 16 alpha = 1.0;
17 } 17 }
18 this.rgb = { 18 this.rgb = {
19 r: red, 19 r: red,
20 g: green, 20 g: green,
21 b: blue, 21 b: blue,
22 a: alpha 22 a: alpha
23 }; 23 };
24}; 24};
25 25
26 26
27// Prototype methods 27// Prototype methods
28 28
29MochiKit.Color.Color.prototype = { 29MochiKit.Color.Color.prototype = {
30 30
31 __class__: MochiKit.Color.Color, 31 __class__: MochiKit.Color.Color,
32 32
33 /** @id MochiKit.Color.Color.prototype.colorWithAlpha */ 33 /** @id MochiKit.Color.Color.prototype.colorWithAlpha */
34 colorWithAlpha: function (alpha) { 34 colorWithAlpha: function (alpha) {
35 var rgb = this.rgb; 35 var rgb = this.rgb;
36 var m = MochiKit.Color; 36 var m = MochiKit.Color;
37 return m.Color.fromRGB(rgb.r, rgb.g, rgb.b, alpha); 37 return m.Color.fromRGB(rgb.r, rgb.g, rgb.b, alpha);
38 }, 38 },
39 39
40 /** @id MochiKit.Color.Color.prototype.colorWithHue */ 40 /** @id MochiKit.Color.Color.prototype.colorWithHue */
41 colorWithHue: function (hue) { 41 colorWithHue: function (hue) {
42 // get an HSL model, and set the new hue... 42 // get an HSL model, and set the new hue...
43 var hsl = this.asHSL(); 43 var hsl = this.asHSL();
44 hsl.h = hue; 44 hsl.h = hue;
45 var m = MochiKit.Color; 45 var m = MochiKit.Color;
46 // convert back to RGB... 46 // convert back to RGB...
47 return m.Color.fromHSL(hsl); 47 return m.Color.fromHSL(hsl);
48 }, 48 },
49 49
50 /** @id MochiKit.Color.Color.prototype.colorWithSaturation */ 50 /** @id MochiKit.Color.Color.prototype.colorWithSaturation */
51 colorWithSaturation: function (saturation) { 51 colorWithSaturation: function (saturation) {
52 // get an HSL model, and set the new hue... 52 // get an HSL model, and set the new hue...
53 var hsl = this.asHSL(); 53 var hsl = this.asHSL();
54 hsl.s = saturation; 54 hsl.s = saturation;
55 var m = MochiKit.Color; 55 var m = MochiKit.Color;
56 // convert back to RGB... 56 // convert back to RGB...
57 return m.Color.fromHSL(hsl); 57 return m.Color.fromHSL(hsl);
58 }, 58 },
59 59
60 /** @id MochiKit.Color.Color.prototype.colorWithLightness */ 60 /** @id MochiKit.Color.Color.prototype.colorWithLightness */
61 colorWithLightness: function (lightness) { 61 colorWithLightness: function (lightness) {
62 // get an HSL model, and set the new hue... 62 // get an HSL model, and set the new hue...
63 var hsl = this.asHSL(); 63 var hsl = this.asHSL();
64 hsl.l = lightness; 64 hsl.l = lightness;
65 var m = MochiKit.Color; 65 var m = MochiKit.Color;
66 // convert back to RGB... 66 // convert back to RGB...
67 return m.Color.fromHSL(hsl); 67 return m.Color.fromHSL(hsl);
68 }, 68 },
69 69
70 /** @id MochiKit.Color.Color.prototype.darkerColorWithLevel */ 70 /** @id MochiKit.Color.Color.prototype.darkerColorWithLevel */
71 darkerColorWithLevel: function (level) { 71 darkerColorWithLevel: function (level) {
72 var hsl = this.asHSL(); 72 var hsl = this.asHSL();
73 hsl.l = Math.max(hsl.l - level, 0); 73 hsl.l = Math.max(hsl.l - level, 0);
74 var m = MochiKit.Color; 74 var m = MochiKit.Color;
75 return m.Color.fromHSL(hsl); 75 return m.Color.fromHSL(hsl);
76 }, 76 },
77 77
78 /** @id MochiKit.Color.Color.prototype.lighterColorWithLevel */ 78 /** @id MochiKit.Color.Color.prototype.lighterColorWithLevel */
79 lighterColorWithLevel: function (level) { 79 lighterColorWithLevel: function (level) {
80 var hsl = this.asHSL(); 80 var hsl = this.asHSL();
81 hsl.l = Math.min(hsl.l + level, 1); 81 hsl.l = Math.min(hsl.l + level, 1);
82 var m = MochiKit.Color; 82 var m = MochiKit.Color;
83 return m.Color.fromHSL(hsl); 83 return m.Color.fromHSL(hsl);
84 }, 84 },
85 85
86 /** @id MochiKit.Color.Color.prototype.blendedColor */ 86 /** @id MochiKit.Color.Color.prototype.blendedColor */
87 blendedColor: function (other, /* optional */ fraction) { 87 blendedColor: function (other, /* optional */ fraction) {
88 if (typeof(fraction) == 'undefined' || fraction === null) { 88 if (typeof(fraction) == 'undefined' || fraction === null) {
89 fraction = 0.5; 89 fraction = 0.5;
90 } 90 }
91 var sf = 1.0 - fraction; 91 var sf = 1.0 - fraction;
92 var s = this.rgb; 92 var s = this.rgb;
93 var d = other.rgb; 93 var d = other.rgb;
94 var df = fraction; 94 var df = fraction;
95 return MochiKit.Color.Color.fromRGB( 95 return MochiKit.Color.Color.fromRGB(
96 (s.r * sf) + (d.r * df), 96 (s.r * sf) + (d.r * df),
97 (s.g * sf) + (d.g * df), 97 (s.g * sf) + (d.g * df),
98 (s.b * sf) + (d.b * df), 98 (s.b * sf) + (d.b * df),
99 (s.a * sf) + (d.a * df) 99 (s.a * sf) + (d.a * df)
100 ); 100 );
101 }, 101 },
102 102
103 /** @id MochiKit.Color.Color.prototype.compareRGB */ 103 /** @id MochiKit.Color.Color.prototype.compareRGB */
104 compareRGB: function (other) { 104 compareRGB: function (other) {
105 var a = this.asRGB(); 105 var a = this.asRGB();
106 var b = other.asRGB(); 106 var b = other.asRGB();
107 return MochiKit.Base.compare( 107 return MochiKit.Base.compare(
108 [a.r, a.g, a.b, a.a], 108 [a.r, a.g, a.b, a.a],
109 [b.r, b.g, b.b, b.a] 109 [b.r, b.g, b.b, b.a]
110 ); 110 );
111 }, 111 },
112 112
113 /** @id MochiKit.Color.Color.prototype.isLight */ 113 /** @id MochiKit.Color.Color.prototype.isLight */
114 isLight: function () { 114 isLight: function () {
115 return this.asHSL().b > 0.5; 115 return this.asHSL().l > 0.5;
116 }, 116 },
117 117
118 /** @id MochiKit.Color.Color.prototype.isDark */ 118 /** @id MochiKit.Color.Color.prototype.isDark */
119 isDark: function () { 119 isDark: function () {
120 return (!this.isLight()); 120 return (!this.isLight());
121 }, 121 },
122 122
123 /** @id MochiKit.Color.Color.prototype.toHSLString */ 123 /** @id MochiKit.Color.Color.prototype.toHSLString */
124 toHSLString: function () { 124 toHSLString: function () {
125 var c = this.asHSL(); 125 var c = this.asHSL();
126 var ccc = MochiKit.Color.clampColorComponent; 126 var ccc = MochiKit.Color.clampColorComponent;
127 var rval = this._hslString; 127 var rval = this._hslString;
128 if (!rval) { 128 if (!rval) {
129 var mid = ( 129 var mid = (
130 ccc(c.h, 360).toFixed(0) 130 ccc(c.h, 360).toFixed(0)
131 + "," + ccc(c.s, 100).toPrecision(4) + "%" 131 + "," + ccc(c.s, 100).toPrecision(4) + "%"
132 + "," + ccc(c.l, 100).toPrecision(4) + "%" 132 + "," + ccc(c.l, 100).toPrecision(4) + "%"
133 ); 133 );
134 var a = c.a; 134 var a = c.a;
135 if (a >= 1) { 135 if (a >= 1) {
136 a = 1; 136 a = 1;
137 rval = "hsl(" + mid + ")"; 137 rval = "hsl(" + mid + ")";
138 } else { 138 } else {
139 if (a <= 0) { 139 if (a <= 0) {
140 a = 0; 140 a = 0;
141 } 141 }
142 rval = "hsla(" + mid + "," + a + ")"; 142 rval = "hsla(" + mid + "," + a + ")";
143 } 143 }
144 this._hslString = rval; 144 this._hslString = rval;
145 } 145 }
146 return rval; 146 return rval;
147 }, 147 },
148 148
149 /** @id MochiKit.Color.Color.prototype.toRGBString */ 149 /** @id MochiKit.Color.Color.prototype.toRGBString */
150 toRGBString: function () { 150 toRGBString: function () {
151 var c = this.rgb; 151 var c = this.rgb;
152 var ccc = MochiKit.Color.clampColorComponent; 152 var ccc = MochiKit.Color.clampColorComponent;
153 var rval = this._rgbString; 153 var rval = this._rgbString;
154 if (!rval) { 154 if (!rval) {
155 var mid = ( 155 var mid = (
156 ccc(c.r, 255).toFixed(0) 156 ccc(c.r, 255).toFixed(0)
157 + "," + ccc(c.g, 255).toFixed(0) 157 + "," + ccc(c.g, 255).toFixed(0)
158 + "," + ccc(c.b, 255).toFixed(0) 158 + "," + ccc(c.b, 255).toFixed(0)
159 ); 159 );
160 if (c.a != 1) { 160 if (c.a != 1) {
161 rval = "rgba(" + mid + "," + c.a + ")"; 161 rval = "rgba(" + mid + "," + c.a + ")";
162 } else { 162 } else {
163 rval = "rgb(" + mid + ")"; 163 rval = "rgb(" + mid + ")";
164 } 164 }
165 this._rgbString = rval; 165 this._rgbString = rval;
166 } 166 }
167 return rval; 167 return rval;
168 }, 168 },
169 169
170 /** @id MochiKit.Color.Color.prototype.asRGB */ 170 /** @id MochiKit.Color.Color.prototype.asRGB */
171 asRGB: function () { 171 asRGB: function () {
172 return MochiKit.Base.clone(this.rgb); 172 return MochiKit.Base.clone(this.rgb);
173 }, 173 },
174 174
175 /** @id MochiKit.Color.Color.prototype.toHexString */ 175 /** @id MochiKit.Color.Color.prototype.toHexString */
176 toHexString: function () { 176 toHexString: function () {
177 var m = MochiKit.Color; 177 var m = MochiKit.Color;
178 var c = this.rgb; 178 var c = this.rgb;
179 var ccc = MochiKit.Color.clampColorComponent; 179 var ccc = MochiKit.Color.clampColorComponent;
180 var rval = this._hexString; 180 var rval = this._hexString;
181 if (!rval) { 181 if (!rval) {
182 rval = ("#" + 182 rval = ("#" +
183 m.toColorPart(ccc(c.r, 255)) + 183 m.toColorPart(ccc(c.r, 255)) +
184 m.toColorPart(ccc(c.g, 255)) + 184 m.toColorPart(ccc(c.g, 255)) +
185 m.toColorPart(ccc(c.b, 255)) 185 m.toColorPart(ccc(c.b, 255))
186 ); 186 );
187 this._hexString = rval; 187 this._hexString = rval;
188 } 188 }
189 return rval; 189 return rval;
190 }, 190 },
191 191
192 /** @id MochiKit.Color.Color.prototype.asHSV */ 192 /** @id MochiKit.Color.Color.prototype.asHSV */
193 asHSV: function () { 193 asHSV: function () {
194 var hsv = this.hsv; 194 var hsv = this.hsv;
195 var c = this.rgb; 195 var c = this.rgb;
196 if (typeof(hsv) == 'undefined' || hsv === null) { 196 if (typeof(hsv) == 'undefined' || hsv === null) {
197 hsv = MochiKit.Color.rgbToHSV(this.rgb); 197 hsv = MochiKit.Color.rgbToHSV(this.rgb);
198 this.hsv = hsv; 198 this.hsv = hsv;
199 } 199 }
200 return MochiKit.Base.clone(hsv); 200 return MochiKit.Base.clone(hsv);
201 }, 201 },
202 202
203 /** @id MochiKit.Color.Color.prototype.asHSL */ 203 /** @id MochiKit.Color.Color.prototype.asHSL */
204 asHSL: function () { 204 asHSL: function () {
205 var hsl = this.hsl; 205 var hsl = this.hsl;
206 var c = this.rgb; 206 var c = this.rgb;
207 if (typeof(hsl) == 'undefined' || hsl === null) { 207 if (typeof(hsl) == 'undefined' || hsl === null) {
208 hsl = MochiKit.Color.rgbToHSL(this.rgb); 208 hsl = MochiKit.Color.rgbToHSL(this.rgb);
209 this.hsl = hsl; 209 this.hsl = hsl;
210 } 210 }
211 return MochiKit.Base.clone(hsl); 211 return MochiKit.Base.clone(hsl);
212 }, 212 },
213 213
214 /** @id MochiKit.Color.Color.prototype.toString */ 214 /** @id MochiKit.Color.Color.prototype.toString */
215 toString: function () { 215 toString: function () {
216 return this.toRGBString(); 216 return this.toRGBString();
217 }, 217 },
218 218
219 /** @id MochiKit.Color.Color.prototype.repr */ 219 /** @id MochiKit.Color.Color.prototype.repr */
220 repr: function () { 220 repr: function () {
221 var c = this.rgb; 221 var c = this.rgb;
222 var col = [c.r, c.g, c.b, c.a]; 222 var col = [c.r, c.g, c.b, c.a];
223 return this.__class__.NAME + "(" + col.join(", ") + ")"; 223 return this.__class__.NAME + "(" + col.join(", ") + ")";
224 } 224 }
225 225
226}; 226};
227 227
228// Constructor methods 228// Constructor methods
229 229
230MochiKit.Base.update(MochiKit.Color.Color, { 230MochiKit.Base.update(MochiKit.Color.Color, {
231 /** @id MochiKit.Color.Color.fromRGB */ 231 /** @id MochiKit.Color.Color.fromRGB */
232 fromRGB: function (red, green, blue, alpha) { 232 fromRGB: function (red, green, blue, alpha) {
233 // designated initializer 233 // designated initializer
234 var Color = MochiKit.Color.Color; 234 var Color = MochiKit.Color.Color;
235 if (arguments.length == 1) { 235 if (arguments.length == 1) {
236 var rgb = red; 236 var rgb = red;
237 red = rgb.r; 237 red = rgb.r;
238 green = rgb.g; 238 green = rgb.g;
239 blue = rgb.b; 239 blue = rgb.b;
240 if (typeof(rgb.a) == 'undefined') { 240 if (typeof(rgb.a) == 'undefined') {
241 alpha = undefined; 241 alpha = undefined;
242 } else { 242 } else {
243 alpha = rgb.a; 243 alpha = rgb.a;
244 } 244 }
245 } 245 }
246 return new Color(red, green, blue, alpha); 246 return new Color(red, green, blue, alpha);
247 }, 247 },
248 248
249 /** @id MochiKit.Color.Color.fromHSL */ 249 /** @id MochiKit.Color.Color.fromHSL */
250 fromHSL: function (hue, saturation, lightness, alpha) { 250 fromHSL: function (hue, saturation, lightness, alpha) {
251 var m = MochiKit.Color; 251 var m = MochiKit.Color;
252 return m.Color.fromRGB(m.hslToRGB.apply(m, arguments)); 252 return m.Color.fromRGB(m.hslToRGB.apply(m, arguments));
253 }, 253 },
254 254
255 /** @id MochiKit.Color.Color.fromHSV */ 255 /** @id MochiKit.Color.Color.fromHSV */
256 fromHSV: function (hue, saturation, value, alpha) { 256 fromHSV: function (hue, saturation, value, alpha) {
257 var m = MochiKit.Color; 257 var m = MochiKit.Color;
258 return m.Color.fromRGB(m.hsvToRGB.apply(m, arguments)); 258 return m.Color.fromRGB(m.hsvToRGB.apply(m, arguments));
259 }, 259 },
260 260
261 /** @id MochiKit.Color.Color.fromName */ 261 /** @id MochiKit.Color.Color.fromName */
262 fromName: function (name) { 262 fromName: function (name) {
263 var Color = MochiKit.Color.Color; 263 var Color = MochiKit.Color.Color;
264 // Opera 9 seems to "quote" named colors(?!) 264 // Opera 9 seems to "quote" named colors(?!)
265 if (name.charAt(0) == '"') { 265 if (name.charAt(0) == '"') {
266 name = name.substr(1, name.length - 2); 266 name = name.substr(1, name.length - 2);
267 } 267 }
268 var htmlColor = Color._namedColors[name.toLowerCase()]; 268 var htmlColor = Color._namedColors[name.toLowerCase()];
269 if (typeof(htmlColor) == 'string') { 269 if (typeof(htmlColor) == 'string') {
270 return Color.fromHexString(htmlColor); 270 return Color.fromHexString(htmlColor);
271 } else if (name == "transparent") { 271 } else if (name == "transparent") {
272 return Color.transparentColor(); 272 return Color.transparentColor();
273 } 273 }
274 return null; 274 return null;
275 }, 275 },
276 276
277 /** @id MochiKit.Color.Color.fromString */ 277 /** @id MochiKit.Color.Color.fromString */
278 fromString: function (colorString) { 278 fromString: function (colorString) {
279 var self = MochiKit.Color.Color; 279 var self = MochiKit.Color.Color;
280 var three = colorString.substr(0, 3); 280 var three = colorString.substr(0, 3);
281 if (three == "rgb") { 281 if (three == "rgb") {
282 return self.fromRGBString(colorString); 282 return self.fromRGBString(colorString);
283 } else if (three == "hsl") { 283 } else if (three == "hsl") {
284 return self.fromHSLString(colorString); 284 return self.fromHSLString(colorString);
285 } else if (colorString.charAt(0) == "#") { 285 } else if (colorString.charAt(0) == "#") {
286 return self.fromHexString(colorString); 286 return self.fromHexString(colorString);
287 } 287 }
288 return self.fromName(colorString); 288 return self.fromName(colorString);
289 }, 289 },
290 290
291 291
292 /** @id MochiKit.Color.Color.fromHexString */ 292 /** @id MochiKit.Color.Color.fromHexString */
293 fromHexString: function (hexCode) { 293 fromHexString: function (hexCode) {
294 if (hexCode.charAt(0) == '#') { 294 if (hexCode.charAt(0) == '#') {
295 hexCode = hexCode.substring(1); 295 hexCode = hexCode.substring(1);
296 } 296 }
297 var components = []; 297 var components = [];
298 var i, hex; 298 var i, hex;
299 if (hexCode.length == 3) { 299 if (hexCode.length == 3) {
300 for (i = 0; i < 3; i++) { 300 for (i = 0; i < 3; i++) {
301 hex = hexCode.substr(i, 1); 301 hex = hexCode.substr(i, 1);
302 components.push(parseInt(hex + hex, 16) / 255.0); 302 components.push(parseInt(hex + hex, 16) / 255.0);
303 } 303 }
304 } else { 304 } else {
305 for (i = 0; i < 6; i += 2) { 305 for (i = 0; i < 6; i += 2) {
306 hex = hexCode.substr(i, 2); 306 hex = hexCode.substr(i, 2);
307 components.push(parseInt(hex, 16) / 255.0); 307 components.push(parseInt(hex, 16) / 255.0);
308 } 308 }
309 } 309 }
310 var Color = MochiKit.Color.Color; 310 var Color = MochiKit.Color.Color;
311 return Color.fromRGB.apply(Color, components); 311 return Color.fromRGB.apply(Color, components);
312 }, 312 },
313 313
314 314
315 _fromColorString: function (pre, method, scales, colorCode) { 315 _fromColorString: function (pre, method, scales, colorCode) {
316 // parses either HSL or RGB 316 // parses either HSL or RGB
317 if (colorCode.indexOf(pre) === 0) { 317 if (colorCode.indexOf(pre) === 0) {
318 colorCode = colorCode.substring(colorCode.indexOf("(", 3) + 1, colorCode.length - 1); 318 colorCode = colorCode.substring(colorCode.indexOf("(", 3) + 1, colorCode.length - 1);
319 } 319 }
320 var colorChunks = colorCode.split(/\s*,\s*/); 320 var colorChunks = colorCode.split(/\s*,\s*/);
321 var colorFloats = []; 321 var colorFloats = [];
322 for (var i = 0; i < colorChunks.length; i++) { 322 for (var i = 0; i < colorChunks.length; i++) {
323 var c = colorChunks[i]; 323 var c = colorChunks[i];
324 var val; 324 var val;
325 var three = c.substring(c.length - 3); 325 var three = c.substring(c.length - 3);
326 if (c.charAt(c.length - 1) == '%') { 326 if (c.charAt(c.length - 1) == '%') {
327 val = 0.01 * parseFloat(c.substring(0, c.length - 1)); 327 val = 0.01 * parseFloat(c.substring(0, c.length - 1));
328 } else if (three == "deg") { 328 } else if (three == "deg") {
329 val = parseFloat(c) / 360.0; 329 val = parseFloat(c) / 360.0;
330 } else if (three == "rad") { 330 } else if (three == "rad") {
331 val = parseFloat(c) / (Math.PI * 2); 331 val = parseFloat(c) / (Math.PI * 2);
332 } else { 332 } else {
333 val = scales[i] * parseFloat(c); 333 val = scales[i] * parseFloat(c);
334 } 334 }
335 colorFloats.push(val); 335 colorFloats.push(val);
336 } 336 }
337 return this[method].apply(this, colorFloats); 337 return this[method].apply(this, colorFloats);
338 }, 338 },
339 339
340 /** @id MochiKit.Color.Color.fromComputedStyle */ 340 /** @id MochiKit.Color.Color.fromComputedStyle */
341 fromComputedStyle: function (elem, style) { 341 fromComputedStyle: function (elem, style) {
342 var d = MochiKit.DOM; 342 var d = MochiKit.DOM;
343 var cls = MochiKit.Color.Color; 343 var cls = MochiKit.Color.Color;
344 for (elem = d.getElement(elem); elem; elem = elem.parentNode) { 344 for (elem = d.getElement(elem); elem; elem = elem.parentNode) {
345 var actualColor = MochiKit.Style.getStyle.apply(d, arguments); 345 var actualColor = MochiKit.Style.getStyle.apply(d, arguments);
346 if (!actualColor) { 346 if (!actualColor) {
347 continue; 347 continue;
348 } 348 }
349 var color = cls.fromString(actualColor); 349 var color = cls.fromString(actualColor);
350 if (!color) { 350 if (!color) {
351 break; 351 break;
352 } 352 }
353 if (color.asRGB().a > 0) { 353 if (color.asRGB().a > 0) {
354 return color; 354 return color;
355 } 355 }
356 } 356 }
357 return null; 357 return null;
358 }, 358 },
359 359
360 /** @id MochiKit.Color.Color.fromBackground */ 360 /** @id MochiKit.Color.Color.fromBackground */
361 fromBackground: function (elem) { 361 fromBackground: function (elem) {
362 var cls = MochiKit.Color.Color; 362 var cls = MochiKit.Color.Color;
363 return cls.fromComputedStyle( 363 return cls.fromComputedStyle(
364 elem, "backgroundColor", "background-color") || cls.whiteColor(); 364 elem, "backgroundColor", "background-color") || cls.whiteColor();
365 }, 365 },
366 366
367 /** @id MochiKit.Color.Color.fromText */ 367 /** @id MochiKit.Color.Color.fromText */
368 fromText: function (elem) { 368 fromText: function (elem) {
369 var cls = MochiKit.Color.Color; 369 var cls = MochiKit.Color.Color;
370 return cls.fromComputedStyle( 370 return cls.fromComputedStyle(
371 elem, "color", "color") || cls.blackColor(); 371 elem, "color", "color") || cls.blackColor();
@@ -388,445 +388,436 @@ MochiKit.Base.update(MochiKit.Color, {
388 return 0; 388 return 0;
389 } else if (v > scale) { 389 } else if (v > scale) {
390 return scale; 390 return scale;
391 } else { 391 } else {
392 return v; 392 return v;
393 } 393 }
394 }, 394 },
395 395
396 _hslValue: function (n1, n2, hue) { 396 _hslValue: function (n1, n2, hue) {
397 if (hue > 6.0) { 397 if (hue > 6.0) {
398 hue -= 6.0; 398 hue -= 6.0;
399 } else if (hue < 0.0) { 399 } else if (hue < 0.0) {
400 hue += 6.0; 400 hue += 6.0;
401 } 401 }
402 var val; 402 var val;
403 if (hue < 1.0) { 403 if (hue < 1.0) {
404 val = n1 + (n2 - n1) * hue; 404 val = n1 + (n2 - n1) * hue;
405 } else if (hue < 3.0) { 405 } else if (hue < 3.0) {
406 val = n2; 406 val = n2;
407 } else if (hue < 4.0) { 407 } else if (hue < 4.0) {
408 val = n1 + (n2 - n1) * (4.0 - hue); 408 val = n1 + (n2 - n1) * (4.0 - hue);
409 } else { 409 } else {
410 val = n1; 410 val = n1;
411 } 411 }
412 return val; 412 return val;
413 }, 413 },
414 414
415 /** @id MochiKit.Color.hsvToRGB */ 415 /** @id MochiKit.Color.hsvToRGB */
416 hsvToRGB: function (hue, saturation, value, alpha) { 416 hsvToRGB: function (hue, saturation, value, alpha) {
417 if (arguments.length == 1) { 417 if (arguments.length == 1) {
418 var hsv = hue; 418 var hsv = hue;
419 hue = hsv.h; 419 hue = hsv.h;
420 saturation = hsv.s; 420 saturation = hsv.s;
421 value = hsv.v; 421 value = hsv.v;
422 alpha = hsv.a; 422 alpha = hsv.a;
423 } 423 }
424 var red; 424 var red;
425 var green; 425 var green;
426 var blue; 426 var blue;
427 if (saturation === 0) { 427 if (saturation === 0) {
428 red = value; 428 red = value;
429 green = value; 429 green = value;
430 blue = value; 430 blue = value;
431 } else { 431 } else {
432 var i = Math.floor(hue * 6); 432 var i = Math.floor(hue * 6);
433 var f = (hue * 6) - i; 433 var f = (hue * 6) - i;
434 var p = value * (1 - saturation); 434 var p = value * (1 - saturation);
435 var q = value * (1 - (saturation * f)); 435 var q = value * (1 - (saturation * f));
436 var t = value * (1 - (saturation * (1 - f))); 436 var t = value * (1 - (saturation * (1 - f)));
437 switch (i) { 437 switch (i) {
438 case 1: red = q; green = value; blue = p; break; 438 case 1: red = q; green = value; blue = p; break;
439 case 2: red = p; green = value; blue = t; break; 439 case 2: red = p; green = value; blue = t; break;
440 case 3: red = p; green = q; blue = value; break; 440 case 3: red = p; green = q; blue = value; break;
441 case 4: red = t; green = p; blue = value; break; 441 case 4: red = t; green = p; blue = value; break;
442 case 5: red = value; green = p; blue = q; break; 442 case 5: red = value; green = p; blue = q; break;
443 case 6: // fall through 443 case 6: // fall through
444 case 0: red = value; green = t; blue = p; break; 444 case 0: red = value; green = t; blue = p; break;
445 } 445 }
446 } 446 }
447 return { 447 return {
448 r: red, 448 r: red,
449 g: green, 449 g: green,
450 b: blue, 450 b: blue,
451 a: alpha 451 a: alpha
452 }; 452 };
453 }, 453 },
454 454
455 /** @id MochiKit.Color.hslToRGB */ 455 /** @id MochiKit.Color.hslToRGB */
456 hslToRGB: function (hue, saturation, lightness, alpha) { 456 hslToRGB: function (hue, saturation, lightness, alpha) {
457 if (arguments.length == 1) { 457 if (arguments.length == 1) {
458 var hsl = hue; 458 var hsl = hue;
459 hue = hsl.h; 459 hue = hsl.h;
460 saturation = hsl.s; 460 saturation = hsl.s;
461 lightness = hsl.l; 461 lightness = hsl.l;
462 alpha = hsl.a; 462 alpha = hsl.a;
463 } 463 }
464 var red; 464 var red;
465 var green; 465 var green;
466 var blue; 466 var blue;
467 if (saturation === 0) { 467 if (saturation === 0) {
468 red = lightness; 468 red = lightness;
469 green = lightness; 469 green = lightness;
470 blue = lightness; 470 blue = lightness;
471 } else { 471 } else {
472 var m2; 472 var m2;
473 if (lightness <= 0.5) { 473 if (lightness <= 0.5) {
474 m2 = lightness * (1.0 + saturation); 474 m2 = lightness * (1.0 + saturation);
475 } else { 475 } else {
476 m2 = lightness + saturation - (lightness * saturation); 476 m2 = lightness + saturation - (lightness * saturation);
477 } 477 }
478 var m1 = (2.0 * lightness) - m2; 478 var m1 = (2.0 * lightness) - m2;
479 var f = MochiKit.Color._hslValue; 479 var f = MochiKit.Color._hslValue;
480 var h6 = hue * 6.0; 480 var h6 = hue * 6.0;
481 red = f(m1, m2, h6 + 2); 481 red = f(m1, m2, h6 + 2);
482 green = f(m1, m2, h6); 482 green = f(m1, m2, h6);
483 blue = f(m1, m2, h6 - 2); 483 blue = f(m1, m2, h6 - 2);
484 } 484 }
485 return { 485 return {
486 r: red, 486 r: red,
487 g: green, 487 g: green,
488 b: blue, 488 b: blue,
489 a: alpha 489 a: alpha
490 }; 490 };
491 }, 491 },
492 492
493 /** @id MochiKit.Color.rgbToHSV */ 493 /** @id MochiKit.Color.rgbToHSV */
494 rgbToHSV: function (red, green, blue, alpha) { 494 rgbToHSV: function (red, green, blue, alpha) {
495 if (arguments.length == 1) { 495 if (arguments.length == 1) {
496 var rgb = red; 496 var rgb = red;
497 red = rgb.r; 497 red = rgb.r;
498 green = rgb.g; 498 green = rgb.g;
499 blue = rgb.b; 499 blue = rgb.b;
500 alpha = rgb.a; 500 alpha = rgb.a;
501 } 501 }
502 var max = Math.max(Math.max(red, green), blue); 502 var max = Math.max(Math.max(red, green), blue);
503 var min = Math.min(Math.min(red, green), blue); 503 var min = Math.min(Math.min(red, green), blue);
504 var hue; 504 var hue;
505 var saturation; 505 var saturation;
506 var value = max; 506 var value = max;
507 if (min == max) { 507 if (min == max) {
508 hue = 0; 508 hue = 0;
509 saturation = 0; 509 saturation = 0;
510 } else { 510 } else {
511 var delta = (max - min); 511 var delta = (max - min);
512 saturation = delta / max; 512 saturation = delta / max;
513 513
514 if (red == max) { 514 if (red == max) {
515 hue = (green - blue) / delta; 515 hue = (green - blue) / delta;
516 } else if (green == max) { 516 } else if (green == max) {
517 hue = 2 + ((blue - red) / delta); 517 hue = 2 + ((blue - red) / delta);
518 } else { 518 } else {
519 hue = 4 + ((red - green) / delta); 519 hue = 4 + ((red - green) / delta);
520 } 520 }
521 hue /= 6; 521 hue /= 6;
522 if (hue < 0) { 522 if (hue < 0) {
523 hue += 1; 523 hue += 1;
524 } 524 }
525 if (hue > 1) { 525 if (hue > 1) {
526 hue -= 1; 526 hue -= 1;
527 } 527 }
528 } 528 }
529 return { 529 return {
530 h: hue, 530 h: hue,
531 s: saturation, 531 s: saturation,
532 v: value, 532 v: value,
533 a: alpha 533 a: alpha
534 }; 534 };
535 }, 535 },
536 536
537 /** @id MochiKit.Color.rgbToHSL */ 537 /** @id MochiKit.Color.rgbToHSL */
538 rgbToHSL: function (red, green, blue, alpha) { 538 rgbToHSL: function (red, green, blue, alpha) {
539 if (arguments.length == 1) { 539 if (arguments.length == 1) {
540 var rgb = red; 540 var rgb = red;
541 red = rgb.r; 541 red = rgb.r;
542 green = rgb.g; 542 green = rgb.g;
543 blue = rgb.b; 543 blue = rgb.b;
544 alpha = rgb.a; 544 alpha = rgb.a;
545 } 545 }
546 var max = Math.max(red, Math.max(green, blue)); 546 var max = Math.max(red, Math.max(green, blue));
547 var min = Math.min(red, Math.min(green, blue)); 547 var min = Math.min(red, Math.min(green, blue));
548 var hue; 548 var hue;
549 var saturation; 549 var saturation;
550 var lightness = (max + min) / 2.0; 550 var lightness = (max + min) / 2.0;
551 var delta = max - min; 551 var delta = max - min;
552 if (delta === 0) { 552 if (delta === 0) {
553 hue = 0; 553 hue = 0;
554 saturation = 0; 554 saturation = 0;
555 } else { 555 } else {
556 if (lightness <= 0.5) { 556 if (lightness <= 0.5) {
557 saturation = delta / (max + min); 557 saturation = delta / (max + min);
558 } else { 558 } else {
559 saturation = delta / (2 - max - min); 559 saturation = delta / (2 - max - min);
560 } 560 }
561 if (red == max) { 561 if (red == max) {
562 hue = (green - blue) / delta; 562 hue = (green - blue) / delta;
563 } else if (green == max) { 563 } else if (green == max) {
564 hue = 2 + ((blue - red) / delta); 564 hue = 2 + ((blue - red) / delta);
565 } else { 565 } else {
566 hue = 4 + ((red - green) / delta); 566 hue = 4 + ((red - green) / delta);
567 } 567 }
568 hue /= 6; 568 hue /= 6;
569 if (hue < 0) { 569 if (hue < 0) {
570 hue += 1; 570 hue += 1;
571 } 571 }
572 if (hue > 1) { 572 if (hue > 1) {
573 hue -= 1; 573 hue -= 1;
574 } 574 }
575 575
576 } 576 }
577 return { 577 return {
578 h: hue, 578 h: hue,
579 s: saturation, 579 s: saturation,
580 l: lightness, 580 l: lightness,
581 a: alpha 581 a: alpha
582 }; 582 };
583 }, 583 },
584 584
585 /** @id MochiKit.Color.toColorPart */ 585 /** @id MochiKit.Color.toColorPart */
586 toColorPart: function (num) { 586 toColorPart: function (num) {
587 num = Math.round(num); 587 num = Math.round(num);
588 var digits = num.toString(16); 588 var digits = num.toString(16);
589 if (num < 16) { 589 if (num < 16) {
590 return '0' + digits; 590 return '0' + digits;
591 } 591 }
592 return digits; 592 return digits;
593 }, 593 },
594 594
595 __new__: function () { 595 __new__: function () {
596 var m = MochiKit.Base; 596 var m = MochiKit.Base;
597 /** @id MochiKit.Color.Color.fromRGBString */ 597 /** @id MochiKit.Color.Color.fromRGBString */
598 this.Color.fromRGBString = m.bind( 598 this.Color.fromRGBString = m.bind(
599 this.Color._fromColorString, this.Color, "rgb", "fromRGB", 599 this.Color._fromColorString, this.Color, "rgb", "fromRGB",
600 [1.0/255.0, 1.0/255.0, 1.0/255.0, 1] 600 [1.0/255.0, 1.0/255.0, 1.0/255.0, 1]
601 ); 601 );
602 /** @id MochiKit.Color.Color.fromHSLString */ 602 /** @id MochiKit.Color.Color.fromHSLString */
603 this.Color.fromHSLString = m.bind( 603 this.Color.fromHSLString = m.bind(
604 this.Color._fromColorString, this.Color, "hsl", "fromHSL", 604 this.Color._fromColorString, this.Color, "hsl", "fromHSL",
605 [1.0/360.0, 0.01, 0.01, 1] 605 [1.0/360.0, 0.01, 0.01, 1]
606 ); 606 );
607 607
608 var third = 1.0 / 3.0; 608 var third = 1.0 / 3.0;
609 /** @id MochiKit.Color.colors */ 609 /** @id MochiKit.Color.colors */
610 var colors = { 610 var colors = {
611 // NSColor colors plus transparent 611 // NSColor colors plus transparent
612 /** @id MochiKit.Color.blackColor */ 612 /** @id MochiKit.Color.blackColor */
613 black: [0, 0, 0], 613 black: [0, 0, 0],
614 /** @id MochiKit.Color.blueColor */ 614 /** @id MochiKit.Color.blueColor */
615 blue: [0, 0, 1], 615 blue: [0, 0, 1],
616 /** @id MochiKit.Color.brownColor */ 616 /** @id MochiKit.Color.brownColor */
617 brown: [0.6, 0.4, 0.2], 617 brown: [0.6, 0.4, 0.2],
618 /** @id MochiKit.Color.cyanColor */ 618 /** @id MochiKit.Color.cyanColor */
619 cyan: [0, 1, 1], 619 cyan: [0, 1, 1],
620 /** @id MochiKit.Color.darkGrayColor */ 620 /** @id MochiKit.Color.darkGrayColor */
621 darkGray: [third, third, third], 621 darkGray: [third, third, third],
622 /** @id MochiKit.Color.grayColor */ 622 /** @id MochiKit.Color.grayColor */
623 gray: [0.5, 0.5, 0.5], 623 gray: [0.5, 0.5, 0.5],
624 /** @id MochiKit.Color.greenColor */ 624 /** @id MochiKit.Color.greenColor */
625 green: [0, 1, 0], 625 green: [0, 1, 0],
626 /** @id MochiKit.Color.lightGrayColor */ 626 /** @id MochiKit.Color.lightGrayColor */
627 lightGray: [2 * third, 2 * third, 2 * third], 627 lightGray: [2 * third, 2 * third, 2 * third],
628 /** @id MochiKit.Color.magentaColor */ 628 /** @id MochiKit.Color.magentaColor */
629 magenta: [1, 0, 1], 629 magenta: [1, 0, 1],
630 /** @id MochiKit.Color.orangeColor */ 630 /** @id MochiKit.Color.orangeColor */
631 orange: [1, 0.5, 0], 631 orange: [1, 0.5, 0],
632 /** @id MochiKit.Color.purpleColor */ 632 /** @id MochiKit.Color.purpleColor */
633 purple: [0.5, 0, 0.5], 633 purple: [0.5, 0, 0.5],
634 /** @id MochiKit.Color.redColor */ 634 /** @id MochiKit.Color.redColor */
635 red: [1, 0, 0], 635 red: [1, 0, 0],
636 /** @id MochiKit.Color.transparentColor */ 636 /** @id MochiKit.Color.transparentColor */
637 transparent: [0, 0, 0, 0], 637 transparent: [0, 0, 0, 0],
638 /** @id MochiKit.Color.whiteColor */ 638 /** @id MochiKit.Color.whiteColor */
639 white: [1, 1, 1], 639 white: [1, 1, 1],
640 /** @id MochiKit.Color.yellowColor */ 640 /** @id MochiKit.Color.yellowColor */
641 yellow: [1, 1, 0] 641 yellow: [1, 1, 0]
642 }; 642 };
643 643
644 var makeColor = function (name, r, g, b, a) {
645 var rval = this.fromRGB(r, g, b, a);
646 this[name] = function () { return rval; };
647 return rval;
648 };
649
650 for (var k in colors) { 644 for (var k in colors) {
651 var name = k + "Color"; 645 var name = k + "Color";
652 var bindArgs = m.concat( 646 var value = this.Color.fromRGB.apply(this.Color, colors[k]);
653 [makeColor, this.Color, name], 647 this.Color[name] = m.partial(m.operator.identity, value);
654 colors[k]
655 );
656 this.Color[name] = m.bind.apply(null, bindArgs);
657 } 648 }
658 649
659 var isColor = function () { 650 var isColor = function () {
660 for (var i = 0; i < arguments.length; i++) { 651 for (var i = 0; i < arguments.length; i++) {
661 if (!(arguments[i] instanceof MochiKit.Color.Color)) { 652 if (!(arguments[i] instanceof MochiKit.Color.Color)) {
662 return false; 653 return false;
663 } 654 }
664 } 655 }
665 return true; 656 return true;
666 }; 657 };
667 658
668 var compareColor = function (a, b) { 659 var compareColor = function (a, b) {
669 return a.compareRGB(b); 660 return a.compareRGB(b);
670 }; 661 };
671 662
672 m.nameFunctions(this); 663 m.nameFunctions(this);
673 664
674 m.registerComparator(this.Color.NAME, isColor, compareColor); 665 m.registerComparator(this.Color.NAME, isColor, compareColor);
675 } 666 }
676}); 667});
677 668
678MochiKit.Color.__new__(); 669MochiKit.Color.__new__();
679 670
680// Full table of css3 X11 colors <http://www.w3.org/TR/css3-color/#X11COLORS> 671// Full table of css3 X11 colors <http://www.w3.org/TR/css3-color/#X11COLORS>
681 672
682MochiKit.Color.Color._namedColors = { 673MochiKit.Color.Color._namedColors = {
683 aliceblue: "#f0f8ff", 674 aliceblue: "#f0f8ff",
684 antiquewhite: "#faebd7", 675 antiquewhite: "#faebd7",
685 aqua: "#00ffff", 676 aqua: "#00ffff",
686 aquamarine: "#7fffd4", 677 aquamarine: "#7fffd4",
687 azure: "#f0ffff", 678 azure: "#f0ffff",
688 beige: "#f5f5dc", 679 beige: "#f5f5dc",
689 bisque: "#ffe4c4", 680 bisque: "#ffe4c4",
690 black: "#000000", 681 black: "#000000",
691 blanchedalmond: "#ffebcd", 682 blanchedalmond: "#ffebcd",
692 blue: "#0000ff", 683 blue: "#0000ff",
693 blueviolet: "#8a2be2", 684 blueviolet: "#8a2be2",
694 brown: "#a52a2a", 685 brown: "#a52a2a",
695 burlywood: "#deb887", 686 burlywood: "#deb887",
696 cadetblue: "#5f9ea0", 687 cadetblue: "#5f9ea0",
697 chartreuse: "#7fff00", 688 chartreuse: "#7fff00",
698 chocolate: "#d2691e", 689 chocolate: "#d2691e",
699 coral: "#ff7f50", 690 coral: "#ff7f50",
700 cornflowerblue: "#6495ed", 691 cornflowerblue: "#6495ed",
701 cornsilk: "#fff8dc", 692 cornsilk: "#fff8dc",
702 crimson: "#dc143c", 693 crimson: "#dc143c",
703 cyan: "#00ffff", 694 cyan: "#00ffff",
704 darkblue: "#00008b", 695 darkblue: "#00008b",
705 darkcyan: "#008b8b", 696 darkcyan: "#008b8b",
706 darkgoldenrod: "#b8860b", 697 darkgoldenrod: "#b8860b",
707 darkgray: "#a9a9a9", 698 darkgray: "#a9a9a9",
708 darkgreen: "#006400", 699 darkgreen: "#006400",
709 darkgrey: "#a9a9a9", 700 darkgrey: "#a9a9a9",
710 darkkhaki: "#bdb76b", 701 darkkhaki: "#bdb76b",
711 darkmagenta: "#8b008b", 702 darkmagenta: "#8b008b",
712 darkolivegreen: "#556b2f", 703 darkolivegreen: "#556b2f",
713 darkorange: "#ff8c00", 704 darkorange: "#ff8c00",
714 darkorchid: "#9932cc", 705 darkorchid: "#9932cc",
715 darkred: "#8b0000", 706 darkred: "#8b0000",
716 darksalmon: "#e9967a", 707 darksalmon: "#e9967a",
717 darkseagreen: "#8fbc8f", 708 darkseagreen: "#8fbc8f",
718 darkslateblue: "#483d8b", 709 darkslateblue: "#483d8b",
719 darkslategray: "#2f4f4f", 710 darkslategray: "#2f4f4f",
720 darkslategrey: "#2f4f4f", 711 darkslategrey: "#2f4f4f",
721 darkturquoise: "#00ced1", 712 darkturquoise: "#00ced1",
722 darkviolet: "#9400d3", 713 darkviolet: "#9400d3",
723 deeppink: "#ff1493", 714 deeppink: "#ff1493",
724 deepskyblue: "#00bfff", 715 deepskyblue: "#00bfff",
725 dimgray: "#696969", 716 dimgray: "#696969",
726 dimgrey: "#696969", 717 dimgrey: "#696969",
727 dodgerblue: "#1e90ff", 718 dodgerblue: "#1e90ff",
728 firebrick: "#b22222", 719 firebrick: "#b22222",
729 floralwhite: "#fffaf0", 720 floralwhite: "#fffaf0",
730 forestgreen: "#228b22", 721 forestgreen: "#228b22",
731 fuchsia: "#ff00ff", 722 fuchsia: "#ff00ff",
732 gainsboro: "#dcdcdc", 723 gainsboro: "#dcdcdc",
733 ghostwhite: "#f8f8ff", 724 ghostwhite: "#f8f8ff",
734 gold: "#ffd700", 725 gold: "#ffd700",
735 goldenrod: "#daa520", 726 goldenrod: "#daa520",
736 gray: "#808080", 727 gray: "#808080",
737 green: "#008000", 728 green: "#008000",
738 greenyellow: "#adff2f", 729 greenyellow: "#adff2f",
739 grey: "#808080", 730 grey: "#808080",
740 honeydew: "#f0fff0", 731 honeydew: "#f0fff0",
741 hotpink: "#ff69b4", 732 hotpink: "#ff69b4",
742 indianred: "#cd5c5c", 733 indianred: "#cd5c5c",
743 indigo: "#4b0082", 734 indigo: "#4b0082",
744 ivory: "#fffff0", 735 ivory: "#fffff0",
745 khaki: "#f0e68c", 736 khaki: "#f0e68c",
746 lavender: "#e6e6fa", 737 lavender: "#e6e6fa",
747 lavenderblush: "#fff0f5", 738 lavenderblush: "#fff0f5",
748 lawngreen: "#7cfc00", 739 lawngreen: "#7cfc00",
749 lemonchiffon: "#fffacd", 740 lemonchiffon: "#fffacd",
750 lightblue: "#add8e6", 741 lightblue: "#add8e6",
751 lightcoral: "#f08080", 742 lightcoral: "#f08080",
752 lightcyan: "#e0ffff", 743 lightcyan: "#e0ffff",
753 lightgoldenrodyellow: "#fafad2", 744 lightgoldenrodyellow: "#fafad2",
754 lightgray: "#d3d3d3", 745 lightgray: "#d3d3d3",
755 lightgreen: "#90ee90", 746 lightgreen: "#90ee90",
756 lightgrey: "#d3d3d3", 747 lightgrey: "#d3d3d3",
757 lightpink: "#ffb6c1", 748 lightpink: "#ffb6c1",
758 lightsalmon: "#ffa07a", 749 lightsalmon: "#ffa07a",
759 lightseagreen: "#20b2aa", 750 lightseagreen: "#20b2aa",
760 lightskyblue: "#87cefa", 751 lightskyblue: "#87cefa",
761 lightslategray: "#778899", 752 lightslategray: "#778899",
762 lightslategrey: "#778899", 753 lightslategrey: "#778899",
763 lightsteelblue: "#b0c4de", 754 lightsteelblue: "#b0c4de",
764 lightyellow: "#ffffe0", 755 lightyellow: "#ffffe0",
765 lime: "#00ff00", 756 lime: "#00ff00",
766 limegreen: "#32cd32", 757 limegreen: "#32cd32",
767 linen: "#faf0e6", 758 linen: "#faf0e6",
768 magenta: "#ff00ff", 759 magenta: "#ff00ff",
769 maroon: "#800000", 760 maroon: "#800000",
770 mediumaquamarine: "#66cdaa", 761 mediumaquamarine: "#66cdaa",
771 mediumblue: "#0000cd", 762 mediumblue: "#0000cd",
772 mediumorchid: "#ba55d3", 763 mediumorchid: "#ba55d3",
773 mediumpurple: "#9370db", 764 mediumpurple: "#9370db",
774 mediumseagreen: "#3cb371", 765 mediumseagreen: "#3cb371",
775 mediumslateblue: "#7b68ee", 766 mediumslateblue: "#7b68ee",
776 mediumspringgreen: "#00fa9a", 767 mediumspringgreen: "#00fa9a",
777 mediumturquoise: "#48d1cc", 768 mediumturquoise: "#48d1cc",
778 mediumvioletred: "#c71585", 769 mediumvioletred: "#c71585",
779 midnightblue: "#191970", 770 midnightblue: "#191970",
780 mintcream: "#f5fffa", 771 mintcream: "#f5fffa",
781 mistyrose: "#ffe4e1", 772 mistyrose: "#ffe4e1",
782 moccasin: "#ffe4b5", 773 moccasin: "#ffe4b5",
783 navajowhite: "#ffdead", 774 navajowhite: "#ffdead",
784 navy: "#000080", 775 navy: "#000080",
785 oldlace: "#fdf5e6", 776 oldlace: "#fdf5e6",
786 olive: "#808000", 777 olive: "#808000",
787 olivedrab: "#6b8e23", 778 olivedrab: "#6b8e23",
788 orange: "#ffa500", 779 orange: "#ffa500",
789 orangered: "#ff4500", 780 orangered: "#ff4500",
790 orchid: "#da70d6", 781 orchid: "#da70d6",
791 palegoldenrod: "#eee8aa", 782 palegoldenrod: "#eee8aa",
792 palegreen: "#98fb98", 783 palegreen: "#98fb98",
793 paleturquoise: "#afeeee", 784 paleturquoise: "#afeeee",
794 palevioletred: "#db7093", 785 palevioletred: "#db7093",
795 papayawhip: "#ffefd5", 786 papayawhip: "#ffefd5",
796 peachpuff: "#ffdab9", 787 peachpuff: "#ffdab9",
797 peru: "#cd853f", 788 peru: "#cd853f",
798 pink: "#ffc0cb", 789 pink: "#ffc0cb",
799 plum: "#dda0dd", 790 plum: "#dda0dd",
800 powderblue: "#b0e0e6", 791 powderblue: "#b0e0e6",
801 purple: "#800080", 792 purple: "#800080",
802 red: "#ff0000", 793 red: "#ff0000",
803 rosybrown: "#bc8f8f", 794 rosybrown: "#bc8f8f",
804 royalblue: "#4169e1", 795 royalblue: "#4169e1",
805 saddlebrown: "#8b4513", 796 saddlebrown: "#8b4513",
806 salmon: "#fa8072", 797 salmon: "#fa8072",
807 sandybrown: "#f4a460", 798 sandybrown: "#f4a460",
808 seagreen: "#2e8b57", 799 seagreen: "#2e8b57",
809 seashell: "#fff5ee", 800 seashell: "#fff5ee",
810 sienna: "#a0522d", 801 sienna: "#a0522d",
811 silver: "#c0c0c0", 802 silver: "#c0c0c0",
812 skyblue: "#87ceeb", 803 skyblue: "#87ceeb",
813 slateblue: "#6a5acd", 804 slateblue: "#6a5acd",
814 slategray: "#708090", 805 slategray: "#708090",
815 slategrey: "#708090", 806 slategrey: "#708090",
816 snow: "#fffafa", 807 snow: "#fffafa",
817 springgreen: "#00ff7f", 808 springgreen: "#00ff7f",
818 steelblue: "#4682b4", 809 steelblue: "#4682b4",
819 tan: "#d2b48c", 810 tan: "#d2b48c",
820 teal: "#008080", 811 teal: "#008080",
821 thistle: "#d8bfd8", 812 thistle: "#d8bfd8",
822 tomato: "#ff6347", 813 tomato: "#ff6347",
823 turquoise: "#40e0d0", 814 turquoise: "#40e0d0",
824 violet: "#ee82ee", 815 violet: "#ee82ee",
825 wheat: "#f5deb3", 816 wheat: "#f5deb3",
826 white: "#ffffff", 817 white: "#ffffff",
827 whitesmoke: "#f5f5f5", 818 whitesmoke: "#f5f5f5",
828 yellow: "#ffff00", 819 yellow: "#ffff00",
829 yellowgreen: "#9acd32" 820 yellowgreen: "#9acd32"
830}; 821};
831 822
832MochiKit.Base._exportSymbols(this, MochiKit.Color); 823MochiKit.Base._exportSymbols(this, MochiKit.Color);
diff --git a/frontend/gamma/js/MochiKit/DOM.js b/frontend/gamma/js/MochiKit/DOM.js
index af5d46f..944ab78 100644
--- a/frontend/gamma/js/MochiKit/DOM.js
+++ b/frontend/gamma/js/MochiKit/DOM.js
@@ -1,610 +1,610 @@
1/*** 1/***
2 2
3MochiKit.DOM 1.5 3MochiKit.DOM 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('DOM', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'DOM', '1.5', ['Base']);
12 12
13MochiKit.Base.update(MochiKit.DOM, { 13MochiKit.Base.update(MochiKit.DOM, {
14 14
15 /** @id MochiKit.DOM.currentWindow */ 15 /** @id MochiKit.DOM.currentWindow */
16 currentWindow: function () { 16 currentWindow: function () {
17 return MochiKit.DOM._window; 17 return MochiKit.DOM._window;
18 }, 18 },
19 19
20 /** @id MochiKit.DOM.currentDocument */ 20 /** @id MochiKit.DOM.currentDocument */
21 currentDocument: function () { 21 currentDocument: function () {
22 return MochiKit.DOM._document; 22 return MochiKit.DOM._document;
23 }, 23 },
24 24
25 /** @id MochiKit.DOM.withWindow */ 25 /** @id MochiKit.DOM.withWindow */
26 withWindow: function (win, func) { 26 withWindow: function (win, func) {
27 var self = MochiKit.DOM; 27 var self = MochiKit.DOM;
28 var oldDoc = self._document; 28 var oldDoc = self._document;
29 var oldWin = self._window; 29 var oldWin = self._window;
30 var rval; 30 var rval;
31 try { 31 try {
32 self._window = win; 32 self._window = win;
33 self._document = win.document; 33 self._document = win.document;
34 rval = func(); 34 rval = func();
35 } catch (e) { 35 } catch (e) {
36 self._window = oldWin; 36 self._window = oldWin;
37 self._document = oldDoc; 37 self._document = oldDoc;
38 throw e; 38 throw e;
39 } 39 }
40 self._window = oldWin; 40 self._window = oldWin;
41 self._document = oldDoc; 41 self._document = oldDoc;
42 return rval; 42 return rval;
43 }, 43 },
44 44
45 /** @id MochiKit.DOM.formContents */ 45 /** @id MochiKit.DOM.formContents */
46 formContents: function (elem/* = document.body */) { 46 formContents: function (elem/* = document.body */) {
47 var names = []; 47 var names = [];
48 var values = []; 48 var values = [];
49 var m = MochiKit.Base; 49 var m = MochiKit.Base;
50 var self = MochiKit.DOM; 50 var self = MochiKit.DOM;
51 if (typeof(elem) == "undefined" || elem === null) { 51 if (typeof(elem) == "undefined" || elem === null) {
52 elem = self._document.body; 52 elem = self._document.body;
53 } else { 53 } else {
54 elem = self.getElement(elem); 54 elem = self.getElement(elem);
55 } 55 }
56 m.nodeWalk(elem, function (elem) { 56 m.nodeWalk(elem, function (elem) {
57 var name = elem.name; 57 var name = elem.name;
58 if (m.isNotEmpty(name)) { 58 if (m.isNotEmpty(name)) {
59 var tagName = elem.tagName.toUpperCase(); 59 var tagName = elem.tagName.toUpperCase();
60 if (tagName === "INPUT" 60 if (tagName === "INPUT"
61 && (elem.type == "radio" || elem.type == "checkbox") 61 && (elem.type == "radio" || elem.type == "checkbox")
62 && !elem.checked 62 && !elem.checked
63 ) { 63 ) {
64 return null; 64 return null;
65 } 65 }
66 if (tagName === "SELECT") { 66 if (tagName === "SELECT") {
67 if (elem.type == "select-one") { 67 if (elem.type == "select-one") {
68 if (elem.selectedIndex >= 0) { 68 if (elem.selectedIndex >= 0) {
69 var opt = elem.options[elem.selectedIndex]; 69 var opt = elem.options[elem.selectedIndex];
70 var v = opt.value; 70 var v = opt.value;
71 if (!v) { 71 if (!v) {
72 var h = opt.outerHTML; 72 var h = opt.outerHTML;
73 // internet explorer sure does suck. 73 // internet explorer sure does suck.
74 if (h && !h.match(/^[^>]+\svalue\s*=/i)) { 74 if (h && !h.match(/^[^>]+\svalue\s*=/i)) {
75 v = opt.text; 75 v = opt.text;
76 } 76 }
77 } 77 }
78 names.push(name); 78 names.push(name);
79 values.push(v); 79 values.push(v);
80 return null; 80 return null;
81 } 81 }
82 // no form elements? 82 // no form elements?
83 names.push(name); 83 names.push(name);
84 values.push(""); 84 values.push("");
85 return null; 85 return null;
86 } else { 86 } else {
87 var opts = elem.options; 87 var opts = elem.options;
88 if (!opts.length) { 88 if (!opts.length) {
89 names.push(name); 89 names.push(name);
90 values.push(""); 90 values.push("");
91 return null; 91 return null;
92 } 92 }
93 for (var i = 0; i < opts.length; i++) { 93 for (var i = 0; i < opts.length; i++) {
94 var opt = opts[i]; 94 var opt = opts[i];
95 if (!opt.selected) { 95 if (!opt.selected) {
96 continue; 96 continue;
97 } 97 }
98 var v = opt.value; 98 var v = opt.value;
99 if (!v) { 99 if (!v) {
100 var h = opt.outerHTML; 100 var h = opt.outerHTML;
101 // internet explorer sure does suck. 101 // internet explorer sure does suck.
102 if (h && !h.match(/^[^>]+\svalue\s*=/i)) { 102 if (h && !h.match(/^[^>]+\svalue\s*=/i)) {
103 v = opt.text; 103 v = opt.text;
104 } 104 }
105 } 105 }
106 names.push(name); 106 names.push(name);
107 values.push(v); 107 values.push(v);
108 } 108 }
109 return null; 109 return null;
110 } 110 }
111 } 111 }
112 if (tagName === "FORM" || tagName === "P" || tagName === "SPAN" 112 if (tagName === "FORM" || tagName === "P" || tagName === "SPAN"
113 || tagName === "DIV" 113 || tagName === "DIV"
114 ) { 114 ) {
115 return elem.childNodes; 115 return elem.childNodes;
116 } 116 }
117 names.push(name); 117 names.push(name);
118 values.push(elem.value || ''); 118 values.push(elem.value || '');
119 return null; 119 return null;
120 } 120 }
121 return elem.childNodes; 121 return elem.childNodes;
122 }); 122 });
123 return [names, values]; 123 return [names, values];
124 }, 124 },
125 125
126 /** @id MochiKit.DOM.withDocument */ 126 /** @id MochiKit.DOM.withDocument */
127 withDocument: function (doc, func) { 127 withDocument: function (doc, func) {
128 var self = MochiKit.DOM; 128 var self = MochiKit.DOM;
129 var oldDoc = self._document; 129 var oldDoc = self._document;
130 var rval; 130 var rval;
131 try { 131 try {
132 self._document = doc; 132 self._document = doc;
133 rval = func(); 133 rval = func();
134 } catch (e) { 134 } catch (e) {
135 self._document = oldDoc; 135 self._document = oldDoc;
136 throw e; 136 throw e;
137 } 137 }
138 self._document = oldDoc; 138 self._document = oldDoc;
139 return rval; 139 return rval;
140 }, 140 },
141 141
142 /** @id MochiKit.DOM.registerDOMConverter */ 142 /** @id MochiKit.DOM.registerDOMConverter */
143 registerDOMConverter: function (name, check, wrap, /* optional */override) { 143 registerDOMConverter: function (name, check, wrap, /* optional */override) {
144 MochiKit.DOM.domConverters.register(name, check, wrap, override); 144 MochiKit.DOM.domConverters.register(name, check, wrap, override);
145 }, 145 },
146 146
147 /** @id MochiKit.DOM.coerceToDOM */ 147 /** @id MochiKit.DOM.coerceToDOM */
148 coerceToDOM: function (node, ctx) { 148 coerceToDOM: function (node, ctx) {
149 var m = MochiKit.Base; 149 var m = MochiKit.Base;
150 var im = MochiKit.Iter; 150 var im = MochiKit.Iter;
151 var self = MochiKit.DOM; 151 var self = MochiKit.DOM;
152 if (im) { 152 if (im) {
153 var iter = im.iter; 153 var iter = im.iter;
154 var repeat = im.repeat; 154 var repeat = im.repeat;
155 } 155 }
156 var map = m.map; 156 var map = m.map;
157 var domConverters = self.domConverters; 157 var domConverters = self.domConverters;
158 var coerceToDOM = arguments.callee; 158 var coerceToDOM = arguments.callee;
159 var NotFound = m.NotFound; 159 var NotFound = m.NotFound;
160 while (true) { 160 while (true) {
161 if (typeof(node) == 'undefined' || node === null) { 161 if (typeof(node) == 'undefined' || node === null) {
162 return null; 162 return null;
163 } 163 }
164 // this is a safari childNodes object, avoiding crashes w/ attr 164 // this is a safari childNodes object, avoiding crashes w/ attr
165 // lookup 165 // lookup
166 if (typeof(node) == "function" && 166 if (typeof(node) == "function" &&
167 typeof(node.length) == "number" && 167 typeof(node.length) == "number" &&
168 !(node instanceof Function)) { 168 !(node instanceof Function)) {
169 node = im ? im.list(node) : m.extend(null, node); 169 node = im ? im.list(node) : m.extend(null, node);
170 } 170 }
171 if (typeof(node.nodeType) != 'undefined' && node.nodeType > 0) { 171 if (typeof(node.nodeType) != 'undefined' && node.nodeType > 0) {
172 return node; 172 return node;
173 } 173 }
174 if (typeof(node) == 'number' || typeof(node) == 'boolean') { 174 if (typeof(node) == 'number' || typeof(node) == 'boolean') {
175 node = node.toString(); 175 node = node.toString();
176 // FALL THROUGH 176 // FALL THROUGH
177 } 177 }
178 if (typeof(node) == 'string') { 178 if (typeof(node) == 'string') {
179 return self._document.createTextNode(node); 179 return self._document.createTextNode(node);
180 } 180 }
181 if (typeof(node.__dom__) == 'function') { 181 if (typeof(node.__dom__) == 'function') {
182 node = node.__dom__(ctx); 182 node = node.__dom__(ctx);
183 continue; 183 continue;
184 } 184 }
185 if (typeof(node.dom) == 'function') { 185 if (typeof(node.dom) == 'function') {
186 node = node.dom(ctx); 186 node = node.dom(ctx);
187 continue; 187 continue;
188 } 188 }
189 if (typeof(node) == 'function') { 189 if (typeof(node) == 'function') {
190 node = node.apply(ctx, [ctx]); 190 node = node.apply(ctx, [ctx]);
191 continue; 191 continue;
192 } 192 }
193 193
194 if (im) { 194 if (im) {
195 // iterable 195 // iterable
196 var iterNodes = null; 196 var iterNodes = null;
197 try { 197 try {
198 iterNodes = iter(node); 198 iterNodes = iter(node);
199 } catch (e) { 199 } catch (e) {
200 // pass 200 // pass
201 } 201 }
202 if (iterNodes) { 202 if (iterNodes) {
203 return map(coerceToDOM, iterNodes, repeat(ctx)); 203 return map(coerceToDOM, iterNodes, repeat(ctx));
204 } 204 }
205 } else if (m.isArrayLike(node)) { 205 } else if (m.isArrayLike(node)) {
206 var func = function (n) { return coerceToDOM(n, ctx); }; 206 var func = function (n) { return coerceToDOM(n, ctx); };
207 return map(func, node); 207 return map(func, node);
208 } 208 }
209 209
210 // adapter 210 // adapter
211 try { 211 try {
212 node = domConverters.match(node, ctx); 212 node = domConverters.match(node, ctx);
213 continue; 213 continue;
214 } catch (e) { 214 } catch (e) {
215 if (e != NotFound) { 215 if (e != NotFound) {
216 throw e; 216 throw e;
217 } 217 }
218 } 218 }
219 219
220 // fallback 220 // fallback
221 return self._document.createTextNode(node.toString()); 221 return self._document.createTextNode(node.toString());
222 } 222 }
223 // mozilla warnings aren't too bright 223 // mozilla warnings aren't too bright
224 return undefined; 224 return undefined;
225 }, 225 },
226 226
227 /** @id MochiKit.DOM.isChildNode */ 227 /** @id MochiKit.DOM.isChildNode */
228 isChildNode: function (node, maybeparent) { 228 isChildNode: function (node, maybeparent) {
229 var self = MochiKit.DOM; 229 var self = MochiKit.DOM;
230 if (typeof(node) == "string") { 230 if (typeof(node) == "string") {
231 node = self.getElement(node); 231 node = self.getElement(node);
232 } 232 }
233 if (typeof(maybeparent) == "string") { 233 if (typeof(maybeparent) == "string") {
234 maybeparent = self.getElement(maybeparent); 234 maybeparent = self.getElement(maybeparent);
235 } 235 }
236 if (typeof(node) == 'undefined' || node === null) { 236 if (typeof(node) == 'undefined' || node === null) {
237 return false; 237 return false;
238 } 238 }
239 while (node != null && node !== self._document) { 239 while (node != null && node !== self._document) {
240 if (node === maybeparent) { 240 if (node === maybeparent) {
241 return true; 241 return true;
242 } 242 }
243 node = node.parentNode; 243 node = node.parentNode;
244 } 244 }
245 return false; 245 return false;
246 }, 246 },
247 247
248 /** @id MochiKit.DOM.setNodeAttribute */ 248 /** @id MochiKit.DOM.setNodeAttribute */
249 setNodeAttribute: function (node, attr, value) { 249 setNodeAttribute: function (node, attr, value) {
250 var o = {}; 250 var o = {};
251 o[attr] = value; 251 o[attr] = value;
252 try { 252 try {
253 return MochiKit.DOM.updateNodeAttributes(node, o); 253 return MochiKit.DOM.updateNodeAttributes(node, o);
254 } catch (e) { 254 } catch (e) {
255 // pass 255 // pass
256 } 256 }
257 return null; 257 return null;
258 }, 258 },
259 259
260 /** @id MochiKit.DOM.getNodeAttribute */ 260 /** @id MochiKit.DOM.getNodeAttribute */
261 getNodeAttribute: function (node, attr) { 261 getNodeAttribute: function (node, attr) {
262 var self = MochiKit.DOM; 262 var self = MochiKit.DOM;
263 var rename = self.attributeArray.renames[attr]; 263 var rename = self.attributeArray.renames[attr];
264 var ignoreValue = self.attributeArray.ignoreAttr[attr]; 264 var ignoreValue = self.attributeArray.ignoreAttr[attr];
265 node = self.getElement(node); 265 node = self.getElement(node);
266 try { 266 try {
267 if (rename) { 267 if (rename) {
268 return node[rename]; 268 return node[rename];
269 } 269 }
270 var value = node.getAttribute(attr); 270 var value = node.getAttribute(attr);
271 if (value != ignoreValue) { 271 if (value != ignoreValue) {
272 return value; 272 return value;
273 } 273 }
274 } catch (e) { 274 } catch (e) {
275 // pass 275 // pass
276 } 276 }
277 return null; 277 return null;
278 }, 278 },
279 279
280 /** @id MochiKit.DOM.removeNodeAttribute */ 280 /** @id MochiKit.DOM.removeNodeAttribute */
281 removeNodeAttribute: function (node, attr) { 281 removeNodeAttribute: function (node, attr) {
282 var self = MochiKit.DOM; 282 var self = MochiKit.DOM;
283 var rename = self.attributeArray.renames[attr]; 283 var rename = self.attributeArray.renames[attr];
284 node = self.getElement(node); 284 node = self.getElement(node);
285 try { 285 try {
286 if (rename) { 286 if (rename) {
287 return node[rename]; 287 return node[rename];
288 } 288 }
289 return node.removeAttribute(attr); 289 return node.removeAttribute(attr);
290 } catch (e) { 290 } catch (e) {
291 // pass 291 // pass
292 } 292 }
293 return null; 293 return null;
294 }, 294 },
295 295
296 /** @id MochiKit.DOM.updateNodeAttributes */ 296 /** @id MochiKit.DOM.updateNodeAttributes */
297 updateNodeAttributes: function (node, attrs) { 297 updateNodeAttributes: function (node, attrs) {
298 var elem = node; 298 var elem = node;
299 var self = MochiKit.DOM; 299 var self = MochiKit.DOM;
300 var base = MochiKit.Base;
300 if (typeof(node) == 'string') { 301 if (typeof(node) == 'string') {
301 elem = self.getElement(node); 302 elem = self.getElement(node);
302 } 303 }
303 if (attrs) { 304 if (attrs) {
304 var updatetree = MochiKit.Base.updatetree;
305 if (self.attributeArray.compliant) { 305 if (self.attributeArray.compliant) {
306 // not IE, good. 306 // not IE, good.
307 for (var k in attrs) { 307 for (var k in attrs) {
308 var v = attrs[k]; 308 var v = attrs[k];
309 if (typeof(v) == 'object' && typeof(elem[k]) == 'object') { 309 if (typeof(v) == 'object' && typeof(elem[k]) == 'object') {
310 if (k == "style" && MochiKit.Style) { 310 if (k == "style" && MochiKit.Style) {
311 MochiKit.Style.setStyle(elem, v); 311 MochiKit.Style.setStyle(elem, v);
312 } else { 312 } else {
313 updatetree(elem[k], v); 313 base.updatetree(elem[k], v);
314 } 314 }
315 } else if (k.substring(0, 2) == "on") { 315 } else if (k.substring(0, 2) == "on") {
316 if (typeof(v) == "string") { 316 if (typeof(v) == "string") {
317 v = new Function(v); 317 v = new Function(v);
318 } 318 }
319 elem[k] = v; 319 elem[k] = v;
320 } else { 320 } else {
321 elem.setAttribute(k, v); 321 elem.setAttribute(k, v);
322 } 322 }
323 if (typeof(elem[k]) == "string" && elem[k] != v) { 323 if (base.isValue(elem[k]) && elem[k] != v) {
324 // Also set property for weird attributes (see #302) 324 // Also set property for weird attributes (see #302 & #335)
325 elem[k] = v; 325 elem[k] = v;
326 } 326 }
327 } 327 }
328 } else { 328 } else {
329 // IE is insane in the membrane 329 // IE is insane in the membrane
330 var renames = self.attributeArray.renames; 330 var renames = self.attributeArray.renames;
331 for (var k in attrs) { 331 for (var k in attrs) {
332 v = attrs[k]; 332 v = attrs[k];
333 var renamed = renames[k]; 333 var renamed = renames[k];
334 if (k == "style" && typeof(v) == "string") { 334 if (k == "style" && typeof(v) == "string") {
335 elem.style.cssText = v; 335 elem.style.cssText = v;
336 } else if (typeof(renamed) == "string") { 336 } else if (typeof(renamed) == "string") {
337 elem[renamed] = v; 337 elem[renamed] = v;
338 } else if (typeof(elem[k]) == 'object' 338 } else if (typeof(elem[k]) == 'object'
339 && typeof(v) == 'object') { 339 && typeof(v) == 'object') {
340 if (k == "style" && MochiKit.Style) { 340 if (k == "style" && MochiKit.Style) {
341 MochiKit.Style.setStyle(elem, v); 341 MochiKit.Style.setStyle(elem, v);
342 } else { 342 } else {
343 updatetree(elem[k], v); 343 base.updatetree(elem[k], v);
344 } 344 }
345 } else if (k.substring(0, 2) == "on") { 345 } else if (k.substring(0, 2) == "on") {
346 if (typeof(v) == "string") { 346 if (typeof(v) == "string") {
347 v = new Function(v); 347 v = new Function(v);
348 } 348 }
349 elem[k] = v; 349 elem[k] = v;
350 } else { 350 } else {
351 elem.setAttribute(k, v); 351 elem.setAttribute(k, v);
352 } 352 }
353 if (typeof(elem[k]) == "string" && elem[k] != v) { 353 if (base.isValue(elem[k]) && elem[k] != v) {
354 // Also set property for weird attributes (see #302) 354 // Also set property for weird attributes (see #302 & #335)
355 elem[k] = v; 355 elem[k] = v;
356 } 356 }
357 } 357 }
358 } 358 }
359 } 359 }
360 return elem; 360 return elem;
361 }, 361 },
362 362
363 /** @id MochiKit.DOM.appendChildNodes */ 363 /** @id MochiKit.DOM.appendChildNodes */
364 appendChildNodes: function (node/*, nodes...*/) { 364 appendChildNodes: function (node/*, nodes...*/) {
365 var elem = node; 365 var elem = node;
366 var self = MochiKit.DOM; 366 var self = MochiKit.DOM;
367 if (typeof(node) == 'string') { 367 if (typeof(node) == 'string') {
368 elem = self.getElement(node); 368 elem = self.getElement(node);
369 } 369 }
370 var nodeStack = [ 370 var nodeStack = [
371 self.coerceToDOM( 371 self.coerceToDOM(
372 MochiKit.Base.extend(null, arguments, 1), 372 MochiKit.Base.extend(null, arguments, 1),
373 elem 373 elem
374 ) 374 )
375 ]; 375 ];
376 var concat = MochiKit.Base.concat; 376 var concat = MochiKit.Base.concat;
377 while (nodeStack.length) { 377 while (nodeStack.length) {
378 var n = nodeStack.shift(); 378 var n = nodeStack.shift();
379 if (typeof(n) == 'undefined' || n === null) { 379 if (typeof(n) == 'undefined' || n === null) {
380 // pass 380 // pass
381 } else if (typeof(n.nodeType) == 'number') { 381 } else if (typeof(n.nodeType) == 'number') {
382 elem.appendChild(n); 382 elem.appendChild(n);
383 } else { 383 } else {
384 nodeStack = concat(n, nodeStack); 384 nodeStack = concat(n, nodeStack);
385 } 385 }
386 } 386 }
387 return elem; 387 return elem;
388 }, 388 },
389 389
390 390
391 /** @id MochiKit.DOM.insertSiblingNodesBefore */ 391 /** @id MochiKit.DOM.insertSiblingNodesBefore */
392 insertSiblingNodesBefore: function (node/*, nodes...*/) { 392 insertSiblingNodesBefore: function (node/*, nodes...*/) {
393 var elem = node; 393 var elem = node;
394 var self = MochiKit.DOM; 394 var self = MochiKit.DOM;
395 if (typeof(node) == 'string') { 395 if (typeof(node) == 'string') {
396 elem = self.getElement(node); 396 elem = self.getElement(node);
397 } 397 }
398 var nodeStack = [ 398 var nodeStack = [
399 self.coerceToDOM( 399 self.coerceToDOM(
400 MochiKit.Base.extend(null, arguments, 1), 400 MochiKit.Base.extend(null, arguments, 1),
401 elem 401 elem
402 ) 402 )
403 ]; 403 ];
404 var parentnode = elem.parentNode; 404 var parentnode = elem.parentNode;
405 var concat = MochiKit.Base.concat; 405 var concat = MochiKit.Base.concat;
406 while (nodeStack.length) { 406 while (nodeStack.length) {
407 var n = nodeStack.shift(); 407 var n = nodeStack.shift();
408 if (typeof(n) == 'undefined' || n === null) { 408 if (typeof(n) == 'undefined' || n === null) {
409 // pass 409 // pass
410 } else if (typeof(n.nodeType) == 'number') { 410 } else if (typeof(n.nodeType) == 'number') {
411 parentnode.insertBefore(n, elem); 411 parentnode.insertBefore(n, elem);
412 } else { 412 } else {
413 nodeStack = concat(n, nodeStack); 413 nodeStack = concat(n, nodeStack);
414 } 414 }
415 } 415 }
416 return parentnode; 416 return parentnode;
417 }, 417 },
418 418
419 /** @id MochiKit.DOM.insertSiblingNodesAfter */ 419 /** @id MochiKit.DOM.insertSiblingNodesAfter */
420 insertSiblingNodesAfter: function (node/*, nodes...*/) { 420 insertSiblingNodesAfter: function (node/*, nodes...*/) {
421 var elem = node; 421 var elem = node;
422 var self = MochiKit.DOM; 422 var self = MochiKit.DOM;
423 423
424 if (typeof(node) == 'string') { 424 if (typeof(node) == 'string') {
425 elem = self.getElement(node); 425 elem = self.getElement(node);
426 } 426 }
427 var nodeStack = [ 427 var nodeStack = [
428 self.coerceToDOM( 428 self.coerceToDOM(
429 MochiKit.Base.extend(null, arguments, 1), 429 MochiKit.Base.extend(null, arguments, 1),
430 elem 430 elem
431 ) 431 )
432 ]; 432 ];
433 433
434 if (elem.nextSibling) { 434 if (elem.nextSibling) {
435 return self.insertSiblingNodesBefore(elem.nextSibling, nodeStack); 435 return self.insertSiblingNodesBefore(elem.nextSibling, nodeStack);
436 } 436 }
437 else { 437 else {
438 return self.appendChildNodes(elem.parentNode, nodeStack); 438 return self.appendChildNodes(elem.parentNode, nodeStack);
439 } 439 }
440 }, 440 },
441 441
442 /** @id MochiKit.DOM.replaceChildNodes */ 442 /** @id MochiKit.DOM.replaceChildNodes */
443 replaceChildNodes: function (node/*, nodes...*/) { 443 replaceChildNodes: function (node/*, nodes...*/) {
444 var elem = node; 444 var elem = node;
445 var self = MochiKit.DOM; 445 var self = MochiKit.DOM;
446 if (typeof(node) == 'string') { 446 if (typeof(node) == 'string') {
447 elem = self.getElement(node); 447 elem = self.getElement(node);
448 arguments[0] = elem; 448 arguments[0] = elem;
449 } 449 }
450 var child; 450 var child;
451 while ((child = elem.firstChild)) { 451 while ((child = elem.firstChild)) {
452 elem.removeChild(child); 452 elem.removeChild(child);
453 } 453 }
454 if (arguments.length < 2) { 454 if (arguments.length < 2) {
455 return elem; 455 return elem;
456 } else { 456 } else {
457 return self.appendChildNodes.apply(this, arguments); 457 return self.appendChildNodes.apply(this, arguments);
458 } 458 }
459 }, 459 },
460 460
461 /** @id MochiKit.DOM.createDOM */ 461 /** @id MochiKit.DOM.createDOM */
462 createDOM: function (name, attrs/*, nodes... */) { 462 createDOM: function (name, attrs/*, nodes... */) {
463 var elem; 463 var elem;
464 var self = MochiKit.DOM; 464 var self = MochiKit.DOM;
465 var m = MochiKit.Base; 465 var m = MochiKit.Base;
466 if (typeof(attrs) == "string" || typeof(attrs) == "number") { 466 if (typeof(attrs) == "string" || typeof(attrs) == "number") {
467 var args = m.extend([name, null], arguments, 1); 467 var args = m.extend([name, null], arguments, 1);
468 return arguments.callee.apply(this, args); 468 return arguments.callee.apply(this, args);
469 } 469 }
470 if (typeof(name) == 'string') { 470 if (typeof(name) == 'string') {
471 // Internet Explorer is dumb 471 // Internet Explorer is dumb
472 var xhtml = self._xhtml; 472 var xhtml = self._xhtml;
473 if (attrs && !self.attributeArray.compliant) { 473 if (attrs && !self.attributeArray.compliant) {
474 // http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/name_2.asp 474 // http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/name_2.asp
475 var contents = ""; 475 var contents = "";
476 if ('name' in attrs) { 476 if ('name' in attrs) {
477 contents += ' name="' + self.escapeHTML(attrs.name) + '"'; 477 contents += ' name="' + self.escapeHTML(attrs.name) + '"';
478 } 478 }
479 if (name == 'input' && 'type' in attrs) { 479 if (name == 'input' && 'type' in attrs) {
480 contents += ' type="' + self.escapeHTML(attrs.type) + '"'; 480 contents += ' type="' + self.escapeHTML(attrs.type) + '"';
481 } 481 }
482 if (contents) { 482 if (contents) {
483 name = "<" + name + contents + ">"; 483 name = "<" + name + contents + ">";
484 xhtml = false; 484 xhtml = false;
485 } 485 }
486 } 486 }
487 var d = self._document; 487 var d = self._document;
488 if (xhtml && d === document) { 488 if (xhtml && d === document) {
489 elem = d.createElementNS("http://www.w3.org/1999/xhtml", name); 489 elem = d.createElementNS("http://www.w3.org/1999/xhtml", name);
490 } else { 490 } else {
491 elem = d.createElement(name); 491 elem = d.createElement(name);
492 } 492 }
493 } else { 493 } else {
494 elem = name; 494 elem = name;
495 } 495 }
496 if (attrs) { 496 if (attrs) {
497 self.updateNodeAttributes(elem, attrs); 497 self.updateNodeAttributes(elem, attrs);
498 } 498 }
499 if (arguments.length <= 2) { 499 if (arguments.length <= 2) {
500 return elem; 500 return elem;
501 } else { 501 } else {
502 var args = m.extend([elem], arguments, 2); 502 var args = m.extend([elem], arguments, 2);
503 return self.appendChildNodes.apply(this, args); 503 return self.appendChildNodes.apply(this, args);
504 } 504 }
505 }, 505 },
506 506
507 /** @id MochiKit.DOM.createDOMFunc */ 507 /** @id MochiKit.DOM.createDOMFunc */
508 createDOMFunc: function (/* tag, attrs, *nodes */) { 508 createDOMFunc: function (/* tag, attrs, *nodes */) {
509 var m = MochiKit.Base; 509 var m = MochiKit.Base;
510 return m.partial.apply( 510 return m.partial.apply(
511 this, 511 this,
512 m.extend([MochiKit.DOM.createDOM], arguments) 512 m.extend([MochiKit.DOM.createDOM], arguments)
513 ); 513 );
514 }, 514 },
515 515
516 /** @id MochiKit.DOM.removeElement */ 516 /** @id MochiKit.DOM.removeElement */
517 removeElement: function (elem) { 517 removeElement: function (elem) {
518 var self = MochiKit.DOM; 518 var self = MochiKit.DOM;
519 if (typeof(elem) == "string") { 519 if (typeof(elem) == "string") {
520 elem = self.getElement(elem); 520 elem = self.getElement(elem);
521 } 521 }
522 var e = self.coerceToDOM(elem); 522 var e = self.coerceToDOM(elem);
523 e.parentNode.removeChild(e); 523 e.parentNode.removeChild(e);
524 return e; 524 return e;
525 }, 525 },
526 526
527 /** @id MochiKit.DOM.swapDOM */ 527 /** @id MochiKit.DOM.swapDOM */
528 swapDOM: function (dest, src) { 528 swapDOM: function (dest, src) {
529 var self = MochiKit.DOM; 529 var self = MochiKit.DOM;
530 dest = self.getElement(dest); 530 dest = self.getElement(dest);
531 var parent = dest.parentNode; 531 var parent = dest.parentNode;
532 if (src) { 532 if (src) {
533 if (typeof(src) == "string") { 533 if (typeof(src) == "string") {
534 src = self.getElement(src); 534 src = self.getElement(src);
535 } 535 }
536 src = self.coerceToDOM(src, parent); 536 src = self.coerceToDOM(src, parent);
537 parent.replaceChild(src, dest); 537 parent.replaceChild(src, dest);
538 } else { 538 } else {
539 parent.removeChild(dest); 539 parent.removeChild(dest);
540 } 540 }
541 return src; 541 return src;
542 }, 542 },
543 543
544 /** @id MochiKit.DOM.getElement */ 544 /** @id MochiKit.DOM.getElement */
545 getElement: function (id) { 545 getElement: function (id) {
546 var self = MochiKit.DOM; 546 var self = MochiKit.DOM;
547 if (arguments.length == 1) { 547 if (arguments.length == 1) {
548 return ((typeof(id) == "string") ? 548 return ((typeof(id) == "string") ?
549 self._document.getElementById(id) : id); 549 self._document.getElementById(id) : id);
550 } else { 550 } else {
551 return MochiKit.Base.map(self.getElement, arguments); 551 return MochiKit.Base.map(self.getElement, arguments);
552 } 552 }
553 }, 553 },
554 554
555 /** @id MochiKit.DOM.getElementsByTagAndClassName */ 555 /** @id MochiKit.DOM.getElementsByTagAndClassName */
556 getElementsByTagAndClassName: function (tagName, className, 556 getElementsByTagAndClassName: function (tagName, className,
557 /* optional */parent) { 557 /* optional */parent) {
558 var self = MochiKit.DOM; 558 var self = MochiKit.DOM;
559 if (typeof(tagName) == 'undefined' || tagName === null) { 559 if (typeof(tagName) == 'undefined' || tagName === null) {
560 tagName = '*'; 560 tagName = '*';
561 } 561 }
562 if (typeof(parent) == 'undefined' || parent === null) { 562 if (typeof(parent) == 'undefined' || parent === null) {
563 parent = self._document; 563 parent = self._document;
564 } 564 }
565 parent = self.getElement(parent); 565 parent = self.getElement(parent);
566 if (parent == null) { 566 if (parent == null) {
567 return []; 567 return [];
568 } 568 }
569 var children = (parent.getElementsByTagName(tagName) 569 var children = (parent.getElementsByTagName(tagName)
570 || self._document.all); 570 || self._document.all);
571 if (typeof(className) == 'undefined' || className === null) { 571 if (typeof(className) == 'undefined' || className === null) {
572 return MochiKit.Base.extend(null, children); 572 return MochiKit.Base.extend(null, children);
573 } 573 }
574 574
575 var elements = []; 575 var elements = [];
576 for (var i = 0; i < children.length; i++) { 576 for (var i = 0; i < children.length; i++) {
577 var child = children[i]; 577 var child = children[i];
578 var cls = child.className; 578 var cls = child.className;
579 if (typeof(cls) != "string") { 579 if (typeof(cls) != "string") {
580 cls = child.getAttribute("class"); 580 cls = child.getAttribute("class");
581 } 581 }
582 if (typeof(cls) == "string") { 582 if (typeof(cls) == "string") {
583 var classNames = cls.split(' '); 583 var classNames = cls.split(' ');
584 for (var j = 0; j < classNames.length; j++) { 584 for (var j = 0; j < classNames.length; j++) {
585 if (classNames[j] == className) { 585 if (classNames[j] == className) {
586 elements.push(child); 586 elements.push(child);
587 break; 587 break;
588 } 588 }
589 } 589 }
590 } 590 }
591 } 591 }
592 592
593 return elements; 593 return elements;
594 }, 594 },
595 595
596 _newCallStack: function (path, once) { 596 _newCallStack: function (path, once) {
597 var rval = function () { 597 var rval = function () {
598 var callStack = arguments.callee.callStack; 598 var callStack = arguments.callee.callStack;
599 for (var i = 0; i < callStack.length; i++) { 599 for (var i = 0; i < callStack.length; i++) {
600 if (callStack[i].apply(this, arguments) === false) { 600 if (callStack[i].apply(this, arguments) === false) {
601 break; 601 break;
602 } 602 }
603 } 603 }
604 if (once) { 604 if (once) {
605 try { 605 try {
606 this[path] = null; 606 this[path] = null;
607 } catch (e) { 607 } catch (e) {
608 // pass 608 // pass
609 } 609 }
610 } 610 }
@@ -737,408 +737,443 @@ MochiKit.Base.update(MochiKit.DOM, {
737 if (res) { 737 if (res) {
738 MochiKit.DOM.addElementClass(obj, toClass); 738 MochiKit.DOM.addElementClass(obj, toClass);
739 } 739 }
740 return res; 740 return res;
741 }, 741 },
742 742
743 /** @id MochiKit.DOM.hasElementClass */ 743 /** @id MochiKit.DOM.hasElementClass */
744 hasElementClass: function (element, className/*...*/) { 744 hasElementClass: function (element, className/*...*/) {
745 var obj = MochiKit.DOM.getElement(element); 745 var obj = MochiKit.DOM.getElement(element);
746 if (obj == null) { 746 if (obj == null) {
747 return false; 747 return false;
748 } 748 }
749 var cls = obj.className; 749 var cls = obj.className;
750 if (typeof(cls) != "string" && typeof(obj.getAttribute) == "function") { 750 if (typeof(cls) != "string" && typeof(obj.getAttribute) == "function") {
751 cls = obj.getAttribute("class"); 751 cls = obj.getAttribute("class");
752 } 752 }
753 if (typeof(cls) != "string") { 753 if (typeof(cls) != "string") {
754 return false; 754 return false;
755 } 755 }
756 var classes = cls.split(" "); 756 var classes = cls.split(" ");
757 for (var i = 1; i < arguments.length; i++) { 757 for (var i = 1; i < arguments.length; i++) {
758 var good = false; 758 var good = false;
759 for (var j = 0; j < classes.length; j++) { 759 for (var j = 0; j < classes.length; j++) {
760 if (classes[j] == arguments[i]) { 760 if (classes[j] == arguments[i]) {
761 good = true; 761 good = true;
762 break; 762 break;
763 } 763 }
764 } 764 }
765 if (!good) { 765 if (!good) {
766 return false; 766 return false;
767 } 767 }
768 } 768 }
769 return true; 769 return true;
770 }, 770 },
771 771
772 /** @id MochiKit.DOM.escapeHTML */ 772 /** @id MochiKit.DOM.escapeHTML */
773 escapeHTML: function (s) { 773 escapeHTML: function (s) {
774 return s.replace(/&/g, "&amp;" 774 return s.replace(/&/g, "&amp;"
775 ).replace(/"/g, "&quot;" 775 ).replace(/"/g, "&quot;"
776 ).replace(/</g, "&lt;" 776 ).replace(/</g, "&lt;"
777 ).replace(/>/g, "&gt;"); 777 ).replace(/>/g, "&gt;");
778 }, 778 },
779 779
780 /** @id MochiKit.DOM.toHTML */ 780 /** @id MochiKit.DOM.toHTML */
781 toHTML: function (dom) { 781 toHTML: function (dom) {
782 return MochiKit.DOM.emitHTML(dom).join(""); 782 return MochiKit.DOM.emitHTML(dom).join("");
783 }, 783 },
784 784
785 /** @id MochiKit.DOM.emitHTML */ 785 /** @id MochiKit.DOM.emitHTML */
786 emitHTML: function (dom, /* optional */lst) { 786 emitHTML: function (dom, /* optional */lst) {
787 if (typeof(lst) == 'undefined' || lst === null) { 787 if (typeof(lst) == 'undefined' || lst === null) {
788 lst = []; 788 lst = [];
789 } 789 }
790 // queue is the call stack, we're doing this non-recursively 790 // queue is the call stack, we're doing this non-recursively
791 var queue = [dom]; 791 var queue = [dom];
792 var self = MochiKit.DOM; 792 var self = MochiKit.DOM;
793 var escapeHTML = self.escapeHTML; 793 var escapeHTML = self.escapeHTML;
794 var attributeArray = self.attributeArray; 794 var attributeArray = self.attributeArray;
795 while (queue.length) { 795 while (queue.length) {
796 dom = queue.pop(); 796 dom = queue.pop();
797 if (typeof(dom) == 'string') { 797 if (typeof(dom) == 'string') {
798 lst.push(dom); 798 lst.push(dom);
799 } else if (dom.nodeType == 1) { 799 } else if (dom.nodeType == 1) {
800 // we're not using higher order stuff here 800 // we're not using higher order stuff here
801 // because safari has heisenbugs.. argh. 801 // because safari has heisenbugs.. argh.
802 // 802 //
803 // I think it might have something to do with 803 // I think it might have something to do with
804 // garbage collection and function calls. 804 // garbage collection and function calls.
805 lst.push('<' + dom.tagName.toLowerCase()); 805 lst.push('<' + dom.tagName.toLowerCase());
806 var attributes = []; 806 var attributes = [];
807 var domAttr = attributeArray(dom); 807 var domAttr = attributeArray(dom);
808 for (var i = 0; i < domAttr.length; i++) { 808 for (var i = 0; i < domAttr.length; i++) {
809 var a = domAttr[i]; 809 var a = domAttr[i];
810 attributes.push([ 810 attributes.push([
811 " ", 811 " ",
812 a.name, 812 a.name,
813 '="', 813 '="',
814 escapeHTML(a.value), 814 escapeHTML(a.value),
815 '"' 815 '"'
816 ]); 816 ]);
817 } 817 }
818 attributes.sort(); 818 attributes.sort();
819 for (i = 0; i < attributes.length; i++) { 819 for (i = 0; i < attributes.length; i++) {
820 var attrs = attributes[i]; 820 var attrs = attributes[i];
821 for (var j = 0; j < attrs.length; j++) { 821 for (var j = 0; j < attrs.length; j++) {
822 lst.push(attrs[j]); 822 lst.push(attrs[j]);
823 } 823 }
824 } 824 }
825 if (dom.hasChildNodes()) { 825 if (dom.hasChildNodes()) {
826 lst.push(">"); 826 lst.push(">");
827 // queue is the FILO call stack, so we put the close tag 827 // queue is the FILO call stack, so we put the close tag
828 // on first 828 // on first
829 queue.push("</" + dom.tagName.toLowerCase() + ">"); 829 queue.push("</" + dom.tagName.toLowerCase() + ">");
830 var cnodes = dom.childNodes; 830 var cnodes = dom.childNodes;
831 for (i = cnodes.length - 1; i >= 0; i--) { 831 for (i = cnodes.length - 1; i >= 0; i--) {
832 queue.push(cnodes[i]); 832 queue.push(cnodes[i]);
833 } 833 }
834 } else { 834 } else {
835 lst.push('/>'); 835 lst.push('/>');
836 } 836 }
837 } else if (dom.nodeType == 3) { 837 } else if (dom.nodeType == 3) {
838 lst.push(escapeHTML(dom.nodeValue)); 838 lst.push(escapeHTML(dom.nodeValue));
839 } 839 }
840 } 840 }
841 return lst; 841 return lst;
842 }, 842 },
843 843
844 /** @id MochiKit.DOM.scrapeText */ 844 /** @id MochiKit.DOM.scrapeText */
845 scrapeText: function (node, /* optional */asArray) { 845 scrapeText: function (node, /* optional */asArray) {
846 var rval = []; 846 var rval = [];
847 (function (node) { 847 (function (node) {
848 var cn = node.childNodes; 848 var cn = node.childNodes;
849 if (cn) { 849 if (cn) {
850 for (var i = 0; i < cn.length; i++) { 850 for (var i = 0; i < cn.length; i++) {
851 arguments.callee.call(this, cn[i]); 851 arguments.callee.call(this, cn[i]);
852 } 852 }
853 } 853 }
854 var nodeValue = node.nodeValue; 854 var nodeValue = node.nodeValue;
855 if (typeof(nodeValue) == 'string') { 855 if (typeof(nodeValue) == 'string') {
856 rval.push(nodeValue); 856 rval.push(nodeValue);
857 } 857 }
858 })(MochiKit.DOM.getElement(node)); 858 })(MochiKit.DOM.getElement(node));
859 if (asArray) { 859 if (asArray) {
860 return rval; 860 return rval;
861 } else { 861 } else {
862 return rval.join(""); 862 return rval.join("");
863 } 863 }
864 }, 864 },
865 865
866 /** @id MochiKit.DOM.removeEmptyTextNodes */ 866 /** @id MochiKit.DOM.removeEmptyTextNodes */
867 removeEmptyTextNodes: function (element) { 867 removeEmptyTextNodes: function (element) {
868 element = MochiKit.DOM.getElement(element); 868 element = MochiKit.DOM.getElement(element);
869 for (var i = 0; i < element.childNodes.length; i++) { 869 for (var i = 0; i < element.childNodes.length; i++) {
870 var node = element.childNodes[i]; 870 var node = element.childNodes[i];
871 if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) { 871 if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
872 node.parentNode.removeChild(node); 872 node.parentNode.removeChild(node);
873 } 873 }
874 } 874 }
875 }, 875 },
876 876
877 /** @id MochiKit.DOM.getFirstElementByTagAndClassName */ 877 /** @id MochiKit.DOM.getFirstElementByTagAndClassName */
878 getFirstElementByTagAndClassName: function (tagName, className, 878 getFirstElementByTagAndClassName: function (tagName, className,
879 /* optional */parent) { 879 /* optional */parent) {
880 var self = MochiKit.DOM; 880 var self = MochiKit.DOM;
881 if (typeof(tagName) == 'undefined' || tagName === null) { 881 if (typeof(tagName) == 'undefined' || tagName === null) {
882 tagName = '*'; 882 tagName = '*';
883 } 883 }
884 if (typeof(parent) == 'undefined' || parent === null) { 884 if (typeof(parent) == 'undefined' || parent === null) {
885 parent = self._document; 885 parent = self._document;
886 } 886 }
887 parent = self.getElement(parent); 887 parent = self.getElement(parent);
888 if (parent == null) { 888 if (parent == null) {
889 return null; 889 return null;
890 } 890 }
891 var children = (parent.getElementsByTagName(tagName) 891 var children = (parent.getElementsByTagName(tagName)
892 || self._document.all); 892 || self._document.all);
893 if (children.length <= 0) { 893 if (children.length <= 0) {
894 return null; 894 return null;
895 } else if (typeof(className) == 'undefined' || className === null) { 895 } else if (typeof(className) == 'undefined' || className === null) {
896 return children[0]; 896 return children[0];
897 } 897 }
898 898
899 for (var i = 0; i < children.length; i++) { 899 for (var i = 0; i < children.length; i++) {
900 var child = children[i]; 900 var child = children[i];
901 var cls = child.className; 901 var cls = child.className;
902 if (typeof(cls) != "string") { 902 if (typeof(cls) != "string") {
903 cls = child.getAttribute("class"); 903 cls = child.getAttribute("class");
904 } 904 }
905 if (typeof(cls) == "string") { 905 if (typeof(cls) == "string") {
906 var classNames = cls.split(' '); 906 var classNames = cls.split(' ');
907 for (var j = 0; j < classNames.length; j++) { 907 for (var j = 0; j < classNames.length; j++) {
908 if (classNames[j] == className) { 908 if (classNames[j] == className) {
909 return child; 909 return child;
910 } 910 }
911 } 911 }
912 } 912 }
913 } 913 }
914 return null; 914 return null;
915 }, 915 },
916 916
917 /** @id MochiKit.DOM.getFirstParentByTagAndClassName */ 917 /** @id MochiKit.DOM.getFirstParentByTagAndClassName */
918 getFirstParentByTagAndClassName: function (elem, tagName, className) { 918 getFirstParentByTagAndClassName: function (elem, tagName, className) {
919 var self = MochiKit.DOM; 919 var self = MochiKit.DOM;
920 elem = self.getElement(elem); 920 elem = self.getElement(elem);
921 if (typeof(tagName) == 'undefined' || tagName === null) { 921 if (typeof(tagName) == 'undefined' || tagName === null) {
922 tagName = '*'; 922 tagName = '*';
923 } else { 923 } else {
924 tagName = tagName.toUpperCase(); 924 tagName = tagName.toUpperCase();
925 } 925 }
926 if (typeof(className) == 'undefined' || className === null) { 926 if (typeof(className) == 'undefined' || className === null) {
927 className = null; 927 className = null;
928 } 928 }
929 if (elem) { 929 if (elem) {
930 elem = elem.parentNode; 930 elem = elem.parentNode;
931 } 931 }
932 while (elem && elem.tagName) { 932 while (elem && elem.tagName) {
933 var curTagName = elem.tagName.toUpperCase(); 933 var curTagName = elem.tagName.toUpperCase();
934 if ((tagName === '*' || tagName == curTagName) && 934 if ((tagName === '*' || tagName == curTagName) &&
935 (className === null || self.hasElementClass(elem, className))) { 935 (className === null || self.hasElementClass(elem, className))) {
936 return elem; 936 return elem;
937 } 937 }
938 elem = elem.parentNode; 938 elem = elem.parentNode;
939 } 939 }
940 return null; 940 return null;
941 }, 941 },
942 942
943 __new__: function (win) { 943 __new__: function (win) {
944 944
945 var m = MochiKit.Base; 945 var m = MochiKit.Base;
946 if (typeof(document) != "undefined") { 946 if (typeof(document) != "undefined") {
947 this._document = document; 947 this._document = document;
948 var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; 948 var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
949 this._xhtml = (document.documentElement && 949 this._xhtml = (document.documentElement &&
950 document.createElementNS && 950 document.createElementNS &&
951 document.documentElement.namespaceURI === kXULNSURI); 951 document.documentElement.namespaceURI === kXULNSURI);
952 } else if (MochiKit.MockDOM) { 952 } else if (MochiKit.MockDOM) {
953 this._document = MochiKit.MockDOM.document; 953 this._document = MochiKit.MockDOM.document;
954 } 954 }
955 this._window = win; 955 this._window = win;
956 956
957 this.domConverters = new m.AdapterRegistry(); 957 this.domConverters = new m.AdapterRegistry();
958 958
959 var __tmpElement = this._document.createElement("span"); 959 var __tmpElement = this._document.createElement("span");
960 var attributeArray; 960 var attributeArray;
961 if (__tmpElement && __tmpElement.attributes && 961 if (__tmpElement && __tmpElement.attributes &&
962 __tmpElement.attributes.length > 0) { 962 __tmpElement.attributes.length > 0) {
963 // for braindead browsers (IE) that insert extra junk 963 // for braindead browsers (IE) that insert extra junk
964 var filter = m.filter; 964 var filter = m.filter;
965 attributeArray = function (node) { 965 attributeArray = function (node) {
966 /*** 966 /***
967 967
968 Return an array of attributes for a given node, 968 Return an array of attributes for a given node,
969 filtering out attributes that don't belong for 969 filtering out attributes that don't belong for
970 that are inserted by "Certain Browsers". 970 that are inserted by "Certain Browsers".
971 971
972 ***/ 972 ***/
973 return filter(attributeArray.ignoreAttrFilter, node.attributes); 973 return filter(attributeArray.ignoreAttrFilter, node.attributes);
974 }; 974 };
975 attributeArray.ignoreAttr = {}; 975 attributeArray.ignoreAttr = {};
976 var attrs = __tmpElement.attributes; 976 var attrs = __tmpElement.attributes;
977 var ignoreAttr = attributeArray.ignoreAttr; 977 var ignoreAttr = attributeArray.ignoreAttr;
978 for (var i = 0; i < attrs.length; i++) { 978 for (var i = 0; i < attrs.length; i++) {
979 var a = attrs[i]; 979 var a = attrs[i];
980 ignoreAttr[a.name] = a.value; 980 ignoreAttr[a.name] = a.value;
981 } 981 }
982 attributeArray.ignoreAttrFilter = function (a) { 982 attributeArray.ignoreAttrFilter = function (a) {
983 return (attributeArray.ignoreAttr[a.name] != a.value); 983 return (attributeArray.ignoreAttr[a.name] != a.value);
984 }; 984 };
985 attributeArray.compliant = false; 985 attributeArray.compliant = false;
986 attributeArray.renames = { 986 attributeArray.renames = {
987 "class": "className", 987 "class": "className",
988 "checked": "defaultChecked", 988 "checked": "defaultChecked",
989 "usemap": "useMap", 989 "usemap": "useMap",
990 "for": "htmlFor", 990 "for": "htmlFor",
991 "readonly": "readOnly", 991 "readonly": "readOnly",
992 "colspan": "colSpan", 992 "colspan": "colSpan",
993 "rowspan": "rowSpan",
993 "bgcolor": "bgColor", 994 "bgcolor": "bgColor",
994 "cellspacing": "cellSpacing", 995 "cellspacing": "cellSpacing",
995 "cellpadding": "cellPadding" 996 "cellpadding": "cellPadding"
996 }; 997 };
997 } else { 998 } else {
998 attributeArray = function (node) { 999 attributeArray = function (node) {
999 return node.attributes; 1000 return node.attributes;
1000 }; 1001 };
1001 attributeArray.compliant = true; 1002 attributeArray.compliant = true;
1002 attributeArray.ignoreAttr = {}; 1003 attributeArray.ignoreAttr = {};
1003 attributeArray.renames = {}; 1004 attributeArray.renames = {};
1004 } 1005 }
1005 attributeArray.__export__ = false; 1006 attributeArray.__export__ = false;
1006 this.attributeArray = attributeArray; 1007 this.attributeArray = attributeArray;
1007 1008
1008 // Backwards compatibility aliases 1009 // Backwards compatibility aliases
1009 /** @id MochiKit.DOM.computedStyle */ 1010 /** @id MochiKit.DOM.computedStyle */
1010 m._deprecated(this, 'computedStyle', 'MochiKit.Style.getStyle', '1.4'); 1011 m._deprecated(this, 'computedStyle', 'MochiKit.Style.getStyle', '1.4', true);
1011 /** @id MochiKit.DOM.elementDimensions */ 1012 /** @id MochiKit.DOM.elementDimensions */
1012 m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.4'); 1013 m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.4');
1013 /** @id MochiKit.DOM.elementPosition */ 1014 /** @id MochiKit.DOM.elementPosition */
1014 m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.4'); 1015 m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.4');
1015 /** @id MochiKit.DOM.getViewportDimensions */ 1016 /** @id MochiKit.DOM.getViewportDimensions */
1016 m._deprecated(this, 'getViewportDimensions', 'MochiKit.Style.getViewportDimensions', '1.4'); 1017 m._deprecated(this, 'getViewportDimensions', 'MochiKit.Style.getViewportDimensions', '1.4');
1017 /** @id MochiKit.DOM.hideElement */ 1018 /** @id MochiKit.DOM.hideElement */
1018 m._deprecated(this, 'hideElement', 'MochiKit.Style.hideElement', '1.4'); 1019 m._deprecated(this, 'hideElement', 'MochiKit.Style.hideElement', '1.4');
1019 /** @id MochiKit.DOM.makeClipping */ 1020 /** @id MochiKit.DOM.makeClipping */
1020 m._deprecated(this, 'makeClipping', 'MochiKit.Style.makeClipping', '1.4.1'); 1021 m._deprecated(this, 'makeClipping', 'MochiKit.Style.makeClipping', '1.4.1');
1021 /** @id MochiKit.DOM.makePositioned */ 1022 /** @id MochiKit.DOM.makePositioned */
1022 m._deprecated(this, 'makePositioned', 'MochiKit.Style.makePositioned', '1.4.1'); 1023 m._deprecated(this, 'makePositioned', 'MochiKit.Style.makePositioned', '1.4.1');
1023 /** @id MochiKit.DOM.setElementDimensions */ 1024 /** @id MochiKit.DOM.setElementDimensions */
1024 m._deprecated(this, 'setElementDimensions', 'MochiKit.Style.setElementDimensions', '1.4'); 1025 m._deprecated(this, 'setElementDimensions', 'MochiKit.Style.setElementDimensions', '1.4');
1025 /** @id MochiKit.DOM.setElementPosition */ 1026 /** @id MochiKit.DOM.setElementPosition */
1026 m._deprecated(this, 'setElementPosition', 'MochiKit.Style.setElementPosition', '1.4'); 1027 m._deprecated(this, 'setElementPosition', 'MochiKit.Style.setElementPosition', '1.4');
1027 /** @id MochiKit.DOM.setDisplayForElement */ 1028 /** @id MochiKit.DOM.setDisplayForElement */
1028 m._deprecated(this, 'setDisplayForElement', 'MochiKit.Style.setDisplayForElement', '1.4'); 1029 m._deprecated(this, 'setDisplayForElement', 'MochiKit.Style.setDisplayForElement', '1.4');
1029 /** @id MochiKit.DOM.setOpacity */ 1030 /** @id MochiKit.DOM.setOpacity */
1030 m._deprecated(this, 'setOpacity', 'MochiKit.Style.setOpacity', '1.4'); 1031 m._deprecated(this, 'setOpacity', 'MochiKit.Style.setOpacity', '1.4');
1031 /** @id MochiKit.DOM.showElement */ 1032 /** @id MochiKit.DOM.showElement */
1032 m._deprecated(this, 'showElement', 'MochiKit.Style.showElement', '1.4'); 1033 m._deprecated(this, 'showElement', 'MochiKit.Style.showElement', '1.4');
1033 /** @id MochiKit.DOM.undoClipping */ 1034 /** @id MochiKit.DOM.undoClipping */
1034 m._deprecated(this, 'undoClipping', 'MochiKit.Style.undoClipping', '1.4.1'); 1035 m._deprecated(this, 'undoClipping', 'MochiKit.Style.undoClipping', '1.4.1');
1035 /** @id MochiKit.DOM.undoPositioned */ 1036 /** @id MochiKit.DOM.undoPositioned */
1036 m._deprecated(this, 'undoPositioned', 'MochiKit.Style.undoPositioned', '1.4.1'); 1037 m._deprecated(this, 'undoPositioned', 'MochiKit.Style.undoPositioned', '1.4.1');
1037 /** @id MochiKit.DOM.Coordinates */ 1038 /** @id MochiKit.DOM.Coordinates */
1038 m._deprecated(this, 'Coordinates', 'MochiKit.Style.Coordinates', '1.4'); 1039 m._deprecated(this, 'Coordinates', 'MochiKit.Style.Coordinates', '1.4');
1039 /** @id MochiKit.DOM.Dimensions */ 1040 /** @id MochiKit.DOM.Dimensions */
1040 m._deprecated(this, 'Dimensions', 'MochiKit.Style.Dimensions', '1.4'); 1041 m._deprecated(this, 'Dimensions', 'MochiKit.Style.Dimensions', '1.4');
1041 1042
1042 // shorthand for createDOM syntax 1043 // shorthand for createDOM syntax
1043 var createDOMFunc = this.createDOMFunc; 1044 var createDOMFunc = this.createDOMFunc;
1044 /** @id MochiKit.DOM.UL */
1045 this.UL = createDOMFunc("ul");
1046 /** @id MochiKit.DOM.OL */
1047 this.OL = createDOMFunc("ol");
1048 /** @id MochiKit.DOM.LI */
1049 this.LI = createDOMFunc("li");
1050 /** @id MochiKit.DOM.DL */
1051 this.DL = createDOMFunc("dl");
1052 /** @id MochiKit.DOM.DT */
1053 this.DT = createDOMFunc("dt");
1054 /** @id MochiKit.DOM.DD */
1055 this.DD = createDOMFunc("dd");
1056 /** @id MochiKit.DOM.TD */
1057 this.TD = createDOMFunc("td");
1058 /** @id MochiKit.DOM.TR */
1059 this.TR = createDOMFunc("tr");
1060 /** @id MochiKit.DOM.TBODY */
1061 this.TBODY = createDOMFunc("tbody");
1062 /** @id MochiKit.DOM.THEAD */
1063 this.THEAD = createDOMFunc("thead");
1064 /** @id MochiKit.DOM.TFOOT */
1065 this.TFOOT = createDOMFunc("tfoot");
1066 /** @id MochiKit.DOM.TABLE */
1067 this.TABLE = createDOMFunc("table");
1068 /** @id MochiKit.DOM.TH */
1069 this.TH = createDOMFunc("th");
1070 /** @id MochiKit.DOM.INPUT */
1071 this.INPUT = createDOMFunc("input");
1072 /** @id MochiKit.DOM.SPAN */
1073 this.SPAN = createDOMFunc("span");
1074 /** @id MochiKit.DOM.A */ 1045 /** @id MochiKit.DOM.A */
1075 this.A = createDOMFunc("a"); 1046 this.A = createDOMFunc("a");
1076 /** @id MochiKit.DOM.DIV */ 1047 /** @id MochiKit.DOM.ARTICLE */
1077 this.DIV = createDOMFunc("div"); 1048 this.ARTICLE = createDOMFunc("article");
1078 /** @id MochiKit.DOM.IMG */ 1049 /** @id MochiKit.DOM.ASIDE */
1079 this.IMG = createDOMFunc("img"); 1050 this.ASIDE = createDOMFunc("aside");
1051 /** @id MochiKit.DOM.BR */
1052 this.BR = createDOMFunc("br");
1080 /** @id MochiKit.DOM.BUTTON */ 1053 /** @id MochiKit.DOM.BUTTON */
1081 this.BUTTON = createDOMFunc("button"); 1054 this.BUTTON = createDOMFunc("button");
1082 /** @id MochiKit.DOM.TT */ 1055 /** @id MochiKit.DOM.CANVAS */
1083 this.TT = createDOMFunc("tt"); 1056 this.CANVAS = createDOMFunc("canvas");
1084 /** @id MochiKit.DOM.PRE */ 1057 /** @id MochiKit.DOM.CAPTION */
1085 this.PRE = createDOMFunc("pre"); 1058 this.CAPTION = createDOMFunc("caption");
1059 /** @id MochiKit.DOM.DD */
1060 this.DD = createDOMFunc("dd");
1061 /** @id MochiKit.DOM.DIV */
1062 this.DIV = createDOMFunc("div");
1063 /** @id MochiKit.DOM.DL */
1064 this.DL = createDOMFunc("dl");
1065 /** @id MochiKit.DOM.DT */
1066 this.DT = createDOMFunc("dt");
1067 /** @id MochiKit.DOM.FIELDSET */
1068 this.FIELDSET = createDOMFunc("fieldset");
1069 /** @id MochiKit.DOM.FIGURE */
1070 this.FIGURE = createDOMFunc("figure");
1071 /** @id MochiKit.DOM.FIGCAPTION */
1072 this.FIGCAPTION = createDOMFunc("figcaption");
1073 /** @id MochiKit.DOM.FOOTER */
1074 this.FOOTER = createDOMFunc("footer");
1075 /** @id MochiKit.DOM.FORM */
1076 this.FORM = createDOMFunc("form");
1086 /** @id MochiKit.DOM.H1 */ 1077 /** @id MochiKit.DOM.H1 */
1087 this.H1 = createDOMFunc("h1"); 1078 this.H1 = createDOMFunc("h1");
1088 /** @id MochiKit.DOM.H2 */ 1079 /** @id MochiKit.DOM.H2 */
1089 this.H2 = createDOMFunc("h2"); 1080 this.H2 = createDOMFunc("h2");
1090 /** @id MochiKit.DOM.H3 */ 1081 /** @id MochiKit.DOM.H3 */
1091 this.H3 = createDOMFunc("h3"); 1082 this.H3 = createDOMFunc("h3");
1092 /** @id MochiKit.DOM.H4 */ 1083 /** @id MochiKit.DOM.H4 */
1093 this.H4 = createDOMFunc("h4"); 1084 this.H4 = createDOMFunc("h4");
1094 /** @id MochiKit.DOM.H5 */ 1085 /** @id MochiKit.DOM.H5 */
1095 this.H5 = createDOMFunc("h5"); 1086 this.H5 = createDOMFunc("h5");
1096 /** @id MochiKit.DOM.H6 */ 1087 /** @id MochiKit.DOM.H6 */
1097 this.H6 = createDOMFunc("h6"); 1088 this.H6 = createDOMFunc("h6");
1098 /** @id MochiKit.DOM.BR */ 1089 /** @id MochiKit.DOM.HEADER */
1099 this.BR = createDOMFunc("br"); 1090 this.HEADER = createDOMFunc("header");
1091 /** @id MochiKit.DOM.HGROUP */
1092 this.HGROUP = createDOMFunc("hgroup");
1100 /** @id MochiKit.DOM.HR */ 1093 /** @id MochiKit.DOM.HR */
1101 this.HR = createDOMFunc("hr"); 1094 this.HR = createDOMFunc("hr");
1095 /** @id MochiKit.DOM.IFRAME */
1096 this.IFRAME = createDOMFunc("iframe");
1097 /** @id MochiKit.DOM.IMG */
1098 this.IMG = createDOMFunc("img");
1099 /** @id MochiKit.DOM.INPUT */
1100 this.INPUT = createDOMFunc("input");
1102 /** @id MochiKit.DOM.LABEL */ 1101 /** @id MochiKit.DOM.LABEL */
1103 this.LABEL = createDOMFunc("label"); 1102 this.LABEL = createDOMFunc("label");
1104 /** @id MochiKit.DOM.TEXTAREA */ 1103 /** @id MochiKit.DOM.LEGEND */
1105 this.TEXTAREA = createDOMFunc("textarea"); 1104 this.LEGEND = createDOMFunc("legend");
1106 /** @id MochiKit.DOM.FORM */ 1105 /** @id MochiKit.DOM.LI */
1107 this.FORM = createDOMFunc("form"); 1106 this.LI = createDOMFunc("li");
1107 /** @id MochiKit.DOM.LINK */
1108 this.LINK = createDOMFunc("link");
1109 /** @id MochiKit.DOM.MARK */
1110 this.MARK = createDOMFunc("mark");
1111 /** @id MochiKit.DOM.METER */
1112 this.METER = createDOMFunc("meter");
1113 /** @id MochiKit.DOM.NAV */
1114 this.NAV = createDOMFunc("nav");
1115 /** @id MochiKit.DOM.OL */
1116 this.OL = createDOMFunc("ol");
1117 /** @id MochiKit.DOM.OPTGROUP */
1118 this.OPTGROUP = createDOMFunc("optgroup");
1119 /** @id MochiKit.DOM.OPTION */
1120 this.OPTION = createDOMFunc("option");
1108 /** @id MochiKit.DOM.P */ 1121 /** @id MochiKit.DOM.P */
1109 this.P = createDOMFunc("p"); 1122 this.P = createDOMFunc("p");
1123 /** @id MochiKit.DOM.PRE */
1124 this.PRE = createDOMFunc("pre");
1125 /** @id MochiKit.DOM.PROGRESS */
1126 this.PROGRESS = createDOMFunc("progress");
1127 /** @id MochiKit.DOM.SCRIPT */
1128 this.SCRIPT = createDOMFunc("script");
1129 /** @id MochiKit.DOM.SECTION */
1130 this.SECTION = createDOMFunc("section");
1110 /** @id MochiKit.DOM.SELECT */ 1131 /** @id MochiKit.DOM.SELECT */
1111 this.SELECT = createDOMFunc("select"); 1132 this.SELECT = createDOMFunc("select");
1112 /** @id MochiKit.DOM.OPTION */ 1133 /** @id MochiKit.DOM.SPAN */
1113 this.OPTION = createDOMFunc("option"); 1134 this.SPAN = createDOMFunc("span");
1114 /** @id MochiKit.DOM.OPTGROUP */
1115 this.OPTGROUP = createDOMFunc("optgroup");
1116 /** @id MochiKit.DOM.LEGEND */
1117 this.LEGEND = createDOMFunc("legend");
1118 /** @id MochiKit.DOM.FIELDSET */
1119 this.FIELDSET = createDOMFunc("fieldset");
1120 /** @id MochiKit.DOM.STRONG */ 1135 /** @id MochiKit.DOM.STRONG */
1121 this.STRONG = createDOMFunc("strong"); 1136 this.STRONG = createDOMFunc("strong");
1122 /** @id MochiKit.DOM.CANVAS */ 1137 /** @id MochiKit.DOM.STYLE */
1123 this.CANVAS = createDOMFunc("canvas"); 1138 this.STYLE = createDOMFunc("style");
1124 1139 /** @id MochiKit.DOM.TABLE */
1140 this.TABLE = createDOMFunc("table");
1141 /** @id MochiKit.DOM.TBODY */
1142 this.TBODY = createDOMFunc("tbody");
1143 /** @id MochiKit.DOM.TD */
1144 this.TD = createDOMFunc("td");
1145 /** @id MochiKit.DOM.TEXTAREA */
1146 this.TEXTAREA = createDOMFunc("textarea");
1147 /** @id MochiKit.DOM.TFOOT */
1148 this.TFOOT = createDOMFunc("tfoot");
1149 /** @id MochiKit.DOM.TH */
1150 this.TH = createDOMFunc("th");
1151 /** @id MochiKit.DOM.THEAD */
1152 this.THEAD = createDOMFunc("thead");
1153 /** @id MochiKit.DOM.TR */
1154 this.TR = createDOMFunc("tr");
1155 /** @id MochiKit.DOM.TT */
1156 this.TT = createDOMFunc("tt");
1157 /** @id MochiKit.DOM.UL */
1158 this.UL = createDOMFunc("ul");
1159 /** @id MochiKit.DOM.NBSP */
1160 this.NBSP = "\u00a0";
1125 /** @id MochiKit.DOM.$ */ 1161 /** @id MochiKit.DOM.$ */
1126 this.$ = this.getElement; 1162 this.$ = this.getElement;
1127 1163
1128 m.nameFunctions(this); 1164 m.nameFunctions(this);
1129
1130 } 1165 }
1131}); 1166});
1132 1167
1133 1168
1134MochiKit.DOM.__new__(((typeof(window) == "undefined") ? this : window)); 1169MochiKit.DOM.__new__(((typeof(window) == "undefined") ? this : window));
1135 1170
1136// 1171//
1137// XXX: Internet Explorer blows 1172// XXX: Internet Explorer blows
1138// 1173//
1139if (MochiKit.__export__) { 1174if (MochiKit.__export__) {
1140 withWindow = MochiKit.DOM.withWindow; 1175 withWindow = MochiKit.DOM.withWindow;
1141 withDocument = MochiKit.DOM.withDocument; 1176 withDocument = MochiKit.DOM.withDocument;
1142} 1177}
1143 1178
1144MochiKit.Base._exportSymbols(this, MochiKit.DOM); 1179MochiKit.Base._exportSymbols(this, MochiKit.DOM);
diff --git a/frontend/gamma/js/MochiKit/DateTime.js b/frontend/gamma/js/MochiKit/DateTime.js
index c7b2d25..658084c 100644
--- a/frontend/gamma/js/MochiKit/DateTime.js
+++ b/frontend/gamma/js/MochiKit/DateTime.js
@@ -1,173 +1,176 @@
1/*** 1/***
2 2
3MochiKit.DateTime 1.5 3MochiKit.DateTime 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('DateTime', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'DateTime', '1.5', ['Base']);
12 12
13/** @id MochiKit.DateTime.isoDate */ 13/** @id MochiKit.DateTime.isoDate */
14MochiKit.DateTime.isoDate = function (str) { 14MochiKit.DateTime.isoDate = function (str) {
15 str = str + ""; 15 str = str + "";
16 if (typeof(str) != "string" || str.length === 0) { 16 if (typeof(str) != "string" || str.length === 0) {
17 return null; 17 return null;
18 } 18 }
19 var iso = str.split('-'); 19 var iso = str.split('-');
20 if (iso.length === 0) { 20 if (iso.length === 0) {
21 return null; 21 return null;
22 } 22 }
23 var date = new Date(iso[0], iso[1] - 1, iso[2]); 23 var date = new Date(parseInt(iso[0], 10), parseInt(iso[1], 10) - 1, parseInt(iso[2], 10));
24 date.setFullYear(iso[0]); 24 date.setFullYear(iso[0]);
25 date.setMonth(iso[1] - 1); 25 date.setMonth(iso[1] - 1);
26 date.setDate(iso[2]); 26 date.setDate(iso[2]);
27 return date; 27 return date;
28}; 28};
29 29
30MochiKit.DateTime._isoRegexp = /(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/; 30MochiKit.DateTime._isoRegexp = /(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/;
31 31
32/** @id MochiKit.DateTime.isoTimestamp */ 32/** @id MochiKit.DateTime.isoTimestamp */
33MochiKit.DateTime.isoTimestamp = function (str) { 33MochiKit.DateTime.isoTimestamp = function (str) {
34 str = str + ""; 34 str = str + "";
35 if (typeof(str) != "string" || str.length === 0) { 35 if (typeof(str) != "string" || str.length === 0) {
36 return null; 36 return null;
37 } 37 }
38 var res = str.match(MochiKit.DateTime._isoRegexp); 38 var res = str.match(MochiKit.DateTime._isoRegexp);
39 if (typeof(res) == "undefined" || res === null) { 39 if (typeof(res) == "undefined" || res === null) {
40 return null; 40 return null;
41 } 41 }
42 var year, month, day, hour, min, sec, msec; 42 var year, month, day, hour, min, sec, msec;
43 year = parseInt(res[1], 10); 43 year = parseInt(res[1], 10);
44 if (typeof(res[2]) == "undefined" || res[2] === '') { 44 if (typeof(res[2]) == "undefined" || res[2] === '') {
45 return new Date(year); 45 return new Date(year);
46 } 46 }
47 month = parseInt(res[2], 10) - 1; 47 month = parseInt(res[2], 10) - 1;
48 day = parseInt(res[3], 10); 48 day = parseInt(res[3], 10);
49 if (typeof(res[4]) == "undefined" || res[4] === '') { 49 if (typeof(res[4]) == "undefined" || res[4] === '') {
50 return new Date(year, month, day); 50 return new Date(year, month, day);
51 } 51 }
52 hour = parseInt(res[4], 10); 52 hour = parseInt(res[4], 10);
53 min = parseInt(res[5], 10); 53 min = parseInt(res[5], 10);
54 sec = (typeof(res[6]) != "undefined" && res[6] !== '') ? parseInt(res[6], 10) : 0; 54 sec = (typeof(res[6]) != "undefined" && res[6] !== '') ? parseInt(res[6], 10) : 0;
55 if (typeof(res[7]) != "undefined" && res[7] !== '') { 55 if (typeof(res[7]) != "undefined" && res[7] !== '') {
56 msec = Math.round(1000.0 * parseFloat("0." + res[7])); 56 msec = Math.round(1000.0 * parseFloat("0." + res[7]));
57 } else { 57 } else {
58 msec = 0; 58 msec = 0;
59 } 59 }
60 if ((typeof(res[8]) == "undefined" || res[8] === '') && (typeof(res[9]) == "undefined" || res[9] === '')) { 60 if ((typeof(res[8]) == "undefined" || res[8] === '') && (typeof(res[9]) == "undefined" || res[9] === '')) {
61 return new Date(year, month, day, hour, min, sec, msec); 61 return new Date(year, month, day, hour, min, sec, msec);
62 } 62 }
63 var ofs; 63 var ofs;
64 if (typeof(res[9]) != "undefined" && res[9] !== '') { 64 if (typeof(res[9]) != "undefined" && res[9] !== '') {
65 ofs = parseInt(res[10], 10) * 3600000; 65 ofs = parseInt(res[10], 10) * 3600000;
66 if (typeof(res[11]) != "undefined" && res[11] !== '') { 66 if (typeof(res[11]) != "undefined" && res[11] !== '') {
67 ofs += parseInt(res[11], 10) * 60000; 67 ofs += parseInt(res[11], 10) * 60000;
68 } 68 }
69 if (res[9] == "-") { 69 if (res[9] == "-") {
70 ofs = -ofs; 70 ofs = -ofs;
71 } 71 }
72 } else { 72 } else {
73 ofs = 0; 73 ofs = 0;
74 } 74 }
75 return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs); 75 return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs);
76}; 76};
77 77
78/** @id MochiKit.DateTime.toISOTime */ 78/** @id MochiKit.DateTime.toISOTime */
79MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) { 79MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) {
80 if (typeof(date) == "undefined" || date === null) { 80 if (typeof(date) == "undefined" || date === null) {
81 return null; 81 return null;
82 } 82 }
83 var hh = date.getHours(); 83 var _padTwo = MochiKit.DateTime._padTwo;
84 var mm = date.getMinutes(); 84 if (realISO) {
85 var ss = date.getSeconds(); 85 // adjust date for UTC timezone
86 date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
87 }
86 var lst = [ 88 var lst = [
87 ((realISO && (hh < 10)) ? "0" + hh : hh), 89 (realISO ? _padTwo(date.getHours()) : date.getHours()),
88 ((mm < 10) ? "0" + mm : mm), 90 _padTwo(date.getMinutes()),
89 ((ss < 10) ? "0" + ss : ss) 91 _padTwo(date.getSeconds())
90 ]; 92 ];
91 return lst.join(":"); 93 return lst.join(":") + (realISO ? "Z" : "");
92}; 94};
93 95
94/** @id MochiKit.DateTime.toISOTimeStamp */ 96/** @id MochiKit.DateTime.toISOTimeStamp */
95MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) { 97MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) {
96 if (typeof(date) == "undefined" || date === null) { 98 if (typeof(date) == "undefined" || date === null) {
97 return null; 99 return null;
98 } 100 }
101 var time = MochiKit.DateTime.toISOTime(date, realISO);
99 var sep = realISO ? "T" : " "; 102 var sep = realISO ? "T" : " ";
100 var foot = realISO ? "Z" : "";
101 if (realISO) { 103 if (realISO) {
104 // adjust date for UTC timezone
102 date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); 105 date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
103 } 106 }
104 return MochiKit.DateTime.toISODate(date) + sep + MochiKit.DateTime.toISOTime(date, realISO) + foot; 107 return MochiKit.DateTime.toISODate(date) + sep + time;
105}; 108};
106 109
107/** @id MochiKit.DateTime.toISODate */ 110/** @id MochiKit.DateTime.toISODate */
108MochiKit.DateTime.toISODate = function (date) { 111MochiKit.DateTime.toISODate = function (date) {
109 if (typeof(date) == "undefined" || date === null) { 112 if (typeof(date) == "undefined" || date === null) {
110 return null; 113 return null;
111 } 114 }
112 var _padTwo = MochiKit.DateTime._padTwo; 115 var _padTwo = MochiKit.DateTime._padTwo;
113 var _padFour = MochiKit.DateTime._padFour; 116 var _padFour = MochiKit.DateTime._padFour;
114 return [ 117 return [
115 _padFour(date.getFullYear()), 118 _padFour(date.getFullYear()),
116 _padTwo(date.getMonth() + 1), 119 _padTwo(date.getMonth() + 1),
117 _padTwo(date.getDate()) 120 _padTwo(date.getDate())
118 ].join("-"); 121 ].join("-");
119}; 122};
120 123
121/** @id MochiKit.DateTime.americanDate */ 124/** @id MochiKit.DateTime.americanDate */
122MochiKit.DateTime.americanDate = function (d) { 125MochiKit.DateTime.americanDate = function (d) {
123 d = d + ""; 126 d = d + "";
124 if (typeof(d) != "string" || d.length === 0) { 127 if (typeof(d) != "string" || d.length === 0) {
125 return null; 128 return null;
126 } 129 }
127 var a = d.split('/'); 130 var a = d.split('/');
128 return new Date(a[2], a[0] - 1, a[1]); 131 return new Date(a[2], a[0] - 1, a[1]);
129}; 132};
130 133
131MochiKit.DateTime._padTwo = function (n) { 134MochiKit.DateTime._padTwo = function (n) {
132 return (n > 9) ? n : "0" + n; 135 return (n > 9) ? n : "0" + n;
133}; 136};
134 137
135MochiKit.DateTime._padFour = function(n) { 138MochiKit.DateTime._padFour = function(n) {
136 switch(n.toString().length) { 139 switch(n.toString().length) {
137 case 1: return "000" + n; break; 140 case 1: return "000" + n; break;
138 case 2: return "00" + n; break; 141 case 2: return "00" + n; break;
139 case 3: return "0" + n; break; 142 case 3: return "0" + n; break;
140 case 4: 143 case 4:
141 default: 144 default:
142 return n; 145 return n;
143 } 146 }
144}; 147};
145 148
146/** @id MochiKit.DateTime.toPaddedAmericanDate */ 149/** @id MochiKit.DateTime.toPaddedAmericanDate */
147MochiKit.DateTime.toPaddedAmericanDate = function (d) { 150MochiKit.DateTime.toPaddedAmericanDate = function (d) {
148 if (typeof(d) == "undefined" || d === null) { 151 if (typeof(d) == "undefined" || d === null) {
149 return null; 152 return null;
150 } 153 }
151 var _padTwo = MochiKit.DateTime._padTwo; 154 var _padTwo = MochiKit.DateTime._padTwo;
152 return [ 155 return [
153 _padTwo(d.getMonth() + 1), 156 _padTwo(d.getMonth() + 1),
154 _padTwo(d.getDate()), 157 _padTwo(d.getDate()),
155 d.getFullYear() 158 d.getFullYear()
156 ].join('/'); 159 ].join('/');
157}; 160};
158 161
159/** @id MochiKit.DateTime.toAmericanDate */ 162/** @id MochiKit.DateTime.toAmericanDate */
160MochiKit.DateTime.toAmericanDate = function (d) { 163MochiKit.DateTime.toAmericanDate = function (d) {
161 if (typeof(d) == "undefined" || d === null) { 164 if (typeof(d) == "undefined" || d === null) {
162 return null; 165 return null;
163 } 166 }
164 return [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/'); 167 return [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/');
165}; 168};
166 169
167MochiKit.DateTime.__new__ = function () { 170MochiKit.DateTime.__new__ = function () {
168 MochiKit.Base.nameFunctions(this); 171 MochiKit.Base.nameFunctions(this);
169}; 172};
170 173
171MochiKit.DateTime.__new__(); 174MochiKit.DateTime.__new__();
172 175
173MochiKit.Base._exportSymbols(this, MochiKit.DateTime); 176MochiKit.Base._exportSymbols(this, MochiKit.DateTime);
diff --git a/frontend/gamma/js/MochiKit/DragAndDrop.js b/frontend/gamma/js/MochiKit/DragAndDrop.js
index 62777c5..cf84f77 100644
--- a/frontend/gamma/js/MochiKit/DragAndDrop.js
+++ b/frontend/gamma/js/MochiKit/DragAndDrop.js
@@ -1,741 +1,741 @@
1/*** 1/***
2MochiKit.DragAndDrop 1.5 2MochiKit.DragAndDrop 1.5
3 3
4See <http://mochikit.com/> for documentation, downloads, license, etc. 4See <http://mochikit.com/> for documentation, downloads, license, etc.
5 5
6Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 6Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
7 Mochi-ized By Thomas Herve (_firstname_@nimail.org) 7 Mochi-ized By Thomas Herve (_firstname_@nimail.org)
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']); 11MochiKit.Base.module(MochiKit, 'DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']);
12 12
13MochiKit.DragAndDrop.Droppables = { 13MochiKit.DragAndDrop.Droppables = {
14 /*** 14 /***
15 15
16 Manage all droppables. Shouldn't be used, use the Droppable object instead. 16 Manage all droppables. Shouldn't be used, use the Droppable object instead.
17 17
18 ***/ 18 ***/
19 drops: [], 19 drops: [],
20 20
21 remove: function (element) { 21 remove: function (element) {
22 this.drops = MochiKit.Base.filter(function (d) { 22 this.drops = MochiKit.Base.filter(function (d) {
23 return d.element != MochiKit.DOM.getElement(element); 23 return d.element != MochiKit.DOM.getElement(element);
24 }, this.drops); 24 }, this.drops);
25 }, 25 },
26 26
27 register: function (drop) { 27 register: function (drop) {
28 this.drops.push(drop); 28 this.drops.push(drop);
29 }, 29 },
30 30
31 unregister: function (drop) { 31 unregister: function (drop) {
32 this.drops = MochiKit.Base.filter(function (d) { 32 this.drops = MochiKit.Base.filter(function (d) {
33 return d != drop; 33 return d != drop;
34 }, this.drops); 34 }, this.drops);
35 }, 35 },
36 36
37 prepare: function (element) { 37 prepare: function (element) {
38 MochiKit.Base.map(function (drop) { 38 MochiKit.Base.map(function (drop) {
39 if (drop.isAccepted(element)) { 39 if (drop.isAccepted(element)) {
40 if (drop.options.activeclass) { 40 if (drop.options.activeclass) {
41 MochiKit.DOM.addElementClass(drop.element, 41 MochiKit.DOM.addElementClass(drop.element,
42 drop.options.activeclass); 42 drop.options.activeclass);
43 } 43 }
44 drop.options.onactive(drop.element, element); 44 drop.options.onactive(drop.element, element);
45 } 45 }
46 }, this.drops); 46 }, this.drops);
47 }, 47 },
48 48
49 findDeepestChild: function (drops) { 49 findDeepestChild: function (drops) {
50 var deepest = drops[0]; 50 var deepest = drops[0];
51 51
52 for (var i = 1; i < drops.length; ++i) { 52 for (var i = 1; i < drops.length; ++i) {
53 if (MochiKit.DOM.isChildNode(drops[i].element, deepest.element)) { 53 if (MochiKit.DOM.isChildNode(drops[i].element, deepest.element)) {
54 deepest = drops[i]; 54 deepest = drops[i];
55 } 55 }
56 } 56 }
57 return deepest; 57 return deepest;
58 }, 58 },
59 59
60 show: function (point, element) { 60 show: function (point, element) {
61 if (!this.drops.length) { 61 if (!this.drops.length) {
62 return; 62 return;
63 } 63 }
64 var affected = []; 64 var affected = [];
65 65
66 if (this.last_active) { 66 if (this.last_active) {
67 this.last_active.deactivate(); 67 this.last_active.deactivate();
68 } 68 }
69 MochiKit.Iter.forEach(this.drops, function (drop) { 69 MochiKit.Iter.forEach(this.drops, function (drop) {
70 if (drop.isAffected(point, element)) { 70 if (drop.isAffected(point, element)) {
71 affected.push(drop); 71 affected.push(drop);
72 } 72 }
73 }); 73 });
74 if (affected.length > 0) { 74 if (affected.length > 0) {
75 var drop = this.findDeepestChild(affected); 75 var drop = this.findDeepestChild(affected);
76 MochiKit.Position.within(drop.element, point.page.x, point.page.y); 76 MochiKit.Position.within(drop.element, point.page.x, point.page.y);
77 drop.options.onhover(element, drop.element, 77 drop.options.onhover(element, drop.element,
78 MochiKit.Position.overlap(drop.options.overlap, drop.element)); 78 MochiKit.Position.overlap(drop.options.overlap, drop.element));
79 drop.activate(); 79 drop.activate();
80 } 80 }
81 }, 81 },
82 82
83 fire: function (event, element) { 83 fire: function (event, element) {
84 if (!this.last_active) { 84 if (!this.last_active) {
85 return; 85 return;
86 } 86 }
87 MochiKit.Position.prepare(); 87 MochiKit.Position.prepare();
88 88
89 if (this.last_active.isAffected(event.mouse(), element)) { 89 if (this.last_active.isAffected(event.mouse(), element)) {
90 this.last_active.options.ondrop(element, 90 this.last_active.options.ondrop(element,
91 this.last_active.element, event); 91 this.last_active.element, event);
92 } 92 }
93 }, 93 },
94 94
95 reset: function (element) { 95 reset: function (element) {
96 MochiKit.Base.map(function (drop) { 96 MochiKit.Base.map(function (drop) {
97 if (drop.options.activeclass) { 97 if (drop.options.activeclass) {
98 MochiKit.DOM.removeElementClass(drop.element, 98 MochiKit.DOM.removeElementClass(drop.element,
99 drop.options.activeclass); 99 drop.options.activeclass);
100 } 100 }
101 drop.options.ondesactive(drop.element, element); 101 drop.options.ondesactive(drop.element, element);
102 }, this.drops); 102 }, this.drops);
103 if (this.last_active) { 103 if (this.last_active) {
104 this.last_active.deactivate(); 104 this.last_active.deactivate();
105 } 105 }
106 } 106 }
107}; 107};
108 108
109/** @id MochiKit.DragAndDrop.Droppable */ 109/** @id MochiKit.DragAndDrop.Droppable */
110MochiKit.DragAndDrop.Droppable = function (element, options) { 110MochiKit.DragAndDrop.Droppable = function (element, options) {
111 var cls = arguments.callee; 111 var cls = arguments.callee;
112 if (!(this instanceof cls)) { 112 if (!(this instanceof cls)) {
113 return new cls(element, options); 113 return new cls(element, options);
114 } 114 }
115 this.__init__(element, options); 115 this.__init__(element, options);
116}; 116};
117 117
118MochiKit.DragAndDrop.Droppable.prototype = { 118MochiKit.DragAndDrop.Droppable.prototype = {
119 /*** 119 /***
120 120
121 A droppable object. Simple use is to create giving an element: 121 A droppable object. Simple use is to create giving an element:
122 122
123 new MochiKit.DragAndDrop.Droppable('myelement'); 123 new MochiKit.DragAndDrop.Droppable('myelement');
124 124
125 Generally you'll want to define the 'ondrop' function and maybe the 125 Generally you'll want to define the 'ondrop' function and maybe the
126 'accept' option to filter draggables. 126 'accept' option to filter draggables.
127 127
128 ***/ 128 ***/
129 __class__: MochiKit.DragAndDrop.Droppable, 129 __class__: MochiKit.DragAndDrop.Droppable,
130 130
131 __init__: function (element, /* optional */options) { 131 __init__: function (element, /* optional */options) {
132 var d = MochiKit.DOM; 132 var d = MochiKit.DOM;
133 var b = MochiKit.Base; 133 var b = MochiKit.Base;
134 this.element = d.getElement(element); 134 this.element = d.getElement(element);
135 this.options = b.update({ 135 this.options = b.update({
136 136
137 /** @id MochiKit.DragAndDrop.greedy */ 137 /** @id MochiKit.DragAndDrop.greedy */
138 greedy: true, 138 greedy: true,
139 139
140 /** @id MochiKit.DragAndDrop.hoverclass */ 140 /** @id MochiKit.DragAndDrop.hoverclass */
141 hoverclass: null, 141 hoverclass: null,
142 142
143 /** @id MochiKit.DragAndDrop.activeclass */ 143 /** @id MochiKit.DragAndDrop.activeclass */
144 activeclass: null, 144 activeclass: null,
145 145
146 /** @id MochiKit.DragAndDrop.hoverfunc */ 146 /** @id MochiKit.DragAndDrop.hoverfunc */
147 hoverfunc: b.noop, 147 hoverfunc: b.noop,
148 148
149 /** @id MochiKit.DragAndDrop.accept */ 149 /** @id MochiKit.DragAndDrop.accept */
150 accept: null, 150 accept: null,
151 151
152 /** @id MochiKit.DragAndDrop.onactive */ 152 /** @id MochiKit.DragAndDrop.onactive */
153 onactive: b.noop, 153 onactive: b.noop,
154 154
155 /** @id MochiKit.DragAndDrop.ondesactive */ 155 /** @id MochiKit.DragAndDrop.ondesactive */
156 ondesactive: b.noop, 156 ondesactive: b.noop,
157 157
158 /** @id MochiKit.DragAndDrop.onhover */ 158 /** @id MochiKit.DragAndDrop.onhover */
159 onhover: b.noop, 159 onhover: b.noop,
160 160
161 /** @id MochiKit.DragAndDrop.ondrop */ 161 /** @id MochiKit.DragAndDrop.ondrop */
162 ondrop: b.noop, 162 ondrop: b.noop,
163 163
164 /** @id MochiKit.DragAndDrop.containment */ 164 /** @id MochiKit.DragAndDrop.containment */
165 containment: [], 165 containment: [],
166 tree: false 166 tree: false
167 }, options); 167 }, options);
168 168
169 // cache containers 169 // cache containers
170 this.options._containers = []; 170 this.options._containers = [];
171 b.map(MochiKit.Base.bind(function (c) { 171 b.map(MochiKit.Base.bind(function (c) {
172 this.options._containers.push(d.getElement(c)); 172 this.options._containers.push(d.getElement(c));
173 }, this), this.options.containment); 173 }, this), this.options.containment);
174 174
175 MochiKit.Style.makePositioned(this.element); // fix IE 175 MochiKit.Style.makePositioned(this.element); // fix IE
176 176
177 MochiKit.DragAndDrop.Droppables.register(this); 177 MochiKit.DragAndDrop.Droppables.register(this);
178 }, 178 },
179 179
180 /** @id MochiKit.DragAndDrop.isContained */ 180 /** @id MochiKit.DragAndDrop.isContained */
181 isContained: function (element) { 181 isContained: function (element) {
182 if (this.options._containers.length) { 182 if (this.options._containers.length) {
183 var containmentNode; 183 var containmentNode;
184 if (this.options.tree) { 184 if (this.options.tree) {
185 containmentNode = element.treeNode; 185 containmentNode = element.treeNode;
186 } else { 186 } else {
187 containmentNode = element.parentNode; 187 containmentNode = element.parentNode;
188 } 188 }
189 return MochiKit.Iter.some(this.options._containers, function (c) { 189 return MochiKit.Iter.some(this.options._containers, function (c) {
190 return containmentNode == c; 190 return containmentNode == c;
191 }); 191 });
192 } else { 192 } else {
193 return true; 193 return true;
194 } 194 }
195 }, 195 },
196 196
197 /** @id MochiKit.DragAndDrop.isAccepted */ 197 /** @id MochiKit.DragAndDrop.isAccepted */
198 isAccepted: function (element) { 198 isAccepted: function (element) {
199 return ((!this.options.accept) || MochiKit.Iter.some( 199 return ((!this.options.accept) || MochiKit.Iter.some(
200 this.options.accept, function (c) { 200 this.options.accept, function (c) {
201 return MochiKit.DOM.hasElementClass(element, c); 201 return MochiKit.DOM.hasElementClass(element, c);
202 })); 202 }));
203 }, 203 },
204 204
205 /** @id MochiKit.DragAndDrop.isAffected */ 205 /** @id MochiKit.DragAndDrop.isAffected */
206 isAffected: function (point, element) { 206 isAffected: function (point, element) {
207 return ((this.element != element) && 207 return ((this.element != element) &&
208 this.isContained(element) && 208 this.isContained(element) &&
209 this.isAccepted(element) && 209 this.isAccepted(element) &&
210 MochiKit.Position.within(this.element, point.page.x, 210 MochiKit.Position.within(this.element, point.page.x,
211 point.page.y)); 211 point.page.y));
212 }, 212 },
213 213
214 /** @id MochiKit.DragAndDrop.deactivate */ 214 /** @id MochiKit.DragAndDrop.deactivate */
215 deactivate: function () { 215 deactivate: function () {
216 /*** 216 /***
217 217
218 A droppable is deactivate when a draggable has been over it and left. 218 A droppable is deactivate when a draggable has been over it and left.
219 219
220 ***/ 220 ***/
221 if (this.options.hoverclass) { 221 if (this.options.hoverclass) {
222 MochiKit.DOM.removeElementClass(this.element, 222 MochiKit.DOM.removeElementClass(this.element,
223 this.options.hoverclass); 223 this.options.hoverclass);
224 } 224 }
225 this.options.hoverfunc(this.element, false); 225 this.options.hoverfunc(this.element, false);
226 MochiKit.DragAndDrop.Droppables.last_active = null; 226 MochiKit.DragAndDrop.Droppables.last_active = null;
227 }, 227 },
228 228
229 /** @id MochiKit.DragAndDrop.activate */ 229 /** @id MochiKit.DragAndDrop.activate */
230 activate: function () { 230 activate: function () {
231 /*** 231 /***
232 232
233 A droppable is active when a draggable is over it. 233 A droppable is active when a draggable is over it.
234 234
235 ***/ 235 ***/
236 if (this.options.hoverclass) { 236 if (this.options.hoverclass) {
237 MochiKit.DOM.addElementClass(this.element, this.options.hoverclass); 237 MochiKit.DOM.addElementClass(this.element, this.options.hoverclass);
238 } 238 }
239 this.options.hoverfunc(this.element, true); 239 this.options.hoverfunc(this.element, true);
240 MochiKit.DragAndDrop.Droppables.last_active = this; 240 MochiKit.DragAndDrop.Droppables.last_active = this;
241 }, 241 },
242 242
243 /** @id MochiKit.DragAndDrop.destroy */ 243 /** @id MochiKit.DragAndDrop.destroy */
244 destroy: function () { 244 destroy: function () {
245 /*** 245 /***
246 246
247 Delete this droppable. 247 Delete this droppable.
248 248
249 ***/ 249 ***/
250 MochiKit.DragAndDrop.Droppables.unregister(this); 250 MochiKit.DragAndDrop.Droppables.unregister(this);
251 }, 251 },
252 252
253 /** @id MochiKit.DragAndDrop.repr */ 253 /** @id MochiKit.DragAndDrop.repr */
254 repr: function () { 254 repr: function () {
255 return '[' + this.__class__.NAME + ", options:" + MochiKit.Base.repr(this.options) + "]"; 255 return '[' + this.__class__.NAME + ", options:" + MochiKit.Base.repr(this.options) + "]";
256 } 256 }
257}; 257};
258 258
259MochiKit.DragAndDrop.Draggables = { 259MochiKit.DragAndDrop.Draggables = {
260 /*** 260 /***
261 261
262 Manage draggables elements. Not intended to direct use. 262 Manage draggables elements. Not intended to direct use.
263 263
264 ***/ 264 ***/
265 drags: [], 265 drags: [],
266 266
267 register: function (draggable) { 267 register: function (draggable) {
268 if (this.drags.length === 0) { 268 if (this.drags.length === 0) {
269 var conn = MochiKit.Signal.connect; 269 var conn = MochiKit.Signal.connect;
270 this.eventMouseUp = conn(document, 'onmouseup', this, this.endDrag); 270 this.eventMouseUp = conn(document, 'onmouseup', this, this.endDrag);
271 this.eventMouseMove = conn(document, 'onmousemove', this, 271 this.eventMouseMove = conn(document, 'onmousemove', this,
272 this.updateDrag); 272 this.updateDrag);
273 this.eventKeypress = conn(document, 'onkeypress', this, 273 this.eventKeypress = conn(document, 'onkeypress', this,
274 this.keyPress); 274 this.keyPress);
275 } 275 }
276 this.drags.push(draggable); 276 this.drags.push(draggable);
277 }, 277 },
278 278
279 unregister: function (draggable) { 279 unregister: function (draggable) {
280 this.drags = MochiKit.Base.filter(function (d) { 280 this.drags = MochiKit.Base.filter(function (d) {
281 return d != draggable; 281 return d != draggable;
282 }, this.drags); 282 }, this.drags);
283 if (this.drags.length === 0) { 283 if (this.drags.length === 0) {
284 var disc = MochiKit.Signal.disconnect; 284 var disc = MochiKit.Signal.disconnect;
285 disc(this.eventMouseUp); 285 disc(this.eventMouseUp);
286 disc(this.eventMouseMove); 286 disc(this.eventMouseMove);
287 disc(this.eventKeypress); 287 disc(this.eventKeypress);
288 } 288 }
289 }, 289 },
290 290
291 activate: function (draggable) { 291 activate: function (draggable) {
292 // allows keypress events if window is not currently focused 292 // allows keypress events if window is not currently focused
293 // fails for Safari 293 // fails for Safari
294 window.focus(); 294 window.focus();
295 this.activeDraggable = draggable; 295 this.activeDraggable = draggable;
296 }, 296 },
297 297
298 deactivate: function () { 298 deactivate: function () {
299 this.activeDraggable = null; 299 this.activeDraggable = null;
300 }, 300 },
301 301
302 updateDrag: function (event) { 302 updateDrag: function (event) {
303 if (!this.activeDraggable) { 303 if (!this.activeDraggable) {
304 return; 304 return;
305 } 305 }
306 var pointer = event.mouse(); 306 var pointer = event.mouse();
307 // Mozilla-based browsers fire successive mousemove events with 307 // Mozilla-based browsers fire successive mousemove events with
308 // the same coordinates, prevent needless redrawing (moz bug?) 308 // the same coordinates, prevent needless redrawing (moz bug?)
309 if (this._lastPointer && (MochiKit.Base.repr(this._lastPointer.page) == 309 if (this._lastPointer &&
310 MochiKit.Base.repr(pointer.page))) { 310 this._lastPointer.page.x == pointer.page.x &&
311 this._lastPointer.page.y == pointer.page.y) {
311 return; 312 return;
312 } 313 }
313 this._lastPointer = pointer; 314 this._lastPointer = pointer;
314 this.activeDraggable.updateDrag(event, pointer); 315 this.activeDraggable.updateDrag(event, pointer);
315 }, 316 },
316 317
317 endDrag: function (event) { 318 endDrag: function (event) {
318 if (!this.activeDraggable) { 319 if (!this.activeDraggable) {
319 return; 320 return;
320 } 321 }
321 this._lastPointer = null; 322 this._lastPointer = null;
322 this.activeDraggable.endDrag(event); 323 this.activeDraggable.endDrag(event);
323 this.activeDraggable = null; 324 this.activeDraggable = null;
324 }, 325 },
325 326
326 keyPress: function (event) { 327 keyPress: function (event) {
327 if (this.activeDraggable) { 328 if (this.activeDraggable) {
328 this.activeDraggable.keyPress(event); 329 this.activeDraggable.keyPress(event);
329 } 330 }
330 }, 331 },
331 332
332 notify: function (eventName, draggable, event) { 333 notify: function (eventName, draggable, event) {
333 MochiKit.Signal.signal(this, eventName, draggable, event); 334 MochiKit.Signal.signal(this, eventName, draggable, event);
334 } 335 }
335}; 336};
336 337
337/** @id MochiKit.DragAndDrop.Draggable */ 338/** @id MochiKit.DragAndDrop.Draggable */
338MochiKit.DragAndDrop.Draggable = function (element, options) { 339MochiKit.DragAndDrop.Draggable = function (element, options) {
339 var cls = arguments.callee; 340 var cls = arguments.callee;
340 if (!(this instanceof cls)) { 341 if (!(this instanceof cls)) {
341 return new cls(element, options); 342 return new cls(element, options);
342 } 343 }
343 this.__init__(element, options); 344 this.__init__(element, options);
344}; 345};
345 346
346MochiKit.DragAndDrop.Draggable.prototype = { 347MochiKit.DragAndDrop.Draggable.prototype = {
347 /*** 348 /***
348 349
349 A draggable object. Simple instantiate : 350 A draggable object. Simple instantiate :
350 351
351 new MochiKit.DragAndDrop.Draggable('myelement'); 352 new MochiKit.DragAndDrop.Draggable('myelement');
352 353
353 ***/ 354 ***/
354 __class__ : MochiKit.DragAndDrop.Draggable, 355 __class__ : MochiKit.DragAndDrop.Draggable,
355 356
356 __init__: function (element, /* optional */options) { 357 __init__: function (element, /* optional */options) {
357 var v = MochiKit.Visual; 358 var v = MochiKit.Visual;
358 var b = MochiKit.Base; 359 var b = MochiKit.Base;
359 options = b.update({ 360 options = b.update({
360 361
361 /** @id MochiKit.DragAndDrop.handle */ 362 /** @id MochiKit.DragAndDrop.handle */
362 handle: false, 363 handle: false,
363 364
364 /** @id MochiKit.DragAndDrop.starteffect */ 365 /** @id MochiKit.DragAndDrop.starteffect */
365 starteffect: function (innerelement) { 366 starteffect: function (innerelement) {
366 this._savedOpacity = MochiKit.Style.getStyle(innerelement, 'opacity') || 1.0; 367 this._savedOpacity = MochiKit.Style.getStyle(innerelement, 'opacity') || 1.0;
367 new v.Opacity(innerelement, {duration:0.2, from:this._savedOpacity, to:0.7}); 368 new v.Opacity(innerelement, {duration:0.2, from:this._savedOpacity, to:0.7});
368 }, 369 },
369 /** @id MochiKit.DragAndDrop.reverteffect */ 370 /** @id MochiKit.DragAndDrop.reverteffect */
370 reverteffect: function (innerelement, top_offset, left_offset) { 371 reverteffect: function (innerelement, top_offset, left_offset) {
371 var dur = Math.sqrt(Math.abs(top_offset^2) + 372 var dur = Math.sqrt(Math.abs(top_offset^2) +
372 Math.abs(left_offset^2))*0.02; 373 Math.abs(left_offset^2))*0.02;
373 return new v.Move(innerelement, 374 return new v.Move(innerelement,
374 {x: -left_offset, y: -top_offset, duration: dur}); 375 {x: -left_offset, y: -top_offset, duration: dur});
375 }, 376 },
376 377
377 /** @id MochiKit.DragAndDrop.endeffect */ 378 /** @id MochiKit.DragAndDrop.endeffect */
378 endeffect: function (innerelement) { 379 endeffect: function (innerelement) {
379 new v.Opacity(innerelement, {duration:0.2, from:0.7, to:this._savedOpacity}); 380 new v.Opacity(innerelement, {duration:0.2, from:0.7, to:this._savedOpacity});
380 }, 381 },
381 382
382 /** @id MochiKit.DragAndDrop.onchange */ 383 /** @id MochiKit.DragAndDrop.onchange */
383 onchange: b.noop, 384 onchange: b.noop,
384 385
385 /** @id MochiKit.DragAndDrop.zindex */ 386 /** @id MochiKit.DragAndDrop.zindex */
386 zindex: 1000, 387 zindex: 1000,
387 388
388 /** @id MochiKit.DragAndDrop.revert */ 389 /** @id MochiKit.DragAndDrop.revert */
389 revert: false, 390 revert: false,
390 391
391 /** @id MochiKit.DragAndDrop.scroll */ 392 /** @id MochiKit.DragAndDrop.scroll */
392 scroll: false, 393 scroll: false,
393 394
394 /** @id MochiKit.DragAndDrop.scrollSensitivity */ 395 /** @id MochiKit.DragAndDrop.scrollSensitivity */
395 scrollSensitivity: 20, 396 scrollSensitivity: 20,
396 397
397 /** @id MochiKit.DragAndDrop.scrollSpeed */ 398 /** @id MochiKit.DragAndDrop.scrollSpeed */
398 scrollSpeed: 15, 399 scrollSpeed: 15,
399 // false, or xy or [x, y] or function (x, y){return [x, y];} 400 // false, or xy or [x, y] or function (x, y){return [x, y];}
400 401
401 /** @id MochiKit.DragAndDrop.snap */ 402 /** @id MochiKit.DragAndDrop.snap */
402 snap: false 403 snap: false
403 }, options); 404 }, options);
404 405
405 var d = MochiKit.DOM; 406 var d = MochiKit.DOM;
406 this.element = d.getElement(element); 407 this.element = d.getElement(element);
407 408
408 if (options.handle && (typeof(options.handle) == 'string')) { 409 if (options.handle && (typeof(options.handle) == 'string')) {
409 this.handle = d.getFirstElementByTagAndClassName(null, 410 this.handle = d.getFirstElementByTagAndClassName(null,
410 options.handle, this.element); 411 options.handle, this.element);
411 } 412 }
412 if (!this.handle) { 413 if (!this.handle) {
413 this.handle = d.getElement(options.handle); 414 this.handle = d.getElement(options.handle);
414 } 415 }
415 if (!this.handle) { 416 if (!this.handle) {
416 this.handle = this.element; 417 this.handle = this.element;
417 } 418 }
418 419
419 if (options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { 420 if (options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
420 options.scroll = d.getElement(options.scroll); 421 options.scroll = d.getElement(options.scroll);
421 this._isScrollChild = MochiKit.DOM.isChildNode(this.element, options.scroll); 422 this._isScrollChild = MochiKit.DOM.isChildNode(this.element, options.scroll);
422 } 423 }
423 424
424 MochiKit.Style.makePositioned(this.element); // fix IE 425 MochiKit.Style.makePositioned(this.element); // fix IE
425 426
426 this.delta = this.currentDelta(); 427 this.delta = this.currentDelta();
427 this.options = options; 428 this.options = options;
428 this.dragging = false; 429 this.dragging = false;
429 430
430 this.eventMouseDown = MochiKit.Signal.connect(this.handle, 431 this.eventMouseDown = MochiKit.Signal.connect(this.handle,
431 'onmousedown', this, this.initDrag); 432 'onmousedown', this, this.initDrag);
432 MochiKit.DragAndDrop.Draggables.register(this); 433 MochiKit.DragAndDrop.Draggables.register(this);
433 }, 434 },
434 435
435 /** @id MochiKit.DragAndDrop.destroy */ 436 /** @id MochiKit.DragAndDrop.destroy */
436 destroy: function () { 437 destroy: function () {
437 MochiKit.Signal.disconnect(this.eventMouseDown); 438 MochiKit.Signal.disconnect(this.eventMouseDown);
438 MochiKit.DragAndDrop.Draggables.unregister(this); 439 MochiKit.DragAndDrop.Draggables.unregister(this);
439 }, 440 },
440 441
441 /** @id MochiKit.DragAndDrop.currentDelta */ 442 /** @id MochiKit.DragAndDrop.currentDelta */
442 currentDelta: function () { 443 currentDelta: function () {
443 var s = MochiKit.Style.getStyle; 444 var s = MochiKit.Style.getStyle;
444 return [ 445 return [
445 parseInt(s(this.element, 'left') || '0'), 446 parseInt(s(this.element, 'left') || '0', 10),
446 parseInt(s(this.element, 'top') || '0')]; 447 parseInt(s(this.element, 'top') || '0', 10)];
447 }, 448 },
448 449
449 /** @id MochiKit.DragAndDrop.initDrag */ 450 /** @id MochiKit.DragAndDrop.initDrag */
450 initDrag: function (event) { 451 initDrag: function (event) {
451 if (!event.mouse().button.left) { 452 if (!event.mouse().button.left) {
452 return; 453 return;
453 } 454 }
454 // abort on form elements, fixes a Firefox issue 455 // abort on form elements, fixes a Firefox issue
455 var src = event.target(); 456 var src = event.target();
456 var tagName = (src.tagName || '').toUpperCase(); 457 var tagName = (src.tagName || '').toUpperCase();
457 if (tagName === 'INPUT' || tagName === 'SELECT' || 458 if (tagName === 'INPUT' || tagName === 'SELECT' ||
458 tagName === 'OPTION' || tagName === 'BUTTON' || 459 tagName === 'OPTION' || tagName === 'BUTTON' ||
459 tagName === 'TEXTAREA') { 460 tagName === 'TEXTAREA') {
460 return; 461 return;
461 } 462 }
462 463
463 if (this._revert) { 464 if (this._revert) {
464 this._revert.cancel(); 465 this._revert.cancel();
465 this._revert = null; 466 this._revert = null;
466 } 467 }
467 468
468 var pointer = event.mouse(); 469 var pointer = event.mouse();
469 var pos = MochiKit.Position.cumulativeOffset(this.element); 470 var pos = MochiKit.Position.cumulativeOffset(this.element);
470 this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y]; 471 this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y];
471 472
472 MochiKit.DragAndDrop.Draggables.activate(this); 473 MochiKit.DragAndDrop.Draggables.activate(this);
473 event.stop(); 474 event.stop();
474 }, 475 },
475 476
476 /** @id MochiKit.DragAndDrop.startDrag */ 477 /** @id MochiKit.DragAndDrop.startDrag */
477 startDrag: function (event) { 478 startDrag: function (event) {
478 this.dragging = true; 479 this.dragging = true;
479 if (this.options.selectclass) { 480 if (this.options.selectclass) {
480 MochiKit.DOM.addElementClass(this.element, 481 MochiKit.DOM.addElementClass(this.element,
481 this.options.selectclass); 482 this.options.selectclass);
482 } 483 }
483 if (this.options.zindex) { 484 if (this.options.zindex) {
484 this.originalZ = parseInt(MochiKit.Style.getStyle(this.element, 485 this.originalZ = MochiKit.Style.getStyle(this.element, 'z-index');
485 'z-index') || '0');
486 this.element.style.zIndex = this.options.zindex; 486 this.element.style.zIndex = this.options.zindex;
487 } 487 }
488 488
489 if (this.options.ghosting) { 489 if (this.options.ghosting) {
490 this._clone = this.element.cloneNode(true); 490 this._clone = this.element.cloneNode(true);
491 this.ghostPosition = MochiKit.Position.absolutize(this.element); 491 this.ghostPosition = MochiKit.Position.absolutize(this.element);
492 this.element.parentNode.insertBefore(this._clone, this.element); 492 this.element.parentNode.insertBefore(this._clone, this.element);
493 } 493 }
494 494
495 if (this.options.scroll) { 495 if (this.options.scroll) {
496 if (this.options.scroll == window) { 496 if (this.options.scroll == window) {
497 var where = this._getWindowScroll(this.options.scroll); 497 var where = this._getWindowScroll(this.options.scroll);
498 this.originalScrollLeft = where.left; 498 this.originalScrollLeft = where.left;
499 this.originalScrollTop = where.top; 499 this.originalScrollTop = where.top;
500 } else { 500 } else {
501 this.originalScrollLeft = this.options.scroll.scrollLeft; 501 this.originalScrollLeft = this.options.scroll.scrollLeft;
502 this.originalScrollTop = this.options.scroll.scrollTop; 502 this.originalScrollTop = this.options.scroll.scrollTop;
503 } 503 }
504 } 504 }
505 505
506 MochiKit.DragAndDrop.Droppables.prepare(this.element); 506 MochiKit.DragAndDrop.Droppables.prepare(this.element);
507 MochiKit.DragAndDrop.Draggables.notify('start', this, event); 507 MochiKit.DragAndDrop.Draggables.notify('start', this, event);
508 if (this.options.starteffect) { 508 if (this.options.starteffect) {
509 this.options.starteffect(this.element); 509 this.options.starteffect(this.element);
510 } 510 }
511 }, 511 },
512 512
513 /** @id MochiKit.DragAndDrop.updateDrag */ 513 /** @id MochiKit.DragAndDrop.updateDrag */
514 updateDrag: function (event, pointer) { 514 updateDrag: function (event, pointer) {
515 if (!this.dragging) { 515 if (!this.dragging) {
516 this.startDrag(event); 516 this.startDrag(event);
517 } 517 }
518 MochiKit.Position.prepare(); 518 MochiKit.Position.prepare();
519 MochiKit.DragAndDrop.Droppables.show(pointer, this.element); 519 MochiKit.DragAndDrop.Droppables.show(pointer, this.element);
520 MochiKit.DragAndDrop.Draggables.notify('drag', this, event); 520 MochiKit.DragAndDrop.Draggables.notify('drag', this, event);
521 this.draw(pointer); 521 this.draw(pointer);
522 this.options.onchange(this); 522 this.options.onchange(this);
523 523
524 if (this.options.scroll) { 524 if (this.options.scroll) {
525 this.stopScrolling(); 525 this.stopScrolling();
526 var p, q; 526 var p, q;
527 if (this.options.scroll == window) { 527 if (this.options.scroll == window) {
528 var s = this._getWindowScroll(this.options.scroll); 528 var s = this._getWindowScroll(this.options.scroll);
529 p = new MochiKit.Style.Coordinates(s.left, s.top); 529 p = new MochiKit.Style.Coordinates(s.left, s.top);
530 q = new MochiKit.Style.Coordinates(s.left + s.width, 530 q = new MochiKit.Style.Coordinates(s.left + s.width,
531 s.top + s.height); 531 s.top + s.height);
532 } else { 532 } else {
533 p = MochiKit.Position.page(this.options.scroll); 533 p = MochiKit.Position.page(this.options.scroll);
534 p.x += this.options.scroll.scrollLeft; 534 p.x += this.options.scroll.scrollLeft;
535 p.y += this.options.scroll.scrollTop; 535 p.y += this.options.scroll.scrollTop;
536 p.x += (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0); 536 p.x += (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0);
537 p.y += (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); 537 p.y += (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
538 q = new MochiKit.Style.Coordinates(p.x + this.options.scroll.offsetWidth, 538 q = new MochiKit.Style.Coordinates(p.x + this.options.scroll.offsetWidth,
539 p.y + this.options.scroll.offsetHeight); 539 p.y + this.options.scroll.offsetHeight);
540 } 540 }
541 var speed = [0, 0]; 541 var speed = [0, 0];
542 if (pointer.page.x > (q.x - this.options.scrollSensitivity)) { 542 if (pointer.page.x > (q.x - this.options.scrollSensitivity)) {
543 speed[0] = pointer.page.x - (q.x - this.options.scrollSensitivity); 543 speed[0] = pointer.page.x - (q.x - this.options.scrollSensitivity);
544 } else if (pointer.page.x < (p.x + this.options.scrollSensitivity)) { 544 } else if (pointer.page.x < (p.x + this.options.scrollSensitivity)) {
545 speed[0] = pointer.page.x - (p.x + this.options.scrollSensitivity); 545 speed[0] = pointer.page.x - (p.x + this.options.scrollSensitivity);
546 } 546 }
547 if (pointer.page.y > (q.y - this.options.scrollSensitivity)) { 547 if (pointer.page.y > (q.y - this.options.scrollSensitivity)) {
548 speed[1] = pointer.page.y - (q.y - this.options.scrollSensitivity); 548 speed[1] = pointer.page.y - (q.y - this.options.scrollSensitivity);
549 } else if (pointer.page.y < (p.y + this.options.scrollSensitivity)) { 549 } else if (pointer.page.y < (p.y + this.options.scrollSensitivity)) {
550 speed[1] = pointer.page.y - (p.y + this.options.scrollSensitivity); 550 speed[1] = pointer.page.y - (p.y + this.options.scrollSensitivity);
551 } 551 }
552 this.startScrolling(speed); 552 this.startScrolling(speed);
553 } 553 }
554 554
555 // fix AppleWebKit rendering 555 // fix AppleWebKit rendering
556 if (/AppleWebKit/.test(navigator.appVersion)) { 556 if (/AppleWebKit/.test(navigator.appVersion)) {
557 window.scrollBy(0, 0); 557 window.scrollBy(0, 0);
558 } 558 }
559 event.stop(); 559 event.stop();
560 }, 560 },
561 561
562 /** @id MochiKit.DragAndDrop.finishDrag */ 562 /** @id MochiKit.DragAndDrop.finishDrag */
563 finishDrag: function (event, success) { 563 finishDrag: function (event, success) {
564 var dr = MochiKit.DragAndDrop; 564 var dr = MochiKit.DragAndDrop;
565 this.dragging = false; 565 this.dragging = false;
566 if (this.options.selectclass) { 566 if (this.options.selectclass) {
567 MochiKit.DOM.removeElementClass(this.element, 567 MochiKit.DOM.removeElementClass(this.element,
568 this.options.selectclass); 568 this.options.selectclass);
569 } 569 }
570 570
571 if (this.options.ghosting) { 571 if (this.options.ghosting) {
572 // XXX: from a user point of view, it would be better to remove 572 // XXX: from a user point of view, it would be better to remove
573 // the node only *after* the MochiKit.Visual.Move end when used 573 // the node only *after* the MochiKit.Visual.Move end when used
574 // with revert. 574 // with revert.
575 MochiKit.Position.relativize(this.element, this.ghostPosition); 575 MochiKit.Position.relativize(this.element, this.ghostPosition);
576 MochiKit.DOM.removeElement(this._clone); 576 MochiKit.DOM.removeElement(this._clone);
577 this._clone = null; 577 this._clone = null;
578 } 578 }
579 579
580 if (success) { 580 if (success) {
581 dr.Droppables.fire(event, this.element); 581 dr.Droppables.fire(event, this.element);
582 } 582 }
583 dr.Draggables.notify('end', this, event); 583 dr.Draggables.notify('end', this, event);
584 584
585 var revert = this.options.revert; 585 var revert = this.options.revert;
586 if (revert && typeof(revert) == 'function') { 586 if (revert && typeof(revert) == 'function') {
587 revert = revert(this.element); 587 revert = revert(this.element);
588 } 588 }
589 589
590 var d = this.currentDelta(); 590 var d = this.currentDelta();
591 if (revert && this.options.reverteffect) { 591 if (revert && this.options.reverteffect) {
592 this._revert = this.options.reverteffect(this.element, 592 this._revert = this.options.reverteffect(this.element,
593 d[1] - this.delta[1], d[0] - this.delta[0]); 593 d[1] - this.delta[1], d[0] - this.delta[0]);
594 } else { 594 } else {
595 this.delta = d; 595 this.delta = d;
596 } 596 }
597 597
598 if (this.options.zindex) { 598 if (this.options.zindex) {
599 this.element.style.zIndex = this.originalZ; 599 this.element.style.zIndex = this.originalZ;
600 } 600 }
601 601
602 if (this.options.endeffect) { 602 if (this.options.endeffect) {
603 this.options.endeffect(this.element); 603 this.options.endeffect(this.element);
604 } 604 }
605 605
606 dr.Draggables.deactivate(); 606 dr.Draggables.deactivate();
607 dr.Droppables.reset(this.element); 607 dr.Droppables.reset(this.element);
608 }, 608 },
609 609
610 /** @id MochiKit.DragAndDrop.keyPress */ 610 /** @id MochiKit.DragAndDrop.keyPress */
611 keyPress: function (event) { 611 keyPress: function (event) {
612 if (event.key().string != "KEY_ESCAPE") { 612 if (event.key().string != "KEY_ESCAPE") {
613 return; 613 return;
614 } 614 }
615 this.finishDrag(event, false); 615 this.finishDrag(event, false);
616 event.stop(); 616 event.stop();
617 }, 617 },
618 618
619 /** @id MochiKit.DragAndDrop.endDrag */ 619 /** @id MochiKit.DragAndDrop.endDrag */
620 endDrag: function (event) { 620 endDrag: function (event) {
621 if (!this.dragging) { 621 if (!this.dragging) {
622 return; 622 return;
623 } 623 }
624 this.stopScrolling(); 624 this.stopScrolling();
625 this.finishDrag(event, true); 625 this.finishDrag(event, true);
626 event.stop(); 626 event.stop();
627 }, 627 },
628 628
629 /** @id MochiKit.DragAndDrop.draw */ 629 /** @id MochiKit.DragAndDrop.draw */
630 draw: function (point) { 630 draw: function (point) {
631 var pos = MochiKit.Position.cumulativeOffset(this.element); 631 var pos = MochiKit.Position.cumulativeOffset(this.element);
632 var d = this.currentDelta(); 632 var d = this.currentDelta();
633 pos.x -= d[0]; 633 pos.x -= d[0];
634 pos.y -= d[1]; 634 pos.y -= d[1];
635 635
636 if (this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { 636 if (this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
637 pos.x -= this.options.scroll.scrollLeft - this.originalScrollLeft; 637 pos.x -= this.options.scroll.scrollLeft - this.originalScrollLeft;
638 pos.y -= this.options.scroll.scrollTop - this.originalScrollTop; 638 pos.y -= this.options.scroll.scrollTop - this.originalScrollTop;
639 } 639 }
640 640
641 var p = [point.page.x - pos.x - this.offset[0], 641 var p = [point.page.x - pos.x - this.offset[0],
642 point.page.y - pos.y - this.offset[1]]; 642 point.page.y - pos.y - this.offset[1]];
643 643
644 if (this.options.snap) { 644 if (this.options.snap) {
645 if (typeof(this.options.snap) == 'function') { 645 if (typeof(this.options.snap) == 'function') {
646 p = this.options.snap(p[0], p[1]); 646 p = this.options.snap(p[0], p[1]);
647 } else { 647 } else {
648 if (this.options.snap instanceof Array) { 648 if (this.options.snap instanceof Array) {
649 var i = -1; 649 var i = -1;
650 p = MochiKit.Base.map(MochiKit.Base.bind(function (v) { 650 p = MochiKit.Base.map(MochiKit.Base.bind(function (v) {
651 i += 1; 651 i += 1;
652 return Math.round(v/this.options.snap[i]) * 652 return Math.round(v/this.options.snap[i]) *
653 this.options.snap[i]; 653 this.options.snap[i];
654 }, this), p); 654 }, this), p);
655 } else { 655 } else {
656 p = MochiKit.Base.map(MochiKit.Base.bind(function (v) { 656 p = MochiKit.Base.map(MochiKit.Base.bind(function (v) {
657 return Math.round(v/this.options.snap) * 657 return Math.round(v/this.options.snap) *
658 this.options.snap; 658 this.options.snap;
659 }, this), p); 659 }, this), p);
660 } 660 }
661 } 661 }
662 } 662 }
663 var style = this.element.style; 663 var style = this.element.style;
664 if ((!this.options.constraint) || 664 if ((!this.options.constraint) ||
665 (this.options.constraint == 'horizontal')) { 665 (this.options.constraint == 'horizontal')) {
666 style.left = p[0] + 'px'; 666 style.left = p[0] + 'px';
667 } 667 }
668 if ((!this.options.constraint) || 668 if ((!this.options.constraint) ||
669 (this.options.constraint == 'vertical')) { 669 (this.options.constraint == 'vertical')) {
670 style.top = p[1] + 'px'; 670 style.top = p[1] + 'px';
671 } 671 }
672 if (style.visibility == 'hidden') { 672 if (style.visibility == 'hidden') {
673 style.visibility = ''; // fix gecko rendering 673 style.visibility = ''; // fix gecko rendering
674 } 674 }
675 }, 675 },
676 676
677 /** @id MochiKit.DragAndDrop.stopScrolling */ 677 /** @id MochiKit.DragAndDrop.stopScrolling */
678 stopScrolling: function () { 678 stopScrolling: function () {
679 if (this.scrollInterval) { 679 if (this.scrollInterval) {
680 clearInterval(this.scrollInterval); 680 clearInterval(this.scrollInterval);
681 this.scrollInterval = null; 681 this.scrollInterval = null;
682 MochiKit.DragAndDrop.Draggables._lastScrollPointer = null; 682 MochiKit.DragAndDrop.Draggables._lastScrollPointer = null;
683 } 683 }
684 }, 684 },
685 685
686 /** @id MochiKit.DragAndDrop.startScrolling */ 686 /** @id MochiKit.DragAndDrop.startScrolling */
687 startScrolling: function (speed) { 687 startScrolling: function (speed) {
688 if (!speed[0] && !speed[1]) { 688 if (!speed[0] && !speed[1]) {
689 return; 689 return;
690 } 690 }
691 this.scrollSpeed = [speed[0] * this.options.scrollSpeed, 691 this.scrollSpeed = [speed[0] * this.options.scrollSpeed,
692 speed[1] * this.options.scrollSpeed]; 692 speed[1] * this.options.scrollSpeed];
693 this.lastScrolled = new Date(); 693 this.lastScrolled = new Date();
694 this.scrollInterval = setInterval(MochiKit.Base.bind(this.scroll, this), 10); 694 this.scrollInterval = setInterval(MochiKit.Base.bind(this.scroll, this), 10);
695 }, 695 },
696 696
697 /** @id MochiKit.DragAndDrop.scroll */ 697 /** @id MochiKit.DragAndDrop.scroll */
698 scroll: function () { 698 scroll: function () {
699 var current = new Date(); 699 var current = new Date();
700 var delta = current - this.lastScrolled; 700 var delta = current - this.lastScrolled;
701 this.lastScrolled = current; 701 this.lastScrolled = current;
702 702
703 if (this.options.scroll == window) { 703 if (this.options.scroll == window) {
704 var s = this._getWindowScroll(this.options.scroll); 704 var s = this._getWindowScroll(this.options.scroll);
705 if (this.scrollSpeed[0] || this.scrollSpeed[1]) { 705 if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
706 var dm = delta / 1000; 706 var dm = delta / 1000;
707 this.options.scroll.scrollTo(s.left + dm * this.scrollSpeed[0], 707 this.options.scroll.scrollTo(s.left + dm * this.scrollSpeed[0],
708 s.top + dm * this.scrollSpeed[1]); 708 s.top + dm * this.scrollSpeed[1]);
709 } 709 }
710 } else { 710 } else {
711 this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; 711 this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
712 this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; 712 this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
713 } 713 }
714 714
715 var d = MochiKit.DragAndDrop; 715 var d = MochiKit.DragAndDrop;
716 716
717 MochiKit.Position.prepare(); 717 MochiKit.Position.prepare();
718 d.Droppables.show(d.Draggables._lastPointer, this.element); 718 d.Droppables.show(d.Draggables._lastPointer, this.element);
719 d.Draggables.notify('drag', this); 719 d.Draggables.notify('drag', this);
720 if (this._isScrollChild) { 720 if (this._isScrollChild) {
721 d.Draggables._lastScrollPointer = d.Draggables._lastScrollPointer || d.Draggables._lastPointer; 721 d.Draggables._lastScrollPointer = d.Draggables._lastScrollPointer || d.Draggables._lastPointer;
722 d.Draggables._lastScrollPointer.x += this.scrollSpeed[0] * delta / 1000; 722 d.Draggables._lastScrollPointer.x += this.scrollSpeed[0] * delta / 1000;
723 d.Draggables._lastScrollPointer.y += this.scrollSpeed[1] * delta / 1000; 723 d.Draggables._lastScrollPointer.y += this.scrollSpeed[1] * delta / 1000;
724 if (d.Draggables._lastScrollPointer.x < 0) { 724 if (d.Draggables._lastScrollPointer.x < 0) {
725 d.Draggables._lastScrollPointer.x = 0; 725 d.Draggables._lastScrollPointer.x = 0;
726 } 726 }
727 if (d.Draggables._lastScrollPointer.y < 0) { 727 if (d.Draggables._lastScrollPointer.y < 0) {
728 d.Draggables._lastScrollPointer.y = 0; 728 d.Draggables._lastScrollPointer.y = 0;
729 } 729 }
730 this.draw(d.Draggables._lastScrollPointer); 730 this.draw(d.Draggables._lastScrollPointer);
731 } 731 }
732 732
733 this.options.onchange(this); 733 this.options.onchange(this);
734 }, 734 },
735 735
736 _getWindowScroll: function (win) { 736 _getWindowScroll: function (win) {
737 var vp, w, h; 737 var vp, w, h;
738 MochiKit.DOM.withWindow(win, function () { 738 MochiKit.DOM.withWindow(win, function () {
739 vp = MochiKit.Style.getViewportPosition(win.document); 739 vp = MochiKit.Style.getViewportPosition(win.document);
740 }); 740 });
741 if (win.innerWidth) { 741 if (win.innerWidth) {
diff --git a/frontend/gamma/js/MochiKit/Format.js b/frontend/gamma/js/MochiKit/Format.js
index 122845e..58877e7 100644
--- a/frontend/gamma/js/MochiKit/Format.js
+++ b/frontend/gamma/js/MochiKit/Format.js
@@ -1,309 +1,309 @@
1/*** 1/***
2 2
3MochiKit.Format 1.5 3MochiKit.Format 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Format', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'Format', '1.5', ['Base']);
12 12
13MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) { 13MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) {
14 return function (num) { 14 return function (num) {
15 num = parseFloat(num); 15 num = parseFloat(num);
16 if (typeof(num) == "undefined" || num === null || isNaN(num)) { 16 if (typeof(num) == "undefined" || num === null || isNaN(num)) {
17 return placeholder; 17 return placeholder;
18 } 18 }
19 var curheader = header; 19 var curheader = header;
20 var curfooter = footer; 20 var curfooter = footer;
21 if (num < 0) { 21 if (num < 0) {
22 num = -num; 22 num = -num;
23 } else { 23 } else {
24 curheader = curheader.replace(/-/, ""); 24 curheader = curheader.replace(/-/, "");
25 } 25 }
26 var me = arguments.callee; 26 var me = arguments.callee;
27 var fmt = MochiKit.Format.formatLocale(locale); 27 var fmt = MochiKit.Format.formatLocale(locale);
28 if (isPercent) { 28 if (isPercent) {
29 num = num * 100.0; 29 num = num * 100.0;
30 curfooter = fmt.percent + curfooter; 30 curfooter = fmt.percent + curfooter;
31 } 31 }
32 num = MochiKit.Format.roundToFixed(num, precision); 32 num = MochiKit.Format.roundToFixed(num, precision);
33 var parts = num.split(/\./); 33 var parts = num.split(/\./);
34 var whole = parts[0]; 34 var whole = parts[0];
35 var frac = (parts.length == 1) ? "" : parts[1]; 35 var frac = (parts.length == 1) ? "" : parts[1];
36 var res = ""; 36 var res = "";
37 while (whole.length < leadingZeros) { 37 while (whole.length < leadingZeros) {
38 whole = "0" + whole; 38 whole = "0" + whole;
39 } 39 }
40 if (separatorAt) { 40 if (separatorAt) {
41 while (whole.length > separatorAt) { 41 while (whole.length > separatorAt) {
42 var i = whole.length - separatorAt; 42 var i = whole.length - separatorAt;
43 //res = res + fmt.separator + whole.substring(i, whole.length); 43 //res = res + fmt.separator + whole.substring(i, whole.length);
44 res = fmt.separator + whole.substring(i, whole.length) + res; 44 res = fmt.separator + whole.substring(i, whole.length) + res;
45 whole = whole.substring(0, i); 45 whole = whole.substring(0, i);
46 } 46 }
47 } 47 }
48 res = whole + res; 48 res = whole + res;
49 if (precision > 0) { 49 if (precision > 0) {
50 while (frac.length < trailingZeros) { 50 while (frac.length < trailingZeros) {
51 frac = frac + "0"; 51 frac = frac + "0";
52 } 52 }
53 res = res + fmt.decimal + frac; 53 res = res + fmt.decimal + frac;
54 } 54 }
55 return curheader + res + curfooter; 55 return curheader + res + curfooter;
56 }; 56 };
57}; 57};
58 58
59/** @id MochiKit.Format.numberFormatter */ 59/** @id MochiKit.Format.numberFormatter */
60MochiKit.Format.numberFormatter = function (pattern, placeholder/* = "" */, locale/* = "default" */) { 60MochiKit.Format.numberFormatter = function (pattern, placeholder/* = "" */, locale/* = "default" */) {
61 // http://java.sun.com/docs/books/tutorial/i18n/format/numberpattern.html 61 // http://java.sun.com/docs/books/tutorial/i18n/format/numberpattern.html
62 // | 0 | leading or trailing zeros 62 // | 0 | leading or trailing zeros
63 // | # | just the number 63 // | # | just the number
64 // | , | separator 64 // | , | separator
65 // | . | decimal separator 65 // | . | decimal separator
66 // | % | Multiply by 100 and format as percent 66 // | % | Multiply by 100 and format as percent
67 if (typeof(placeholder) == "undefined") { 67 if (typeof(placeholder) == "undefined") {
68 placeholder = ""; 68 placeholder = "";
69 } 69 }
70 var match = pattern.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/); 70 var match = pattern.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
71 if (!match) { 71 if (!match) {
72 throw TypeError("Invalid pattern"); 72 throw TypeError("Invalid pattern");
73 } 73 }
74 var header = pattern.substr(0, match.index); 74 var header = pattern.substr(0, match.index);
75 var footer = pattern.substr(match.index + match[0].length); 75 var footer = pattern.substr(match.index + match[0].length);
76 if (header.search(/-/) == -1) { 76 if (header.search(/-/) == -1) {
77 header = header + "-"; 77 header = header + "-";
78 } 78 }
79 var whole = match[1]; 79 var whole = match[1];
80 var frac = (typeof(match[2]) == "string" && match[2] != "") ? match[2] : ""; 80 var frac = (typeof(match[2]) == "string" && match[2] != "") ? match[2] : "";
81 var isPercent = (typeof(match[3]) == "string" && match[3] != ""); 81 var isPercent = (typeof(match[3]) == "string" && match[3] != "");
82 var tmp = whole.split(/,/); 82 var tmp = whole.split(/,/);
83 var separatorAt; 83 var separatorAt;
84 if (typeof(locale) == "undefined") { 84 if (typeof(locale) == "undefined") {
85 locale = "default"; 85 locale = "default";
86 } 86 }
87 if (tmp.length == 1) { 87 if (tmp.length == 1) {
88 separatorAt = null; 88 separatorAt = null;
89 } else { 89 } else {
90 separatorAt = tmp[1].length; 90 separatorAt = tmp[1].length;
91 } 91 }
92 var leadingZeros = whole.length - whole.replace(/0/g, "").length; 92 var leadingZeros = whole.length - whole.replace(/0/g, "").length;
93 var trailingZeros = frac.length - frac.replace(/0/g, "").length; 93 var trailingZeros = frac.length - frac.replace(/0/g, "").length;
94 var precision = frac.length; 94 var precision = frac.length;
95 var rval = MochiKit.Format._numberFormatter( 95 var rval = MochiKit.Format._numberFormatter(
96 placeholder, header, footer, locale, isPercent, precision, 96 placeholder, header, footer, locale, isPercent, precision,
97 leadingZeros, separatorAt, trailingZeros 97 leadingZeros, separatorAt, trailingZeros
98 ); 98 );
99 var m = MochiKit.Base; 99 var m = MochiKit.Base;
100 if (m) { 100 if (m) {
101 var fn = arguments.callee; 101 var fn = arguments.callee;
102 var args = m.concat(arguments); 102 var args = m.concat(arguments);
103 rval.repr = function () { 103 rval.repr = function () {
104 return [ 104 return [
105 self.NAME, 105 self.NAME,
106 "(", 106 "(",
107 map(m.repr, args).join(", "), 107 m.map(m.repr, args).join(", "),
108 ")" 108 ")"
109 ].join(""); 109 ].join("");
110 }; 110 };
111 } 111 }
112 return rval; 112 return rval;
113}; 113};
114 114
115/** @id MochiKit.Format.formatLocale */ 115/** @id MochiKit.Format.formatLocale */
116MochiKit.Format.formatLocale = function (locale) { 116MochiKit.Format.formatLocale = function (locale) {
117 if (typeof(locale) == "undefined" || locale === null) { 117 if (typeof(locale) == "undefined" || locale === null) {
118 locale = "default"; 118 locale = "default";
119 } 119 }
120 if (typeof(locale) == "string") { 120 if (typeof(locale) == "string") {
121 var rval = MochiKit.Format.LOCALE[locale]; 121 var rval = MochiKit.Format.LOCALE[locale];
122 if (typeof(rval) == "string") { 122 if (typeof(rval) == "string") {
123 rval = arguments.callee(rval); 123 rval = arguments.callee(rval);
124 MochiKit.Format.LOCALE[locale] = rval; 124 MochiKit.Format.LOCALE[locale] = rval;
125 } 125 }
126 return rval; 126 return rval;
127 } else { 127 } else {
128 return locale; 128 return locale;
129 } 129 }
130}; 130};
131 131
132/** @id MochiKit.Format.twoDigitAverage */ 132/** @id MochiKit.Format.twoDigitAverage */
133MochiKit.Format.twoDigitAverage = function (numerator, denominator) { 133MochiKit.Format.twoDigitAverage = function (numerator, denominator) {
134 if (denominator) { 134 if (denominator) {
135 var res = numerator / denominator; 135 var res = numerator / denominator;
136 if (!isNaN(res)) { 136 if (!isNaN(res)) {
137 return MochiKit.Format.twoDigitFloat(res); 137 return MochiKit.Format.twoDigitFloat(res);
138 } 138 }
139 } 139 }
140 return "0"; 140 return "0";
141}; 141};
142 142
143/** @id MochiKit.Format.twoDigitFloat */ 143/** @id MochiKit.Format.twoDigitFloat */
144MochiKit.Format.twoDigitFloat = function (aNumber) { 144MochiKit.Format.twoDigitFloat = function (aNumber) {
145 var res = roundToFixed(aNumber, 2); 145 var res = MochiKit.Format.roundToFixed(aNumber, 2);
146 if (res.indexOf(".00") > 0) { 146 if (res.indexOf(".00") > 0) {
147 return res.substring(0, res.length - 3); 147 return res.substring(0, res.length - 3);
148 } else if (res.charAt(res.length - 1) == "0") { 148 } else if (res.charAt(res.length - 1) == "0") {
149 return res.substring(0, res.length - 1); 149 return res.substring(0, res.length - 1);
150 } else { 150 } else {
151 return res; 151 return res;
152 } 152 }
153}; 153};
154 154
155/** @id MochiKit.Format.lstrip */ 155/** @id MochiKit.Format.lstrip */
156MochiKit.Format.lstrip = function (str, /* optional */chars) { 156MochiKit.Format.lstrip = function (str, /* optional */chars) {
157 str = str + ""; 157 str = str + "";
158 if (typeof(str) != "string") { 158 if (typeof(str) != "string") {
159 return null; 159 return null;
160 } 160 }
161 if (!chars) { 161 if (!chars) {
162 return str.replace(/^\s+/, ""); 162 return str.replace(/^\s+/, "");
163 } else { 163 } else {
164 return str.replace(new RegExp("^[" + chars + "]+"), ""); 164 return str.replace(new RegExp("^[" + chars + "]+"), "");
165 } 165 }
166}; 166};
167 167
168/** @id MochiKit.Format.rstrip */ 168/** @id MochiKit.Format.rstrip */
169MochiKit.Format.rstrip = function (str, /* optional */chars) { 169MochiKit.Format.rstrip = function (str, /* optional */chars) {
170 str = str + ""; 170 str = str + "";
171 if (typeof(str) != "string") { 171 if (typeof(str) != "string") {
172 return null; 172 return null;
173 } 173 }
174 if (!chars) { 174 if (!chars) {
175 return str.replace(/\s+$/, ""); 175 return str.replace(/\s+$/, "");
176 } else { 176 } else {
177 return str.replace(new RegExp("[" + chars + "]+$"), ""); 177 return str.replace(new RegExp("[" + chars + "]+$"), "");
178 } 178 }
179}; 179};
180 180
181/** @id MochiKit.Format.strip */ 181/** @id MochiKit.Format.strip */
182MochiKit.Format.strip = function (str, /* optional */chars) { 182MochiKit.Format.strip = function (str, /* optional */chars) {
183 var self = MochiKit.Format; 183 var self = MochiKit.Format;
184 return self.rstrip(self.lstrip(str, chars), chars); 184 return self.rstrip(self.lstrip(str, chars), chars);
185}; 185};
186 186
187/** @id MochiKit.Format.truncToFixed */ 187/** @id MochiKit.Format.truncToFixed */
188MochiKit.Format.truncToFixed = function (aNumber, precision) { 188MochiKit.Format.truncToFixed = function (aNumber, precision) {
189 var fixed = MochiKit.Format._numberToFixed(aNumber, precision); 189 var fixed = MochiKit.Format._numberToFixed(aNumber, precision);
190 var fracPos = fixed.indexOf("."); 190 var fracPos = fixed.indexOf(".");
191 if (fracPos > 0 && fracPos + precision + 1 < fixed.length) { 191 if (fracPos > 0 && fracPos + precision + 1 < fixed.length) {
192 fixed = fixed.substring(0, fracPos + precision + 1); 192 fixed = fixed.substring(0, fracPos + precision + 1);
193 fixed = MochiKit.Format._shiftNumber(fixed, 0); 193 fixed = MochiKit.Format._shiftNumber(fixed, 0);
194 } 194 }
195 return fixed; 195 return fixed;
196} 196};
197 197
198/** @id MochiKit.Format.roundToFixed */ 198/** @id MochiKit.Format.roundToFixed */
199MochiKit.Format.roundToFixed = function (aNumber, precision) { 199MochiKit.Format.roundToFixed = function (aNumber, precision) {
200 var fixed = MochiKit.Format._numberToFixed(aNumber, precision); 200 var fixed = MochiKit.Format._numberToFixed(aNumber, precision);
201 var fracPos = fixed.indexOf("."); 201 var fracPos = fixed.indexOf(".");
202 if (fracPos > 0 && fracPos + precision + 1 < fixed.length) { 202 if (fracPos > 0 && fracPos + precision + 1 < fixed.length) {
203 var str = MochiKit.Format._shiftNumber(fixed, precision); 203 var str = MochiKit.Format._shiftNumber(fixed, precision);
204 str = MochiKit.Format._numberToFixed(Math.round(parseFloat(str)), 0); 204 str = MochiKit.Format._numberToFixed(Math.round(parseFloat(str)), 0);
205 fixed = MochiKit.Format._shiftNumber(str, -precision); 205 fixed = MochiKit.Format._shiftNumber(str, -precision);
206 } 206 }
207 return fixed; 207 return fixed;
208} 208};
209 209
210/** 210/**
211 * Converts a number to a fixed format string. This function handles 211 * Converts a number to a fixed format string. This function handles
212 * conversion of exponents by shifting the decimal point to the left 212 * conversion of exponents by shifting the decimal point to the left
213 * or the right. It also guarantees a specified minimum number of 213 * or the right. It also guarantees a specified minimum number of
214 * fractional digits (but no maximum). 214 * fractional digits (but no maximum).
215 * 215 *
216 * @param {Number} aNumber the number to convert 216 * @param {Number} aNumber the number to convert
217 * @param {Number} precision the minimum number of decimal digits 217 * @param {Number} precision the minimum number of decimal digits
218 * 218 *
219 * @return {String} the fixed format number string 219 * @return {String} the fixed format number string
220 */ 220 */
221MochiKit.Format._numberToFixed = function (aNumber, precision) { 221MochiKit.Format._numberToFixed = function (aNumber, precision) {
222 var str = aNumber.toString(); 222 var str = aNumber.toString();
223 var parts = str.split(/[eE]/); 223 var parts = str.split(/[eE]/);
224 var exp = (parts.length === 1) ? 0 : parseInt(parts[1]) || 0; 224 var exp = (parts.length === 1) ? 0 : parseInt(parts[1], 10) || 0;
225 var fixed = MochiKit.Format._shiftNumber(parts[0], exp); 225 var fixed = MochiKit.Format._shiftNumber(parts[0], exp);
226 parts = fixed.split(/\./); 226 parts = fixed.split(/\./);
227 var whole = parts[0]; 227 var whole = parts[0];
228 var frac = (parts.length === 1) ? "" : parts[1]; 228 var frac = (parts.length === 1) ? "" : parts[1];
229 while (frac.length < precision) { 229 while (frac.length < precision) {
230 frac += "0"; 230 frac += "0";
231 } 231 }
232 if (frac.length > 0) { 232 if (frac.length > 0) {
233 return whole + "." + frac; 233 return whole + "." + frac;
234 } else { 234 } else {
235 return whole; 235 return whole;
236 } 236 }
237} 237};
238 238
239/** 239/**
240 * Shifts the decimal dot location in a fixed format number string. 240 * Shifts the decimal dot location in a fixed format number string.
241 * This function handles negative values and will add and remove 241 * This function handles negative values and will add and remove
242 * leading and trailing zeros as needed. 242 * leading and trailing zeros as needed.
243 * 243 *
244 * @param {String} num the fixed format number string 244 * @param {String} num the fixed format number string
245 * @param {Number} exp the base-10 exponent to apply 245 * @param {Number} exp the base-10 exponent to apply
246 * 246 *
247 * @return {String} the new fixed format number string 247 * @return {String} the new fixed format number string
248 */ 248 */
249MochiKit.Format._shiftNumber = function (num, exp) { 249MochiKit.Format._shiftNumber = function (num, exp) {
250 var pos = num.indexOf("."); 250 var pos = num.indexOf(".");
251 if (pos < 0) { 251 if (pos < 0) {
252 pos = num.length; 252 pos = num.length;
253 } else { 253 } else {
254 num = num.substring(0, pos) + num.substring(pos + 1); 254 num = num.substring(0, pos) + num.substring(pos + 1);
255 } 255 }
256 pos += exp; 256 pos += exp;
257 while (pos <= 0 || (pos <= 1 && num.charAt(0) === "-")) { 257 while (pos <= 0 || (pos <= 1 && num.charAt(0) === "-")) {
258 if (num.charAt(0) === "-") { 258 if (num.charAt(0) === "-") {
259 num = "-0" + num.substring(1); 259 num = "-0" + num.substring(1);
260 } else { 260 } else {
261 num = "0" + num; 261 num = "0" + num;
262 } 262 }
263 pos++; 263 pos++;
264 } 264 }
265 while (pos > num.length) { 265 while (pos > num.length) {
266 num += "0"; 266 num += "0";
267 } 267 }
268 if (pos < num.length) { 268 if (pos < num.length) {
269 num = num.substring(0, pos) + "." + num.substring(pos); 269 num = num.substring(0, pos) + "." + num.substring(pos);
270 } 270 }
271 while (/^0[^.]/.test(num)) { 271 while (/^0[^.]/.test(num)) {
272 num = num.substring(1); 272 num = num.substring(1);
273 } 273 }
274 while (/^-0[^.]/.test(num)) { 274 while (/^-0[^.]/.test(num)) {
275 num = "-" + num.substring(2); 275 num = "-" + num.substring(2);
276 } 276 }
277 return num; 277 return num;
278} 278};
279 279
280/** @id MochiKit.Format.percentFormat */ 280/** @id MochiKit.Format.percentFormat */
281MochiKit.Format.percentFormat = function (aNumber) { 281MochiKit.Format.percentFormat = function (aNumber) {
282 return MochiKit.Format.twoDigitFloat(100 * aNumber) + '%'; 282 return MochiKit.Format.twoDigitFloat(100 * aNumber) + '%';
283}; 283};
284 284
285MochiKit.Format.LOCALE = { 285MochiKit.Format.LOCALE = {
286 en_US: {separator: ",", decimal: ".", percent: "%"}, 286 en_US: {separator: ",", decimal: ".", percent: "%"},
287 de_DE: {separator: ".", decimal: ",", percent: "%"}, 287 de_DE: {separator: ".", decimal: ",", percent: "%"},
288 pt_BR: {separator: ".", decimal: ",", percent: "%"}, 288 pt_BR: {separator: ".", decimal: ",", percent: "%"},
289 fr_FR: {separator: " ", decimal: ",", percent: "%"}, 289 fr_FR: {separator: " ", decimal: ",", percent: "%"},
290 "default": "en_US", 290 "default": "en_US",
291 __export__: false 291 __export__: false
292}; 292};
293 293
294MochiKit.Format.__new__ = function () { 294MochiKit.Format.__new__ = function () {
295 MochiKit.Base.nameFunctions(this); 295 MochiKit.Base.nameFunctions(this);
296 var base = this.NAME + "."; 296 var base = this.NAME + ".";
297 var k, v, o; 297 var k, v, o;
298 for (k in this.LOCALE) { 298 for (k in this.LOCALE) {
299 o = this.LOCALE[k]; 299 o = this.LOCALE[k];
300 if (typeof(o) == "object") { 300 if (typeof(o) == "object") {
301 o.repr = function () { return this.NAME; }; 301 o.repr = function () { return this.NAME; };
302 o.NAME = base + "LOCALE." + k; 302 o.NAME = base + "LOCALE." + k;
303 } 303 }
304 } 304 }
305}; 305};
306 306
307MochiKit.Format.__new__(); 307MochiKit.Format.__new__();
308 308
309MochiKit.Base._exportSymbols(this, MochiKit.Format); 309MochiKit.Base._exportSymbols(this, MochiKit.Format);
diff --git a/frontend/gamma/js/MochiKit/Iter.js b/frontend/gamma/js/MochiKit/Iter.js
index 524b2bc..77623bc 100644
--- a/frontend/gamma/js/MochiKit/Iter.js
+++ b/frontend/gamma/js/MochiKit/Iter.js
@@ -1,672 +1,670 @@
1/*** 1/***
2 2
3MochiKit.Iter 1.5 3MochiKit.Iter 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Iter', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'Iter', '1.5', ['Base']);
12 12
13MochiKit.Base.update(MochiKit.Iter, { 13MochiKit.Base.update(MochiKit.Iter, {
14 /** @id MochiKit.Iter.registerIteratorFactory */ 14 /** @id MochiKit.Iter.registerIteratorFactory */
15 registerIteratorFactory: function (name, check, iterfactory, /* optional */ override) { 15 registerIteratorFactory: function (name, check, iterfactory, /* optional */ override) {
16 MochiKit.Iter.iteratorRegistry.register(name, check, iterfactory, override); 16 MochiKit.Iter.iteratorRegistry.register(name, check, iterfactory, override);
17 }, 17 },
18 18
19 /** @id MochiKit.Iter.isIterable */ 19 /** @id MochiKit.Iter.isIterable */
20 isIterable: function(o) { 20 isIterable: function(o) {
21 return o != null && 21 return o != null &&
22 (typeof(o.next) == "function" || typeof(o.iter) == "function"); 22 (typeof(o.next) == "function" || typeof(o.iter) == "function");
23 }, 23 },
24 24
25 /** @id MochiKit.Iter.iter */ 25 /** @id MochiKit.Iter.iter */
26 iter: function (iterable, /* optional */ sentinel) { 26 iter: function (iterable, /* optional */ sentinel) {
27 var self = MochiKit.Iter; 27 var self = MochiKit.Iter;
28 if (arguments.length == 2) { 28 if (arguments.length == 2) {
29 return self.takewhile( 29 return self.takewhile(
30 function (a) { return a != sentinel; }, 30 function (a) { return a != sentinel; },
31 iterable 31 iterable
32 ); 32 );
33 } 33 }
34 if (typeof(iterable.next) == 'function') { 34 if (typeof(iterable.next) == 'function') {
35 return iterable; 35 return iterable;
36 } else if (typeof(iterable.iter) == 'function') { 36 } else if (typeof(iterable.iter) == 'function') {
37 return iterable.iter(); 37 return iterable.iter();
38 /* 38 /*
39 } else if (typeof(iterable.__iterator__) == 'function') { 39 } else if (typeof(iterable.__iterator__) == 'function') {
40 // 40 //
41 // XXX: We can't support JavaScript 1.7 __iterator__ directly 41 // XXX: We can't support JavaScript 1.7 __iterator__ directly
42 // because of Object.prototype.__iterator__ 42 // because of Object.prototype.__iterator__
43 // 43 //
44 return iterable.__iterator__(); 44 return iterable.__iterator__();
45 */ 45 */
46 } 46 }
47 47
48 try { 48 try {
49 return self.iteratorRegistry.match(iterable); 49 return self.iteratorRegistry.match(iterable);
50 } catch (e) { 50 } catch (e) {
51 var m = MochiKit.Base; 51 var m = MochiKit.Base;
52 if (e == m.NotFound) { 52 if (e == m.NotFound) {
53 e = new TypeError(typeof(iterable) + ": " + m.repr(iterable) + " is not iterable"); 53 e = new TypeError(typeof(iterable) + ": " + m.repr(iterable) + " is not iterable");
54 } 54 }
55 throw e; 55 throw e;
56 } 56 }
57 }, 57 },
58 58
59 /** @id MochiKit.Iter.count */ 59 /** @id MochiKit.Iter.count */
60 count: function (n) { 60 count: function (n) {
61 if (!n) { 61 if (!n) {
62 n = 0; 62 n = 0;
63 } 63 }
64 var m = MochiKit.Base; 64 var m = MochiKit.Base;
65 return { 65 return {
66 repr: function () { return "count(" + n + ")"; }, 66 repr: function () { return "count(" + n + ")"; },
67 toString: m.forwardCall("repr"), 67 toString: m.forwardCall("repr"),
68 next: m.counter(n) 68 next: m.counter(n)
69 }; 69 };
70 }, 70 },
71 71
72 /** @id MochiKit.Iter.cycle */ 72 /** @id MochiKit.Iter.cycle */
73 cycle: function (p) { 73 cycle: function (p) {
74 var self = MochiKit.Iter; 74 var self = MochiKit.Iter;
75 var m = MochiKit.Base; 75 var m = MochiKit.Base;
76 var lst = []; 76 var lst = [];
77 var iterator = self.iter(p); 77 var iterator = self.iter(p);
78 return { 78 return {
79 repr: function () { return "cycle(...)"; }, 79 repr: function () { return "cycle(...)"; },
80 toString: m.forwardCall("repr"), 80 toString: m.forwardCall("repr"),
81 next: function () { 81 next: function () {
82 try { 82 try {
83 var rval = iterator.next(); 83 var rval = iterator.next();
84 lst.push(rval); 84 lst.push(rval);
85 return rval; 85 return rval;
86 } catch (e) { 86 } catch (e) {
87 if (e != self.StopIteration) { 87 if (e != self.StopIteration) {
88 throw e; 88 throw e;
89 } 89 }
90 if (lst.length === 0) { 90 if (lst.length === 0) {
91 this.next = function () { 91 this.next = function () {
92 throw self.StopIteration; 92 throw self.StopIteration;
93 }; 93 };
94 } else { 94 } else {
95 var i = -1; 95 var i = -1;
96 this.next = function () { 96 this.next = function () {
97 i = (i + 1) % lst.length; 97 i = (i + 1) % lst.length;
98 return lst[i]; 98 return lst[i];
99 }; 99 };
100 } 100 }
101 return this.next(); 101 return this.next();
102 } 102 }
103 } 103 }
104 }; 104 };
105 }, 105 },
106 106
107 /** @id MochiKit.Iter.repeat */ 107 /** @id MochiKit.Iter.repeat */
108 repeat: function (elem, /* optional */n) { 108 repeat: function (elem, /* optional */n) {
109 var m = MochiKit.Base; 109 var m = MochiKit.Base;
110 if (typeof(n) == 'undefined') { 110 if (typeof(n) == 'undefined') {
111 return { 111 return {
112 repr: function () { 112 repr: function () {
113 return "repeat(" + m.repr(elem) + ")"; 113 return "repeat(" + m.repr(elem) + ")";
114 }, 114 },
115 toString: m.forwardCall("repr"), 115 toString: m.forwardCall("repr"),
116 next: function () { 116 next: function () {
117 return elem; 117 return elem;
118 } 118 }
119 }; 119 };
120 } 120 }
121 return { 121 return {
122 repr: function () { 122 repr: function () {
123 return "repeat(" + m.repr(elem) + ", " + n + ")"; 123 return "repeat(" + m.repr(elem) + ", " + n + ")";
124 }, 124 },
125 toString: m.forwardCall("repr"), 125 toString: m.forwardCall("repr"),
126 next: function () { 126 next: function () {
127 if (n <= 0) { 127 if (n <= 0) {
128 throw MochiKit.Iter.StopIteration; 128 throw MochiKit.Iter.StopIteration;
129 } 129 }
130 n -= 1; 130 n -= 1;
131 return elem; 131 return elem;
132 } 132 }
133 }; 133 };
134 }, 134 },
135 135
136 /** @id MochiKit.Iter.next */ 136 /** @id MochiKit.Iter.next */
137 next: function (iterator) { 137 next: function (iterator) {
138 return iterator.next(); 138 return iterator.next();
139 }, 139 },
140 140
141 /** @id MochiKit.Iter.izip */ 141 /** @id MochiKit.Iter.izip */
142 izip: function (p, q/*, ...*/) { 142 izip: function (p, q/*, ...*/) {
143 var m = MochiKit.Base; 143 var m = MochiKit.Base;
144 var self = MochiKit.Iter; 144 var self = MochiKit.Iter;
145 var next = self.next; 145 var next = self.next;
146 var iterables = m.map(self.iter, arguments); 146 var iterables = m.map(self.iter, arguments);
147 return { 147 return {
148 repr: function () { return "izip(...)"; }, 148 repr: function () { return "izip(...)"; },
149 toString: m.forwardCall("repr"), 149 toString: m.forwardCall("repr"),
150 next: function () { return m.map(next, iterables); } 150 next: function () { return m.map(next, iterables); }
151 }; 151 };
152 }, 152 },
153 153
154 /** @id MochiKit.Iter.ifilter */ 154 /** @id MochiKit.Iter.ifilter */
155 ifilter: function (pred, seq) { 155 ifilter: function (pred, seq) {
156 var m = MochiKit.Base; 156 var m = MochiKit.Base;
157 seq = MochiKit.Iter.iter(seq); 157 seq = MochiKit.Iter.iter(seq);
158 if (pred === null) { 158 if (pred === null) {
159 pred = m.operator.truth; 159 pred = m.operator.truth;
160 } 160 }
161 return { 161 return {
162 repr: function () { return "ifilter(...)"; }, 162 repr: function () { return "ifilter(...)"; },
163 toString: m.forwardCall("repr"), 163 toString: m.forwardCall("repr"),
164 next: function () { 164 next: function () {
165 while (true) { 165 while (true) {
166 var rval = seq.next(); 166 var rval = seq.next();
167 if (pred(rval)) { 167 if (pred(rval)) {
168 return rval; 168 return rval;
169 } 169 }
170 } 170 }
171 // mozilla warnings aren't too bright 171 // mozilla warnings aren't too bright
172 return undefined; 172 return undefined;
173 } 173 }
174 }; 174 };
175 }, 175 },
176 176
177 /** @id MochiKit.Iter.ifilterfalse */ 177 /** @id MochiKit.Iter.ifilterfalse */
178 ifilterfalse: function (pred, seq) { 178 ifilterfalse: function (pred, seq) {
179 var m = MochiKit.Base; 179 var m = MochiKit.Base;
180 seq = MochiKit.Iter.iter(seq); 180 seq = MochiKit.Iter.iter(seq);
181 if (pred === null) { 181 if (pred === null) {
182 pred = m.operator.truth; 182 pred = m.operator.truth;
183 } 183 }
184 return { 184 return {
185 repr: function () { return "ifilterfalse(...)"; }, 185 repr: function () { return "ifilterfalse(...)"; },
186 toString: m.forwardCall("repr"), 186 toString: m.forwardCall("repr"),
187 next: function () { 187 next: function () {
188 while (true) { 188 while (true) {
189 var rval = seq.next(); 189 var rval = seq.next();
190 if (!pred(rval)) { 190 if (!pred(rval)) {
191 return rval; 191 return rval;
192 } 192 }
193 } 193 }
194 // mozilla warnings aren't too bright 194 // mozilla warnings aren't too bright
195 return undefined; 195 return undefined;
196 } 196 }
197 }; 197 };
198 }, 198 },
199 199
200 /** @id MochiKit.Iter.islice */ 200 /** @id MochiKit.Iter.islice */
201 islice: function (seq/*, [start,] stop[, step] */) { 201 islice: function (seq/*, [start,] stop[, step] */) {
202 var self = MochiKit.Iter; 202 var self = MochiKit.Iter;
203 var m = MochiKit.Base; 203 var m = MochiKit.Base;
204 seq = self.iter(seq); 204 seq = self.iter(seq);
205 var start = 0; 205 var start = 0;
206 var stop = 0; 206 var stop = 0;
207 var step = 1; 207 var step = 1;
208 var i = -1; 208 var i = -1;
209 if (arguments.length == 2) { 209 if (arguments.length == 2) {
210 stop = arguments[1]; 210 stop = arguments[1];
211 } else if (arguments.length == 3) { 211 } else if (arguments.length == 3) {
212 start = arguments[1]; 212 start = arguments[1];
213 stop = arguments[2]; 213 stop = arguments[2];
214 } else { 214 } else {
215 start = arguments[1]; 215 start = arguments[1];
216 stop = arguments[2]; 216 stop = arguments[2];
217 step = arguments[3]; 217 step = arguments[3];
218 } 218 }
219 return { 219 return {
220 repr: function () { 220 repr: function () {
221 return "islice(" + ["...", start, stop, step].join(", ") + ")"; 221 return "islice(" + ["...", start, stop, step].join(", ") + ")";
222 }, 222 },
223 toString: m.forwardCall("repr"), 223 toString: m.forwardCall("repr"),
224 next: function () { 224 next: function () {
225 if (start >= stop) {
226 throw self.StopIteration;
227 }
228
225 var rval; 229 var rval;
226 while (i < start) { 230 while (i < start) {
227 rval = seq.next(); 231 rval = seq.next();
228 i++; 232 i++;
229 } 233 }
230 if (start >= stop) {
231 throw self.StopIteration;
232 }
233 start += step; 234 start += step;
234 return rval; 235 return rval;
235 } 236 }
236 }; 237 };
237 }, 238 },
238 239
239 /** @id MochiKit.Iter.imap */ 240 /** @id MochiKit.Iter.imap */
240 imap: function (fun, p, q/*, ...*/) { 241 imap: function (fun, p, q/*, ...*/) {
241 var m = MochiKit.Base; 242 var m = MochiKit.Base;
242 var self = MochiKit.Iter; 243 var self = MochiKit.Iter;
243 var iterables = m.map(self.iter, m.extend(null, arguments, 1)); 244 var iterables = m.map(self.iter, m.extend(null, arguments, 1));
244 var map = m.map; 245 var map = m.map;
245 var next = self.next; 246 var next = self.next;
246 return { 247 return {
247 repr: function () { return "imap(...)"; }, 248 repr: function () { return "imap(...)"; },
248 toString: m.forwardCall("repr"), 249 toString: m.forwardCall("repr"),
249 next: function () { 250 next: function () {
250 return fun.apply(this, map(next, iterables)); 251 return fun.apply(this, map(next, iterables));
251 } 252 }
252 }; 253 };
253 }, 254 },
254 255
255 /** @id MochiKit.Iter.applymap */ 256 /** @id MochiKit.Iter.applymap */
256 applymap: function (fun, seq, self) { 257 applymap: function (fun, seq, self) {
257 seq = MochiKit.Iter.iter(seq); 258 seq = MochiKit.Iter.iter(seq);
258 var m = MochiKit.Base; 259 var m = MochiKit.Base;
259 return { 260 return {
260 repr: function () { return "applymap(...)"; }, 261 repr: function () { return "applymap(...)"; },
261 toString: m.forwardCall("repr"), 262 toString: m.forwardCall("repr"),
262 next: function () { 263 next: function () {
263 return fun.apply(self, seq.next()); 264 return fun.apply(self, seq.next());
264 } 265 }
265 }; 266 };
266 }, 267 },
267 268
268 /** @id MochiKit.Iter.chain */ 269 /** @id MochiKit.Iter.chain */
269 chain: function (p, q/*, ...*/) { 270 chain: function (p, q/*, ...*/) {
270 // dumb fast path 271 // dumb fast path
271 var self = MochiKit.Iter; 272 var self = MochiKit.Iter;
272 var m = MochiKit.Base; 273 var m = MochiKit.Base;
273 if (arguments.length == 1) { 274 if (arguments.length == 1) {
274 return self.iter(arguments[0]); 275 return self.iter(arguments[0]);
275 } 276 }
276 var argiter = m.map(self.iter, arguments); 277 var argiter = m.map(self.iter, arguments);
277 return { 278 return {
278 repr: function () { return "chain(...)"; }, 279 repr: function () { return "chain(...)"; },
279 toString: m.forwardCall("repr"), 280 toString: m.forwardCall("repr"),
280 next: function () { 281 next: function () {
281 while (argiter.length > 1) { 282 while (argiter.length > 1) {
282 try { 283 try {
283 var result = argiter[0].next(); 284 return argiter[0].next();
284 return result;
285 } catch (e) { 285 } catch (e) {
286 if (e != self.StopIteration) { 286 if (e != self.StopIteration) {
287 throw e; 287 throw e;
288 } 288 }
289 argiter.shift(); 289 argiter.shift();
290 var result = argiter[0].next();
291 return result;
292 } 290 }
293 } 291 }
294 if (argiter.length == 1) { 292 if (argiter.length == 1) {
295 // optimize last element 293 // optimize last element
296 var arg = argiter.shift(); 294 var arg = argiter.shift();
297 this.next = m.bind("next", arg); 295 this.next = m.bind("next", arg);
298 return this.next(); 296 return this.next();
299 } 297 }
300 throw self.StopIteration; 298 throw self.StopIteration;
301 } 299 }
302 }; 300 };
303 }, 301 },
304 302
305 /** @id MochiKit.Iter.takewhile */ 303 /** @id MochiKit.Iter.takewhile */
306 takewhile: function (pred, seq) { 304 takewhile: function (pred, seq) {
307 var self = MochiKit.Iter; 305 var self = MochiKit.Iter;
308 seq = self.iter(seq); 306 seq = self.iter(seq);
309 return { 307 return {
310 repr: function () { return "takewhile(...)"; }, 308 repr: function () { return "takewhile(...)"; },
311 toString: MochiKit.Base.forwardCall("repr"), 309 toString: MochiKit.Base.forwardCall("repr"),
312 next: function () { 310 next: function () {
313 var rval = seq.next(); 311 var rval = seq.next();
314 if (!pred(rval)) { 312 if (!pred(rval)) {
315 this.next = function () { 313 this.next = function () {
316 throw self.StopIteration; 314 throw self.StopIteration;
317 }; 315 };
318 this.next(); 316 this.next();
319 } 317 }
320 return rval; 318 return rval;
321 } 319 }
322 }; 320 };
323 }, 321 },
324 322
325 /** @id MochiKit.Iter.dropwhile */ 323 /** @id MochiKit.Iter.dropwhile */
326 dropwhile: function (pred, seq) { 324 dropwhile: function (pred, seq) {
327 seq = MochiKit.Iter.iter(seq); 325 seq = MochiKit.Iter.iter(seq);
328 var m = MochiKit.Base; 326 var m = MochiKit.Base;
329 var bind = m.bind; 327 var bind = m.bind;
330 return { 328 return {
331 "repr": function () { return "dropwhile(...)"; }, 329 "repr": function () { return "dropwhile(...)"; },
332 "toString": m.forwardCall("repr"), 330 "toString": m.forwardCall("repr"),
333 "next": function () { 331 "next": function () {
334 while (true) { 332 while (true) {
335 var rval = seq.next(); 333 var rval = seq.next();
336 if (!pred(rval)) { 334 if (!pred(rval)) {
337 break; 335 break;
338 } 336 }
339 } 337 }
340 this.next = bind("next", seq); 338 this.next = bind("next", seq);
341 return rval; 339 return rval;
342 } 340 }
343 }; 341 };
344 }, 342 },
345 343
346 _tee: function (ident, sync, iterable) { 344 _tee: function (ident, sync, iterable) {
347 sync.pos[ident] = -1; 345 sync.pos[ident] = -1;
348 var m = MochiKit.Base; 346 var m = MochiKit.Base;
349 var listMin = m.listMin; 347 var listMin = m.listMin;
350 return { 348 return {
351 repr: function () { return "tee(" + ident + ", ...)"; }, 349 repr: function () { return "tee(" + ident + ", ...)"; },
352 toString: m.forwardCall("repr"), 350 toString: m.forwardCall("repr"),
353 next: function () { 351 next: function () {
354 var rval; 352 var rval;
355 var i = sync.pos[ident]; 353 var i = sync.pos[ident];
356 354
357 if (i == sync.max) { 355 if (i == sync.max) {
358 rval = iterable.next(); 356 rval = iterable.next();
359 sync.deque.push(rval); 357 sync.deque.push(rval);
360 sync.max += 1; 358 sync.max += 1;
361 sync.pos[ident] += 1; 359 sync.pos[ident] += 1;
362 } else { 360 } else {
363 rval = sync.deque[i - sync.min]; 361 rval = sync.deque[i - sync.min];
364 sync.pos[ident] += 1; 362 sync.pos[ident] += 1;
365 if (i == sync.min && listMin(sync.pos) != sync.min) { 363 if (i == sync.min && listMin(sync.pos) != sync.min) {
366 sync.min += 1; 364 sync.min += 1;
367 sync.deque.shift(); 365 sync.deque.shift();
368 } 366 }
369 } 367 }
370 return rval; 368 return rval;
371 } 369 }
372 }; 370 };
373 }, 371 },
374 372
375 /** @id MochiKit.Iter.tee */ 373 /** @id MochiKit.Iter.tee */
376 tee: function (iterable, n/* = 2 */) { 374 tee: function (iterable, n/* = 2 */) {
377 var rval = []; 375 var rval = [];
378 var sync = { 376 var sync = {
379 "pos": [], 377 "pos": [],
380 "deque": [], 378 "deque": [],
381 "max": -1, 379 "max": -1,
382 "min": -1 380 "min": -1
383 }; 381 };
384 if (arguments.length == 1 || typeof(n) == "undefined" || n === null) { 382 if (arguments.length == 1 || typeof(n) == "undefined" || n === null) {
385 n = 2; 383 n = 2;
386 } 384 }
387 var self = MochiKit.Iter; 385 var self = MochiKit.Iter;
388 iterable = self.iter(iterable); 386 iterable = self.iter(iterable);
389 var _tee = self._tee; 387 var _tee = self._tee;
390 for (var i = 0; i < n; i++) { 388 for (var i = 0; i < n; i++) {
391 rval.push(_tee(i, sync, iterable)); 389 rval.push(_tee(i, sync, iterable));
392 } 390 }
393 return rval; 391 return rval;
394 }, 392 },
395 393
396 /** @id MochiKit.Iter.list */ 394 /** @id MochiKit.Iter.list */
397 list: function (iterable) { 395 list: function (iterable) {
398 // Fast-path for Array and Array-like 396 // Fast-path for Array and Array-like
399 var rval; 397 var rval;
400 if (iterable instanceof Array) { 398 if (iterable instanceof Array) {
401 return iterable.slice(); 399 return iterable.slice();
402 } 400 }
403 // this is necessary to avoid a Safari crash 401 // this is necessary to avoid a Safari crash
404 if (typeof(iterable) == "function" && 402 if (typeof(iterable) == "function" &&
405 !(iterable instanceof Function) && 403 !(iterable instanceof Function) &&
406 typeof(iterable.length) == 'number') { 404 typeof(iterable.length) == 'number') {
407 rval = []; 405 rval = [];
408 for (var i = 0; i < iterable.length; i++) { 406 for (var i = 0; i < iterable.length; i++) {
409 rval.push(iterable[i]); 407 rval.push(iterable[i]);
410 } 408 }
411 return rval; 409 return rval;
412 } 410 }
413 411
414 var self = MochiKit.Iter; 412 var self = MochiKit.Iter;
415 iterable = self.iter(iterable); 413 iterable = self.iter(iterable);
416 var rval = []; 414 rval = [];
417 var a_val; 415 var a_val;
418 try { 416 try {
419 while (true) { 417 while (true) {
420 a_val = iterable.next(); 418 a_val = iterable.next();
421 rval.push(a_val); 419 rval.push(a_val);
422 } 420 }
423 } catch (e) { 421 } catch (e) {
424 if (e != self.StopIteration) { 422 if (e != self.StopIteration) {
425 throw e; 423 throw e;
426 } 424 }
427 return rval; 425 return rval;
428 } 426 }
429 // mozilla warnings aren't too bright 427 // mozilla warnings aren't too bright
430 return undefined; 428 return undefined;
431 }, 429 },
432 430
433 431
434 /** @id MochiKit.Iter.reduce */ 432 /** @id MochiKit.Iter.reduce */
435 reduce: function (fn, iterable, /* optional */initial) { 433 reduce: function (fn, iterable, /* optional */initial) {
436 var i = 0; 434 var i = 0;
437 var x = initial; 435 var x = initial;
438 var self = MochiKit.Iter; 436 var self = MochiKit.Iter;
439 iterable = self.iter(iterable); 437 iterable = self.iter(iterable);
440 if (arguments.length < 3) { 438 if (arguments.length < 3) {
441 try { 439 try {
442 x = iterable.next(); 440 x = iterable.next();
443 } catch (e) { 441 } catch (e) {
444 if (e == self.StopIteration) { 442 if (e == self.StopIteration) {
445 e = new TypeError("reduce() of empty sequence with no initial value"); 443 e = new TypeError("reduce() of empty sequence with no initial value");
446 } 444 }
447 throw e; 445 throw e;
448 } 446 }
449 i++; 447 i++;
450 } 448 }
451 try { 449 try {
452 while (true) { 450 while (true) {
453 x = fn(x, iterable.next()); 451 x = fn(x, iterable.next());
454 } 452 }
455 } catch (e) { 453 } catch (e) {
456 if (e != self.StopIteration) { 454 if (e != self.StopIteration) {
457 throw e; 455 throw e;
458 } 456 }
459 } 457 }
460 return x; 458 return x;
461 }, 459 },
462 460
463 /** @id MochiKit.Iter.range */ 461 /** @id MochiKit.Iter.range */
464 range: function (/* [start,] stop[, step] */) { 462 range: function (/* [start,] stop[, step] */) {
465 var start = 0; 463 var start = 0;
466 var stop = 0; 464 var stop = 0;
467 var step = 1; 465 var step = 1;
468 if (arguments.length == 1) { 466 if (arguments.length == 1) {
469 stop = arguments[0]; 467 stop = arguments[0];
470 } else if (arguments.length == 2) { 468 } else if (arguments.length == 2) {
471 start = arguments[0]; 469 start = arguments[0];
472 stop = arguments[1]; 470 stop = arguments[1];
473 } else if (arguments.length == 3) { 471 } else if (arguments.length == 3) {
474 start = arguments[0]; 472 start = arguments[0];
475 stop = arguments[1]; 473 stop = arguments[1];
476 step = arguments[2]; 474 step = arguments[2];
477 } else { 475 } else {
478 throw new TypeError("range() takes 1, 2, or 3 arguments!"); 476 throw new TypeError("range() takes 1, 2, or 3 arguments!");
479 } 477 }
480 if (step === 0) { 478 if (step === 0) {
481 throw new TypeError("range() step must not be 0"); 479 throw new TypeError("range() step must not be 0");
482 } 480 }
483 return { 481 return {
484 next: function () { 482 next: function () {
485 if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) { 483 if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
486 throw MochiKit.Iter.StopIteration; 484 throw MochiKit.Iter.StopIteration;
487 } 485 }
488 var rval = start; 486 var rval = start;
489 start += step; 487 start += step;
490 return rval; 488 return rval;
491 }, 489 },
492 repr: function () { 490 repr: function () {
493 return "range(" + [start, stop, step].join(", ") + ")"; 491 return "range(" + [start, stop, step].join(", ") + ")";
494 }, 492 },
495 toString: MochiKit.Base.forwardCall("repr") 493 toString: MochiKit.Base.forwardCall("repr")
496 }; 494 };
497 }, 495 },
498 496
499 /** @id MochiKit.Iter.sum */ 497 /** @id MochiKit.Iter.sum */
500 sum: function (iterable, start/* = 0 */) { 498 sum: function (iterable, start/* = 0 */) {
501 if (typeof(start) == "undefined" || start === null) { 499 if (typeof(start) == "undefined" || start === null) {
502 start = 0; 500 start = 0;
503 } 501 }
504 var x = start; 502 var x = start;
505 var self = MochiKit.Iter; 503 var self = MochiKit.Iter;
506 iterable = self.iter(iterable); 504 iterable = self.iter(iterable);
507 try { 505 try {
508 while (true) { 506 while (true) {
509 x += iterable.next(); 507 x += iterable.next();
510 } 508 }
511 } catch (e) { 509 } catch (e) {
512 if (e != self.StopIteration) { 510 if (e != self.StopIteration) {
513 throw e; 511 throw e;
514 } 512 }
515 } 513 }
516 return x; 514 return x;
517 }, 515 },
518 516
519 /** @id MochiKit.Iter.exhaust */ 517 /** @id MochiKit.Iter.exhaust */
520 exhaust: function (iterable) { 518 exhaust: function (iterable) {
521 var self = MochiKit.Iter; 519 var self = MochiKit.Iter;
522 iterable = self.iter(iterable); 520 iterable = self.iter(iterable);
523 try { 521 try {
524 while (true) { 522 while (true) {
525 iterable.next(); 523 iterable.next();
526 } 524 }
527 } catch (e) { 525 } catch (e) {
528 if (e != self.StopIteration) { 526 if (e != self.StopIteration) {
529 throw e; 527 throw e;
530 } 528 }
531 } 529 }
532 }, 530 },
533 531
534 /** @id MochiKit.Iter.forEach */ 532 /** @id MochiKit.Iter.forEach */
535 forEach: function (iterable, func, /* optional */obj) { 533 forEach: function (iterable, func, /* optional */obj) {
536 var m = MochiKit.Base; 534 var m = MochiKit.Base;
537 var self = MochiKit.Iter; 535 var self = MochiKit.Iter;
538 if (arguments.length > 2) { 536 if (arguments.length > 2) {
539 func = m.bind(func, obj); 537 func = m.bind(func, obj);
540 } 538 }
541 // fast path for array 539 // fast path for array
542 if (m.isArrayLike(iterable) && !self.isIterable(iterable)) { 540 if (m.isArrayLike(iterable) && !self.isIterable(iterable)) {
543 try { 541 try {
544 for (var i = 0; i < iterable.length; i++) { 542 for (var i = 0; i < iterable.length; i++) {
545 func(iterable[i]); 543 func(iterable[i]);
546 } 544 }
547 } catch (e) { 545 } catch (e) {
548 if (e != self.StopIteration) { 546 if (e != self.StopIteration) {
549 throw e; 547 throw e;
550 } 548 }
551 } 549 }
552 } else { 550 } else {
553 self.exhaust(self.imap(func, iterable)); 551 self.exhaust(self.imap(func, iterable));
554 } 552 }
555 }, 553 },
556 554
557 /** @id MochiKit.Iter.every */ 555 /** @id MochiKit.Iter.every */
558 every: function (iterable, func) { 556 every: function (iterable, func) {
559 var self = MochiKit.Iter; 557 var self = MochiKit.Iter;
560 try { 558 try {
561 self.ifilterfalse(func, iterable).next(); 559 self.ifilterfalse(func, iterable).next();
562 return false; 560 return false;
563 } catch (e) { 561 } catch (e) {
564 if (e != self.StopIteration) { 562 if (e != self.StopIteration) {
565 throw e; 563 throw e;
566 } 564 }
567 return true; 565 return true;
568 } 566 }
569 }, 567 },
570 568
571 /** @id MochiKit.Iter.sorted */ 569 /** @id MochiKit.Iter.sorted */
572 sorted: function (iterable, /* optional */cmp) { 570 sorted: function (iterable, /* optional */cmp) {
573 var rval = MochiKit.Iter.list(iterable); 571 var rval = MochiKit.Iter.list(iterable);
574 if (arguments.length == 1) { 572 if (arguments.length == 1) {
575 cmp = MochiKit.Base.compare; 573 cmp = MochiKit.Base.compare;
576 } 574 }
577 rval.sort(cmp); 575 rval.sort(cmp);
578 return rval; 576 return rval;
579 }, 577 },
580 578
581 /** @id MochiKit.Iter.reversed */ 579 /** @id MochiKit.Iter.reversed */
582 reversed: function (iterable) { 580 reversed: function (iterable) {
583 var rval = MochiKit.Iter.list(iterable); 581 var rval = MochiKit.Iter.list(iterable);
584 rval.reverse(); 582 rval.reverse();
585 return rval; 583 return rval;
586 }, 584 },
587 585
588 /** @id MochiKit.Iter.some */ 586 /** @id MochiKit.Iter.some */
589 some: function (iterable, func) { 587 some: function (iterable, func) {
590 var self = MochiKit.Iter; 588 var self = MochiKit.Iter;
591 try { 589 try {
592 self.ifilter(func, iterable).next(); 590 self.ifilter(func, iterable).next();
593 return true; 591 return true;
594 } catch (e) { 592 } catch (e) {
595 if (e != self.StopIteration) { 593 if (e != self.StopIteration) {
596 throw e; 594 throw e;
597 } 595 }
598 return false; 596 return false;
599 } 597 }
600 }, 598 },
601 599
602 /** @id MochiKit.Iter.iextend */ 600 /** @id MochiKit.Iter.iextend */
603 iextend: function (lst, iterable) { 601 iextend: function (lst, iterable) {
604 var m = MochiKit.Base; 602 var m = MochiKit.Base;
605 var self = MochiKit.Iter; 603 var self = MochiKit.Iter;
606 if (m.isArrayLike(iterable) && !self.isIterable(iterable)) { 604 if (m.isArrayLike(iterable) && !self.isIterable(iterable)) {
607 // fast-path for array-like 605 // fast-path for array-like
608 for (var i = 0; i < iterable.length; i++) { 606 for (var i = 0; i < iterable.length; i++) {
609 lst.push(iterable[i]); 607 lst.push(iterable[i]);
610 } 608 }
611 } else { 609 } else {
612 iterable = self.iter(iterable); 610 iterable = self.iter(iterable);
613 try { 611 try {
614 while (true) { 612 while (true) {
615 lst.push(iterable.next()); 613 lst.push(iterable.next());
616 } 614 }
617 } catch (e) { 615 } catch (e) {
618 if (e != self.StopIteration) { 616 if (e != self.StopIteration) {
619 throw e; 617 throw e;
620 } 618 }
621 } 619 }
622 } 620 }
623 return lst; 621 return lst;
624 }, 622 },
625 623
626 /** @id MochiKit.Iter.groupby */ 624 /** @id MochiKit.Iter.groupby */
627 groupby: function(iterable, /* optional */ keyfunc) { 625 groupby: function(iterable, /* optional */ keyfunc) {
628 var m = MochiKit.Base; 626 var m = MochiKit.Base;
629 var self = MochiKit.Iter; 627 var self = MochiKit.Iter;
630 if (arguments.length < 2) { 628 if (arguments.length < 2) {
631 keyfunc = m.operator.identity; 629 keyfunc = m.operator.identity;
632 } 630 }
633 iterable = self.iter(iterable); 631 iterable = self.iter(iterable);
634 632
635 // shared 633 // shared
636 var pk = undefined; 634 var pk = undefined;
637 var k = undefined; 635 var k = undefined;
638 var v; 636 var v;
639 637
640 function fetch() { 638 function fetch() {
641 v = iterable.next(); 639 v = iterable.next();
642 k = keyfunc(v); 640 k = keyfunc(v);
643 }; 641 };
644 642
645 function eat() { 643 function eat() {
646 var ret = v; 644 var ret = v;
647 v = undefined; 645 v = undefined;
648 return ret; 646 return ret;
649 }; 647 };
650 648
651 var first = true; 649 var first = true;
652 var compare = m.compare; 650 var compare = m.compare;
653 return { 651 return {
654 repr: function () { return "groupby(...)"; }, 652 repr: function () { return "groupby(...)"; },
655 next: function() { 653 next: function() {
656 // iterator-next 654 // iterator-next
657 655
658 // iterate until meet next group 656 // iterate until meet next group
659 while (compare(k, pk) === 0) { 657 while (compare(k, pk) === 0) {
660 fetch(); 658 fetch();
661 if (first) { 659 if (first) {
662 first = false; 660 first = false;
663 break; 661 break;
664 } 662 }
665 } 663 }
666 pk = k; 664 pk = k;
667 return [k, { 665 return [k, {
668 next: function() { 666 next: function() {
669 // subiterator-next 667 // subiterator-next
670 if (v == undefined) { // Is there something to eat? 668 if (v == undefined) { // Is there something to eat?
671 fetch(); 669 fetch();
672 } 670 }
diff --git a/frontend/gamma/js/MochiKit/Logging.js b/frontend/gamma/js/MochiKit/Logging.js
index f00996b..8b06e0b 100644
--- a/frontend/gamma/js/MochiKit/Logging.js
+++ b/frontend/gamma/js/MochiKit/Logging.js
@@ -1,262 +1,262 @@
1/*** 1/***
2 2
3MochiKit.Logging 1.5 3MochiKit.Logging 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Logging', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'Logging', '1.5', ['Base']);
12 12
13 /** @id MochiKit.Logging.LogMessage */ 13 /** @id MochiKit.Logging.LogMessage */
14MochiKit.Logging.LogMessage = function (num, level, info) { 14MochiKit.Logging.LogMessage = function (num, level, info) {
15 this.num = num; 15 this.num = num;
16 this.level = level; 16 this.level = level;
17 this.info = info; 17 this.info = info;
18 this.timestamp = new Date(); 18 this.timestamp = new Date();
19}; 19};
20 20
21MochiKit.Logging.LogMessage.prototype = { 21MochiKit.Logging.LogMessage.prototype = {
22 /** @id MochiKit.Logging.LogMessage.prototype.repr */ 22 /** @id MochiKit.Logging.LogMessage.prototype.repr */
23 repr: function () { 23 repr: function () {
24 var m = MochiKit.Base; 24 var m = MochiKit.Base;
25 return 'LogMessage(' + 25 return 'LogMessage(' +
26 m.map( 26 m.map(
27 m.repr, 27 m.repr,
28 [this.num, this.level, this.info] 28 [this.num, this.level, this.info]
29 ).join(', ') + ')'; 29 ).join(', ') + ')';
30 }, 30 },
31 /** @id MochiKit.Logging.LogMessage.prototype.toString */ 31 /** @id MochiKit.Logging.LogMessage.prototype.toString */
32 toString: MochiKit.Base.forwardCall("repr") 32 toString: MochiKit.Base.forwardCall("repr")
33}; 33};
34 34
35MochiKit.Base.update(MochiKit.Logging, { 35MochiKit.Base.update(MochiKit.Logging, {
36 /** @id MochiKit.Logging.logLevelAtLeast */ 36 /** @id MochiKit.Logging.logLevelAtLeast */
37 logLevelAtLeast: function (minLevel) { 37 logLevelAtLeast: function (minLevel) {
38 var self = MochiKit.Logging; 38 var self = MochiKit.Logging;
39 if (typeof(minLevel) == 'string') { 39 if (typeof(minLevel) == 'string') {
40 minLevel = self.LogLevel[minLevel]; 40 minLevel = self.LogLevel[minLevel];
41 } 41 }
42 return function (msg) { 42 return function (msg) {
43 var msgLevel = msg.level; 43 var msgLevel = msg.level;
44 if (typeof(msgLevel) == 'string') { 44 if (typeof(msgLevel) == 'string') {
45 msgLevel = self.LogLevel[msgLevel]; 45 msgLevel = self.LogLevel[msgLevel];
46 } 46 }
47 return msgLevel >= minLevel; 47 return msgLevel >= minLevel;
48 }; 48 };
49 }, 49 },
50 50
51 /** @id MochiKit.Logging.isLogMessage */ 51 /** @id MochiKit.Logging.isLogMessage */
52 isLogMessage: function (/* ... */) { 52 isLogMessage: function (/* ... */) {
53 var LogMessage = MochiKit.Logging.LogMessage; 53 var LogMessage = MochiKit.Logging.LogMessage;
54 for (var i = 0; i < arguments.length; i++) { 54 for (var i = 0; i < arguments.length; i++) {
55 if (!(arguments[i] instanceof LogMessage)) { 55 if (!(arguments[i] instanceof LogMessage)) {
56 return false; 56 return false;
57 } 57 }
58 } 58 }
59 return true; 59 return true;
60 }, 60 },
61 61
62 /** @id MochiKit.Logging.compareLogMessage */ 62 /** @id MochiKit.Logging.compareLogMessage */
63 compareLogMessage: function (a, b) { 63 compareLogMessage: function (a, b) {
64 return MochiKit.Base.compare([a.level, a.info], [b.level, b.info]); 64 return MochiKit.Base.compare([a.level, a.info], [b.level, b.info]);
65 }, 65 },
66 66
67 /** @id MochiKit.Logging.alertListener */ 67 /** @id MochiKit.Logging.alertListener */
68 alertListener: function (msg) { 68 alertListener: function (msg) {
69 alert( 69 alert(
70 "num: " + msg.num + 70 "num: " + msg.num +
71 "\nlevel: " + msg.level + 71 "\nlevel: " + msg.level +
72 "\ninfo: " + msg.info.join(" ") 72 "\ninfo: " + msg.info.join(" ")
73 ); 73 );
74 } 74 }
75 75
76}); 76});
77 77
78/** @id MochiKit.Logging.Logger */ 78/** @id MochiKit.Logging.Logger */
79MochiKit.Logging.Logger = function (/* optional */maxSize) { 79MochiKit.Logging.Logger = function (/* optional */maxSize) {
80 this.counter = 0; 80 this.counter = 0;
81 if (typeof(maxSize) == 'undefined' || maxSize === null) { 81 if (typeof(maxSize) == 'undefined' || maxSize === null) {
82 maxSize = -1; 82 maxSize = -1;
83 } 83 }
84 this.maxSize = maxSize; 84 this.maxSize = maxSize;
85 this._messages = []; 85 this._messages = [];
86 this.listeners = {}; 86 this.listeners = {};
87 this.useNativeConsole = false; 87 this.useNativeConsole = false;
88}; 88};
89 89
90MochiKit.Logging.Logger.prototype = { 90MochiKit.Logging.Logger.prototype = {
91 /** @id MochiKit.Logging.Logger.prototype.clear */ 91 /** @id MochiKit.Logging.Logger.prototype.clear */
92 clear: function () { 92 clear: function () {
93 this._messages.splice(0, this._messages.length); 93 this._messages.splice(0, this._messages.length);
94 }, 94 },
95 95
96 /** @id MochiKit.Logging.Logger.prototype.logToConsole */ 96 /** @id MochiKit.Logging.Logger.prototype.logToConsole */
97 logToConsole: function (msg) { 97 logToConsole: function (msg) {
98 if (typeof(window) != "undefined" && window.console 98 if (typeof(window) != "undefined" && window.console
99 && window.console.log) { 99 && window.console.log) {
100 // Safari and FireBug 0.4 100 // Safari and FireBug 0.4
101 // Percent replacement is a workaround for cute Safari crashing bug 101 // Percent replacement is a workaround for cute Safari crashing bug
102 window.console.log(msg.replace(/%/g, '\uFF05')); 102 window.console.log(msg.replace(/%/g, '\uFF05'));
103 } else if (typeof(opera) != "undefined" && opera.postError) { 103 } else if (typeof(opera) != "undefined" && opera.postError) {
104 // Opera 104 // Opera
105 opera.postError(msg); 105 opera.postError(msg);
106 } else if (typeof(Debug) != "undefined" && Debug.writeln) { 106 } else if (typeof(Debug) != "undefined" && Debug.writeln) {
107 // IE Web Development Helper (?) 107 // IE Web Development Helper (?)
108 // http://www.nikhilk.net/Entry.aspx?id=93 108 // http://www.nikhilk.net/Entry.aspx?id=93
109 Debug.writeln(msg); 109 Debug.writeln(msg);
110 } else if (typeof(debug) != "undefined" && debug.trace) { 110 } else if (typeof(debug) != "undefined" && debug.trace) {
111 // Atlas framework (?) 111 // Atlas framework (?)
112 // http://www.nikhilk.net/Entry.aspx?id=93 112 // http://www.nikhilk.net/Entry.aspx?id=93
113 debug.trace(msg); 113 debug.trace(msg);
114 } 114 }
115 }, 115 },
116 116
117 /** @id MochiKit.Logging.Logger.prototype.dispatchListeners */ 117 /** @id MochiKit.Logging.Logger.prototype.dispatchListeners */
118 dispatchListeners: function (msg) { 118 dispatchListeners: function (msg) {
119 for (var k in this.listeners) { 119 for (var k in this.listeners) {
120 var pair = this.listeners[k]; 120 var pair = this.listeners[k];
121 if (pair.ident != k || (pair[0] && !pair[0](msg))) { 121 if (pair.ident != k || (pair[0] && !pair[0](msg))) {
122 continue; 122 continue;
123 } 123 }
124 pair[1](msg); 124 pair[1](msg);
125 } 125 }
126 }, 126 },
127 127
128 /** @id MochiKit.Logging.Logger.prototype.addListener */ 128 /** @id MochiKit.Logging.Logger.prototype.addListener */
129 addListener: function (ident, filter, listener) { 129 addListener: function (ident, filter, listener) {
130 if (typeof(filter) == 'string') { 130 if (typeof(filter) == 'string') {
131 filter = MochiKit.Logging.logLevelAtLeast(filter); 131 filter = MochiKit.Logging.logLevelAtLeast(filter);
132 } 132 }
133 var entry = [filter, listener]; 133 var entry = [filter, listener];
134 entry.ident = ident; 134 entry.ident = ident;
135 this.listeners[ident] = entry; 135 this.listeners[ident] = entry;
136 }, 136 },
137 137
138 /** @id MochiKit.Logging.Logger.prototype.removeListener */ 138 /** @id MochiKit.Logging.Logger.prototype.removeListener */
139 removeListener: function (ident) { 139 removeListener: function (ident) {
140 delete this.listeners[ident]; 140 delete this.listeners[ident];
141 }, 141 },
142 142
143 /** @id MochiKit.Logging.Logger.prototype.baseLog */ 143 /** @id MochiKit.Logging.Logger.prototype.baseLog */
144 baseLog: function (level, message/*, ...*/) { 144 baseLog: function (level, message/*, ...*/) {
145 if (typeof(level) == "number") { 145 if (typeof(level) == "number") {
146 if (level >= MochiKit.Logging.LogLevel.FATAL) { 146 if (level >= MochiKit.Logging.LogLevel.FATAL) {
147 level = 'FATAL'; 147 level = 'FATAL';
148 } else if (level >= MochiKit.Logging.LogLevel.ERROR) { 148 } else if (level >= MochiKit.Logging.LogLevel.ERROR) {
149 level = 'ERROR'; 149 level = 'ERROR';
150 } else if (level >= MochiKit.Logging.LogLevel.WARNING) { 150 } else if (level >= MochiKit.Logging.LogLevel.WARNING) {
151 level = 'WARNING'; 151 level = 'WARNING';
152 } else if (level >= MochiKit.Logging.LogLevel.INFO) { 152 } else if (level >= MochiKit.Logging.LogLevel.INFO) {
153 level = 'INFO'; 153 level = 'INFO';
154 } else { 154 } else {
155 level = 'DEBUG'; 155 level = 'DEBUG';
156 } 156 }
157 } 157 }
158 var msg = new MochiKit.Logging.LogMessage( 158 var msg = new MochiKit.Logging.LogMessage(
159 this.counter, 159 this.counter,
160 level, 160 level,
161 MochiKit.Base.extend(null, arguments, 1) 161 MochiKit.Base.extend(null, arguments, 1)
162 ); 162 );
163 this._messages.push(msg); 163 this._messages.push(msg);
164 this.dispatchListeners(msg); 164 this.dispatchListeners(msg);
165 if (this.useNativeConsole) { 165 if (this.useNativeConsole) {
166 this.logToConsole(msg.level + ": " + msg.info.join(" ")); 166 this.logToConsole(msg.level + ": " + msg.info.join(" "));
167 } 167 }
168 this.counter += 1; 168 this.counter += 1;
169 while (this.maxSize >= 0 && this._messages.length > this.maxSize) { 169 while (this.maxSize >= 0 && this._messages.length > this.maxSize) {
170 this._messages.shift(); 170 this._messages.shift();
171 } 171 }
172 }, 172 },
173 173
174 /** @id MochiKit.Logging.Logger.prototype.getMessages */ 174 /** @id MochiKit.Logging.Logger.prototype.getMessages */
175 getMessages: function (howMany) { 175 getMessages: function (howMany) {
176 var firstMsg = 0; 176 var firstMsg = 0;
177 if (!(typeof(howMany) == 'undefined' || howMany === null)) { 177 if (!(typeof(howMany) == 'undefined' || howMany === null)) {
178 firstMsg = Math.max(0, this._messages.length - howMany); 178 firstMsg = Math.max(0, this._messages.length - howMany);
179 } 179 }
180 return this._messages.slice(firstMsg); 180 return this._messages.slice(firstMsg);
181 }, 181 },
182 182
183 /** @id MochiKit.Logging.Logger.prototype.getMessageText */ 183 /** @id MochiKit.Logging.Logger.prototype.getMessageText */
184 getMessageText: function (howMany) { 184 getMessageText: function (howMany) {
185 if (typeof(howMany) == 'undefined' || howMany === null) { 185 if (typeof(howMany) == 'undefined' || howMany === null) {
186 howMany = 30; 186 howMany = 30;
187 } 187 }
188 var messages = this.getMessages(howMany); 188 var messages = this.getMessages(howMany);
189 if (messages.length) { 189 if (messages.length) {
190 var lst = map(function (m) { 190 var lst = MochiKit.Base.map(function (m) {
191 return '\n [' + m.num + '] ' + m.level + ': ' + m.info.join(' '); 191 return '\n [' + m.num + '] ' + m.level + ': ' + m.info.join(' ');
192 }, messages); 192 }, messages);
193 lst.unshift('LAST ' + messages.length + ' MESSAGES:'); 193 lst.unshift('LAST ' + messages.length + ' MESSAGES:');
194 return lst.join(''); 194 return lst.join('');
195 } 195 }
196 return ''; 196 return '';
197 }, 197 },
198 198
199 /** @id MochiKit.Logging.Logger.prototype.debuggingBookmarklet */ 199 /** @id MochiKit.Logging.Logger.prototype.debuggingBookmarklet */
200 debuggingBookmarklet: function (inline) { 200 debuggingBookmarklet: function (inline) {
201 if (typeof(MochiKit.LoggingPane) == "undefined") { 201 if (typeof(MochiKit.LoggingPane) == "undefined") {
202 alert(this.getMessageText()); 202 alert(this.getMessageText());
203 } else { 203 } else {
204 MochiKit.LoggingPane.createLoggingPane(inline || false); 204 MochiKit.LoggingPane.createLoggingPane(inline || false);
205 } 205 }
206 } 206 }
207}; 207};
208 208
209MochiKit.Logging.__new__ = function () { 209MochiKit.Logging.__new__ = function () {
210 this.LogLevel = { 210 this.LogLevel = {
211 ERROR: 40, 211 ERROR: 40,
212 FATAL: 50, 212 FATAL: 50,
213 WARNING: 30, 213 WARNING: 30,
214 INFO: 20, 214 INFO: 20,
215 DEBUG: 10 215 DEBUG: 10
216 }; 216 };
217 217
218 var m = MochiKit.Base; 218 var m = MochiKit.Base;
219 m.registerComparator("LogMessage", 219 m.registerComparator("LogMessage",
220 this.isLogMessage, 220 this.isLogMessage,
221 this.compareLogMessage 221 this.compareLogMessage
222 ); 222 );
223 223
224 var partial = m.partial; 224 var partial = m.partial;
225 225
226 var Logger = this.Logger; 226 var Logger = this.Logger;
227 var baseLog = Logger.prototype.baseLog; 227 var baseLog = Logger.prototype.baseLog;
228 m.update(this.Logger.prototype, { 228 m.update(this.Logger.prototype, {
229 debug: partial(baseLog, 'DEBUG'), 229 debug: partial(baseLog, 'DEBUG'),
230 log: partial(baseLog, 'INFO'), 230 log: partial(baseLog, 'INFO'),
231 error: partial(baseLog, 'ERROR'), 231 error: partial(baseLog, 'ERROR'),
232 fatal: partial(baseLog, 'FATAL'), 232 fatal: partial(baseLog, 'FATAL'),
233 warning: partial(baseLog, 'WARNING') 233 warning: partial(baseLog, 'WARNING')
234 }); 234 });
235 235
236 // indirectly find logger so it can be replaced 236 // indirectly find logger so it can be replaced
237 var self = this; 237 var self = this;
238 var connectLog = function (name) { 238 var connectLog = function (name) {
239 return function () { 239 return function () {
240 self.logger[name].apply(self.logger, arguments); 240 self.logger[name].apply(self.logger, arguments);
241 }; 241 };
242 }; 242 };
243 243
244 /** @id MochiKit.Logging.log */ 244 /** @id MochiKit.Logging.log */
245 this.log = connectLog('log'); 245 this.log = connectLog('log');
246 /** @id MochiKit.Logging.logError */ 246 /** @id MochiKit.Logging.logError */
247 this.logError = connectLog('error'); 247 this.logError = connectLog('error');
248 /** @id MochiKit.Logging.logDebug */ 248 /** @id MochiKit.Logging.logDebug */
249 this.logDebug = connectLog('debug'); 249 this.logDebug = connectLog('debug');
250 /** @id MochiKit.Logging.logFatal */ 250 /** @id MochiKit.Logging.logFatal */
251 this.logFatal = connectLog('fatal'); 251 this.logFatal = connectLog('fatal');
252 /** @id MochiKit.Logging.logWarning */ 252 /** @id MochiKit.Logging.logWarning */
253 this.logWarning = connectLog('warning'); 253 this.logWarning = connectLog('warning');
254 this.logger = new Logger(); 254 this.logger = new Logger();
255 this.logger.useNativeConsole = true; 255 this.logger.useNativeConsole = true;
256 256
257 m.nameFunctions(this); 257 m.nameFunctions(this);
258}; 258};
259 259
260MochiKit.Logging.__new__(); 260MochiKit.Logging.__new__();
261 261
262MochiKit.Base._exportSymbols(this, MochiKit.Logging); 262MochiKit.Base._exportSymbols(this, MochiKit.Logging);
diff --git a/frontend/gamma/js/MochiKit/LoggingPane.js b/frontend/gamma/js/MochiKit/LoggingPane.js
index c960c21..b7ea120 100644
--- a/frontend/gamma/js/MochiKit/LoggingPane.js
+++ b/frontend/gamma/js/MochiKit/LoggingPane.js
@@ -1,327 +1,330 @@
1/*** 1/***
2 2
3MochiKit.LoggingPane 1.5 3MochiKit.LoggingPane 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('LoggingPane', '1.5', ['Base', 'Logging']); 11MochiKit.Base.module(MochiKit, 'LoggingPane', '1.5', ['Base', 'Logging']);
12 12
13/** @id MochiKit.LoggingPane.createLoggingPane */ 13/** @id MochiKit.LoggingPane.createLoggingPane */
14MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) { 14MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) {
15 var m = MochiKit.LoggingPane; 15 var m = MochiKit.LoggingPane;
16 inline = !(!inline); 16 inline = !(!inline);
17 if (m._loggingPane && m._loggingPane.inline != inline) { 17 if (m._loggingPane && m._loggingPane.inline != inline) {
18 m._loggingPane.closePane(); 18 m._loggingPane.closePane();
19 m._loggingPane = null; 19 m._loggingPane = null;
20 } 20 }
21 if (!m._loggingPane || m._loggingPane.closed) { 21 if (!m._loggingPane || m._loggingPane.closed) {
22 m._loggingPane = new m.LoggingPane(inline, MochiKit.Logging.logger); 22 m._loggingPane = new m.LoggingPane(inline, MochiKit.Logging.logger);
23 } 23 }
24 return m._loggingPane; 24 return m._loggingPane;
25}; 25};
26 26
27/** @id MochiKit.LoggingPane.LoggingPane */ 27/**
28 * @id MochiKit.LoggingPane.LoggingPane
29 * @constructor
30 */
28MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = MochiKit.Logging.logger */) { 31MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = MochiKit.Logging.logger */) {
29 32
30 /* Use a div if inline, pop up a window if not */ 33 /* Use a div if inline, pop up a window if not */
31 /* Create the elements */ 34 /* Create the elements */
32 if (typeof(logger) == "undefined" || logger === null) { 35 if (typeof(logger) == "undefined" || logger === null) {
33 logger = MochiKit.Logging.logger; 36 logger = MochiKit.Logging.logger;
34 } 37 }
35 this.logger = logger; 38 this.logger = logger;
36 var update = MochiKit.Base.update; 39 var update = MochiKit.Base.update;
37 var updatetree = MochiKit.Base.updatetree; 40 var updatetree = MochiKit.Base.updatetree;
38 var bind = MochiKit.Base.bind; 41 var bind = MochiKit.Base.bind;
39 var clone = MochiKit.Base.clone; 42 var clone = MochiKit.Base.clone;
40 var win = window; 43 var win = window;
41 var uid = "_MochiKit_LoggingPane"; 44 var uid = "_MochiKit_LoggingPane";
42 if (typeof(MochiKit.DOM) != "undefined") { 45 if (typeof(MochiKit.DOM) != "undefined") {
43 win = MochiKit.DOM.currentWindow(); 46 win = MochiKit.DOM.currentWindow();
44 } 47 }
45 if (!inline) { 48 if (!inline) {
46 // name the popup with the base URL for uniqueness 49 // name the popup with the base URL for uniqueness
47 var url = win.location.href.split("?")[0].replace(/[#:\/.><&%-]/g, "_"); 50 var url = win.location.href.split("?")[0].replace(/[#:\/.><&%-]/g, "_");
48 var name = uid + "_" + url; 51 var name = uid + "_" + url;
49 var nwin = win.open("", name, "dependent,resizable,height=200"); 52 var nwin = win.open("", name, "dependent,resizable,height=200");
50 if (!nwin) { 53 if (!nwin) {
51 alert("Not able to open debugging window due to pop-up blocking."); 54 alert("Not able to open debugging window due to pop-up blocking.");
52 return undefined; 55 return undefined;
53 } 56 }
54 nwin.document.write( 57 nwin.document.write(
55 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ' 58 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" '
56 + '"http://www.w3.org/TR/html4/loose.dtd">' 59 + '"http://www.w3.org/TR/html4/loose.dtd">'
57 + '<html><head><title>[MochiKit.LoggingPane]</title></head>' 60 + '<html><head><title>[MochiKit.LoggingPane]</title></head>'
58 + '<body></body></html>' 61 + '<body></body></html>'
59 ); 62 );
60 nwin.document.close(); 63 nwin.document.close();
61 nwin.document.title += ' ' + win.document.title; 64 nwin.document.title += ' ' + win.document.title;
62 win = nwin; 65 win = nwin;
63 } 66 }
64 var doc = win.document; 67 var doc = win.document;
65 this.doc = doc; 68 this.doc = doc;
66 69
67 // Connect to the debug pane if it already exists (i.e. in a window orphaned by the page being refreshed) 70 // Connect to the debug pane if it already exists (i.e. in a window orphaned by the page being refreshed)
68 var debugPane = doc.getElementById(uid); 71 var debugPane = doc.getElementById(uid);
69 var existing_pane = !!debugPane; 72 var existing_pane = !!debugPane;
70 if (debugPane && typeof(debugPane.loggingPane) != "undefined") { 73 if (debugPane && typeof(debugPane.loggingPane) != "undefined") {
71 debugPane.loggingPane.logger = this.logger; 74 debugPane.loggingPane.logger = this.logger;
72 debugPane.loggingPane.buildAndApplyFilter(); 75 debugPane.loggingPane.buildAndApplyFilter();
73 return debugPane.loggingPane; 76 return debugPane.loggingPane;
74 } 77 }
75 78
76 if (existing_pane) { 79 if (existing_pane) {
77 // clear any existing contents 80 // clear any existing contents
78 var child; 81 var child;
79 while ((child = debugPane.firstChild)) { 82 while ((child = debugPane.firstChild)) {
80 debugPane.removeChild(child); 83 debugPane.removeChild(child);
81 } 84 }
82 } else { 85 } else {
83 debugPane = doc.createElement("div"); 86 debugPane = doc.createElement("div");
84 debugPane.id = uid; 87 debugPane.id = uid;
85 } 88 }
86 debugPane.loggingPane = this; 89 debugPane.loggingPane = this;
87 var levelFilterField = doc.createElement("input"); 90 var levelFilterField = doc.createElement("input");
88 var infoFilterField = doc.createElement("input"); 91 var infoFilterField = doc.createElement("input");
89 var filterButton = doc.createElement("button"); 92 var filterButton = doc.createElement("button");
90 var loadButton = doc.createElement("button"); 93 var loadButton = doc.createElement("button");
91 var clearButton = doc.createElement("button"); 94 var clearButton = doc.createElement("button");
92 var closeButton = doc.createElement("button"); 95 var closeButton = doc.createElement("button");
93 var logPaneArea = doc.createElement("div"); 96 var logPaneArea = doc.createElement("div");
94 var logPane = doc.createElement("div"); 97 var logPane = doc.createElement("div");
95 98
96 /* Set up the functions */ 99 /* Set up the functions */
97 var listenerId = uid + "_Listener"; 100 var listenerId = uid + "_Listener";
98 this.colorTable = clone(this.colorTable); 101 this.colorTable = clone(this.colorTable);
99 var messages = []; 102 var messages = [];
100 var messageFilter = null; 103 var messageFilter = null;
101 104
102 /** @id MochiKit.LoggingPane.messageLevel */ 105 /** @id MochiKit.LoggingPane.messageLevel */
103 var messageLevel = function (msg) { 106 var messageLevel = function (msg) {
104 var level = msg.level; 107 var level = msg.level;
105 if (typeof(level) == "number") { 108 if (typeof(level) == "number") {
106 level = MochiKit.Logging.LogLevel[level]; 109 level = MochiKit.Logging.LogLevel[level];
107 } 110 }
108 return level; 111 return level;
109 }; 112 };
110 113
111 /** @id MochiKit.LoggingPane.messageText */ 114 /** @id MochiKit.LoggingPane.messageText */
112 var messageText = function (msg) { 115 var messageText = function (msg) {
113 return msg.info.join(" "); 116 return msg.info.join(" ");
114 }; 117 };
115 118
116 /** @id MochiKit.LoggingPane.addMessageText */ 119 /** @id MochiKit.LoggingPane.addMessageText */
117 var addMessageText = bind(function (msg) { 120 var addMessageText = bind(function (msg) {
118 var level = messageLevel(msg); 121 var level = messageLevel(msg);
119 var text = messageText(msg); 122 var text = messageText(msg);
120 var c = this.colorTable[level]; 123 var c = this.colorTable[level];
121 var p = doc.createElement("span"); 124 var p = doc.createElement("span");
122 p.className = "MochiKit-LogMessage MochiKit-LogLevel-" + level; 125 p.className = "MochiKit-LogMessage MochiKit-LogLevel-" + level;
123 p.style.cssText = "margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: " + c; 126 p.style.cssText = "margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: " + c;
124 p.appendChild(doc.createTextNode(level + ": " + text)); 127 p.appendChild(doc.createTextNode(level + ": " + text));
125 logPane.appendChild(p); 128 logPane.appendChild(p);
126 logPane.appendChild(doc.createElement("br")); 129 logPane.appendChild(doc.createElement("br"));
127 if (logPaneArea.offsetHeight > logPaneArea.scrollHeight) { 130 if (logPaneArea.offsetHeight > logPaneArea.scrollHeight) {
128 logPaneArea.scrollTop = 0; 131 logPaneArea.scrollTop = 0;
129 } else { 132 } else {
130 logPaneArea.scrollTop = logPaneArea.scrollHeight; 133 logPaneArea.scrollTop = logPaneArea.scrollHeight;
131 } 134 }
132 }, this); 135 }, this);
133 136
134 /** @id MochiKit.LoggingPane.addMessage */ 137 /** @id MochiKit.LoggingPane.addMessage */
135 var addMessage = function (msg) { 138 var addMessage = function (msg) {
136 messages[messages.length] = msg; 139 messages[messages.length] = msg;
137 addMessageText(msg); 140 addMessageText(msg);
138 }; 141 };
139 142
140 /** @id MochiKit.LoggingPane.buildMessageFilter */ 143 /** @id MochiKit.LoggingPane.buildMessageFilter */
141 var buildMessageFilter = function () { 144 var buildMessageFilter = function () {
142 var levelre, infore; 145 var levelre, infore;
143 try { 146 try {
144 /* Catch any exceptions that might arise due to invalid regexes */ 147 /* Catch any exceptions that might arise due to invalid regexes */
145 levelre = new RegExp(levelFilterField.value); 148 levelre = new RegExp(levelFilterField.value);
146 infore = new RegExp(infoFilterField.value); 149 infore = new RegExp(infoFilterField.value);
147 } catch(e) { 150 } catch(e) {
148 /* If there was an error with the regexes, do no filtering */ 151 /* If there was an error with the regexes, do no filtering */
149 logDebug("Error in filter regex: " + e.message); 152 MochiKit.Logging.logDebug("Error in filter regex: " + e.message);
150 return null; 153 return null;
151 } 154 }
152 155
153 return function (msg) { 156 return function (msg) {
154 return ( 157 return (
155 levelre.test(messageLevel(msg)) && 158 levelre.test(messageLevel(msg)) &&
156 infore.test(messageText(msg)) 159 infore.test(messageText(msg))
157 ); 160 );
158 }; 161 };
159 }; 162 };
160 163
161 /** @id MochiKit.LoggingPane.clearMessagePane */ 164 /** @id MochiKit.LoggingPane.clearMessagePane */
162 var clearMessagePane = function () { 165 var clearMessagePane = function () {
163 while (logPane.firstChild) { 166 while (logPane.firstChild) {
164 logPane.removeChild(logPane.firstChild); 167 logPane.removeChild(logPane.firstChild);
165 } 168 }
166 }; 169 };
167 170
168 /** @id MochiKit.LoggingPane.clearMessages */ 171 /** @id MochiKit.LoggingPane.clearMessages */
169 var clearMessages = function () { 172 var clearMessages = function () {
170 messages = []; 173 messages = [];
171 clearMessagePane(); 174 clearMessagePane();
172 }; 175 };
173 176
174 /** @id MochiKit.LoggingPane.closePane */ 177 /** @id MochiKit.LoggingPane.closePane */
175 var closePane = bind(function () { 178 var closePane = bind(function () {
176 if (this.closed) { 179 if (this.closed) {
177 return; 180 return;
178 } 181 }
179 this.closed = true; 182 this.closed = true;
180 if (MochiKit.LoggingPane._loggingPane == this) { 183 if (MochiKit.LoggingPane._loggingPane == this) {
181 MochiKit.LoggingPane._loggingPane = null; 184 MochiKit.LoggingPane._loggingPane = null;
182 } 185 }
183 this.logger.removeListener(listenerId); 186 this.logger.removeListener(listenerId);
184 try { 187 try {
185 try { 188 try {
186 debugPane.loggingPane = null; 189 debugPane.loggingPane = null;
187 } catch(e) { logFatal("Bookmarklet was closed incorrectly."); } 190 } catch(e) { MochiKit.Logging.logFatal("Bookmarklet was closed incorrectly."); }
188 if (inline) { 191 if (inline) {
189 debugPane.parentNode.removeChild(debugPane); 192 debugPane.parentNode.removeChild(debugPane);
190 } else { 193 } else {
191 this.win.close(); 194 this.win.close();
192 } 195 }
193 } catch(e) {} 196 } catch(e) {}
194 }, this); 197 }, this);
195 198
196 /** @id MochiKit.LoggingPane.filterMessages */ 199 /** @id MochiKit.LoggingPane.filterMessages */
197 var filterMessages = function () { 200 var filterMessages = function () {
198 clearMessagePane(); 201 clearMessagePane();
199 202
200 for (var i = 0; i < messages.length; i++) { 203 for (var i = 0; i < messages.length; i++) {
201 var msg = messages[i]; 204 var msg = messages[i];
202 if (messageFilter === null || messageFilter(msg)) { 205 if (messageFilter === null || messageFilter(msg)) {
203 addMessageText(msg); 206 addMessageText(msg);
204 } 207 }
205 } 208 }
206 }; 209 };
207 210
208 this.buildAndApplyFilter = function () { 211 this.buildAndApplyFilter = function () {
209 messageFilter = buildMessageFilter(); 212 messageFilter = buildMessageFilter();
210 213
211 filterMessages(); 214 filterMessages();
212 215
213 this.logger.removeListener(listenerId); 216 this.logger.removeListener(listenerId);
214 this.logger.addListener(listenerId, messageFilter, addMessage); 217 this.logger.addListener(listenerId, messageFilter, addMessage);
215 }; 218 };
216 219
217 220
218 /** @id MochiKit.LoggingPane.loadMessages */ 221 /** @id MochiKit.LoggingPane.loadMessages */
219 var loadMessages = bind(function () { 222 var loadMessages = bind(function () {
220 messages = this.logger.getMessages(); 223 messages = this.logger.getMessages();
221 filterMessages(); 224 filterMessages();
222 }, this); 225 }, this);
223 226
224 /** @id MochiKit.LoggingPane.filterOnEnter */ 227 /** @id MochiKit.LoggingPane.filterOnEnter */
225 var filterOnEnter = bind(function (event) { 228 var filterOnEnter = bind(function (event) {
226 event = event || window.event; 229 event = event || window.event;
227 key = event.which || event.keyCode; 230 var key = event.which || event.keyCode;
228 if (key == 13) { 231 if (key == 13) {
229 this.buildAndApplyFilter(); 232 this.buildAndApplyFilter();
230 } 233 }
231 }, this); 234 }, this);
232 235
233 /* Create the debug pane */ 236 /* Create the debug pane */
234 var style = "display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: " + this.logFont; 237 var style = "display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: " + this.logFont;
235 if (inline) { 238 if (inline) {
236 style += "; height: 10em; border-top: 2px solid black"; 239 style += "; height: 10em; border-top: 2px solid black";
237 } else { 240 } else {
238 style += "; height: 100%;"; 241 style += "; height: 100%;";
239 } 242 }
240 debugPane.style.cssText = style; 243 debugPane.style.cssText = style;
241 244
242 if (!existing_pane) { 245 if (!existing_pane) {
243 doc.body.appendChild(debugPane); 246 doc.body.appendChild(debugPane);
244 } 247 }
245 248
246 /* Create the filter fields */ 249 /* Create the filter fields */
247 style = {"cssText": "width: 33%; display: inline; font: " + this.logFont}; 250 style = {"cssText": "width: 33%; display: inline; font: " + this.logFont};
248 251
249 updatetree(levelFilterField, { 252 updatetree(levelFilterField, {
250 "value": "FATAL|ERROR|WARNING|INFO|DEBUG", 253 "value": "FATAL|ERROR|WARNING|INFO|DEBUG",
251 "onkeypress": filterOnEnter, 254 "onkeypress": filterOnEnter,
252 "style": style 255 "style": style
253 }); 256 });
254 debugPane.appendChild(levelFilterField); 257 debugPane.appendChild(levelFilterField);
255 258
256 updatetree(infoFilterField, { 259 updatetree(infoFilterField, {
257 "value": ".*", 260 "value": ".*",
258 "onkeypress": filterOnEnter, 261 "onkeypress": filterOnEnter,
259 "style": style 262 "style": style
260 }); 263 });
261 debugPane.appendChild(infoFilterField); 264 debugPane.appendChild(infoFilterField);
262 265
263 /* Create the buttons */ 266 /* Create the buttons */
264 style = "width: 8%; display:inline; font: " + this.logFont; 267 style = "width: 8%; display:inline; font: " + this.logFont;
265 268
266 filterButton.appendChild(doc.createTextNode("Filter")); 269 filterButton.appendChild(doc.createTextNode("Filter"));
267 filterButton.onclick = bind("buildAndApplyFilter", this); 270 filterButton.onclick = bind("buildAndApplyFilter", this);
268 filterButton.style.cssText = style; 271 filterButton.style.cssText = style;
269 debugPane.appendChild(filterButton); 272 debugPane.appendChild(filterButton);
270 273
271 loadButton.appendChild(doc.createTextNode("Load")); 274 loadButton.appendChild(doc.createTextNode("Load"));
272 loadButton.onclick = loadMessages; 275 loadButton.onclick = loadMessages;
273 loadButton.style.cssText = style; 276 loadButton.style.cssText = style;
274 debugPane.appendChild(loadButton); 277 debugPane.appendChild(loadButton);
275 278
276 clearButton.appendChild(doc.createTextNode("Clear")); 279 clearButton.appendChild(doc.createTextNode("Clear"));
277 clearButton.onclick = clearMessages; 280 clearButton.onclick = clearMessages;
278 clearButton.style.cssText = style; 281 clearButton.style.cssText = style;
279 debugPane.appendChild(clearButton); 282 debugPane.appendChild(clearButton);
280 283
281 closeButton.appendChild(doc.createTextNode("Close")); 284 closeButton.appendChild(doc.createTextNode("Close"));
282 closeButton.onclick = closePane; 285 closeButton.onclick = closePane;
283 closeButton.style.cssText = style; 286 closeButton.style.cssText = style;
284 debugPane.appendChild(closeButton); 287 debugPane.appendChild(closeButton);
285 288
286 /* Create the logging pane */ 289 /* Create the logging pane */
287 logPaneArea.style.cssText = "overflow: auto; width: 100%"; 290 logPaneArea.style.cssText = "overflow: auto; width: 100%";
288 logPane.style.cssText = "width: 100%; height: " + (inline ? "8em" : "100%"); 291 logPane.style.cssText = "width: 100%; height: " + (inline ? "8em" : "100%");
289 292
290 logPaneArea.appendChild(logPane); 293 logPaneArea.appendChild(logPane);
291 debugPane.appendChild(logPaneArea); 294 debugPane.appendChild(logPaneArea);
292 295
293 this.buildAndApplyFilter(); 296 this.buildAndApplyFilter();
294 loadMessages(); 297 loadMessages();
295 298
296 if (inline) { 299 if (inline) {
297 this.win = undefined; 300 this.win = undefined;
298 } else { 301 } else {
299 this.win = win; 302 this.win = win;
300 } 303 }
301 this.inline = inline; 304 this.inline = inline;
302 this.closePane = closePane; 305 this.closePane = closePane;
303 this.closed = false; 306 this.closed = false;
304 307
305 308
306 return this; 309 return this;
307}; 310};
308 311
309MochiKit.LoggingPane.LoggingPane.prototype = { 312MochiKit.LoggingPane.LoggingPane.prototype = {
310 "logFont": "8pt Verdana,sans-serif", 313 "logFont": "8pt Verdana,sans-serif",
311 "colorTable": { 314 "colorTable": {
312 "ERROR": "red", 315 "ERROR": "red",
313 "FATAL": "darkred", 316 "FATAL": "darkred",
314 "WARNING": "blue", 317 "WARNING": "blue",
315 "INFO": "black", 318 "INFO": "black",
316 "DEBUG": "green" 319 "DEBUG": "green"
317 } 320 }
318}; 321};
319 322
320MochiKit.LoggingPane.__new__ = function () { 323MochiKit.LoggingPane.__new__ = function () {
321 MochiKit.Base.nameFunctions(this); 324 MochiKit.Base.nameFunctions(this);
322 MochiKit.LoggingPane._loggingPane = null; 325 MochiKit.LoggingPane._loggingPane = null;
323}; 326};
324 327
325MochiKit.LoggingPane.__new__(); 328MochiKit.LoggingPane.__new__();
326 329
327MochiKit.Base._exportSymbols(this, MochiKit.LoggingPane); 330MochiKit.Base._exportSymbols(this, MochiKit.LoggingPane);
diff --git a/frontend/gamma/js/MochiKit/MochiKit.js b/frontend/gamma/js/MochiKit/MochiKit.js
index 8e5be68..511e075 100644
--- a/frontend/gamma/js/MochiKit/MochiKit.js
+++ b/frontend/gamma/js/MochiKit/MochiKit.js
@@ -1,136 +1,133 @@
1/*** 1/***
2 2
3MochiKit.MochiKit 1.5 3MochiKit.MochiKit 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11if (typeof(MochiKit) == 'undefined') { 11var MochiKit = MochiKit || {};
12 MochiKit = {};
13}
14 12
15if (typeof(MochiKit.MochiKit) == 'undefined') { 13/** @id MochiKit.MochiKit */
16 /** @id MochiKit.MochiKit */ 14MochiKit.MochiKit = MochiKit.MochiKit || {};
17 MochiKit.MochiKit = {};
18}
19 15
20MochiKit.MochiKit.NAME = "MochiKit.MochiKit"; 16MochiKit.MochiKit.NAME = "MochiKit.MochiKit";
21MochiKit.MochiKit.VERSION = "1.5"; 17MochiKit.MochiKit.VERSION = "1.5";
18MochiKit.MochiKit.__export__ = false;
22MochiKit.MochiKit.__repr__ = function () { 19MochiKit.MochiKit.__repr__ = function () {
23 return "[" + this.NAME + " " + this.VERSION + "]"; 20 return "[" + this.NAME + " " + this.VERSION + "]";
24}; 21};
25 22
26/** @id MochiKit.MochiKit.toString */ 23/** @id MochiKit.MochiKit.toString */
27MochiKit.MochiKit.toString = function () { 24MochiKit.MochiKit.toString = function () {
28 return this.__repr__(); 25 return this.__repr__();
29}; 26};
30 27
31/** @id MochiKit.MochiKit.SUBMODULES */ 28/** @id MochiKit.MochiKit.SUBMODULES */
32MochiKit.MochiKit.SUBMODULES = [ 29MochiKit.MochiKit.SUBMODULES = [
33 "Base", 30 "Base",
34 "Iter", 31 "Iter",
35 "Logging", 32 "Logging",
36 "DateTime", 33 "DateTime",
37 "Format", 34 "Format",
38 "Text", 35 "Text",
39 "Async", 36 "Async",
40 "DOM", 37 "DOM",
41 "Selector", 38 "Selector",
42 "Style", 39 "Style",
43 "LoggingPane", 40 "LoggingPane",
44 "Color", 41 "Color",
45 "Signal", 42 "Signal",
46 "Position", 43 "Position",
47 "Visual", 44 "Visual",
48 "DragAndDrop", 45 "DragAndDrop",
49 "Sortable" 46 "Sortable"
50]; 47];
51 48
52(function () { 49(function () {
53 if (typeof(document) == "undefined") { 50 if (typeof(document) == "undefined") {
54 return; 51 return;
55 } 52 }
56 var scripts = document.getElementsByTagName("script"); 53 var scripts = document.getElementsByTagName("script");
57 var kXHTMLNSURI = "http://www.w3.org/1999/xhtml"; 54 var kXHTMLNSURI = "http://www.w3.org/1999/xhtml";
58 var kSVGNSURI = "http://www.w3.org/2000/svg"; 55 var kSVGNSURI = "http://www.w3.org/2000/svg";
59 var kXLINKNSURI = "http://www.w3.org/1999/xlink"; 56 var kXLINKNSURI = "http://www.w3.org/1999/xlink";
60 var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; 57 var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
61 var base = null; 58 var base = null;
62 var baseElem = null; 59 var baseElem = null;
63 var allScripts = {}; 60 var allScripts = {};
64 var i; 61 var i;
65 var src; 62 var src;
66 for (i = 0; i < scripts.length; i++) { 63 for (i = 0; i < scripts.length; i++) {
67 src = null; 64 src = null;
68 switch (scripts[i].namespaceURI) { 65 switch (scripts[i].namespaceURI) {
69 case kSVGNSURI: 66 case kSVGNSURI:
70 src = scripts[i].getAttributeNS(kXLINKNSURI, "href"); 67 src = scripts[i].getAttributeNS(kXLINKNSURI, "href");
71 break; 68 break;
72 /* 69 /*
73 case null: // HTML 70 case null: // HTML
74 case '': // HTML 71 case '': // HTML
75 case kXHTMLNSURI: 72 case kXHTMLNSURI:
76 case kXULNSURI: 73 case kXULNSURI:
77 */ 74 */
78 default: 75 default:
79 src = scripts[i].getAttribute("src"); 76 src = scripts[i].getAttribute("src");
80 break; 77 break;
81 } 78 }
82 if (!src) { 79 if (!src) {
83 continue; 80 continue;
84 } 81 }
85 allScripts[src] = true; 82 allScripts[src] = true;
86 if (src.match(/MochiKit.js(\?.*)?$/)) { 83 if (src.match(/MochiKit.js(\?.*)?$/)) {
87 base = src.substring(0, src.lastIndexOf('MochiKit.js')); 84 base = src.substring(0, src.lastIndexOf('MochiKit.js'));
88 baseElem = scripts[i]; 85 baseElem = scripts[i];
89 } 86 }
90 } 87 }
91 if (base === null) { 88 if (base === null) {
92 return; 89 return;
93 } 90 }
94 var modules = MochiKit.MochiKit.SUBMODULES; 91 var modules = MochiKit.MochiKit.SUBMODULES;
95 for (var i = 0; i < modules.length; i++) { 92 for (var i = 0; i < modules.length; i++) {
96 if (MochiKit[modules[i]]) { 93 if (MochiKit[modules[i]]) {
97 continue; 94 continue;
98 } 95 }
99 var uri = base + modules[i] + '.js'; 96 var uri = base + modules[i] + '.js';
100 if (uri in allScripts) { 97 if (uri in allScripts) {
101 continue; 98 continue;
102 } 99 }
103 if (baseElem.namespaceURI == kSVGNSURI || 100 if (baseElem.namespaceURI == kSVGNSURI ||
104 baseElem.namespaceURI == kXULNSURI) { 101 baseElem.namespaceURI == kXULNSURI) {
105 // SVG, XUL 102 // SVG, XUL
106 /* 103 /*
107 SVG does not support document.write, so if Safari wants to 104 SVG does not support document.write, so if Safari wants to
108 support SVG tests it should fix its deferred loading bug 105 support SVG tests it should fix its deferred loading bug
109 (see following below). 106 (see following below).
110 */ 107 */
111 var s = document.createElementNS(baseElem.namespaceURI, 'script'); 108 var s = document.createElementNS(baseElem.namespaceURI, 'script');
112 s.setAttribute("id", "MochiKit_" + base + modules[i]); 109 s.setAttribute("id", "MochiKit_" + base + modules[i]);
113 if (baseElem.namespaceURI == kSVGNSURI) { 110 if (baseElem.namespaceURI == kSVGNSURI) {
114 s.setAttributeNS(kXLINKNSURI, 'href', uri); 111 s.setAttributeNS(kXLINKNSURI, 'href', uri);
115 } else { 112 } else {
116 s.setAttribute('src', uri); 113 s.setAttribute('src', uri);
117 } 114 }
118 s.setAttribute("type", "application/x-javascript"); 115 s.setAttribute("type", "application/x-javascript");
119 baseElem.parentNode.appendChild(s); 116 baseElem.parentNode.appendChild(s);
120 } else { 117 } else {
121 // HTML, XHTML 118 // HTML, XHTML
122 /* 119 /*
123 DOM can not be used here because Safari does 120 DOM can not be used here because Safari does
124 deferred loading of scripts unless they are 121 deferred loading of scripts unless they are
125 in the document or inserted with document.write 122 in the document or inserted with document.write
126 123
127 This is not XHTML compliant. If you want XHTML 124 This is not XHTML compliant. If you want XHTML
128 compliance then you must use the packed version of MochiKit 125 compliance then you must use the packed version of MochiKit
129 or include each script individually (basically unroll 126 or include each script individually (basically unroll
130 these document.write calls into your XHTML source) 127 these document.write calls into your XHTML source)
131 */ 128 */
132 document.write('<' + baseElem.nodeName + ' src="' + uri + 129 document.write('<' + baseElem.nodeName + ' src="' + uri +
133 '" type="text/javascript"></script>'); 130 '" type="text/javascript"></script>');
134 } 131 }
135 }; 132 };
136})(); 133})();
diff --git a/frontend/gamma/js/MochiKit/MockDOM.js b/frontend/gamma/js/MochiKit/MockDOM.js
index abdb54a..7e6d60b 100644
--- a/frontend/gamma/js/MochiKit/MockDOM.js
+++ b/frontend/gamma/js/MochiKit/MockDOM.js
@@ -1,115 +1,112 @@
1/*** 1/***
2 2
3MochiKit.MockDOM 1.5 3MochiKit.MockDOM 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11if (typeof(MochiKit) == "undefined") { 11var MochiKit = MochiKit || {};
12 MochiKit = {};
13}
14 12
15if (typeof(MochiKit.MockDOM) == "undefined") { 13MochiKit.MockDOM = MochiKit.MockDOM || {};
16 MochiKit.MockDOM = {};
17}
18 14
19MochiKit.MockDOM.NAME = "MochiKit.MockDOM"; 15MochiKit.MockDOM.NAME = "MochiKit.MockDOM";
20MochiKit.MockDOM.VERSION = "1.5"; 16MochiKit.MockDOM.VERSION = "1.5";
17MochiKit.MockDOM.__export__ = false;
21 18
22MochiKit.MockDOM.__repr__ = function () { 19MochiKit.MockDOM.__repr__ = function () {
23 return "[" + this.NAME + " " + this.VERSION + "]"; 20 return "[" + this.NAME + " " + this.VERSION + "]";
24}; 21};
25 22
26/** @id MochiKit.MockDOM.toString */ 23/** @id MochiKit.MockDOM.toString */
27MochiKit.MockDOM.toString = function () { 24MochiKit.MockDOM.toString = function () {
28 return this.__repr__(); 25 return this.__repr__();
29}; 26};
30 27
31/** @id MochiKit.MockDOM.createDocument */ 28/** @id MochiKit.MockDOM.createDocument */
32MochiKit.MockDOM.createDocument = function () { 29MochiKit.MockDOM.createDocument = function () {
33 var doc = new MochiKit.MockDOM.MockElement("DOCUMENT"); 30 var doc = new MochiKit.MockDOM.MockElement("DOCUMENT");
34 doc.body = doc.createElement("BODY"); 31 doc.body = doc.createElement("BODY");
35 doc.appendChild(doc.body); 32 doc.appendChild(doc.body);
36 return doc; 33 return doc;
37}; 34};
38 35
39/** @id MochiKit.MockDOM.MockElement */ 36/** @id MochiKit.MockDOM.MockElement */
40MochiKit.MockDOM.MockElement = function (name, data, ownerDocument) { 37MochiKit.MockDOM.MockElement = function (name, data, ownerDocument) {
41 this.tagName = this.nodeName = name.toUpperCase(); 38 this.tagName = this.nodeName = name.toUpperCase();
42 this.ownerDocument = ownerDocument || null; 39 this.ownerDocument = ownerDocument || null;
43 if (name == "DOCUMENT") { 40 if (name == "DOCUMENT") {
44 this.nodeType = 9; 41 this.nodeType = 9;
45 this.childNodes = []; 42 this.childNodes = [];
46 } else if (typeof(data) == "string") { 43 } else if (typeof(data) == "string") {
47 this.nodeValue = data; 44 this.nodeValue = data;
48 this.nodeType = 3; 45 this.nodeType = 3;
49 } else { 46 } else {
50 this.nodeType = 1; 47 this.nodeType = 1;
51 this.childNodes = []; 48 this.childNodes = [];
52 } 49 }
53 if (name.substring(0, 1) == "<") { 50 if (name.substring(0, 1) == "<") {
54 var nameattr = name.substring( 51 var nameattr = name.substring(
55 name.indexOf('"') + 1, name.lastIndexOf('"')); 52 name.indexOf('"') + 1, name.lastIndexOf('"'));
56 name = name.substring(1, name.indexOf(" ")); 53 name = name.substring(1, name.indexOf(" "));
57 this.tagName = this.nodeName = name.toUpperCase(); 54 this.tagName = this.nodeName = name.toUpperCase();
58 this.setAttribute("name", nameattr); 55 this.setAttribute("name", nameattr);
59 } 56 }
60}; 57};
61 58
62MochiKit.MockDOM.MockElement.prototype = { 59MochiKit.MockDOM.MockElement.prototype = {
63 /** @id MochiKit.MockDOM.MockElement.prototype.createElement */ 60 /** @id MochiKit.MockDOM.MockElement.prototype.createElement */
64 createElement: function (tagName) { 61 createElement: function (tagName) {
65 return new MochiKit.MockDOM.MockElement(tagName, null, this.nodeType == 9 ? this : this.ownerDocument); 62 return new MochiKit.MockDOM.MockElement(tagName, null, this.nodeType == 9 ? this : this.ownerDocument);
66 }, 63 },
67 /** @id MochiKit.MockDOM.MockElement.prototype.createTextNode */ 64 /** @id MochiKit.MockDOM.MockElement.prototype.createTextNode */
68 createTextNode: function (text) { 65 createTextNode: function (text) {
69 return new MochiKit.MockDOM.MockElement("text", text, this.nodeType == 9 ? this : this.ownerDocument); 66 return new MochiKit.MockDOM.MockElement("text", text, this.nodeType == 9 ? this : this.ownerDocument);
70 }, 67 },
71 /** @id MochiKit.MockDOM.MockElement.prototype.setAttribute */ 68 /** @id MochiKit.MockDOM.MockElement.prototype.setAttribute */
72 setAttribute: function (name, value) { 69 setAttribute: function (name, value) {
73 this[name] = value; 70 this[name] = value;
74 }, 71 },
75 /** @id MochiKit.MockDOM.MockElement.prototype.getAttribute */ 72 /** @id MochiKit.MockDOM.MockElement.prototype.getAttribute */
76 getAttribute: function (name) { 73 getAttribute: function (name) {
77 return this[name]; 74 return this[name];
78 }, 75 },
79 /** @id MochiKit.MockDOM.MockElement.prototype.appendChild */ 76 /** @id MochiKit.MockDOM.MockElement.prototype.appendChild */
80 appendChild: function (child) { 77 appendChild: function (child) {
81 this.childNodes.push(child); 78 this.childNodes.push(child);
82 }, 79 },
83 /** @id MochiKit.MockDOM.MockElement.prototype.toString */ 80 /** @id MochiKit.MockDOM.MockElement.prototype.toString */
84 toString: function () { 81 toString: function () {
85 return "MockElement(" + this.tagName + ")"; 82 return "MockElement(" + this.tagName + ")";
86 }, 83 },
87 /** @id MochiKit.MockDOM.MockElement.prototype.getElementsByTagName */ 84 /** @id MochiKit.MockDOM.MockElement.prototype.getElementsByTagName */
88 getElementsByTagName: function (tagName) { 85 getElementsByTagName: function (tagName) {
89 var foundElements = []; 86 var foundElements = [];
90 MochiKit.Base.nodeWalk(this, function(node){ 87 MochiKit.Base.nodeWalk(this, function(node){
91 if (tagName == '*' || tagName == node.tagName) { 88 if (tagName == '*' || tagName == node.tagName) {
92 foundElements.push(node); 89 foundElements.push(node);
93 return node.childNodes; 90 return node.childNodes;
94 } 91 }
95 }); 92 });
96 return foundElements; 93 return foundElements;
97 } 94 }
98}; 95};
99 96
100 /** @id MochiKit.MockDOM.EXPORT_OK */ 97 /** @id MochiKit.MockDOM.EXPORT_OK */
101MochiKit.MockDOM.EXPORT_OK = [ 98MochiKit.MockDOM.EXPORT_OK = [
102 "mockElement", 99 "mockElement",
103 "createDocument" 100 "createDocument"
104]; 101];
105 102
106 /** @id MochiKit.MockDOM.EXPORT */ 103 /** @id MochiKit.MockDOM.EXPORT */
107MochiKit.MockDOM.EXPORT = [ 104MochiKit.MockDOM.EXPORT = [
108 "document" 105 "document"
109]; 106];
110 107
111MochiKit.MockDOM.__new__ = function () { 108MochiKit.MockDOM.__new__ = function () {
112 this.document = this.createDocument(); 109 this.document = this.createDocument();
113}; 110};
114 111
115MochiKit.MockDOM.__new__(); 112MochiKit.MockDOM.__new__();
diff --git a/frontend/gamma/js/MochiKit/Position.js b/frontend/gamma/js/MochiKit/Position.js
index 6bc5b39..2680507 100644
--- a/frontend/gamma/js/MochiKit/Position.js
+++ b/frontend/gamma/js/MochiKit/Position.js
@@ -1,218 +1,218 @@
1/*** 1/***
2 2
3MochiKit.Position 1.5 3MochiKit.Position 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005-2006 Bob Ippolito and others. All rights Reserved. 7(c) 2005-2006 Bob Ippolito and others. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Position', '1.5', ['Base', 'DOM', 'Style']); 11MochiKit.Base.module(MochiKit, 'Position', '1.5', ['Base', 'DOM', 'Style']);
12 12
13MochiKit.Base.update(MochiKit.Position, { 13MochiKit.Base.update(MochiKit.Position, {
14 // Don't export from this module 14 // Don't export from this module
15 __export__: false, 15 __export__: false,
16 16
17 // set to true if needed, warning: firefox performance problems 17 // set to true if needed, warning: firefox performance problems
18 // NOT neeeded for page scrolling, only if draggable contained in 18 // NOT neeeded for page scrolling, only if draggable contained in
19 // scrollable elements 19 // scrollable elements
20 includeScrollOffsets: false, 20 includeScrollOffsets: false,
21 21
22 /** @id MochiKit.Position.prepare */ 22 /** @id MochiKit.Position.prepare */
23 prepare: function () { 23 prepare: function () {
24 var deltaX = window.pageXOffset 24 var deltaX = window.pageXOffset
25 || document.documentElement.scrollLeft 25 || document.documentElement.scrollLeft
26 || document.body.scrollLeft 26 || document.body.scrollLeft
27 || 0; 27 || 0;
28 var deltaY = window.pageYOffset 28 var deltaY = window.pageYOffset
29 || document.documentElement.scrollTop 29 || document.documentElement.scrollTop
30 || document.body.scrollTop 30 || document.body.scrollTop
31 || 0; 31 || 0;
32 this.windowOffset = new MochiKit.Style.Coordinates(deltaX, deltaY); 32 this.windowOffset = new MochiKit.Style.Coordinates(deltaX, deltaY);
33 }, 33 },
34 34
35 /** @id MochiKit.Position.cumulativeOffset */ 35 /** @id MochiKit.Position.cumulativeOffset */
36 cumulativeOffset: function (element) { 36 cumulativeOffset: function (element) {
37 var valueT = 0; 37 var valueT = 0;
38 var valueL = 0; 38 var valueL = 0;
39 do { 39 do {
40 valueT += element.offsetTop || 0; 40 valueT += element.offsetTop || 0;
41 valueL += element.offsetLeft || 0; 41 valueL += element.offsetLeft || 0;
42 element = element.offsetParent; 42 element = element.offsetParent;
43 } while (element); 43 } while (element);
44 return new MochiKit.Style.Coordinates(valueL, valueT); 44 return new MochiKit.Style.Coordinates(valueL, valueT);
45 }, 45 },
46 46
47 /** @id MochiKit.Position.realOffset */ 47 /** @id MochiKit.Position.realOffset */
48 realOffset: function (element) { 48 realOffset: function (element) {
49 var valueT = 0; 49 var valueT = 0;
50 var valueL = 0; 50 var valueL = 0;
51 do { 51 do {
52 valueT += element.scrollTop || 0; 52 valueT += element.scrollTop || 0;
53 valueL += element.scrollLeft || 0; 53 valueL += element.scrollLeft || 0;
54 element = element.parentNode; 54 element = element.parentNode;
55 } while (element); 55 } while (element);
56 return new MochiKit.Style.Coordinates(valueL, valueT); 56 return new MochiKit.Style.Coordinates(valueL, valueT);
57 }, 57 },
58 58
59 /** @id MochiKit.Position.within */ 59 /** @id MochiKit.Position.within */
60 within: function (element, x, y) { 60 within: function (element, x, y) {
61 if (this.includeScrollOffsets) { 61 if (this.includeScrollOffsets) {
62 return this.withinIncludingScrolloffsets(element, x, y); 62 return this.withinIncludingScrolloffsets(element, x, y);
63 } 63 }
64 this.xcomp = x; 64 this.xcomp = x;
65 this.ycomp = y; 65 this.ycomp = y;
66 this.offset = this.cumulativeOffset(element); 66 this.offset = this.cumulativeOffset(element);
67 if (element.style.position == "fixed") { 67 if (element.style.position == "fixed") {
68 this.offset.x += this.windowOffset.x; 68 this.offset.x += this.windowOffset.x;
69 this.offset.y += this.windowOffset.y; 69 this.offset.y += this.windowOffset.y;
70 } 70 }
71 71
72 return (y >= this.offset.y && 72 return (y >= this.offset.y &&
73 y < this.offset.y + element.offsetHeight && 73 y < this.offset.y + element.offsetHeight &&
74 x >= this.offset.x && 74 x >= this.offset.x &&
75 x < this.offset.x + element.offsetWidth); 75 x < this.offset.x + element.offsetWidth);
76 }, 76 },
77 77
78 /** @id MochiKit.Position.withinIncludingScrolloffsets */ 78 /** @id MochiKit.Position.withinIncludingScrolloffsets */
79 withinIncludingScrolloffsets: function (element, x, y) { 79 withinIncludingScrolloffsets: function (element, x, y) {
80 var offsetcache = this.realOffset(element); 80 var offsetcache = this.realOffset(element);
81 81
82 this.xcomp = x + offsetcache.x - this.windowOffset.x; 82 this.xcomp = x + offsetcache.x - this.windowOffset.x;
83 this.ycomp = y + offsetcache.y - this.windowOffset.y; 83 this.ycomp = y + offsetcache.y - this.windowOffset.y;
84 this.offset = this.cumulativeOffset(element); 84 this.offset = this.cumulativeOffset(element);
85 85
86 return (this.ycomp >= this.offset.y && 86 return (this.ycomp >= this.offset.y &&
87 this.ycomp < this.offset.y + element.offsetHeight && 87 this.ycomp < this.offset.y + element.offsetHeight &&
88 this.xcomp >= this.offset.x && 88 this.xcomp >= this.offset.x &&
89 this.xcomp < this.offset.x + element.offsetWidth); 89 this.xcomp < this.offset.x + element.offsetWidth);
90 }, 90 },
91 91
92 // within must be called directly before 92 // within must be called directly before
93 /** @id MochiKit.Position.overlap */ 93 /** @id MochiKit.Position.overlap */
94 overlap: function (mode, element) { 94 overlap: function (mode, element) {
95 if (!mode) { 95 if (!mode) {
96 return 0; 96 return 0;
97 } 97 }
98 if (mode == 'vertical') { 98 if (mode == 'vertical') {
99 return ((this.offset.y + element.offsetHeight) - this.ycomp) / 99 return ((this.offset.y + element.offsetHeight) - this.ycomp) /
100 element.offsetHeight; 100 element.offsetHeight;
101 } 101 }
102 if (mode == 'horizontal') { 102 if (mode == 'horizontal') {
103 return ((this.offset.x + element.offsetWidth) - this.xcomp) / 103 return ((this.offset.x + element.offsetWidth) - this.xcomp) /
104 element.offsetWidth; 104 element.offsetWidth;
105 } 105 }
106 }, 106 },
107 107
108 /** @id MochiKit.Position.absolutize */ 108 /** @id MochiKit.Position.absolutize */
109 absolutize: function (element) { 109 absolutize: function (element) {
110 element = MochiKit.DOM.getElement(element); 110 element = MochiKit.DOM.getElement(element);
111 if (element.style.position == 'absolute') { 111 if (element.style.position == 'absolute') {
112 return; 112 return;
113 } 113 }
114 MochiKit.Position.prepare(); 114 MochiKit.Position.prepare();
115 115
116 var offsets = MochiKit.Position.positionedOffset(element); 116 var offsets = MochiKit.Position.positionedOffset(element);
117 var width = element.clientWidth; 117 var width = element.clientWidth;
118 var height = element.clientHeight; 118 var height = element.clientHeight;
119 119
120 var oldStyle = { 120 var oldStyle = {
121 'position': element.style.position, 121 'position': element.style.position,
122 'left': offsets.x - parseFloat(element.style.left || 0), 122 'left': offsets.x - parseFloat(element.style.left || 0),
123 'top': offsets.y - parseFloat(element.style.top || 0), 123 'top': offsets.y - parseFloat(element.style.top || 0),
124 'width': element.style.width, 124 'width': element.style.width,
125 'height': element.style.height 125 'height': element.style.height
126 }; 126 };
127 127
128 element.style.position = 'absolute'; 128 element.style.position = 'absolute';
129 element.style.top = offsets.y + 'px'; 129 element.style.top = offsets.y + 'px';
130 element.style.left = offsets.x + 'px'; 130 element.style.left = offsets.x + 'px';
131 element.style.width = width + 'px'; 131 element.style.width = width + 'px';
132 element.style.height = height + 'px'; 132 element.style.height = height + 'px';
133 133
134 return oldStyle; 134 return oldStyle;
135 }, 135 },
136 136
137 /** @id MochiKit.Position.positionedOffset */ 137 /** @id MochiKit.Position.positionedOffset */
138 positionedOffset: function (element) { 138 positionedOffset: function (element) {
139 var valueT = 0, valueL = 0; 139 var valueT = 0, valueL = 0;
140 do { 140 do {
141 valueT += element.offsetTop || 0; 141 valueT += element.offsetTop || 0;
142 valueL += element.offsetLeft || 0; 142 valueL += element.offsetLeft || 0;
143 element = element.offsetParent; 143 element = element.offsetParent;
144 if (element) { 144 if (element) {
145 var p = MochiKit.Style.getStyle(element, 'position'); 145 var p = MochiKit.Style.getStyle(element, 'position');
146 if (p == 'relative' || p == 'absolute') { 146 if (p == 'relative' || p == 'absolute') {
147 break; 147 break;
148 } 148 }
149 } 149 }
150 } while (element); 150 } while (element);
151 return new MochiKit.Style.Coordinates(valueL, valueT); 151 return new MochiKit.Style.Coordinates(valueL, valueT);
152 }, 152 },
153 153
154 /** @id MochiKit.Position.relativize */ 154 /** @id MochiKit.Position.relativize */
155 relativize: function (element, oldPos) { 155 relativize: function (element, oldPos) {
156 element = MochiKit.DOM.getElement(element); 156 element = MochiKit.DOM.getElement(element);
157 if (element.style.position == 'relative') { 157 if (element.style.position == 'relative') {
158 return; 158 return;
159 } 159 }
160 MochiKit.Position.prepare(); 160 MochiKit.Position.prepare();
161 161
162 var top = parseFloat(element.style.top || 0) - 162 var top = parseFloat(element.style.top || 0) -
163 (oldPos['top'] || 0); 163 (oldPos['top'] || 0);
164 var left = parseFloat(element.style.left || 0) - 164 var left = parseFloat(element.style.left || 0) -
165 (oldPos['left'] || 0); 165 (oldPos['left'] || 0);
166 166
167 element.style.position = oldPos['position']; 167 element.style.position = oldPos['position'];
168 element.style.top = top + 'px'; 168 element.style.top = top + 'px';
169 element.style.left = left + 'px'; 169 element.style.left = left + 'px';
170 element.style.width = oldPos['width']; 170 element.style.width = oldPos['width'];
171 element.style.height = oldPos['height']; 171 element.style.height = oldPos['height'];
172 }, 172 },
173 173
174 /** @id MochiKit.Position.clone */ 174 /** @id MochiKit.Position.clone */
175 clone: function (source, target) { 175 clone: function (source, target) {
176 source = MochiKit.DOM.getElement(source); 176 source = MochiKit.DOM.getElement(source);
177 target = MochiKit.DOM.getElement(target); 177 target = MochiKit.DOM.getElement(target);
178 target.style.position = 'absolute'; 178 target.style.position = 'absolute';
179 var offsets = this.cumulativeOffset(source); 179 var offsets = this.cumulativeOffset(source);
180 target.style.top = offsets.y + 'px'; 180 target.style.top = offsets.y + 'px';
181 target.style.left = offsets.x + 'px'; 181 target.style.left = offsets.x + 'px';
182 target.style.width = source.offsetWidth + 'px'; 182 target.style.width = source.offsetWidth + 'px';
183 target.style.height = source.offsetHeight + 'px'; 183 target.style.height = source.offsetHeight + 'px';
184 }, 184 },
185 185
186 /** @id MochiKit.Position.page */ 186 /** @id MochiKit.Position.page */
187 page: function (forElement) { 187 page: function (forElement) {
188 var valueT = 0; 188 var valueT = 0;
189 var valueL = 0; 189 var valueL = 0;
190 190
191 var element = forElement; 191 var element = forElement;
192 do { 192 do {
193 valueT += element.offsetTop || 0; 193 valueT += element.offsetTop || 0;
194 valueL += element.offsetLeft || 0; 194 valueL += element.offsetLeft || 0;
195 195
196 // Safari fix 196 // Safari fix
197 if (element.offsetParent == document.body && MochiKit.Style.getStyle(element, 'position') == 'absolute') { 197 if (element.offsetParent == document.body && MochiKit.Style.getStyle(element, 'position') == 'absolute') {
198 break; 198 break;
199 } 199 }
200 } while (element = element.offsetParent); 200 } while (element = element.offsetParent);
201 201
202 element = forElement; 202 element = forElement;
203 do { 203 do {
204 valueT -= element.scrollTop || 0; 204 valueT -= element.scrollTop || 0;
205 valueL -= element.scrollLeft || 0; 205 valueL -= element.scrollLeft || 0;
206 } while (element = element.parentNode); 206 } while (element = element.parentNode);
207 207
208 return new MochiKit.Style.Coordinates(valueL, valueT); 208 return new MochiKit.Style.Coordinates(valueL, valueT);
209 } 209 }
210}); 210});
211 211
212MochiKit.Position.__new__ = function (win) { 212MochiKit.Position.__new__ = function (win) {
213 MochiKit.Base.nameFunctions(this); 213 MochiKit.Base.nameFunctions(this);
214}; 214};
215 215
216MochiKit.Position.__new__(this); 216MochiKit.Position.__new__(this);
217 217
218MochiKit.Base._exportSymbols(this, MochiKit.Position); 218MochiKit.Base._exportSymbols(this, MochiKit.Position);
diff --git a/frontend/gamma/js/MochiKit/Selector.js b/frontend/gamma/js/MochiKit/Selector.js
index 6aec892..3187fe9 100644
--- a/frontend/gamma/js/MochiKit/Selector.js
+++ b/frontend/gamma/js/MochiKit/Selector.js
@@ -1,387 +1,393 @@
1/*** 1/***
2 2
3MochiKit.Selector 1.5 3MochiKit.Selector 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito and others. All rights Reserved. 7(c) 2005 Bob Ippolito and others. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Selector', '1.5', ['Base', 'DOM', 'Iter']); 11MochiKit.Base.module(MochiKit, 'Selector', '1.5', ['Base', 'DOM', 'Iter']);
12 12
13MochiKit.Selector.Selector = function (expression) { 13MochiKit.Selector.Selector = function (expression) {
14 this.params = {classNames: [], pseudoClassNames: []}; 14 this.params = {classNames: [], pseudoClassNames: []};
15 this.expression = expression.toString().replace(/(^\s+|\s+$)/g, ''); 15 this.expression = expression.toString().replace(/(^\s+|\s+$)/g, '');
16 this.parseExpression(); 16 this.parseExpression();
17 this.compileMatcher(); 17 this.compileMatcher();
18}; 18};
19 19
20MochiKit.Selector.Selector.prototype = { 20MochiKit.Selector.Selector.prototype = {
21 /*** 21 /***
22 22
23 Selector class: convenient object to make CSS selections. 23 Selector class: convenient object to make CSS selections.
24 24
25 ***/ 25 ***/
26 __class__: MochiKit.Selector.Selector, 26 __class__: MochiKit.Selector.Selector,
27 27
28 /** @id MochiKit.Selector.Selector.prototype.parseExpression */ 28 /** @id MochiKit.Selector.Selector.prototype.parseExpression */
29 parseExpression: function () { 29 parseExpression: function () {
30 function abort(message) { 30 function abort(message) {
31 throw 'Parse error in selector: ' + message; 31 throw 'Parse error in selector: ' + message;
32 } 32 }
33 33
34 if (this.expression == '') { 34 if (this.expression == '') {
35 abort('empty expression'); 35 abort('empty expression');
36 } 36 }
37 37
38 var repr = MochiKit.Base.repr; 38 var repr = MochiKit.Base.repr;
39 var params = this.params; 39 var params = this.params;
40 var expr = this.expression; 40 var expr = this.expression;
41 var match, modifier, clause, rest; 41 var match, modifier, clause, rest;
42 while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!^$*]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) { 42 while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!^$*]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) {
43 params.attributes = params.attributes || []; 43 params.attributes = params.attributes || [];
44 params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''}); 44 params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''});
45 expr = match[1]; 45 expr = match[1];
46 } 46 }
47 47
48 if (expr == '*') { 48 if (expr == '*') {
49 return this.params.wildcard = true; 49 return this.params.wildcard = true;
50 } 50 }
51 51
52 while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+(?:\([^)]*\))?)(.*)/i)) { 52 while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+(?:\([^)]*\))?)(.*)/i)) {
53 modifier = match[1]; 53 modifier = match[1];
54 clause = match[2]; 54 clause = match[2];
55 rest = match[3]; 55 rest = match[3];
56 switch (modifier) { 56 switch (modifier) {
57 case '#': 57 case '#':
58 params.id = clause; 58 params.id = clause;
59 break; 59 break;
60 case '.': 60 case '.':
61 params.classNames.push(clause); 61 params.classNames.push(clause);
62 break; 62 break;
63 case ':': 63 case ':':
64 params.pseudoClassNames.push(clause); 64 params.pseudoClassNames.push(clause);
65 break; 65 break;
66 case '': 66 case '':
67 case undefined: 67 case undefined:
68 params.tagName = clause.toUpperCase(); 68 params.tagName = clause.toUpperCase();
69 break; 69 break;
70 default: 70 default:
71 abort(repr(expr)); 71 abort(repr(expr));
72 } 72 }
73 expr = rest; 73 expr = rest;
74 } 74 }
75 75
76 if (expr.length > 0) { 76 if (expr.length > 0) {
77 abort(repr(expr)); 77 abort(repr(expr));
78 } 78 }
79 }, 79 },
80 80
81 /** @id MochiKit.Selector.Selector.prototype.buildMatchExpression */ 81 /** @id MochiKit.Selector.Selector.prototype.buildMatchExpression */
82 buildMatchExpression: function () { 82 buildMatchExpression: function () {
83 var repr = MochiKit.Base.repr; 83 var repr = MochiKit.Base.repr;
84 var params = this.params; 84 var params = this.params;
85 var conditions = []; 85 var conditions = [];
86 var clause, i; 86 var clause, i;
87 87
88 function childElements(element) { 88 function childElements(element) {
89 return "MochiKit.Base.filter(function (node) { return node.nodeType == 1; }, " + element + ".childNodes)"; 89 return "MochiKit.Base.filter(function (node) { return node.nodeType == 1; }, " + element + ".childNodes)";
90 } 90 }
91 91
92 if (params.wildcard) { 92 if (params.wildcard) {
93 conditions.push('true'); 93 conditions.push('true');
94 } 94 }
95 if (clause = params.id) { 95 if (clause = params.id) {
96 conditions.push('element.id == ' + repr(clause)); 96 conditions.push('element.id == ' + repr(clause));
97 } 97 }
98 if (clause = params.tagName) { 98 if (clause = params.tagName) {
99 conditions.push('element.tagName.toUpperCase() == ' + repr(clause)); 99 conditions.push('element.tagName.toUpperCase() == ' + repr(clause));
100 } 100 }
101 if ((clause = params.classNames).length > 0) { 101 if ((clause = params.classNames).length > 0) {
102 for (i = 0; i < clause.length; i++) { 102 for (i = 0; i < clause.length; i++) {
103 conditions.push('MochiKit.DOM.hasElementClass(element, ' + repr(clause[i]) + ')'); 103 conditions.push('MochiKit.DOM.hasElementClass(element, ' + repr(clause[i]) + ')');
104 } 104 }
105 } 105 }
106 if ((clause = params.pseudoClassNames).length > 0) { 106 if ((clause = params.pseudoClassNames).length > 0) {
107 for (i = 0; i < clause.length; i++) { 107 for (i = 0; i < clause.length; i++) {
108 var match = clause[i].match(/^([^(]+)(?:\((.*)\))?$/); 108 var match = clause[i].match(/^([^(]+)(?:\((.*)\))?$/);
109 var pseudoClass = match[1]; 109 var pseudoClass = match[1];
110 var pseudoClassArgument = match[2]; 110 var pseudoClassArgument = match[2];
111 switch (pseudoClass) { 111 switch (pseudoClass) {
112 case 'root': 112 case 'root':
113 conditions.push('element.nodeType == 9 || element === element.ownerDocument.documentElement'); break; 113 conditions.push('element.nodeType == 9 || element === element.ownerDocument.documentElement'); break;
114 case 'nth-child': 114 case 'nth-child':
115 case 'nth-last-child': 115 case 'nth-last-child':
116 case 'nth-of-type': 116 case 'nth-of-type':
117 case 'nth-last-of-type': 117 case 'nth-last-of-type':
118 match = pseudoClassArgument.match(/^((?:(\d+)n\+)?(\d+)|odd|even)$/); 118 match = pseudoClassArgument.match(/^((?:(\d+)n\+)?(\d+)|odd|even)$/);
119 if (!match) { 119 if (!match) {
120 throw "Invalid argument to pseudo element nth-child: " + pseudoClassArgument; 120 throw "Invalid argument to pseudo element nth-child: " + pseudoClassArgument;
121 } 121 }
122 var a, b; 122 var a, b;
123 if (match[0] == 'odd') { 123 if (match[0] == 'odd') {
124 a = 2; 124 a = 2;
125 b = 1; 125 b = 1;
126 } else if (match[0] == 'even') { 126 } else if (match[0] == 'even') {
127 a = 2; 127 a = 2;
128 b = 0; 128 b = 0;
129 } else { 129 } else {
130 a = match[2] && parseInt(match) || null; 130 a = match[2] && parseInt(match, 10) || null;
131 b = parseInt(match[3]); 131 b = parseInt(match[3], 10);
132 } 132 }
133 conditions.push('this.nthChild(element,' + a + ',' + b 133 conditions.push('this.nthChild(element,' + a + ',' + b
134 + ',' + !!pseudoClass.match('^nth-last') // Reverse 134 + ',' + !!pseudoClass.match('^nth-last') // Reverse
135 + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName 135 + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName
136 + ')'); 136 + ')');
137 break; 137 break;
138 case 'first-child': 138 case 'first-child':
139 conditions.push('this.nthChild(element, null, 1)'); 139 conditions.push('this.nthChild(element, null, 1)');
140 break; 140 break;
141 case 'last-child': 141 case 'last-child':
142 conditions.push('this.nthChild(element, null, 1, true)'); 142 conditions.push('this.nthChild(element, null, 1, true)');
143 break; 143 break;
144 case 'first-of-type': 144 case 'first-of-type':
145 conditions.push('this.nthChild(element, null, 1, false, true)'); 145 conditions.push('this.nthChild(element, null, 1, false, true)');
146 break; 146 break;
147 case 'last-of-type': 147 case 'last-of-type':
148 conditions.push('this.nthChild(element, null, 1, true, true)'); 148 conditions.push('this.nthChild(element, null, 1, true, true)');
149 break; 149 break;
150 case 'only-child': 150 case 'only-child':
151 conditions.push(childElements('element.parentNode') + '.length == 1'); 151 conditions.push(childElements('element.parentNode') + '.length == 1');
152 break; 152 break;
153 case 'only-of-type': 153 case 'only-of-type':
154 conditions.push('MochiKit.Base.filter(function (node) { return node.tagName == element.tagName; }, ' + childElements('element.parentNode') + ').length == 1'); 154 conditions.push('MochiKit.Base.filter(function (node) { return node.tagName == element.tagName; }, ' + childElements('element.parentNode') + ').length == 1');
155 break; 155 break;
156 case 'empty': 156 case 'empty':
157 conditions.push('element.childNodes.length == 0'); 157 conditions.push('element.childNodes.length == 0');
158 break; 158 break;
159 case 'enabled': 159 case 'enabled':
160 conditions.push('(this.isUIElement(element) && element.disabled === false)'); 160 conditions.push('(this.isUIElement(element) && element.disabled === false)');
161 break; 161 break;
162 case 'disabled': 162 case 'disabled':
163 conditions.push('(this.isUIElement(element) && element.disabled === true)'); 163 conditions.push('(this.isUIElement(element) && element.disabled === true)');
164 break; 164 break;
165 case 'checked': 165 case 'checked':
166 conditions.push('(this.isUIElement(element) && element.checked === true)'); 166 conditions.push('(this.isUIElement(element) && element.checked === true)');
167 break; 167 break;
168 case 'not': 168 case 'not':
169 var subselector = new MochiKit.Selector.Selector(pseudoClassArgument); 169 var subselector = new MochiKit.Selector.Selector(pseudoClassArgument);
170 conditions.push('!( ' + subselector.buildMatchExpression() + ')') 170 conditions.push('!( ' + subselector.buildMatchExpression() + ')');
171 break; 171 break;
172 } 172 }
173 } 173 }
174 } 174 }
175 if (clause = params.attributes) { 175 if (clause = params.attributes) {
176 MochiKit.Base.map(function (attribute) { 176 MochiKit.Base.map(function (attribute) {
177 var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')'; 177 var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')';
178 var splitValueBy = function (delimiter) { 178 var splitValueBy = function (delimiter) {
179 return value + '.split(' + repr(delimiter) + ')'; 179 return value + '.split(' + repr(delimiter) + ')';
180 } 180 };
181 conditions.push(value + ' != null'); 181 conditions.push(value + ' != null');
182 switch (attribute.operator) { 182 switch (attribute.operator) {
183 case '=': 183 case '=':
184 conditions.push(value + ' == ' + repr(attribute.value)); 184 conditions.push(value + ' == ' + repr(attribute.value));
185 break; 185 break;
186 case '~=': 186 case '~=':
187 conditions.push('MochiKit.Base.findValue(' + splitValueBy(' ') + ', ' + repr(attribute.value) + ') > -1'); 187 conditions.push('MochiKit.Base.findValue(' + splitValueBy(' ') + ', ' + repr(attribute.value) + ') > -1');
188 break; 188 break;
189 case '^=': 189 case '^=':
190 conditions.push(value + '.substring(0, ' + attribute.value.length + ') == ' + repr(attribute.value)); 190 conditions.push(value + '.substring(0, ' + attribute.value.length + ') == ' + repr(attribute.value));
191 break; 191 break;
192 case '$=': 192 case '$=':
193 conditions.push(value + '.substring(' + value + '.length - ' + attribute.value.length + ') == ' + repr(attribute.value)); 193 conditions.push(value + '.substring(' + value + '.length - ' + attribute.value.length + ') == ' + repr(attribute.value));
194 break; 194 break;
195 case '*=': 195 case '*=':
196 conditions.push(value + '.match(' + repr(attribute.value) + ')'); 196 conditions.push(value + '.match(' + repr(attribute.value) + ')');
197 break; 197 break;
198 case '|=': 198 case '|=':
199 conditions.push(splitValueBy('-') + '[0].toUpperCase() == ' + repr(attribute.value.toUpperCase())); 199 conditions.push(splitValueBy('-') + '[0].toUpperCase() == ' + repr(attribute.value.toUpperCase()));
200 break; 200 break;
201 case '!=': 201 case '!=':
202 conditions.push(value + ' != ' + repr(attribute.value)); 202 conditions.push(value + ' != ' + repr(attribute.value));
203 break; 203 break;
204 case '': 204 case '':
205 case undefined: 205 case undefined:
206 // Condition already added above 206 // Condition already added above
207 break; 207 break;
208 default: 208 default:
209 throw 'Unknown operator ' + attribute.operator + ' in selector'; 209 throw 'Unknown operator ' + attribute.operator + ' in selector';
210 } 210 }
211 }, clause); 211 }, clause);
212 } 212 }
213 213
214 return conditions.join(' && '); 214 return conditions.join(' && ');
215 }, 215 },
216 216
217 /** @id MochiKit.Selector.Selector.prototype.compileMatcher */ 217 /** @id MochiKit.Selector.Selector.prototype.compileMatcher */
218 compileMatcher: function () { 218 compileMatcher: function () {
219 var code = 'return (!element.tagName) ? false : ' + 219 var code = 'return (!element.tagName) ? false : ' +
220 this.buildMatchExpression() + ';'; 220 this.buildMatchExpression() + ';';
221 this.match = new Function('element', code); 221 this.match = new Function('element', code);
222 }, 222 },
223 223
224 /** @id MochiKit.Selector.Selector.prototype.nthChild */ 224 /** @id MochiKit.Selector.Selector.prototype.nthChild */
225 nthChild: function (element, a, b, reverse, sametag){ 225 nthChild: function (element, a, b, reverse, sametag){
226 var siblings = MochiKit.Base.filter(function (node) { 226 var siblings = MochiKit.Base.filter(function (node) {
227 return node.nodeType == 1; 227 return node.nodeType == 1;
228 }, element.parentNode.childNodes); 228 }, element.parentNode.childNodes);
229 if (sametag) { 229 if (sametag) {
230 siblings = MochiKit.Base.filter(function (node) { 230 siblings = MochiKit.Base.filter(function (node) {
231 return node.tagName == element.tagName; 231 return node.tagName == element.tagName;
232 }, siblings); 232 }, siblings);
233 } 233 }
234 if (reverse) { 234 if (reverse) {
235 siblings = MochiKit.Iter.reversed(siblings); 235 siblings = MochiKit.Iter.reversed(siblings);
236 } 236 }
237 if (a) { 237 if (a) {
238 var actualIndex = MochiKit.Base.findIdentical(siblings, element); 238 var actualIndex = MochiKit.Base.findIdentical(siblings, element);
239 return ((actualIndex + 1 - b) / a) % 1 == 0; 239 return ((actualIndex + 1 - b) / a) % 1 == 0;
240 } else { 240 } else {
241 return b == MochiKit.Base.findIdentical(siblings, element) + 1; 241 return b == MochiKit.Base.findIdentical(siblings, element) + 1;
242 } 242 }
243 }, 243 },
244 244
245 /** @id MochiKit.Selector.Selector.prototype.isUIElement */ 245 /** @id MochiKit.Selector.Selector.prototype.isUIElement */
246 isUIElement: function (element) { 246 isUIElement: function (element) {
247 return MochiKit.Base.findValue(['input', 'button', 'select', 'option', 'textarea', 'object'], 247 return MochiKit.Base.findValue(['input', 'button', 'select', 'option', 'textarea', 'object'],
248 element.tagName.toLowerCase()) > -1; 248 element.tagName.toLowerCase()) > -1;
249 }, 249 },
250 250
251 /** @id MochiKit.Selector.Selector.prototype.findElements */ 251 /** @id MochiKit.Selector.Selector.prototype.findElements */
252 findElements: function (scope, axis) { 252 findElements: function (scope, axis) {
253 var element; 253 var element;
254 254
255 if (axis == undefined) { 255 if (axis == undefined) {
256 axis = ""; 256 axis = "";
257 } 257 }
258 258
259 function inScope(element, scope) { 259 function inScope(element, scope) {
260 if (axis == "") { 260 if (axis == "") {
261 return MochiKit.DOM.isChildNode(element, scope); 261 return MochiKit.DOM.isChildNode(element, scope);
262 } else if (axis == ">") { 262 } else if (axis == ">") {
263 return element.parentNode === scope; 263 return element.parentNode === scope;
264 } else if (axis == "+") { 264 } else if (axis == "+") {
265 return element === nextSiblingElement(scope); 265 return element === nextSiblingElement(scope);
266 } else if (axis == "~") { 266 } else if (axis == "~") {
267 var sibling = scope; 267 var sibling = scope;
268 while (sibling = nextSiblingElement(sibling)) { 268 while (sibling = nextSiblingElement(sibling)) {
269 if (element === sibling) { 269 if (element === sibling) {
270 return true; 270 return true;
271 } 271 }
272 } 272 }
273 return false; 273 return false;
274 } else { 274 } else {
275 throw "Invalid axis: " + axis; 275 throw "Invalid axis: " + axis;
276 } 276 }
277 } 277 }
278 278
279 if (element = MochiKit.DOM.getElement(this.params.id)) { 279 if (element = MochiKit.DOM.getElement(this.params.id)) {
280 if (this.match(element)) { 280 if (this.match(element)) {
281 if (!scope || inScope(element, scope)) { 281 if (!scope || inScope(element, scope)) {
282 return [element]; 282 return [element];
283 } 283 }
284 } 284 }
285 } 285 }
286 286
287 function nextSiblingElement(node) { 287 function nextSiblingElement(node) {
288 node = node.nextSibling; 288 node = node.nextSibling;
289 while (node && node.nodeType != 1) { 289 while (node && node.nodeType != 1) {
290 node = node.nextSibling; 290 node = node.nextSibling;
291 } 291 }
292 return node; 292 return node;
293 } 293 }
294 294
295 if (axis == "") { 295 if (axis == "") {
296 scope = (scope || MochiKit.DOM.currentDocument()).getElementsByTagName(this.params.tagName || '*'); 296 scope = (scope || MochiKit.DOM.currentDocument()).getElementsByTagName(this.params.tagName || '*');
297 } else if (axis == ">") { 297 } else if (axis == ">") {
298 if (!scope) { 298 if (!scope) {
299 throw "> combinator not allowed without preceeding expression"; 299 throw "> combinator not allowed without preceeding expression";
300 } 300 }
301 scope = MochiKit.Base.filter(function (node) { 301 scope = MochiKit.Base.filter(function (node) {
302 return node.nodeType == 1; 302 return node.nodeType == 1;
303 }, scope.childNodes); 303 }, scope.childNodes);
304 } else if (axis == "+") { 304 } else if (axis == "+") {
305 if (!scope) { 305 if (!scope) {
306 throw "+ combinator not allowed without preceeding expression"; 306 throw "+ combinator not allowed without preceeding expression";
307 } 307 }
308 scope = nextSiblingElement(scope) && [nextSiblingElement(scope)]; 308 scope = nextSiblingElement(scope) && [nextSiblingElement(scope)];
309 } else if (axis == "~") { 309 } else if (axis == "~") {
310 if (!scope) { 310 if (!scope) {
311 throw "~ combinator not allowed without preceeding expression"; 311 throw "~ combinator not allowed without preceeding expression";
312 } 312 }
313 var newscope = []; 313 var newscope = [];
314 while (nextSiblingElement(scope)) { 314 while (nextSiblingElement(scope)) {
315 scope = nextSiblingElement(scope); 315 scope = nextSiblingElement(scope);
316 newscope.push(scope); 316 newscope.push(scope);
317 } 317 }
318 scope = newscope; 318 scope = newscope;
319 } 319 }
320 320
321 if (!scope) { 321 if (!scope) {
322 return []; 322 return [];
323 } 323 }
324 324
325 var results = MochiKit.Base.filter(MochiKit.Base.bind(function (scopeElt) { 325 var results = MochiKit.Base.filter(MochiKit.Base.bind(function (scopeElt) {
326 return this.match(scopeElt); 326 return this.match(scopeElt);
327 }, this), scope); 327 }, this), scope);
328 328
329 return results; 329 return results;
330 }, 330 },
331 331
332 /** @id MochiKit.Selector.Selector.prototype.repr */ 332 /** @id MochiKit.Selector.Selector.prototype.repr */
333 repr: function () { 333 repr: function () {
334 return 'Selector(' + this.expression + ')'; 334 return 'Selector(' + this.expression + ')';
335 }, 335 },
336 336
337 toString: MochiKit.Base.forwardCall("repr") 337 toString: MochiKit.Base.forwardCall("repr")
338}; 338};
339 339
340MochiKit.Base.update(MochiKit.Selector, { 340MochiKit.Base.update(MochiKit.Selector, {
341 341
342 /** @id MochiKit.Selector.findChildElements */ 342 /** @id MochiKit.Selector.findChildElements */
343 findChildElements: function (element, expressions) { 343 findChildElements: function (element, expressions) {
344 element = MochiKit.DOM.getElement(element); 344 element = MochiKit.DOM.getElement(element);
345 var uniq = function(arr) { 345 var uniq = function(arr) {
346 var res = []; 346 var res = [];
347 for (var i = 0; i < arr.length; i++) { 347 for (var i = 0; i < arr.length; i++) {
348 if (MochiKit.Base.findIdentical(res, arr[i]) < 0) { 348 if (MochiKit.Base.findIdentical(res, arr[i]) < 0) {
349 res.push(arr[i]); 349 res.push(arr[i]);
350 } 350 }
351 } 351 }
352 return res; 352 return res;
353 }; 353 };
354 return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) { 354 return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) {
355 try {
356 var res = element.querySelectorAll(expression);
357 return Array.prototype.slice.call(res, 0);
358 } catch (ignore) {
359 // No querySelectorAll or extended expression syntax used
360 }
355 var nextScope = ""; 361 var nextScope = "";
356 var reducer = function (results, expr) { 362 var reducer = function (results, expr) {
357 var match = expr.match(/^[>+~]$/); 363 var match = expr.match(/^[>+~]$/);
358 if (match) { 364 if (match) {
359 nextScope = match[0]; 365 nextScope = match[0];
360 return results; 366 return results;
361 } else { 367 } else {
362 var selector = new MochiKit.Selector.Selector(expr); 368 var selector = new MochiKit.Selector.Selector(expr);
363 var elements = MochiKit.Iter.reduce(function (elements, result) { 369 var elements = MochiKit.Iter.reduce(function (elements, result) {
364 return MochiKit.Base.extend(elements, selector.findElements(result || element, nextScope)); 370 return MochiKit.Base.extend(elements, selector.findElements(result || element, nextScope));
365 }, results, []); 371 }, results, []);
366 nextScope = ""; 372 nextScope = "";
367 return elements; 373 return elements;
368 } 374 }
369 }; 375 };
370 var exprs = expression.replace(/(^\s+|\s+$)/g, '').split(/\s+/); 376 var exprs = expression.replace(/(^\s+|\s+$)/g, '').split(/\s+/);
371 return uniq(MochiKit.Iter.reduce(reducer, exprs, [null])); 377 return uniq(MochiKit.Iter.reduce(reducer, exprs, [null]));
372 }, expressions)); 378 }, expressions));
373 }, 379 },
374 380
375 findDocElements: function () { 381 findDocElements: function () {
376 return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(), arguments); 382 return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(), arguments);
377 }, 383 },
378 384
379 __new__: function () { 385 __new__: function () {
380 this.$$ = this.findDocElements; 386 this.$$ = this.findDocElements;
381 MochiKit.Base.nameFunctions(this); 387 MochiKit.Base.nameFunctions(this);
382 } 388 }
383}); 389});
384 390
385MochiKit.Selector.__new__(); 391MochiKit.Selector.__new__();
386 392
387MochiKit.Base._exportSymbols(this, MochiKit.Selector); 393MochiKit.Base._exportSymbols(this, MochiKit.Selector);
diff --git a/frontend/gamma/js/MochiKit/Signal.js b/frontend/gamma/js/MochiKit/Signal.js
index 7df5619..11590c1 100644
--- a/frontend/gamma/js/MochiKit/Signal.js
+++ b/frontend/gamma/js/MochiKit/Signal.js
@@ -1,888 +1,901 @@
1/*** 1/***
2 2
3MochiKit.Signal 1.5 3MochiKit.Signal 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito. All rights Reserved. 7(c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Signal', '1.5', ['Base', 'DOM', 'Style']); 11MochiKit.Base.module(MochiKit, 'Signal', '1.5', ['Base', 'DOM']);
12 12
13MochiKit.Signal._observers = []; 13MochiKit.Signal._observers = [];
14 14
15/** @id MochiKit.Signal.Event */ 15/** @id MochiKit.Signal.Event */
16MochiKit.Signal.Event = function (src, e) { 16MochiKit.Signal.Event = function (src, e) {
17 this._event = e || window.event; 17 this._event = e || window.event;
18 this._src = src; 18 this._src = src;
19}; 19};
20MochiKit.Signal.Event.__export__ = false; 20MochiKit.Signal.Event.__export__ = false;
21 21
22MochiKit.Base.update(MochiKit.Signal.Event.prototype, { 22MochiKit.Base.update(MochiKit.Signal.Event.prototype, {
23 23
24 __repr__: function () { 24 __repr__: function () {
25 var repr = MochiKit.Base.repr; 25 var repr = MochiKit.Base.repr;
26 var str = '{event(): ' + repr(this.event()) + 26 var str = '{event(): ' + repr(this.event()) +
27 ', src(): ' + repr(this.src()) + 27 ', src(): ' + repr(this.src()) +
28 ', type(): ' + repr(this.type()) + 28 ', type(): ' + repr(this.type()) +
29 ', target(): ' + repr(this.target()); 29 ', target(): ' + repr(this.target());
30 30
31 if (this.type() && 31 if (this.type() &&
32 this.type().indexOf('key') === 0 || 32 this.type().indexOf('key') === 0 ||
33 this.type().indexOf('mouse') === 0 || 33 this.type().indexOf('mouse') === 0 ||
34 this.type().indexOf('click') != -1 || 34 this.type().indexOf('click') != -1 ||
35 this.type() == 'contextmenu') { 35 this.type() == 'contextmenu') {
36 str += ', modifier(): ' + '{alt: ' + repr(this.modifier().alt) + 36 str += ', modifier(): ' + '{alt: ' + repr(this.modifier().alt) +
37 ', ctrl: ' + repr(this.modifier().ctrl) + 37 ', ctrl: ' + repr(this.modifier().ctrl) +
38 ', meta: ' + repr(this.modifier().meta) + 38 ', meta: ' + repr(this.modifier().meta) +
39 ', shift: ' + repr(this.modifier().shift) + 39 ', shift: ' + repr(this.modifier().shift) +
40 ', any: ' + repr(this.modifier().any) + '}'; 40 ', any: ' + repr(this.modifier().any) + '}';
41 } 41 }
42 42
43 if (this.type() && this.type().indexOf('key') === 0) { 43 if (this.type() && this.type().indexOf('key') === 0) {
44 str += ', key(): {code: ' + repr(this.key().code) + 44 str += ', key(): {code: ' + repr(this.key().code) +
45 ', string: ' + repr(this.key().string) + '}'; 45 ', string: ' + repr(this.key().string) + '}';
46 } 46 }
47 47
48 if (this.type() && ( 48 if (this.type() && (
49 this.type().indexOf('mouse') === 0 || 49 this.type().indexOf('mouse') === 0 ||
50 this.type().indexOf('click') != -1 || 50 this.type().indexOf('click') != -1 ||
51 this.type() == 'contextmenu')) { 51 this.type() == 'contextmenu')) {
52 52
53 str += ', mouse(): {page: ' + repr(this.mouse().page) + 53 str += ', mouse(): {page: ' + repr(this.mouse().page) +
54 ', client: ' + repr(this.mouse().client); 54 ', client: ' + repr(this.mouse().client);
55 55
56 if (this.type() != 'mousemove' && this.type() != 'mousewheel') { 56 if (this.type() != 'mousemove' && this.type() != 'mousewheel') {
57 str += ', button: {left: ' + repr(this.mouse().button.left) + 57 str += ', button: {left: ' + repr(this.mouse().button.left) +
58 ', middle: ' + repr(this.mouse().button.middle) + 58 ', middle: ' + repr(this.mouse().button.middle) +
59 ', right: ' + repr(this.mouse().button.right) + '}'; 59 ', right: ' + repr(this.mouse().button.right) + '}';
60 } 60 }
61 if (this.type() == 'mousewheel') { 61 if (this.type() == 'mousewheel') {
62 str += ', wheel: ' + repr(this.mouse().wheel); 62 str += ', wheel: ' + repr(this.mouse().wheel);
63 } 63 }
64 str += '}'; 64 str += '}';
65 } 65 }
66 if (this.type() == 'mouseover' || this.type() == 'mouseout' || 66 if (this.type() == 'mouseover' || this.type() == 'mouseout' ||
67 this.type() == 'mouseenter' || this.type() == 'mouseleave') { 67 this.type() == 'mouseenter' || this.type() == 'mouseleave') {
68 str += ', relatedTarget(): ' + repr(this.relatedTarget()); 68 str += ', relatedTarget(): ' + repr(this.relatedTarget());
69 } 69 }
70 str += '}'; 70 str += '}';
71 return str; 71 return str;
72 }, 72 },
73 73
74 /** @id MochiKit.Signal.Event.prototype.toString */ 74 /** @id MochiKit.Signal.Event.prototype.toString */
75 toString: function () { 75 toString: function () {
76 return this.__repr__(); 76 return this.__repr__();
77 }, 77 },
78 78
79 /** @id MochiKit.Signal.Event.prototype.src */ 79 /** @id MochiKit.Signal.Event.prototype.src */
80 src: function () { 80 src: function () {
81 return this._src; 81 return this._src;
82 }, 82 },
83 83
84 /** @id MochiKit.Signal.Event.prototype.event */ 84 /** @id MochiKit.Signal.Event.prototype.event */
85 event: function () { 85 event: function () {
86 return this._event; 86 return this._event;
87 }, 87 },
88 88
89 /** @id MochiKit.Signal.Event.prototype.type */ 89 /** @id MochiKit.Signal.Event.prototype.type */
90 type: function () { 90 type: function () {
91 if (this._event.type === "DOMMouseScroll") { 91 if (this._event.type === "DOMMouseScroll") {
92 return "mousewheel"; 92 return "mousewheel";
93 } else { 93 } else {
94 return this._event.type || undefined; 94 return this._event.type || undefined;
95 } 95 }
96 }, 96 },
97 97
98 /** @id MochiKit.Signal.Event.prototype.target */ 98 /** @id MochiKit.Signal.Event.prototype.target */
99 target: function () { 99 target: function () {
100 return this._event.target || this._event.srcElement; 100 return this._event.target || this._event.srcElement;
101 }, 101 },
102 102
103 _relatedTarget: null, 103 _relatedTarget: null,
104 /** @id MochiKit.Signal.Event.prototype.relatedTarget */ 104 /** @id MochiKit.Signal.Event.prototype.relatedTarget */
105 relatedTarget: function () { 105 relatedTarget: function () {
106 if (this._relatedTarget !== null) { 106 if (this._relatedTarget !== null) {
107 return this._relatedTarget; 107 return this._relatedTarget;
108 } 108 }
109 109
110 var elem = null; 110 var elem = null;
111 if (this.type() == 'mouseover' || this.type() == 'mouseenter') { 111 if (this.type() == 'mouseover' || this.type() == 'mouseenter') {
112 elem = (this._event.relatedTarget || 112 elem = (this._event.relatedTarget ||
113 this._event.fromElement); 113 this._event.fromElement);
114 } else if (this.type() == 'mouseout' || this.type() == 'mouseleave') { 114 } else if (this.type() == 'mouseout' || this.type() == 'mouseleave') {
115 elem = (this._event.relatedTarget || 115 elem = (this._event.relatedTarget ||
116 this._event.toElement); 116 this._event.toElement);
117 } 117 }
118 try { 118 try {
119 if (elem !== null && elem.nodeType !== null) { 119 if (elem !== null && elem.nodeType !== null) {
120 this._relatedTarget = elem; 120 this._relatedTarget = elem;
121 return elem; 121 return elem;
122 } 122 }
123 } catch (ignore) { 123 } catch (ignore) {
124 // Firefox 3 throws a permission denied error when accessing 124 // Firefox 3 throws a permission denied error when accessing
125 // any property on XUL elements (e.g. scrollbars)... 125 // any property on XUL elements (e.g. scrollbars)...
126 } 126 }
127 127
128 return undefined; 128 return undefined;
129 }, 129 },
130 130
131 _modifier: null, 131 _modifier: null,
132 /** @id MochiKit.Signal.Event.prototype.modifier */ 132 /** @id MochiKit.Signal.Event.prototype.modifier */
133 modifier: function () { 133 modifier: function () {
134 if (this._modifier !== null) { 134 if (this._modifier !== null) {
135 return this._modifier; 135 return this._modifier;
136 } 136 }
137 var m = {}; 137 var m = {};
138 m.alt = this._event.altKey; 138 m.alt = this._event.altKey;
139 m.ctrl = this._event.ctrlKey; 139 m.ctrl = this._event.ctrlKey;
140 m.meta = this._event.metaKey || false; // IE and Opera punt here 140 m.meta = this._event.metaKey || false; // IE and Opera punt here
141 m.shift = this._event.shiftKey; 141 m.shift = this._event.shiftKey;
142 m.any = m.alt || m.ctrl || m.shift || m.meta; 142 m.any = m.alt || m.ctrl || m.shift || m.meta;
143 this._modifier = m; 143 this._modifier = m;
144 return m; 144 return m;
145 }, 145 },
146 146
147 _key: null, 147 _key: null,
148 /** @id MochiKit.Signal.Event.prototype.key */ 148 /** @id MochiKit.Signal.Event.prototype.key */
149 key: function () { 149 key: function () {
150 if (this._key !== null) { 150 if (this._key !== null) {
151 return this._key; 151 return this._key;
152 } 152 }
153 var k = {}; 153 var k = {};
154 if (this.type() && this.type().indexOf('key') === 0) { 154 if (this.type() && this.type().indexOf('key') === 0) {
155 155
156 /* 156 /*
157 157
158 If you're looking for a special key, look for it in keydown or 158 If you're looking for a special key, look for it in keydown or
159 keyup, but never keypress. If you're looking for a Unicode 159 keyup, but never keypress. If you're looking for a Unicode
160 chracter, look for it with keypress, but never keyup or 160 chracter, look for it with keypress, but never keyup or
161 keydown. 161 keydown.
162 162
163 Notes: 163 Notes:
164 164
165 FF key event behavior: 165 FF key event behavior:
166 key event charCode keyCode 166 key event charCode keyCode
167 DOWN ku,kd 0 40 167 DOWN ku,kd 0 40
168 DOWN kp 0 40 168 DOWN kp 0 40
169 ESC ku,kd 0 27 169 ESC ku,kd 0 27
170 ESC kp 0 27 170 ESC kp 0 27
171 a ku,kd 0 65 171 a ku,kd 0 65
172 a kp 97 0 172 a kp 97 0
173 shift+a ku,kd 0 65 173 shift+a ku,kd 0 65
174 shift+a kp 65 0 174 shift+a kp 65 0
175 1 ku,kd 0 49 175 1 ku,kd 0 49
176 1 kp 49 0 176 1 kp 49 0
177 shift+1 ku,kd 0 0 177 shift+1 ku,kd 0 0
178 shift+1 kp 33 0 178 shift+1 kp 33 0
179 179
180 IE key event behavior: 180 IE key event behavior:
181 (IE doesn't fire keypress events for special keys.) 181 (IE doesn't fire keypress events for special keys.)
182 key event keyCode 182 key event keyCode
183 DOWN ku,kd 40 183 DOWN ku,kd 40
184 DOWN kp undefined 184 DOWN kp undefined
185 ESC ku,kd 27 185 ESC ku,kd 27
186 ESC kp 27 186 ESC kp 27
187 a ku,kd 65 187 a ku,kd 65
188 a kp 97 188 a kp 97
189 shift+a ku,kd 65 189 shift+a ku,kd 65
190 shift+a kp 65 190 shift+a kp 65
191 1 ku,kd 49 191 1 ku,kd 49
192 1 kp 49 192 1 kp 49
193 shift+1 ku,kd 49 193 shift+1 ku,kd 49
194 shift+1 kp 33 194 shift+1 kp 33
195 195
196 Safari key event behavior: 196 Safari key event behavior:
197 (Safari sets charCode and keyCode to something crazy for 197 (Safari sets charCode and keyCode to something crazy for
198 special keys.) 198 special keys.)
199 key event charCode keyCode 199 key event charCode keyCode
200 DOWN ku,kd 63233 40 200 DOWN ku,kd 63233 40
201 DOWN kp 63233 63233 201 DOWN kp 63233 63233
202 ESC ku,kd 27 27 202 ESC ku,kd 27 27
203 ESC kp 27 27 203 ESC kp 27 27
204 a ku,kd 97 65 204 a ku,kd 97 65
205 a kp 97 97 205 a kp 97 97
206 shift+a ku,kd 65 65 206 shift+a ku,kd 65 65
207 shift+a kp 65 65 207 shift+a kp 65 65
208 1 ku,kd 49 49 208 1 ku,kd 49 49
209 1 kp 49 49 209 1 kp 49 49
210 shift+1 ku,kd 33 49 210 shift+1 ku,kd 33 49
211 shift+1 kp 33 33 211 shift+1 kp 33 33
212 212
213 */ 213 */
214 214
215 /* look for special keys here */ 215 /* look for special keys here */
216 if (this.type() == 'keydown' || this.type() == 'keyup') { 216 if (this.type() == 'keydown' || this.type() == 'keyup') {
217 k.code = this._event.keyCode; 217 k.code = this._event.keyCode;
218 k.string = (MochiKit.Signal._specialKeys[k.code] || 218 k.string = (MochiKit.Signal._specialKeys[k.code] ||
219 'KEY_UNKNOWN'); 219 'KEY_UNKNOWN');
220 this._key = k; 220 this._key = k;
221 return k; 221 return k;
222 222
223 /* look for characters here */ 223 /* look for characters here */
224 } else if (this.type() == 'keypress') { 224 } else if (this.type() == 'keypress') {
225 225
226 /* 226 /*
227 227
228 Special key behavior: 228 Special key behavior:
229 229
230 IE: does not fire keypress events for special keys 230 IE: does not fire keypress events for special keys
231 FF: sets charCode to 0, and sets the correct keyCode 231 FF: sets charCode to 0, and sets the correct keyCode
232 Safari: sets keyCode and charCode to something stupid 232 Safari: sets keyCode and charCode to something stupid
233 233
234 */ 234 */
235 235
236 k.code = 0; 236 k.code = 0;
237 k.string = ''; 237 k.string = '';
238 238
239 if (typeof(this._event.charCode) != 'undefined' && 239 if (typeof(this._event.charCode) != 'undefined' &&
240 this._event.charCode !== 0 && 240 this._event.charCode !== 0 &&
241 !MochiKit.Signal._specialMacKeys[this._event.charCode]) { 241 !MochiKit.Signal._specialMacKeys[this._event.charCode]) {
242 k.code = this._event.charCode; 242 k.code = this._event.charCode;
243 k.string = String.fromCharCode(k.code); 243 k.string = String.fromCharCode(k.code);
244 } else if (this._event.keyCode && 244 } else if (this._event.keyCode &&
245 typeof(this._event.charCode) == 'undefined') { // IE 245 typeof(this._event.charCode) == 'undefined') { // IE
246 k.code = this._event.keyCode; 246 k.code = this._event.keyCode;
247 k.string = String.fromCharCode(k.code); 247 k.string = String.fromCharCode(k.code);
248 } 248 }
249 249
250 this._key = k; 250 this._key = k;
251 return k; 251 return k;
252 } 252 }
253 } 253 }
254 return undefined; 254 return undefined;
255 }, 255 },
256 256
257 _mouse: null, 257 _mouse: null,
258 /** @id MochiKit.Signal.Event.prototype.mouse */ 258 /** @id MochiKit.Signal.Event.prototype.mouse */
259 mouse: function () { 259 mouse: function () {
260 if (this._mouse !== null) { 260 if (this._mouse !== null) {
261 return this._mouse; 261 return this._mouse;
262 } 262 }
263 263
264 var m = {}; 264 var m = {};
265 var e = this._event; 265 var e = this._event;
266 266
267 if (this.type() && ( 267 if (this.type() && (
268 this.type().indexOf('mouse') === 0 || 268 this.type().indexOf('mouse') === 0 ||
269 this.type().indexOf('drag') === 0 ||
269 this.type().indexOf('click') != -1 || 270 this.type().indexOf('click') != -1 ||
270 this.type() == 'contextmenu')) { 271 this.type() == 'contextmenu')) {
271 272
272 m.client = new MochiKit.Style.Coordinates(0, 0); 273 m.client = { x: 0, y: 0 };
273 if (e.clientX || e.clientY) { 274 if (e.clientX || e.clientY) {
274 m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX; 275 m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX;
275 m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY; 276 m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY;
276 } 277 }
277 278
278 m.page = new MochiKit.Style.Coordinates(0, 0); 279 m.page = { x: 0, y: 0 };
279 if (e.pageX || e.pageY) { 280 if (e.pageX || e.pageY) {
280 m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX; 281 m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX;
281 m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY; 282 m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY;
282 } else { 283 } else {
283 /* 284 /*
284 285
285 The IE shortcut can be off by two. We fix it. See: 286 The IE shortcut can be off by two. We fix it. See:
286 http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp 287 http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp
287 288
288 This is similar to the method used in 289 This is similar to the method used in
289 MochiKit.Style.getElementPosition(). 290 MochiKit.Style.getElementPosition().
290 291
291 */ 292 */
292 var de = MochiKit.DOM._document.documentElement; 293 var de = MochiKit.DOM._document.documentElement;
293 var b = MochiKit.DOM._document.body; 294 var b = MochiKit.DOM._document.body;
294 295
295 m.page.x = e.clientX + 296 m.page.x = e.clientX +
296 (de.scrollLeft || b.scrollLeft) - 297 (de.scrollLeft || b.scrollLeft) -
297 (de.clientLeft || 0); 298 (de.clientLeft || 0);
298 299
299 m.page.y = e.clientY + 300 m.page.y = e.clientY +
300 (de.scrollTop || b.scrollTop) - 301 (de.scrollTop || b.scrollTop) -
301 (de.clientTop || 0); 302 (de.clientTop || 0);
302 303
303 } 304 }
304 if (this.type() != 'mousemove' && this.type() != 'mousewheel') { 305 if (this.type() != 'mousemove' && this.type() != 'mousewheel') {
305 m.button = {}; 306 m.button = {};
306 m.button.left = false; 307 m.button.left = false;
307 m.button.right = false; 308 m.button.right = false;
308 m.button.middle = false; 309 m.button.middle = false;
309 310
310 /* we could check e.button, but which is more consistent */ 311 /* we could check e.button, but which is more consistent */
311 if (e.which) { 312 if (e.which) {
312 m.button.left = (e.which == 1); 313 m.button.left = (e.which == 1);
313 m.button.middle = (e.which == 2); 314 m.button.middle = (e.which == 2);
314 m.button.right = (e.which == 3); 315 m.button.right = (e.which == 3);
315 316
316 /* 317 /*
317 318
318 Mac browsers and right click: 319 Mac browsers and right click:
319 320
320 - Safari doesn't fire any click events on a right 321 - Safari doesn't fire any click events on a right
321 click: 322 click:
322 http://bugs.webkit.org/show_bug.cgi?id=6595 323 http://bugs.webkit.org/show_bug.cgi?id=6595
323 324
324 - Firefox fires the event, and sets ctrlKey = true 325 - Firefox fires the event, and sets ctrlKey = true
325 326
326 - Opera fires the event, and sets metaKey = true 327 - Opera fires the event, and sets metaKey = true
327 328
328 oncontextmenu is fired on right clicks between 329 oncontextmenu is fired on right clicks between
329 browsers and across platforms. 330 browsers and across platforms.
330 331
331 */ 332 */
332 333
333 } else { 334 } else {
334 m.button.left = !!(e.button & 1); 335 m.button.left = !!(e.button & 1);
335 m.button.right = !!(e.button & 2); 336 m.button.right = !!(e.button & 2);
336 m.button.middle = !!(e.button & 4); 337 m.button.middle = !!(e.button & 4);
337 } 338 }
338 } 339 }
339 if (this.type() == 'mousewheel') { 340 if (this.type() == 'mousewheel') {
340 m.wheel = new MochiKit.Style.Coordinates(0, 0); 341 m.wheel = { x: 0, y: 0 };
341 if (e.wheelDeltaX || e.wheelDeltaY) { 342 if (e.wheelDeltaX || e.wheelDeltaY) {
342 m.wheel.x = e.wheelDeltaX / -40 || 0; 343 m.wheel.x = e.wheelDeltaX / -40 || 0;
343 m.wheel.y = e.wheelDeltaY / -40 || 0; 344 m.wheel.y = e.wheelDeltaY / -40 || 0;
344 } else if (e.wheelDelta) { 345 } else if (e.wheelDelta) {
345 m.wheel.y = e.wheelDelta / -40; 346 m.wheel.y = e.wheelDelta / -40;
346 } else { 347 } else {
347 m.wheel.y = e.detail || 0; 348 m.wheel.y = e.detail || 0;
348 } 349 }
349 } 350 }
350 this._mouse = m; 351 this._mouse = m;
351 return m; 352 return m;
352 } 353 }
353 return undefined; 354 return undefined;
354 }, 355 },
355 356
356 /** @id MochiKit.Signal.Event.prototype.stop */ 357 /** @id MochiKit.Signal.Event.prototype.stop */
357 stop: function () { 358 stop: function () {
358 this.stopPropagation(); 359 this.stopPropagation();
359 this.preventDefault(); 360 this.preventDefault();
360 }, 361 },
361 362
362 /** @id MochiKit.Signal.Event.prototype.stopPropagation */ 363 /** @id MochiKit.Signal.Event.prototype.stopPropagation */
363 stopPropagation: function () { 364 stopPropagation: function () {
364 if (this._event.stopPropagation) { 365 if (this._event.stopPropagation) {
365 this._event.stopPropagation(); 366 this._event.stopPropagation();
366 } else { 367 } else {
367 this._event.cancelBubble = true; 368 this._event.cancelBubble = true;
368 } 369 }
369 }, 370 },
370 371
371 /** @id MochiKit.Signal.Event.prototype.preventDefault */ 372 /** @id MochiKit.Signal.Event.prototype.preventDefault */
372 preventDefault: function () { 373 preventDefault: function () {
373 if (this._event.preventDefault) { 374 if (this._event.preventDefault) {
374 this._event.preventDefault(); 375 this._event.preventDefault();
375 } else if (this._confirmUnload === null) { 376 } else if (this._confirmUnload === null) {
376 this._event.returnValue = false; 377 this._event.returnValue = false;
377 } 378 }
378 }, 379 },
379 380
380 _confirmUnload: null, 381 _confirmUnload: null,
381 382
382 /** @id MochiKit.Signal.Event.prototype.confirmUnload */ 383 /** @id MochiKit.Signal.Event.prototype.confirmUnload */
383 confirmUnload: function (msg) { 384 confirmUnload: function (msg) {
384 if (this.type() == 'beforeunload') { 385 if (this.type() == 'beforeunload') {
385 this._confirmUnload = msg; 386 this._confirmUnload = msg;
386 this._event.returnValue = msg; 387 this._event.returnValue = msg;
387 } 388 }
388 } 389 }
389}); 390});
390 391
391/* Safari sets keyCode to these special values onkeypress. */ 392/* Safari sets keyCode to these special values onkeypress. */
392MochiKit.Signal._specialMacKeys = { 393MochiKit.Signal._specialMacKeys = {
393 3: 'KEY_ENTER', 394 3: 'KEY_ENTER',
394 63289: 'KEY_NUM_PAD_CLEAR', 395 63289: 'KEY_NUM_PAD_CLEAR',
395 63276: 'KEY_PAGE_UP', 396 63276: 'KEY_PAGE_UP',
396 63277: 'KEY_PAGE_DOWN', 397 63277: 'KEY_PAGE_DOWN',
397 63275: 'KEY_END', 398 63275: 'KEY_END',
398 63273: 'KEY_HOME', 399 63273: 'KEY_HOME',
399 63234: 'KEY_ARROW_LEFT', 400 63234: 'KEY_ARROW_LEFT',
400 63232: 'KEY_ARROW_UP', 401 63232: 'KEY_ARROW_UP',
401 63235: 'KEY_ARROW_RIGHT', 402 63235: 'KEY_ARROW_RIGHT',
402 63233: 'KEY_ARROW_DOWN', 403 63233: 'KEY_ARROW_DOWN',
403 63302: 'KEY_INSERT', 404 63302: 'KEY_INSERT',
404 63272: 'KEY_DELETE' 405 63272: 'KEY_DELETE'
405}; 406};
406 407
407/* for KEY_F1 - KEY_F12 */ 408/* for KEY_F1 - KEY_F12 */
408(function () { 409(function () {
409 var _specialMacKeys = MochiKit.Signal._specialMacKeys; 410 var _specialMacKeys = MochiKit.Signal._specialMacKeys;
410 for (var i = 63236; i <= 63242; i++) { 411 for (var i = 63236; i <= 63242; i++) {
411 // no F0 412 // no F0
412 _specialMacKeys[i] = 'KEY_F' + (i - 63236 + 1); 413 _specialMacKeys[i] = 'KEY_F' + (i - 63236 + 1);
413 } 414 }
414})(); 415})();
415 416
416/* Standard keyboard key codes. */ 417/* Standard keyboard key codes. */
417MochiKit.Signal._specialKeys = { 418MochiKit.Signal._specialKeys = {
418 8: 'KEY_BACKSPACE', 419 8: 'KEY_BACKSPACE',
419 9: 'KEY_TAB', 420 9: 'KEY_TAB',
420 12: 'KEY_NUM_PAD_CLEAR', // weird, for Safari and Mac FF only 421 12: 'KEY_NUM_PAD_CLEAR', // weird, for Safari and Mac FF only
421 13: 'KEY_ENTER', 422 13: 'KEY_ENTER',
422 16: 'KEY_SHIFT', 423 16: 'KEY_SHIFT',
423 17: 'KEY_CTRL', 424 17: 'KEY_CTRL',
424 18: 'KEY_ALT', 425 18: 'KEY_ALT',
425 19: 'KEY_PAUSE', 426 19: 'KEY_PAUSE',
426 20: 'KEY_CAPS_LOCK', 427 20: 'KEY_CAPS_LOCK',
427 27: 'KEY_ESCAPE', 428 27: 'KEY_ESCAPE',
428 32: 'KEY_SPACEBAR', 429 32: 'KEY_SPACEBAR',
429 33: 'KEY_PAGE_UP', 430 33: 'KEY_PAGE_UP',
430 34: 'KEY_PAGE_DOWN', 431 34: 'KEY_PAGE_DOWN',
431 35: 'KEY_END', 432 35: 'KEY_END',
432 36: 'KEY_HOME', 433 36: 'KEY_HOME',
433 37: 'KEY_ARROW_LEFT', 434 37: 'KEY_ARROW_LEFT',
434 38: 'KEY_ARROW_UP', 435 38: 'KEY_ARROW_UP',
435 39: 'KEY_ARROW_RIGHT', 436 39: 'KEY_ARROW_RIGHT',
436 40: 'KEY_ARROW_DOWN', 437 40: 'KEY_ARROW_DOWN',
437 44: 'KEY_PRINT_SCREEN', 438 44: 'KEY_PRINT_SCREEN',
438 45: 'KEY_INSERT', 439 45: 'KEY_INSERT',
439 46: 'KEY_DELETE', 440 46: 'KEY_DELETE',
440 59: 'KEY_SEMICOLON', // weird, for Safari and IE only 441 59: 'KEY_SEMICOLON', // weird, for Safari and IE only
441 91: 'KEY_WINDOWS_LEFT', 442 91: 'KEY_WINDOWS_LEFT',
442 92: 'KEY_WINDOWS_RIGHT', 443 92: 'KEY_WINDOWS_RIGHT',
443 93: 'KEY_SELECT', 444 93: 'KEY_SELECT',
444 106: 'KEY_NUM_PAD_ASTERISK', 445 106: 'KEY_NUM_PAD_ASTERISK',
445 107: 'KEY_NUM_PAD_PLUS_SIGN', 446 107: 'KEY_NUM_PAD_PLUS_SIGN',
446 109: 'KEY_NUM_PAD_HYPHEN-MINUS', 447 109: 'KEY_NUM_PAD_HYPHEN-MINUS',
447 110: 'KEY_NUM_PAD_FULL_STOP', 448 110: 'KEY_NUM_PAD_FULL_STOP',
448 111: 'KEY_NUM_PAD_SOLIDUS', 449 111: 'KEY_NUM_PAD_SOLIDUS',
449 144: 'KEY_NUM_LOCK', 450 144: 'KEY_NUM_LOCK',
450 145: 'KEY_SCROLL_LOCK', 451 145: 'KEY_SCROLL_LOCK',
451 186: 'KEY_SEMICOLON', 452 186: 'KEY_SEMICOLON',
452 187: 'KEY_EQUALS_SIGN', 453 187: 'KEY_EQUALS_SIGN',
453 188: 'KEY_COMMA', 454 188: 'KEY_COMMA',
454 189: 'KEY_HYPHEN-MINUS', 455 189: 'KEY_HYPHEN-MINUS',
455 190: 'KEY_FULL_STOP', 456 190: 'KEY_FULL_STOP',
456 191: 'KEY_SOLIDUS', 457 191: 'KEY_SOLIDUS',
457 192: 'KEY_GRAVE_ACCENT', 458 192: 'KEY_GRAVE_ACCENT',
458 219: 'KEY_LEFT_SQUARE_BRACKET', 459 219: 'KEY_LEFT_SQUARE_BRACKET',
459 220: 'KEY_REVERSE_SOLIDUS', 460 220: 'KEY_REVERSE_SOLIDUS',
460 221: 'KEY_RIGHT_SQUARE_BRACKET', 461 221: 'KEY_RIGHT_SQUARE_BRACKET',
461 222: 'KEY_APOSTROPHE' 462 222: 'KEY_APOSTROPHE'
462 // undefined: 'KEY_UNKNOWN' 463 // undefined: 'KEY_UNKNOWN'
463}; 464};
464 465
465(function () { 466(function () {
466 /* for KEY_0 - KEY_9 */ 467 /* for KEY_0 - KEY_9 */
467 var _specialKeys = MochiKit.Signal._specialKeys; 468 var _specialKeys = MochiKit.Signal._specialKeys;
468 for (var i = 48; i <= 57; i++) { 469 for (var i = 48; i <= 57; i++) {
469 _specialKeys[i] = 'KEY_' + (i - 48); 470 _specialKeys[i] = 'KEY_' + (i - 48);
470 } 471 }
471 472
472 /* for KEY_A - KEY_Z */ 473 /* for KEY_A - KEY_Z */
473 for (i = 65; i <= 90; i++) { 474 for (i = 65; i <= 90; i++) {
474 _specialKeys[i] = 'KEY_' + String.fromCharCode(i); 475 _specialKeys[i] = 'KEY_' + String.fromCharCode(i);
475 } 476 }
476 477
477 /* for KEY_NUM_PAD_0 - KEY_NUM_PAD_9 */ 478 /* for KEY_NUM_PAD_0 - KEY_NUM_PAD_9 */
478 for (i = 96; i <= 105; i++) { 479 for (i = 96; i <= 105; i++) {
479 _specialKeys[i] = 'KEY_NUM_PAD_' + (i - 96); 480 _specialKeys[i] = 'KEY_NUM_PAD_' + (i - 96);
480 } 481 }
481 482
482 /* for KEY_F1 - KEY_F12 */ 483 /* for KEY_F1 - KEY_F12 */
483 for (i = 112; i <= 123; i++) { 484 for (i = 112; i <= 123; i++) {
484 // no F0 485 // no F0
485 _specialKeys[i] = 'KEY_F' + (i - 112 + 1); 486 _specialKeys[i] = 'KEY_F' + (i - 112 + 1);
486 } 487 }
487})(); 488})();
488 489
489/* Internal object to keep track of created signals. */ 490/* Internal object to keep track of created signals. */
490MochiKit.Signal.Ident = function (ident) { 491MochiKit.Signal.Ident = function (ident) {
491 this.source = ident.source; 492 this.source = ident.source;
492 this.signal = ident.signal; 493 this.signal = ident.signal;
493 this.listener = ident.listener; 494 this.listener = ident.listener;
494 this.isDOM = ident.isDOM; 495 this.isDOM = ident.isDOM;
495 this.objOrFunc = ident.objOrFunc; 496 this.objOrFunc = ident.objOrFunc;
496 this.funcOrStr = ident.funcOrStr; 497 this.funcOrStr = ident.funcOrStr;
497 this.connected = ident.connected; 498 this.connected = ident.connected;
498}; 499};
499MochiKit.Signal.Ident.__export__ = false; 500MochiKit.Signal.Ident.__export__ = false;
500MochiKit.Signal.Ident.prototype = {}; 501MochiKit.Signal.Ident.prototype = {};
501 502
502MochiKit.Base.update(MochiKit.Signal, { 503MochiKit.Base.update(MochiKit.Signal, {
503 504
504 _unloadCache: function () { 505 _unloadCache: function () {
505 var self = MochiKit.Signal; 506 var self = MochiKit.Signal;
506 var observers = self._observers; 507 var observers = self._observers;
507 508
508 for (var i = 0; i < observers.length; i++) { 509 for (var i = 0; i < observers.length; i++) {
509 if (observers[i].signal !== 'onload' && observers[i].signal !== 'onunload') { 510 if (observers[i].signal !== 'onload' && observers[i].signal !== 'onunload') {
510 self._disconnect(observers[i]); 511 self._disconnect(observers[i]);
511 } 512 }
512 } 513 }
513 }, 514 },
514 515
515 _listener: function (src, sig, func, obj, isDOM) { 516 _listener: function (src, sig, func, obj, isDOM) {
516 var self = MochiKit.Signal; 517 var self = MochiKit.Signal;
517 var E = self.Event; 518 var E = self.Event;
518 if (!isDOM) { 519 if (!isDOM) {
519 /* We don't want to re-bind already bound methods */ 520 /* We don't want to re-bind already bound methods */
520 if (typeof(func.im_self) == 'undefined') { 521 if (typeof(func.im_self) == 'undefined') {
521 return MochiKit.Base.bindLate(func, obj); 522 return MochiKit.Base.bindLate(func, obj);
522 } else { 523 } else {
523 return func; 524 return func;
524 } 525 }
525 } 526 }
526 obj = obj || src; 527 obj = obj || src;
527 if (typeof(func) == "string") { 528 if (typeof(func) == "string") {
528 if (sig === 'onload' || sig === 'onunload') { 529 if (sig === 'onload' || sig === 'onunload') {
529 return function (nativeEvent) { 530 return function (nativeEvent) {
530 obj[func].apply(obj, [new E(src, nativeEvent)]); 531 obj[func].apply(obj, [new E(src, nativeEvent)]);
531 532
532 var ident = new MochiKit.Signal.Ident({ 533 var ident = new MochiKit.Signal.Ident({
533 source: src, signal: sig, objOrFunc: obj, funcOrStr: func}); 534 source: src, signal: sig, objOrFunc: obj, funcOrStr: func});
534 535
535 MochiKit.Signal._disconnect(ident); 536 MochiKit.Signal._disconnect(ident);
536 }; 537 };
537 } else { 538 } else {
538 return function (nativeEvent) { 539 return function (nativeEvent) {
539 obj[func].apply(obj, [new E(src, nativeEvent)]); 540 obj[func].apply(obj, [new E(src, nativeEvent)]);
540 }; 541 };
541 } 542 }
542 } else { 543 } else {
543 if (sig === 'onload' || sig === 'onunload') { 544 if (sig === 'onload' || sig === 'onunload') {
544 return function (nativeEvent) { 545 return function (nativeEvent) {
545 func.apply(obj, [new E(src, nativeEvent)]); 546 func.apply(obj, [new E(src, nativeEvent)]);
546 547
547 var ident = new MochiKit.Signal.Ident({ 548 var ident = new MochiKit.Signal.Ident({
548 source: src, signal: sig, objOrFunc: func}); 549 source: src, signal: sig, objOrFunc: func});
549 550
550 MochiKit.Signal._disconnect(ident); 551 MochiKit.Signal._disconnect(ident);
551 }; 552 };
552 } else { 553 } else {
553 return function (nativeEvent) { 554 return function (nativeEvent) {
554 func.apply(obj, [new E(src, nativeEvent)]); 555 func.apply(obj, [new E(src, nativeEvent)]);
555 }; 556 };
556 } 557 }
557 } 558 }
558 }, 559 },
559 560
560 _browserAlreadyHasMouseEnterAndLeave: function () { 561 _browserAlreadyHasMouseEnterAndLeave: function () {
561 return /MSIE/.test(navigator.userAgent); 562 return /MSIE/.test(navigator.userAgent);
562 }, 563 },
563 564
564 _browserLacksMouseWheelEvent: function () { 565 _browserLacksMouseWheelEvent: function () {
565 return /Gecko\//.test(navigator.userAgent); 566 return /Gecko\//.test(navigator.userAgent);
566 }, 567 },
567 568
568 _mouseEnterListener: function (src, sig, func, obj) { 569 _mouseEnterListener: function (src, sig, func, obj) {
569 var E = MochiKit.Signal.Event; 570 var E = MochiKit.Signal.Event;
570 return function (nativeEvent) { 571 return function (nativeEvent) {
571 var e = new E(src, nativeEvent); 572 var e = new E(src, nativeEvent);
572 try { 573 try {
573 e.relatedTarget().nodeName; 574 e.relatedTarget().nodeName;
574 } catch (err) { 575 } catch (err) {
575 /* probably hit a permission denied error; possibly one of 576 /* probably hit a permission denied error; possibly one of
576 * firefox's screwy anonymous DIVs inside an input element. 577 * firefox's screwy anonymous DIVs inside an input element.
577 * Allow this event to propogate up. 578 * Allow this event to propogate up.
578 */ 579 */
579 return; 580 return;
580 } 581 }
581 e.stop(); 582 e.stop();
582 if (MochiKit.DOM.isChildNode(e.relatedTarget(), src)) { 583 if (MochiKit.DOM.isChildNode(e.relatedTarget(), src)) {
583 /* We've moved between our node and a child. Ignore. */ 584 /* We've moved between our node and a child. Ignore. */
584 return; 585 return;
585 } 586 }
586 e.type = function () { return sig; }; 587 e.type = function () { return sig; };
587 if (typeof(func) == "string") { 588 if (typeof(func) == "string") {
588 return obj[func].apply(obj, [e]); 589 return obj[func].apply(obj, [e]);
589 } else { 590 } else {
590 return func.apply(obj, [e]); 591 return func.apply(obj, [e]);
591 } 592 }
592 }; 593 };
593 }, 594 },
594 595
595 _getDestPair: function (objOrFunc, funcOrStr) { 596 _getDestPair: function (objOrFunc, funcOrStr) {
596 var obj = null; 597 var obj = null;
597 var func = null; 598 var func = null;
598 if (typeof(funcOrStr) != 'undefined') { 599 if (typeof(funcOrStr) != 'undefined') {
599 obj = objOrFunc; 600 obj = objOrFunc;
600 func = funcOrStr; 601 func = funcOrStr;
601 if (typeof(funcOrStr) == 'string') { 602 if (typeof(funcOrStr) == 'string') {
602 if (typeof(objOrFunc[funcOrStr]) != "function") { 603 if (typeof(objOrFunc[funcOrStr]) != "function") {
603 throw new Error("'funcOrStr' must be a function on 'objOrFunc'"); 604 throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
604 } 605 }
605 } else if (typeof(funcOrStr) != 'function') { 606 } else if (typeof(funcOrStr) != 'function') {
606 throw new Error("'funcOrStr' must be a function or string"); 607 throw new Error("'funcOrStr' must be a function or string");
607 } 608 }
608 } else if (typeof(objOrFunc) != "function") { 609 } else if (typeof(objOrFunc) != "function") {
609 throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given"); 610 throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
610 } else { 611 } else {
611 func = objOrFunc; 612 func = objOrFunc;
612 } 613 }
613 return [obj, func]; 614 return [obj, func];
614 }, 615 },
615 616
616 /** @id MochiKit.Signal.connect */ 617 /** @id MochiKit.Signal.connect */
617 connect: function (src, sig, objOrFunc/* optional */, funcOrStr) { 618 connect: function (src, sig, objOrFunc/* optional */, funcOrStr) {
618 if (typeof(src) == "string") { 619 if (typeof(src) == "string") {
619 src = MochiKit.DOM.getElement(src); 620 src = MochiKit.DOM.getElement(src);
620 } 621 }
621 var self = MochiKit.Signal; 622 var self = MochiKit.Signal;
622 623
623 if (typeof(sig) != 'string') { 624 if (typeof(sig) != 'string') {
624 throw new Error("'sig' must be a string"); 625 throw new Error("'sig' must be a string");
625 } 626 }
626 627
627 var destPair = self._getDestPair(objOrFunc, funcOrStr); 628 var destPair = self._getDestPair(objOrFunc, funcOrStr);
628 var obj = destPair[0]; 629 var obj = destPair[0];
629 var func = destPair[1]; 630 var func = destPair[1];
630 if (typeof(obj) == 'undefined' || obj === null) { 631 if (typeof(obj) == 'undefined' || obj === null) {
631 obj = src; 632 obj = src;
632 } 633 }
633 634
634 var isDOM = !!(src.addEventListener || src.attachEvent); 635 var isDOM = !!(src.addEventListener || src.attachEvent);
635 if (isDOM && (sig === "onmouseenter" || sig === "onmouseleave") 636 if (isDOM && (sig === "onmouseenter" || sig === "onmouseleave")
636 && !self._browserAlreadyHasMouseEnterAndLeave()) { 637 && !self._browserAlreadyHasMouseEnterAndLeave()) {
637 var listener = self._mouseEnterListener(src, sig.substr(2), func, obj); 638 var listener = self._mouseEnterListener(src, sig.substr(2), func, obj);
638 if (sig === "onmouseenter") { 639 if (sig === "onmouseenter") {
639 sig = "onmouseover"; 640 sig = "onmouseover";
640 } else { 641 } else {
641 sig = "onmouseout"; 642 sig = "onmouseout";
642 } 643 }
643 } else if (isDOM && sig == "onmousewheel" && self._browserLacksMouseWheelEvent()) { 644 } else if (isDOM && sig == "onmousewheel" && self._browserLacksMouseWheelEvent()) {
644 var listener = self._listener(src, sig, func, obj, isDOM); 645 var listener = self._listener(src, sig, func, obj, isDOM);
645 sig = "onDOMMouseScroll"; 646 sig = "onDOMMouseScroll";
646 } else { 647 } else {
647 var listener = self._listener(src, sig, func, obj, isDOM); 648 var listener = self._listener(src, sig, func, obj, isDOM);
648 } 649 }
649 650
650 if (src.addEventListener) { 651 if (src.addEventListener) {
651 src.addEventListener(sig.substr(2), listener, false); 652 src.addEventListener(sig.substr(2), listener, false);
652 } else if (src.attachEvent) { 653 } else if (src.attachEvent) {
653 src.attachEvent(sig, listener); // useCapture unsupported 654 src.attachEvent(sig, listener); // useCapture unsupported
654 } 655 }
655 656
656 var ident = new MochiKit.Signal.Ident({ 657 var ident = new MochiKit.Signal.Ident({
657 source: src, 658 source: src,
658 signal: sig, 659 signal: sig,
659 listener: listener, 660 listener: listener,
660 isDOM: isDOM, 661 isDOM: isDOM,
661 objOrFunc: objOrFunc, 662 objOrFunc: objOrFunc,
662 funcOrStr: funcOrStr, 663 funcOrStr: funcOrStr,
663 connected: true 664 connected: true
664 }); 665 });
665 self._observers.push(ident); 666 self._observers.push(ident);
666 667
667 if (!isDOM && typeof(src.__connect__) == 'function') { 668 if (!isDOM && typeof(src.__connect__) == 'function') {
668 var args = MochiKit.Base.extend([ident], arguments, 1); 669 var args = MochiKit.Base.extend([ident], arguments, 1);
669 src.__connect__.apply(src, args); 670 src.__connect__.apply(src, args);
670 } 671 }
671 672
672 return ident; 673 return ident;
673 }, 674 },
674 675
676 /** @id MochiKit.Signal.connectOnce */
677 connectOnce: function (src, sig, objOrFunc/* optional */, funcOrStr) {
678 var self = MochiKit.Signal;
679 var ident1 = self.connect(src, sig, objOrFunc, funcOrStr);
680 var ident2;
681 ident2 = self.connect(src, sig, function() {
682 self.disconnect(ident1);
683 self.disconnect(ident2);
684 });
685 return ident1;
686 },
687
675 _disconnect: function (ident) { 688 _disconnect: function (ident) {
676 // already disconnected 689 // already disconnected
677 if (!ident.connected) { 690 if (!ident.connected) {
678 return; 691 return;
679 } 692 }
680 ident.connected = false; 693 ident.connected = false;
681 var src = ident.source; 694 var src = ident.source;
682 var sig = ident.signal; 695 var sig = ident.signal;
683 var listener = ident.listener; 696 var listener = ident.listener;
684 // check isDOM 697 // check isDOM
685 if (!ident.isDOM) { 698 if (!ident.isDOM) {
686 if (typeof(src.__disconnect__) == 'function') { 699 if (typeof(src.__disconnect__) == 'function') {
687 src.__disconnect__(ident, sig, ident.objOrFunc, ident.funcOrStr); 700 src.__disconnect__(ident, sig, ident.objOrFunc, ident.funcOrStr);
688 } 701 }
689 return; 702 return;
690 } 703 }
691 if (src.removeEventListener) { 704 if (src.removeEventListener) {
692 src.removeEventListener(sig.substr(2), listener, false); 705 src.removeEventListener(sig.substr(2), listener, false);
693 } else if (src.detachEvent) { 706 } else if (src.detachEvent) {
694 src.detachEvent(sig, listener); // useCapture unsupported 707 src.detachEvent(sig, listener); // useCapture unsupported
695 } else { 708 } else {
696 throw new Error("'src' must be a DOM element"); 709 throw new Error("'src' must be a DOM element");
697 } 710 }
698 }, 711 },
699 712
700 /** @id MochiKit.Signal.disconnect */ 713 /** @id MochiKit.Signal.disconnect */
701 disconnect: function (ident) { 714 disconnect: function (ident) {
702 var self = MochiKit.Signal; 715 var self = MochiKit.Signal;
703 var observers = self._observers; 716 var observers = self._observers;
704 var m = MochiKit.Base; 717 var m = MochiKit.Base;
705 if (arguments.length > 1) { 718 if (arguments.length > 1) {
706 // compatibility API 719 // compatibility API
707 var src = arguments[0]; 720 var src = arguments[0];
708 if (typeof(src) == "string") { 721 if (typeof(src) == "string") {
709 src = MochiKit.DOM.getElement(src); 722 src = MochiKit.DOM.getElement(src);
710 } 723 }
711 var sig = arguments[1]; 724 var sig = arguments[1];
712 var obj = arguments[2]; 725 var obj = arguments[2];
713 var func = arguments[3]; 726 var func = arguments[3];
714 for (var i = observers.length - 1; i >= 0; i--) { 727 for (var i = observers.length - 1; i >= 0; i--) {
715 var o = observers[i]; 728 var o = observers[i];
716 if (o.source === src && o.signal === sig && o.objOrFunc === obj && o.funcOrStr === func) { 729 if (o.source === src && o.signal === sig && o.objOrFunc === obj && o.funcOrStr === func) {
717 self._disconnect(o); 730 self._disconnect(o);
718 if (!self._lock) { 731 if (self._lock === 0) {
719 observers.splice(i, 1); 732 observers.splice(i, 1);
720 } else { 733 } else {
721 self._dirty = true; 734 self._dirty = true;
722 } 735 }
723 return true; 736 return true;
724 } 737 }
725 } 738 }
726 } else { 739 } else {
727 var idx = m.findIdentical(observers, ident); 740 var idx = m.findIdentical(observers, ident);
728 if (idx >= 0) { 741 if (idx >= 0) {
729 self._disconnect(ident); 742 self._disconnect(ident);
730 if (!self._lock) { 743 if (self._lock === 0) {
731 observers.splice(idx, 1); 744 observers.splice(idx, 1);
732 } else { 745 } else {
733 self._dirty = true; 746 self._dirty = true;
734 } 747 }
735 return true; 748 return true;
736 } 749 }
737 } 750 }
738 return false; 751 return false;
739 }, 752 },
740 753
741 /** @id MochiKit.Signal.disconnectAllTo */ 754 /** @id MochiKit.Signal.disconnectAllTo */
742 disconnectAllTo: function (objOrFunc, /* optional */funcOrStr) { 755 disconnectAllTo: function (objOrFunc, /* optional */funcOrStr) {
743 var self = MochiKit.Signal; 756 var self = MochiKit.Signal;
744 var observers = self._observers; 757 var observers = self._observers;
745 var disconnect = self._disconnect; 758 var disconnect = self._disconnect;
746 var locked = self._lock; 759 var lock = self._lock;
747 var dirty = self._dirty; 760 var dirty = self._dirty;
748 if (typeof(funcOrStr) === 'undefined') { 761 if (typeof(funcOrStr) === 'undefined') {
749 funcOrStr = null; 762 funcOrStr = null;
750 } 763 }
751 for (var i = observers.length - 1; i >= 0; i--) { 764 for (var i = observers.length - 1; i >= 0; i--) {
752 var ident = observers[i]; 765 var ident = observers[i];
753 if (ident.objOrFunc === objOrFunc && 766 if (ident.objOrFunc === objOrFunc &&
754 (funcOrStr === null || ident.funcOrStr === funcOrStr)) { 767 (funcOrStr === null || ident.funcOrStr === funcOrStr)) {
755 disconnect(ident); 768 disconnect(ident);
756 if (locked) { 769 if (lock === 0) {
757 dirty = true;
758 } else {
759 observers.splice(i, 1); 770 observers.splice(i, 1);
771 } else {
772 dirty = true;
760 } 773 }
761 } 774 }
762 } 775 }
763 self._dirty = dirty; 776 self._dirty = dirty;
764 }, 777 },
765 778
766 /** @id MochiKit.Signal.disconnectAll */ 779 /** @id MochiKit.Signal.disconnectAll */
767 disconnectAll: function (src/* optional */, sig) { 780 disconnectAll: function (src/* optional */, sig) {
768 if (typeof(src) == "string") { 781 if (typeof(src) == "string") {
769 src = MochiKit.DOM.getElement(src); 782 src = MochiKit.DOM.getElement(src);
770 } 783 }
771 var m = MochiKit.Base; 784 var m = MochiKit.Base;
772 var signals = m.flattenArguments(m.extend(null, arguments, 1)); 785 var signals = m.flattenArguments(m.extend(null, arguments, 1));
773 var self = MochiKit.Signal; 786 var self = MochiKit.Signal;
774 var disconnect = self._disconnect; 787 var disconnect = self._disconnect;
775 var observers = self._observers; 788 var observers = self._observers;
776 var i, ident; 789 var i, ident;
777 var locked = self._lock; 790 var lock = self._lock;
778 var dirty = self._dirty; 791 var dirty = self._dirty;
779 if (signals.length === 0) { 792 if (signals.length === 0) {
780 // disconnect all 793 // disconnect all
781 for (i = observers.length - 1; i >= 0; i--) { 794 for (i = observers.length - 1; i >= 0; i--) {
782 ident = observers[i]; 795 ident = observers[i];
783 if (ident.source === src) { 796 if (ident.source === src) {
784 disconnect(ident); 797 disconnect(ident);
785 if (!locked) { 798 if (lock === 0) {
786 observers.splice(i, 1); 799 observers.splice(i, 1);
787 } else { 800 } else {
788 dirty = true; 801 dirty = true;
789 } 802 }
790 } 803 }
791 } 804 }
792 } else { 805 } else {
793 var sigs = {}; 806 var sigs = {};
794 for (i = 0; i < signals.length; i++) { 807 for (i = 0; i < signals.length; i++) {
795 sigs[signals[i]] = true; 808 sigs[signals[i]] = true;
796 } 809 }
797 for (i = observers.length - 1; i >= 0; i--) { 810 for (i = observers.length - 1; i >= 0; i--) {
798 ident = observers[i]; 811 ident = observers[i];
799 if (ident.source === src && ident.signal in sigs) { 812 if (ident.source === src && ident.signal in sigs) {
800 disconnect(ident); 813 disconnect(ident);
801 if (!locked) { 814 if (lock === 0) {
802 observers.splice(i, 1); 815 observers.splice(i, 1);
803 } else { 816 } else {
804 dirty = true; 817 dirty = true;
805 } 818 }
806 } 819 }
807 } 820 }
808 } 821 }
809 self._dirty = dirty; 822 self._dirty = dirty;
810 }, 823 },
811 824
812 /** @id MochiKit.Signal.signal */ 825 /** @id MochiKit.Signal.signal */
813 signal: function (src, sig) { 826 signal: function (src, sig) {
814 var self = MochiKit.Signal; 827 var self = MochiKit.Signal;
815 var observers = self._observers; 828 var observers = self._observers;
816 if (typeof(src) == "string") { 829 if (typeof(src) == "string") {
817 src = MochiKit.DOM.getElement(src); 830 src = MochiKit.DOM.getElement(src);
818 } 831 }
819 var args = MochiKit.Base.extend(null, arguments, 2); 832 var args = MochiKit.Base.extend(null, arguments, 2);
820 var errors = []; 833 var errors = [];
821 self._lock = true; 834 self._lock++;
822 for (var i = 0; i < observers.length; i++) { 835 for (var i = 0; i < observers.length; i++) {
823 var ident = observers[i]; 836 var ident = observers[i];
824 if (ident.source === src && ident.signal === sig && 837 if (ident.source === src && ident.signal === sig &&
825 ident.connected) { 838 ident.connected) {
826 try { 839 try {
827 if (ident.isDOM && ident.funcOrStr != null) { 840 if (ident.isDOM && ident.funcOrStr != null) {
828 var obj = ident.objOrFunc; 841 var obj = ident.objOrFunc;
829 obj[ident.funcOrStr].apply(obj, args); 842 obj[ident.funcOrStr].apply(obj, args);
830 } else if (ident.isDOM) { 843 } else if (ident.isDOM) {
831 ident.objOrFunc.apply(src, args); 844 ident.objOrFunc.apply(src, args);
832 } else { 845 } else {
833 ident.listener.apply(src, args); 846 ident.listener.apply(src, args);
834 } 847 }
835 } catch (e) { 848 } catch (e) {
836 errors.push(e); 849 errors.push(e);
837 } 850 }
838 } 851 }
839 } 852 }
840 self._lock = false; 853 self._lock--;
841 if (self._dirty) { 854 if (self._lock === 0 && self._dirty) {
842 self._dirty = false; 855 self._dirty = false;
843 for (var i = observers.length - 1; i >= 0; i--) { 856 for (var i = observers.length - 1; i >= 0; i--) {
844 if (!observers[i].connected) { 857 if (!observers[i].connected) {
845 observers.splice(i, 1); 858 observers.splice(i, 1);
846 } 859 }
847 } 860 }
848 } 861 }
849 if (errors.length == 1) { 862 if (errors.length == 1) {
850 throw errors[0]; 863 throw errors[0];
851 } else if (errors.length > 1) { 864 } else if (errors.length > 1) {
852 var e = new Error("Multiple errors thrown in handling 'sig', see errors property"); 865 var e = new Error("Multiple errors thrown in handling 'sig', see errors property");
853 e.errors = errors; 866 e.errors = errors;
854 throw e; 867 throw e;
855 } 868 }
856 } 869 }
857 870
858}); 871});
859 872
860MochiKit.Signal.__new__ = function (win) { 873MochiKit.Signal.__new__ = function (win) {
861 var m = MochiKit.Base; 874 var m = MochiKit.Base;
862 this._document = document; 875 this._document = document;
863 this._window = win; 876 this._window = win;
864 this._lock = false; 877 this._lock = 0;
865 this._dirty = false; 878 this._dirty = false;
866 879
867 try { 880 try {
868 this.connect(window, 'onunload', this._unloadCache); 881 this.connect(window, 'onunload', this._unloadCache);
869 } catch (e) { 882 } catch (e) {
870 // pass: might not be a browser 883 // pass: might not be a browser
871 } 884 }
872 885
873 m.nameFunctions(this); 886 m.nameFunctions(this);
874}; 887};
875 888
876MochiKit.Signal.__new__(this); 889MochiKit.Signal.__new__(this);
877 890
878// 891//
879// XXX: Internet Explorer blows 892// XXX: Internet Explorer blows
880// 893//
881if (MochiKit.__export__) { 894if (MochiKit.__export__) {
882 connect = MochiKit.Signal.connect; 895 connect = MochiKit.Signal.connect;
883 disconnect = MochiKit.Signal.disconnect; 896 disconnect = MochiKit.Signal.disconnect;
884 disconnectAll = MochiKit.Signal.disconnectAll; 897 disconnectAll = MochiKit.Signal.disconnectAll;
885 signal = MochiKit.Signal.signal; 898 signal = MochiKit.Signal.signal;
886} 899}
887 900
888MochiKit.Base._exportSymbols(this, MochiKit.Signal); 901MochiKit.Base._exportSymbols(this, MochiKit.Signal);
diff --git a/frontend/gamma/js/MochiKit/Sortable.js b/frontend/gamma/js/MochiKit/Sortable.js
index 863b506..ca9db21 100644
--- a/frontend/gamma/js/MochiKit/Sortable.js
+++ b/frontend/gamma/js/MochiKit/Sortable.js
@@ -1,569 +1,569 @@
1/*** 1/***
2Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
3 Mochi-ized By Thomas Herve (_firstname_@nimail.org) 3 Mochi-ized By Thomas Herve (_firstname_@nimail.org)
4 4
5See scriptaculous.js for full license. 5See scriptaculous.js for full license.
6 6
7***/ 7***/
8 8
9MochiKit.Base._module('Sortable', '1.5', ['Base', 'Iter', 'DOM', 'Position', 'DragAndDrop']); 9MochiKit.Base.module(MochiKit, 'Sortable', '1.5', ['Base', 'Iter', 'DOM', 'Position', 'DragAndDrop']);
10 10
11MochiKit.Base.update(MochiKit.Sortable, { 11MochiKit.Base.update(MochiKit.Sortable, {
12 __export__: false, 12 __export__: false,
13 13
14 /*** 14 /***
15 15
16 Manage sortables. Mainly use the create function to add a sortable. 16 Manage sortables. Mainly use the create function to add a sortable.
17 17
18 ***/ 18 ***/
19 sortables: {}, 19 sortables: {},
20 20
21 _findRootElement: function (element) { 21 _findRootElement: function (element) {
22 while (element.tagName.toUpperCase() != "BODY") { 22 while (element.tagName.toUpperCase() != "BODY") {
23 if (element.id && MochiKit.Sortable.sortables[element.id]) { 23 if (element.id && MochiKit.Sortable.sortables[element.id]) {
24 return element; 24 return element;
25 } 25 }
26 element = element.parentNode; 26 element = element.parentNode;
27 } 27 }
28 }, 28 },
29 29
30 _createElementId: function(element) { 30 _createElementId: function(element) {
31 if (element.id == null || element.id == "") { 31 if (element.id == null || element.id == "") {
32 var d = MochiKit.DOM; 32 var d = MochiKit.DOM;
33 var id; 33 var id;
34 var count = 1; 34 var count = 1;
35 while (d.getElement(id = "sortable" + count) != null) { 35 while (d.getElement(id = "sortable" + count) != null) {
36 count += 1; 36 count += 1;
37 } 37 }
38 d.setNodeAttribute(element, "id", id); 38 d.setNodeAttribute(element, "id", id);
39 } 39 }
40 }, 40 },
41 41
42 /** @id MochiKit.Sortable.options */ 42 /** @id MochiKit.Sortable.options */
43 options: function (element) { 43 options: function (element) {
44 element = MochiKit.Sortable._findRootElement(MochiKit.DOM.getElement(element)); 44 element = MochiKit.Sortable._findRootElement(MochiKit.DOM.getElement(element));
45 if (!element) { 45 if (!element) {
46 return; 46 return;
47 } 47 }
48 return MochiKit.Sortable.sortables[element.id]; 48 return MochiKit.Sortable.sortables[element.id];
49 }, 49 },
50 50
51 /** @id MochiKit.Sortable.destroy */ 51 /** @id MochiKit.Sortable.destroy */
52 destroy: function (element){ 52 destroy: function (element){
53 var s = MochiKit.Sortable.options(element); 53 var s = MochiKit.Sortable.options(element);
54 var b = MochiKit.Base; 54 var b = MochiKit.Base;
55 var d = MochiKit.DragAndDrop; 55 var d = MochiKit.DragAndDrop;
56 56
57 if (s) { 57 if (s) {
58 MochiKit.Signal.disconnect(s.startHandle); 58 MochiKit.Signal.disconnect(s.startHandle);
59 MochiKit.Signal.disconnect(s.endHandle); 59 MochiKit.Signal.disconnect(s.endHandle);
60 b.map(function (dr) { 60 b.map(function (dr) {
61 d.Droppables.remove(dr); 61 d.Droppables.remove(dr);
62 }, s.droppables); 62 }, s.droppables);
63 b.map(function (dr) { 63 b.map(function (dr) {
64 dr.destroy(); 64 dr.destroy();
65 }, s.draggables); 65 }, s.draggables);
66 66
67 delete MochiKit.Sortable.sortables[s.element.id]; 67 delete MochiKit.Sortable.sortables[s.element.id];
68 } 68 }
69 }, 69 },
70 70
71 /** @id MochiKit.Sortable.create */ 71 /** @id MochiKit.Sortable.create */
72 create: function (element, options) { 72 create: function (element, options) {
73 element = MochiKit.DOM.getElement(element); 73 element = MochiKit.DOM.getElement(element);
74 var self = MochiKit.Sortable; 74 var self = MochiKit.Sortable;
75 self._createElementId(element); 75 self._createElementId(element);
76 76
77 /** @id MochiKit.Sortable.options */ 77 /** @id MochiKit.Sortable.options */
78 options = MochiKit.Base.update({ 78 options = MochiKit.Base.update({
79 79
80 /** @id MochiKit.Sortable.element */ 80 /** @id MochiKit.Sortable.element */
81 element: element, 81 element: element,
82 82
83 /** @id MochiKit.Sortable.tag */ 83 /** @id MochiKit.Sortable.tag */
84 tag: 'li', // assumes li children, override with tag: 'tagname' 84 tag: 'li', // assumes li children, override with tag: 'tagname'
85 85
86 /** @id MochiKit.Sortable.dropOnEmpty */ 86 /** @id MochiKit.Sortable.dropOnEmpty */
87 dropOnEmpty: false, 87 dropOnEmpty: false,
88 88
89 /** @id MochiKit.Sortable.tree */ 89 /** @id MochiKit.Sortable.tree */
90 tree: false, 90 tree: false,
91 91
92 /** @id MochiKit.Sortable.treeTag */ 92 /** @id MochiKit.Sortable.treeTag */
93 treeTag: 'ul', 93 treeTag: 'ul',
94 94
95 /** @id MochiKit.Sortable.overlap */ 95 /** @id MochiKit.Sortable.overlap */
96 overlap: 'vertical', // one of 'vertical', 'horizontal' 96 overlap: 'vertical', // one of 'vertical', 'horizontal'
97 97
98 /** @id MochiKit.Sortable.constraint */ 98 /** @id MochiKit.Sortable.constraint */
99 constraint: 'vertical', // one of 'vertical', 'horizontal', false 99 constraint: 'vertical', // one of 'vertical', 'horizontal', false
100 // also takes array of elements (or ids); or false 100 // also takes array of elements (or ids); or false
101 101
102 /** @id MochiKit.Sortable.containment */ 102 /** @id MochiKit.Sortable.containment */
103 containment: [element], 103 containment: [element],
104 104
105 /** @id MochiKit.Sortable.handle */ 105 /** @id MochiKit.Sortable.handle */
106 handle: false, // or a CSS class 106 handle: false, // or a CSS class
107 107
108 /** @id MochiKit.Sortable.only */ 108 /** @id MochiKit.Sortable.only */
109 only: false, 109 only: false,
110 110
111 /** @id MochiKit.Sortable.hoverclass */ 111 /** @id MochiKit.Sortable.hoverclass */
112 hoverclass: null, 112 hoverclass: null,
113 113
114 /** @id MochiKit.Sortable.ghosting */ 114 /** @id MochiKit.Sortable.ghosting */
115 ghosting: false, 115 ghosting: false,
116 116
117 /** @id MochiKit.Sortable.scroll */ 117 /** @id MochiKit.Sortable.scroll */
118 scroll: false, 118 scroll: false,
119 119
120 /** @id MochiKit.Sortable.scrollSensitivity */ 120 /** @id MochiKit.Sortable.scrollSensitivity */
121 scrollSensitivity: 20, 121 scrollSensitivity: 20,
122 122
123 /** @id MochiKit.Sortable.scrollSpeed */ 123 /** @id MochiKit.Sortable.scrollSpeed */
124 scrollSpeed: 15, 124 scrollSpeed: 15,
125 125
126 /** @id MochiKit.Sortable.format */ 126 /** @id MochiKit.Sortable.format */
127 format: /^[^_]*_(.*)$/, 127 format: /^[^_]*_(.*)$/,
128 128
129 /** @id MochiKit.Sortable.onChange */ 129 /** @id MochiKit.Sortable.onChange */
130 onChange: MochiKit.Base.noop, 130 onChange: MochiKit.Base.noop,
131 131
132 /** @id MochiKit.Sortable.onUpdate */ 132 /** @id MochiKit.Sortable.onUpdate */
133 onUpdate: MochiKit.Base.noop, 133 onUpdate: MochiKit.Base.noop,
134 134
135 /** @id MochiKit.Sortable.accept */ 135 /** @id MochiKit.Sortable.accept */
136 accept: null 136 accept: null
137 }, options); 137 }, options);
138 138
139 // clear any old sortable with same element 139 // clear any old sortable with same element
140 self.destroy(element); 140 self.destroy(element);
141 141
142 // build options for the draggables 142 // build options for the draggables
143 var options_for_draggable = { 143 var options_for_draggable = {
144 revert: true, 144 revert: true,
145 ghosting: options.ghosting, 145 ghosting: options.ghosting,
146 scroll: options.scroll, 146 scroll: options.scroll,
147 scrollSensitivity: options.scrollSensitivity, 147 scrollSensitivity: options.scrollSensitivity,
148 scrollSpeed: options.scrollSpeed, 148 scrollSpeed: options.scrollSpeed,
149 constraint: options.constraint, 149 constraint: options.constraint,
150 handle: options.handle 150 handle: options.handle
151 }; 151 };
152 152
153 if (options.starteffect) { 153 if (options.starteffect) {
154 options_for_draggable.starteffect = options.starteffect; 154 options_for_draggable.starteffect = options.starteffect;
155 } 155 }
156 156
157 if (options.reverteffect) { 157 if (options.reverteffect) {
158 options_for_draggable.reverteffect = options.reverteffect; 158 options_for_draggable.reverteffect = options.reverteffect;
159 } else if (options.ghosting) { 159 } else if (options.ghosting) {
160 options_for_draggable.reverteffect = function (innerelement) { 160 options_for_draggable.reverteffect = function (innerelement) {
161 innerelement.style.top = 0; 161 innerelement.style.top = 0;
162 innerelement.style.left = 0; 162 innerelement.style.left = 0;
163 }; 163 };
164 } 164 }
165 165
166 if (options.endeffect) { 166 if (options.endeffect) {
167 options_for_draggable.endeffect = options.endeffect; 167 options_for_draggable.endeffect = options.endeffect;
168 } 168 }
169 169
170 if (options.zindex) { 170 if (options.zindex) {
171 options_for_draggable.zindex = options.zindex; 171 options_for_draggable.zindex = options.zindex;
172 } 172 }
173 173
174 // build options for the droppables 174 // build options for the droppables
175 var options_for_droppable = { 175 var options_for_droppable = {
176 overlap: options.overlap, 176 overlap: options.overlap,
177 containment: options.containment, 177 containment: options.containment,
178 hoverclass: options.hoverclass, 178 hoverclass: options.hoverclass,
179 onhover: self.onHover, 179 onhover: self.onHover,
180 tree: options.tree, 180 tree: options.tree,
181 accept: options.accept 181 accept: options.accept
182 } 182 };
183 183
184 var options_for_tree = { 184 var options_for_tree = {
185 onhover: self.onEmptyHover, 185 onhover: self.onEmptyHover,
186 overlap: options.overlap, 186 overlap: options.overlap,
187 containment: options.containment, 187 containment: options.containment,
188 hoverclass: options.hoverclass, 188 hoverclass: options.hoverclass,
189 accept: options.accept 189 accept: options.accept
190 } 190 };
191 191
192 // fix for gecko engine 192 // fix for gecko engine
193 MochiKit.DOM.removeEmptyTextNodes(element); 193 MochiKit.DOM.removeEmptyTextNodes(element);
194 194
195 options.draggables = []; 195 options.draggables = [];
196 options.droppables = []; 196 options.droppables = [];
197 197
198 // drop on empty handling 198 // drop on empty handling
199 if (options.dropOnEmpty || options.tree) { 199 if (options.dropOnEmpty || options.tree) {
200 new MochiKit.DragAndDrop.Droppable(element, options_for_tree); 200 new MochiKit.DragAndDrop.Droppable(element, options_for_tree);
201 options.droppables.push(element); 201 options.droppables.push(element);
202 } 202 }
203 MochiKit.Base.map(function (e) { 203 MochiKit.Base.map(function (e) {
204 // handles are per-draggable 204 // handles are per-draggable
205 var handle = options.handle ? 205 var handle = options.handle ?
206 MochiKit.DOM.getFirstElementByTagAndClassName(null, 206 MochiKit.DOM.getFirstElementByTagAndClassName(null,
207 options.handle, e) : e; 207 options.handle, e) : e;
208 options.draggables.push( 208 options.draggables.push(
209 new MochiKit.DragAndDrop.Draggable(e, 209 new MochiKit.DragAndDrop.Draggable(e,
210 MochiKit.Base.update(options_for_draggable, 210 MochiKit.Base.update(options_for_draggable,
211 {handle: handle}))); 211 {handle: handle})));
212 new MochiKit.DragAndDrop.Droppable(e, options_for_droppable); 212 new MochiKit.DragAndDrop.Droppable(e, options_for_droppable);
213 if (options.tree) { 213 if (options.tree) {
214 e.treeNode = element; 214 e.treeNode = element;
215 } 215 }
216 options.droppables.push(e); 216 options.droppables.push(e);
217 }, (self.findElements(element, options) || [])); 217 }, (self.findElements(element, options) || []));
218 218
219 if (options.tree) { 219 if (options.tree) {
220 MochiKit.Base.map(function (e) { 220 MochiKit.Base.map(function (e) {
221 new MochiKit.DragAndDrop.Droppable(e, options_for_tree); 221 new MochiKit.DragAndDrop.Droppable(e, options_for_tree);
222 e.treeNode = element; 222 e.treeNode = element;
223 options.droppables.push(e); 223 options.droppables.push(e);
224 }, (self.findTreeElements(element, options) || [])); 224 }, (self.findTreeElements(element, options) || []));
225 } 225 }
226 226
227 // keep reference 227 // keep reference
228 self.sortables[element.id] = options; 228 self.sortables[element.id] = options;
229 229
230 options.lastValue = self.serialize(element); 230 options.lastValue = self.serialize(element);
231 options.startHandle = MochiKit.Signal.connect(MochiKit.DragAndDrop.Draggables, 'start', 231 options.startHandle = MochiKit.Signal.connect(MochiKit.DragAndDrop.Draggables, 'start',
232 MochiKit.Base.partial(self.onStart, element)); 232 MochiKit.Base.partial(self.onStart, element));
233 options.endHandle = MochiKit.Signal.connect(MochiKit.DragAndDrop.Draggables, 'end', 233 options.endHandle = MochiKit.Signal.connect(MochiKit.DragAndDrop.Draggables, 'end',
234 MochiKit.Base.partial(self.onEnd, element)); 234 MochiKit.Base.partial(self.onEnd, element));
235 }, 235 },
236 236
237 /** @id MochiKit.Sortable.onStart */ 237 /** @id MochiKit.Sortable.onStart */
238 onStart: function (element, draggable) { 238 onStart: function (element, draggable) {
239 var self = MochiKit.Sortable; 239 var self = MochiKit.Sortable;
240 var options = self.options(element); 240 var options = self.options(element);
241 options.lastValue = self.serialize(options.element); 241 options.lastValue = self.serialize(options.element);
242 }, 242 },
243 243
244 /** @id MochiKit.Sortable.onEnd */ 244 /** @id MochiKit.Sortable.onEnd */
245 onEnd: function (element, draggable) { 245 onEnd: function (element, draggable) {
246 var self = MochiKit.Sortable; 246 var self = MochiKit.Sortable;
247 self.unmark(); 247 self.unmark();
248 var options = self.options(element); 248 var options = self.options(element);
249 if (options.lastValue != self.serialize(options.element)) { 249 if (options.lastValue != self.serialize(options.element)) {
250 options.onUpdate(options.element); 250 options.onUpdate(options.element);
251 } 251 }
252 }, 252 },
253 253
254 // return all suitable-for-sortable elements in a guaranteed order 254 // return all suitable-for-sortable elements in a guaranteed order
255 255
256 /** @id MochiKit.Sortable.findElements */ 256 /** @id MochiKit.Sortable.findElements */
257 findElements: function (element, options) { 257 findElements: function (element, options) {
258 return MochiKit.Sortable.findChildren(element, options.only, options.tree, options.tag); 258 return MochiKit.Sortable.findChildren(element, options.only, options.tree, options.tag);
259 }, 259 },
260 260
261 /** @id MochiKit.Sortable.findTreeElements */ 261 /** @id MochiKit.Sortable.findTreeElements */
262 findTreeElements: function (element, options) { 262 findTreeElements: function (element, options) {
263 return MochiKit.Sortable.findChildren( 263 return MochiKit.Sortable.findChildren(
264 element, options.only, options.tree ? true : false, options.treeTag); 264 element, options.only, options.tree ? true : false, options.treeTag);
265 }, 265 },
266 266
267 /** @id MochiKit.Sortable.findChildren */ 267 /** @id MochiKit.Sortable.findChildren */
268 findChildren: function (element, only, recursive, tagName) { 268 findChildren: function (element, only, recursive, tagName) {
269 if (!element.hasChildNodes()) { 269 if (!element.hasChildNodes()) {
270 return null; 270 return null;
271 } 271 }
272 tagName = tagName.toUpperCase(); 272 tagName = tagName.toUpperCase();
273 if (only) { 273 if (only) {
274 only = MochiKit.Base.flattenArray([only]); 274 only = MochiKit.Base.flattenArray([only]);
275 } 275 }
276 var elements = []; 276 var elements = [];
277 MochiKit.Base.map(function (e) { 277 MochiKit.Base.map(function (e) {
278 if (e.tagName && 278 if (e.tagName &&
279 e.tagName.toUpperCase() == tagName && 279 e.tagName.toUpperCase() == tagName &&
280 (!only || 280 (!only ||
281 MochiKit.Iter.some(only, function (c) { 281 MochiKit.Iter.some(only, function (c) {
282 return MochiKit.DOM.hasElementClass(e, c); 282 return MochiKit.DOM.hasElementClass(e, c);
283 }))) { 283 }))) {
284 elements.push(e); 284 elements.push(e);
285 } 285 }
286 if (recursive) { 286 if (recursive) {
287 var grandchildren = MochiKit.Sortable.findChildren(e, only, recursive, tagName); 287 var grandchildren = MochiKit.Sortable.findChildren(e, only, recursive, tagName);
288 if (grandchildren && grandchildren.length > 0) { 288 if (grandchildren && grandchildren.length > 0) {
289 elements = elements.concat(grandchildren); 289 elements = elements.concat(grandchildren);
290 } 290 }
291 } 291 }
292 }, element.childNodes); 292 }, element.childNodes);
293 return elements; 293 return elements;
294 }, 294 },
295 295
296 /** @id MochiKit.Sortable.onHover */ 296 /** @id MochiKit.Sortable.onHover */
297 onHover: function (element, dropon, overlap) { 297 onHover: function (element, dropon, overlap) {
298 if (MochiKit.DOM.isChildNode(dropon, element)) { 298 if (MochiKit.DOM.isChildNode(dropon, element)) {
299 return; 299 return;
300 } 300 }
301 var self = MochiKit.Sortable; 301 var self = MochiKit.Sortable;
302 302
303 if (overlap > .33 && overlap < .66 && self.options(dropon).tree) { 303 if (overlap > .33 && overlap < .66 && self.options(dropon).tree) {
304 return; 304 return;
305 } else if (overlap > 0.5) { 305 } else if (overlap > 0.5) {
306 self.mark(dropon, 'before'); 306 self.mark(dropon, 'before');
307 if (dropon.previousSibling != element) { 307 if (dropon.previousSibling != element) {
308 var oldParentNode = element.parentNode; 308 var oldParentNode = element.parentNode;
309 element.style.visibility = 'hidden'; // fix gecko rendering 309 element.style.visibility = 'hidden'; // fix gecko rendering
310 dropon.parentNode.insertBefore(element, dropon); 310 dropon.parentNode.insertBefore(element, dropon);
311 if (dropon.parentNode != oldParentNode) { 311 if (dropon.parentNode != oldParentNode) {
312 self.options(oldParentNode).onChange(element); 312 self.options(oldParentNode).onChange(element);
313 } 313 }
314 self.options(dropon.parentNode).onChange(element); 314 self.options(dropon.parentNode).onChange(element);
315 } 315 }
316 } else { 316 } else {
317 self.mark(dropon, 'after'); 317 self.mark(dropon, 'after');
318 var nextElement = dropon.nextSibling || null; 318 var nextElement = dropon.nextSibling || null;
319 if (nextElement != element) { 319 if (nextElement != element) {
320 var oldParentNode = element.parentNode; 320 var oldParentNode = element.parentNode;
321 element.style.visibility = 'hidden'; // fix gecko rendering 321 element.style.visibility = 'hidden'; // fix gecko rendering
322 dropon.parentNode.insertBefore(element, nextElement); 322 dropon.parentNode.insertBefore(element, nextElement);
323 if (dropon.parentNode != oldParentNode) { 323 if (dropon.parentNode != oldParentNode) {
324 self.options(oldParentNode).onChange(element); 324 self.options(oldParentNode).onChange(element);
325 } 325 }
326 self.options(dropon.parentNode).onChange(element); 326 self.options(dropon.parentNode).onChange(element);
327 } 327 }
328 } 328 }
329 }, 329 },
330 330
331 _offsetSize: function (element, type) { 331 _offsetSize: function (element, type) {
332 if (type == 'vertical' || type == 'height') { 332 if (type == 'vertical' || type == 'height') {
333 return element.offsetHeight; 333 return element.offsetHeight;
334 } else { 334 } else {
335 return element.offsetWidth; 335 return element.offsetWidth;
336 } 336 }
337 }, 337 },
338 338
339 /** @id MochiKit.Sortable.onEmptyHover */ 339 /** @id MochiKit.Sortable.onEmptyHover */
340 onEmptyHover: function (element, dropon, overlap) { 340 onEmptyHover: function (element, dropon, overlap) {
341 var oldParentNode = element.parentNode; 341 var oldParentNode = element.parentNode;
342 var self = MochiKit.Sortable; 342 var self = MochiKit.Sortable;
343 var droponOptions = self.options(dropon); 343 var droponOptions = self.options(dropon);
344 344
345 if (!MochiKit.DOM.isChildNode(dropon, element)) { 345 if (!MochiKit.DOM.isChildNode(dropon, element)) {
346 var index; 346 var index;
347 347
348 var children = self.findElements(dropon, {tag: droponOptions.tag, 348 var children = self.findElements(dropon, {tag: droponOptions.tag,
349 only: droponOptions.only}); 349 only: droponOptions.only});
350 var child = null; 350 var child = null;
351 351
352 if (children) { 352 if (children) {
353 var offset = self._offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); 353 var offset = self._offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
354 354
355 for (index = 0; index < children.length; index += 1) { 355 for (index = 0; index < children.length; index += 1) {
356 if (offset - self._offsetSize(children[index], droponOptions.overlap) >= 0) { 356 if (offset - self._offsetSize(children[index], droponOptions.overlap) >= 0) {
357 offset -= self._offsetSize(children[index], droponOptions.overlap); 357 offset -= self._offsetSize(children[index], droponOptions.overlap);
358 } else if (offset - (self._offsetSize (children[index], droponOptions.overlap) / 2) >= 0) { 358 } else if (offset - (self._offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {
359 child = index + 1 < children.length ? children[index + 1] : null; 359 child = index + 1 < children.length ? children[index + 1] : null;
360 break; 360 break;
361 } else { 361 } else {
362 child = children[index]; 362 child = children[index];
363 break; 363 break;
364 } 364 }
365 } 365 }
366 } 366 }
367 367
368 dropon.insertBefore(element, child); 368 dropon.insertBefore(element, child);
369 369
370 self.options(oldParentNode).onChange(element); 370 self.options(oldParentNode).onChange(element);
371 droponOptions.onChange(element); 371 droponOptions.onChange(element);
372 } 372 }
373 }, 373 },
374 374
375 /** @id MochiKit.Sortable.unmark */ 375 /** @id MochiKit.Sortable.unmark */
376 unmark: function () { 376 unmark: function () {
377 var m = MochiKit.Sortable._marker; 377 var m = MochiKit.Sortable._marker;
378 if (m) { 378 if (m) {
379 MochiKit.Style.hideElement(m); 379 MochiKit.Style.hideElement(m);
380 } 380 }
381 }, 381 },
382 382
383 /** @id MochiKit.Sortable.mark */ 383 /** @id MochiKit.Sortable.mark */
384 mark: function (dropon, position) { 384 mark: function (dropon, position) {
385 // mark on ghosting only 385 // mark on ghosting only
386 var d = MochiKit.DOM; 386 var d = MochiKit.DOM;
387 var self = MochiKit.Sortable; 387 var self = MochiKit.Sortable;
388 var sortable = self.options(dropon.parentNode); 388 var sortable = self.options(dropon.parentNode);
389 if (sortable && !sortable.ghosting) { 389 if (sortable && !sortable.ghosting) {
390 return; 390 return;
391 } 391 }
392 392
393 if (!self._marker) { 393 if (!self._marker) {
394 self._marker = d.getElement('dropmarker') || 394 self._marker = d.getElement('dropmarker') ||
395 document.createElement('DIV'); 395 document.createElement('DIV');
396 MochiKit.Style.hideElement(self._marker); 396 MochiKit.Style.hideElement(self._marker);
397 d.addElementClass(self._marker, 'dropmarker'); 397 d.addElementClass(self._marker, 'dropmarker');
398 self._marker.style.position = 'absolute'; 398 self._marker.style.position = 'absolute';
399 document.getElementsByTagName('body').item(0).appendChild(self._marker); 399 document.getElementsByTagName('body').item(0).appendChild(self._marker);
400 } 400 }
401 var offsets = MochiKit.Position.cumulativeOffset(dropon); 401 var offsets = MochiKit.Position.cumulativeOffset(dropon);
402 self._marker.style.left = offsets.x + 'px'; 402 self._marker.style.left = offsets.x + 'px';
403 self._marker.style.top = offsets.y + 'px'; 403 self._marker.style.top = offsets.y + 'px';
404 404
405 if (position == 'after') { 405 if (position == 'after') {
406 if (sortable.overlap == 'horizontal') { 406 if (sortable.overlap == 'horizontal') {
407 self._marker.style.left = (offsets.x + dropon.clientWidth) + 'px'; 407 self._marker.style.left = (offsets.x + dropon.clientWidth) + 'px';
408 } else { 408 } else {
409 self._marker.style.top = (offsets.y + dropon.clientHeight) + 'px'; 409 self._marker.style.top = (offsets.y + dropon.clientHeight) + 'px';
410 } 410 }
411 } 411 }
412 MochiKit.Style.showElement(self._marker); 412 MochiKit.Style.showElement(self._marker);
413 }, 413 },
414 414
415 _tree: function (element, options, parent) { 415 _tree: function (element, options, parent) {
416 var self = MochiKit.Sortable; 416 var self = MochiKit.Sortable;
417 var children = self.findElements(element, options) || []; 417 var children = self.findElements(element, options) || [];
418 418
419 for (var i = 0; i < children.length; ++i) { 419 for (var i = 0; i < children.length; ++i) {
420 var match = children[i].id.match(options.format); 420 var match = children[i].id.match(options.format);
421 421
422 if (!match) { 422 if (!match) {
423 continue; 423 continue;
424 } 424 }
425 425
426 var child = { 426 var child = {
427 id: encodeURIComponent(match ? match[1] : null), 427 id: encodeURIComponent(match ? match[1] : null),
428 element: element, 428 element: element,
429 parent: parent, 429 parent: parent,
430 children: [], 430 children: [],
431 position: parent.children.length, 431 position: parent.children.length,
432 container: self._findChildrenElement(children[i], options.treeTag.toUpperCase()) 432 container: self._findChildrenElement(children[i], options.treeTag.toUpperCase())
433 } 433 };
434 434
435 /* Get the element containing the children and recurse over it */ 435 /* Get the element containing the children and recurse over it */
436 if (child.container) { 436 if (child.container) {
437 self._tree(child.container, options, child) 437 self._tree(child.container, options, child);
438 } 438 }
439 439
440 parent.children.push (child); 440 parent.children.push (child);
441 } 441 }
442 442
443 return parent; 443 return parent;
444 }, 444 },
445 445
446 /* Finds the first element of the given tag type within a parent element. 446 /* Finds the first element of the given tag type within a parent element.
447 Used for finding the first LI[ST] within a L[IST]I[TEM].*/ 447 Used for finding the first LI[ST] within a L[IST]I[TEM].*/
448 _findChildrenElement: function (element, containerTag) { 448 _findChildrenElement: function (element, containerTag) {
449 if (element && element.hasChildNodes) { 449 if (element && element.hasChildNodes) {
450 containerTag = containerTag.toUpperCase(); 450 containerTag = containerTag.toUpperCase();
451 for (var i = 0; i < element.childNodes.length; ++i) { 451 for (var i = 0; i < element.childNodes.length; ++i) {
452 if (element.childNodes[i].tagName.toUpperCase() == containerTag) { 452 if (element.childNodes[i].tagName.toUpperCase() == containerTag) {
453 return element.childNodes[i]; 453 return element.childNodes[i];
454 } 454 }
455 } 455 }
456 } 456 }
457 return null; 457 return null;
458 }, 458 },
459 459
460 /** @id MochiKit.Sortable.tree */ 460 /** @id MochiKit.Sortable.tree */
461 tree: function (element, options) { 461 tree: function (element, options) {
462 element = MochiKit.DOM.getElement(element); 462 element = MochiKit.DOM.getElement(element);
463 var sortableOptions = MochiKit.Sortable.options(element); 463 var sortableOptions = MochiKit.Sortable.options(element);
464 options = MochiKit.Base.update({ 464 options = MochiKit.Base.update({
465 tag: sortableOptions.tag, 465 tag: sortableOptions.tag,
466 treeTag: sortableOptions.treeTag, 466 treeTag: sortableOptions.treeTag,
467 only: sortableOptions.only, 467 only: sortableOptions.only,
468 name: element.id, 468 name: element.id,
469 format: sortableOptions.format 469 format: sortableOptions.format
470 }, options || {}); 470 }, options || {});
471 471
472 var root = { 472 var root = {
473 id: null, 473 id: null,
474 parent: null, 474 parent: null,
475 children: new Array, 475 children: new Array,
476 container: element, 476 container: element,
477 position: 0 477 position: 0
478 } 478 };
479 479
480 return MochiKit.Sortable._tree(element, options, root); 480 return MochiKit.Sortable._tree(element, options, root);
481 }, 481 },
482 482
483 /** 483 /**
484 * Specifies the sequence for the Sortable. 484 * Specifies the sequence for the Sortable.
485 * @param {Node} element Element to use as the Sortable. 485 * @param {Node} element Element to use as the Sortable.
486 * @param {Object} newSequence New sequence to use. 486 * @param {Object} newSequence New sequence to use.
487 * @param {Object} options Options to use fro the Sortable. 487 * @param {Object} options Options to use fro the Sortable.
488 */ 488 */
489 setSequence: function (element, newSequence, options) { 489 setSequence: function (element, newSequence, options) {
490 var self = MochiKit.Sortable; 490 var self = MochiKit.Sortable;
491 var b = MochiKit.Base; 491 var b = MochiKit.Base;
492 element = MochiKit.DOM.getElement(element); 492 element = MochiKit.DOM.getElement(element);
493 options = b.update(self.options(element), options || {}); 493 options = b.update(self.options(element), options || {});
494 494
495 var nodeMap = {}; 495 var nodeMap = {};
496 b.map(function (n) { 496 b.map(function (n) {
497 var m = n.id.match(options.format); 497 var m = n.id.match(options.format);
498 if (m) { 498 if (m) {
499 nodeMap[m[1]] = [n, n.parentNode]; 499 nodeMap[m[1]] = [n, n.parentNode];
500 } 500 }
501 n.parentNode.removeChild(n); 501 n.parentNode.removeChild(n);
502 }, self.findElements(element, options)); 502 }, self.findElements(element, options));
503 503
504 b.map(function (ident) { 504 b.map(function (ident) {
505 var n = nodeMap[ident]; 505 var n = nodeMap[ident];
506 if (n) { 506 if (n) {
507 n[1].appendChild(n[0]); 507 n[1].appendChild(n[0]);
508 delete nodeMap[ident]; 508 delete nodeMap[ident];
509 } 509 }
510 }, newSequence); 510 }, newSequence);
511 }, 511 },
512 512
513 /* Construct a [i] index for a particular node */ 513 /* Construct a [i] index for a particular node */
514 _constructIndex: function (node) { 514 _constructIndex: function (node) {
515 var index = ''; 515 var index = '';
516 do { 516 do {
517 if (node.id) { 517 if (node.id) {
518 index = '[' + node.position + ']' + index; 518 index = '[' + node.position + ']' + index;
519 } 519 }
520 } while ((node = node.parent) != null); 520 } while ((node = node.parent) != null);
521 return index; 521 return index;
522 }, 522 },
523 523
524 /** @id MochiKit.Sortable.sequence */ 524 /** @id MochiKit.Sortable.sequence */
525 sequence: function (element, options) { 525 sequence: function (element, options) {
526 element = MochiKit.DOM.getElement(element); 526 element = MochiKit.DOM.getElement(element);
527 var self = MochiKit.Sortable; 527 var self = MochiKit.Sortable;
528 var options = MochiKit.Base.update(self.options(element), options || {}); 528 var options = MochiKit.Base.update(self.options(element), options || {});
529 529
530 return MochiKit.Base.map(function (item) { 530 return MochiKit.Base.map(function (item) {
531 return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; 531 return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
532 }, MochiKit.DOM.getElement(self.findElements(element, options) || [])); 532 }, MochiKit.DOM.getElement(self.findElements(element, options) || []));
533 }, 533 },
534 534
535 /** 535 /**
536 * Serializes the content of a Sortable. Useful to send this content through a XMLHTTPRequest. 536 * Serializes the content of a Sortable. Useful to send this content through a XMLHTTPRequest.
537 * These options override the Sortable options for the serialization only. 537 * These options override the Sortable options for the serialization only.
538 * @param {Node} element Element to serialize. 538 * @param {Node} element Element to serialize.
539 * @param {Object} options Serialization options. 539 * @param {Object} options Serialization options.
540 */ 540 */
541 serialize: function (element, options) { 541 serialize: function (element, options) {
542 element = MochiKit.DOM.getElement(element); 542 element = MochiKit.DOM.getElement(element);
543 var self = MochiKit.Sortable; 543 var self = MochiKit.Sortable;
544 options = MochiKit.Base.update(self.options(element), options || {}); 544 options = MochiKit.Base.update(self.options(element), options || {});
545 var name = encodeURIComponent(options.name || element.id); 545 var name = encodeURIComponent(options.name || element.id);
546 546
547 if (options.tree) { 547 if (options.tree) {
548 return MochiKit.Base.flattenArray(MochiKit.Base.map(function (item) { 548 return MochiKit.Base.flattenArray(MochiKit.Base.map(function (item) {
549 return [name + self._constructIndex(item) + "[id]=" + 549 return [name + self._constructIndex(item) + "[id]=" +
550 encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); 550 encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
551 }, self.tree(element, options).children)).join('&'); 551 }, self.tree(element, options).children)).join('&');
552 } else { 552 } else {
553 return MochiKit.Base.map(function (item) { 553 return MochiKit.Base.map(function (item) {
554 return name + "[]=" + encodeURIComponent(item); 554 return name + "[]=" + encodeURIComponent(item);
555 }, self.sequence(element, options)).join('&'); 555 }, self.sequence(element, options)).join('&');
556 } 556 }
557 } 557 }
558}); 558});
559 559
560// trunk compatibility 560// trunk compatibility
561MochiKit.Sortable.Sortable = MochiKit.Sortable; 561MochiKit.Sortable.Sortable = MochiKit.Sortable;
562 562
563MochiKit.Sortable.__new__ = function () { 563MochiKit.Sortable.__new__ = function () {
564 MochiKit.Base.nameFunctions(this); 564 MochiKit.Base.nameFunctions(this);
565}; 565};
566 566
567MochiKit.Sortable.__new__(); 567MochiKit.Sortable.__new__();
568 568
569MochiKit.Base._exportSymbols(this, MochiKit.Sortable); 569MochiKit.Base._exportSymbols(this, MochiKit.Sortable);
diff --git a/frontend/gamma/js/MochiKit/Style.js b/frontend/gamma/js/MochiKit/Style.js
index 7f10117..740fd2f 100644
--- a/frontend/gamma/js/MochiKit/Style.js
+++ b/frontend/gamma/js/MochiKit/Style.js
@@ -1,558 +1,561 @@
1/*** 1/***
2 2
3MochiKit.Style 1.5 3MochiKit.Style 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved. 7(c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved.
8 8
9The MochiKit.Style.getElementPosition function is adapted from
10YAHOO.util.Dom.getXY v0.9.0. which is copyrighted by Yahoo! Inc.
11
9***/ 12***/
10 13
11MochiKit.Base._module('Style', '1.5', ['Base', 'DOM']); 14MochiKit.Base.module(MochiKit, 'Style', '1.5', ['Base', 'DOM']);
12 15
13 16
14/** @id MochiKit.Style.Dimensions */ 17/** @id MochiKit.Style.Dimensions */
15MochiKit.Style.Dimensions = function (w, h) { 18MochiKit.Style.Dimensions = function (w, h) {
16 if (!(this instanceof MochiKit.Style.Dimensions)) { 19 if (!(this instanceof MochiKit.Style.Dimensions)) {
17 return new MochiKit.Style.Dimensions(w, h); 20 return new MochiKit.Style.Dimensions(w, h);
18 } 21 }
19 this.w = w; 22 this.w = w;
20 this.h = h; 23 this.h = h;
21}; 24};
22 25
23MochiKit.Style.Dimensions.prototype.__repr__ = function () { 26MochiKit.Style.Dimensions.prototype.__repr__ = function () {
24 var repr = MochiKit.Base.repr; 27 var repr = MochiKit.Base.repr;
25 return '{w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}'; 28 return '{w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}';
26}; 29};
27 30
28MochiKit.Style.Dimensions.prototype.toString = function () { 31MochiKit.Style.Dimensions.prototype.toString = function () {
29 return this.__repr__(); 32 return this.__repr__();
30}; 33};
31 34
32 35
33/** @id MochiKit.Style.Coordinates */ 36/** @id MochiKit.Style.Coordinates */
34MochiKit.Style.Coordinates = function (x, y) { 37MochiKit.Style.Coordinates = function (x, y) {
35 if (!(this instanceof MochiKit.Style.Coordinates)) { 38 if (!(this instanceof MochiKit.Style.Coordinates)) {
36 return new MochiKit.Style.Coordinates(x, y); 39 return new MochiKit.Style.Coordinates(x, y);
37 } 40 }
38 this.x = x; 41 this.x = x;
39 this.y = y; 42 this.y = y;
40}; 43};
41 44
42MochiKit.Style.Coordinates.prototype.__repr__ = function () { 45MochiKit.Style.Coordinates.prototype.__repr__ = function () {
43 var repr = MochiKit.Base.repr; 46 var repr = MochiKit.Base.repr;
44 return '{x: ' + repr(this.x) + ', y: ' + repr(this.y) + '}'; 47 return '{x: ' + repr(this.x) + ', y: ' + repr(this.y) + '}';
45}; 48};
46 49
47MochiKit.Style.Coordinates.prototype.toString = function () { 50MochiKit.Style.Coordinates.prototype.toString = function () {
48 return this.__repr__(); 51 return this.__repr__();
49}; 52};
50 53
51 54
52MochiKit.Base.update(MochiKit.Style, { 55MochiKit.Base.update(MochiKit.Style, {
53 56
54 /** @id MochiKit.Style.getStyle */ 57 /** @id MochiKit.Style.getStyle */
55 getStyle: function (elem, cssProperty) { 58 getStyle: function (elem, cssProperty) {
56 var dom = MochiKit.DOM; 59 var dom = MochiKit.DOM;
57 var d = dom._document; 60 var d = dom._document;
58 61
59 elem = dom.getElement(elem); 62 elem = dom.getElement(elem);
60 cssProperty = MochiKit.Base.camelize(cssProperty); 63 cssProperty = MochiKit.Base.camelize(cssProperty);
61 64
62 if (!elem || elem == d) { 65 if (!elem || elem == d) {
63 return undefined; 66 return undefined;
64 } 67 }
65 if (cssProperty == 'opacity' && typeof(elem.filters) != 'undefined') { 68 if (cssProperty == 'opacity' && typeof(elem.filters) != 'undefined') {
66 var opacity = (MochiKit.Style.getStyle(elem, 'filter') || '').match(/alpha\(opacity=(.*)\)/); 69 var opacity = (MochiKit.Style.getStyle(elem, 'filter') || '').match(/alpha\(opacity=(.*)\)/);
67 if (opacity && opacity[1]) { 70 if (opacity && opacity[1]) {
68 return parseFloat(opacity[1]) / 100; 71 return parseFloat(opacity[1]) / 100;
69 } 72 }
70 return 1.0; 73 return 1.0;
71 } 74 }
72 if (cssProperty == 'float' || cssProperty == 'cssFloat' || cssProperty == 'styleFloat') { 75 if (cssProperty == 'float' || cssProperty == 'cssFloat' || cssProperty == 'styleFloat') {
73 if (elem.style["float"]) { 76 if (elem.style["float"]) {
74 return elem.style["float"]; 77 return elem.style["float"];
75 } else if (elem.style.cssFloat) { 78 } else if (elem.style.cssFloat) {
76 return elem.style.cssFloat; 79 return elem.style.cssFloat;
77 } else if (elem.style.styleFloat) { 80 } else if (elem.style.styleFloat) {
78 return elem.style.styleFloat; 81 return elem.style.styleFloat;
79 } else { 82 } else {
80 return "none"; 83 return "none";
81 } 84 }
82 } 85 }
83 var value = elem.style ? elem.style[cssProperty] : null; 86 var value = elem.style ? elem.style[cssProperty] : null;
84 if (!value) { 87 if (!value) {
85 if (d.defaultView && d.defaultView.getComputedStyle) { 88 if (d.defaultView && d.defaultView.getComputedStyle) {
86 var css = d.defaultView.getComputedStyle(elem, null); 89 var css = d.defaultView.getComputedStyle(elem, null);
87 cssProperty = cssProperty.replace(/([A-Z])/g, '-$1' 90 cssProperty = cssProperty.replace(/([A-Z])/g, '-$1'
88 ).toLowerCase(); // from dojo.style.toSelectorCase 91 ).toLowerCase(); // from dojo.style.toSelectorCase
89 value = css ? css.getPropertyValue(cssProperty) : null; 92 value = css ? css.getPropertyValue(cssProperty) : null;
90 } else if (elem.currentStyle) { 93 } else if (elem.currentStyle) {
91 value = elem.currentStyle[cssProperty]; 94 value = elem.currentStyle[cssProperty];
92 if (/^\d/.test(value) && !/px$/.test(value) && cssProperty != 'fontWeight') { 95 if (/^\d/.test(value) && !/px$/.test(value) && cssProperty != 'fontWeight') {
93 /* Convert to px using an hack from Dean Edwards */ 96 /* Convert to px using an hack from Dean Edwards */
94 var left = elem.style.left; 97 var left = elem.style.left;
95 var rsLeft = elem.runtimeStyle.left; 98 var rsLeft = elem.runtimeStyle.left;
96 elem.runtimeStyle.left = elem.currentStyle.left; 99 elem.runtimeStyle.left = elem.currentStyle.left;
97 elem.style.left = value || 0; 100 elem.style.left = value || 0;
98 value = elem.style.pixelLeft + "px"; 101 value = elem.style.pixelLeft + "px";
99 elem.style.left = left; 102 elem.style.left = left;
100 elem.runtimeStyle.left = rsLeft; 103 elem.runtimeStyle.left = rsLeft;
101 } 104 }
102 } 105 }
103 } 106 }
104 if (cssProperty == 'opacity') { 107 if (cssProperty == 'opacity') {
105 value = parseFloat(value); 108 value = parseFloat(value);
106 } 109 }
107 110
108 if (/Opera/.test(navigator.userAgent) && (MochiKit.Base.findValue(['left', 'top', 'right', 'bottom'], cssProperty) != -1)) { 111 if (/Opera/.test(navigator.userAgent) && (MochiKit.Base.findValue(['left', 'top', 'right', 'bottom'], cssProperty) != -1)) {
109 if (MochiKit.Style.getStyle(elem, 'position') == 'static') { 112 if (MochiKit.Style.getStyle(elem, 'position') == 'static') {
110 value = 'auto'; 113 value = 'auto';
111 } 114 }
112 } 115 }
113 116
114 return value == 'auto' ? null : value; 117 return value == 'auto' ? null : value;
115 }, 118 },
116 119
117 /** @id MochiKit.Style.setStyle */ 120 /** @id MochiKit.Style.setStyle */
118 setStyle: function (elem, style) { 121 setStyle: function (elem, style) {
119 elem = MochiKit.DOM.getElement(elem); 122 elem = MochiKit.DOM.getElement(elem);
120 for (var name in style) { 123 for (var name in style) {
121 switch (name) { 124 switch (name) {
122 case 'opacity': 125 case 'opacity':
123 MochiKit.Style.setOpacity(elem, style[name]); 126 MochiKit.Style.setOpacity(elem, style[name]);
124 break; 127 break;
125 case 'float': 128 case 'float':
126 case 'cssFloat': 129 case 'cssFloat':
127 case 'styleFloat': 130 case 'styleFloat':
128 if (typeof(elem.style["float"]) != "undefined") { 131 if (typeof(elem.style["float"]) != "undefined") {
129 elem.style["float"] = style[name]; 132 elem.style["float"] = style[name];
130 } else if (typeof(elem.style.cssFloat) != "undefined") { 133 } else if (typeof(elem.style.cssFloat) != "undefined") {
131 elem.style.cssFloat = style[name]; 134 elem.style.cssFloat = style[name];
132 } else { 135 } else {
133 elem.style.styleFloat = style[name]; 136 elem.style.styleFloat = style[name];
134 } 137 }
135 break; 138 break;
136 default: 139 default:
137 elem.style[MochiKit.Base.camelize(name)] = style[name]; 140 elem.style[MochiKit.Base.camelize(name)] = style[name];
138 } 141 }
139 } 142 }
140 }, 143 },
141 144
142 /** @id MochiKit.Style.setOpacity */ 145 /** @id MochiKit.Style.setOpacity */
143 setOpacity: function (elem, o) { 146 setOpacity: function (elem, o) {
144 elem = MochiKit.DOM.getElement(elem); 147 elem = MochiKit.DOM.getElement(elem);
145 var self = MochiKit.Style; 148 var self = MochiKit.Style;
146 if (o == 1) { 149 if (o == 1) {
147 var toSet = /Gecko/.test(navigator.userAgent) && !(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent)); 150 var toSet = /Gecko/.test(navigator.userAgent) && !(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent));
148 elem.style["opacity"] = toSet ? 0.999999 : 1.0; 151 elem.style["opacity"] = toSet ? 0.999999 : 1.0;
149 if (/MSIE/.test(navigator.userAgent)) { 152 if (/MSIE/.test(navigator.userAgent)) {
150 elem.style['filter'] = 153 elem.style['filter'] =
151 self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, ''); 154 self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, '');
152 } 155 }
153 } else { 156 } else {
154 if (o < 0.00001) { 157 if (o < 0.00001) {
155 o = 0; 158 o = 0;
156 } 159 }
157 elem.style["opacity"] = o; 160 elem.style["opacity"] = o;
158 if (/MSIE/.test(navigator.userAgent)) { 161 if (/MSIE/.test(navigator.userAgent)) {
159 elem.style['filter'] = 162 elem.style['filter'] =
160 self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, '') + 'alpha(opacity=' + o * 100 + ')'; 163 self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, '') + 'alpha(opacity=' + o * 100 + ')';
161 } 164 }
162 } 165 }
163 }, 166 },
164 167
165 /* 168 /*
166 169
167 getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0. 170 getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0.
168 Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved. 171 Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved.
169 License: BSD, http://developer.yahoo.net/yui/license.txt 172 License: BSD, http://developer.yahoo.net/yui/license.txt
170 173
171 */ 174 */
172 175
173 /** @id MochiKit.Style.getElementPosition */ 176 /** @id MochiKit.Style.getElementPosition */
174 getElementPosition: function (elem, /* optional */relativeTo) { 177 getElementPosition: function (elem, /* optional */relativeTo) {
175 var self = MochiKit.Style; 178 var self = MochiKit.Style;
176 var dom = MochiKit.DOM; 179 var dom = MochiKit.DOM;
177 var isCoordinates = function (o) { 180 var isCoordinates = function (o) {
178 return o != null && 181 return o != null &&
179 o.nodeType == null && 182 o.nodeType == null &&
180 typeof(o.x) == "number" && 183 typeof(o.x) == "number" &&
181 typeof(o.y) == "number"; 184 typeof(o.y) == "number";
182 } 185 };
183 186
184 if (typeof(elem) == "string") { 187 if (typeof(elem) == "string") {
185 elem = dom.getElement(elem); 188 elem = dom.getElement(elem);
186 } 189 }
187 if (elem == null || 190 if (elem == null ||
188 (!isCoordinates(elem) && self.getStyle(elem, 'display') == 'none')) { 191 (!isCoordinates(elem) && self.getStyle(elem, 'display') == 'none')) {
189 return undefined; 192 return undefined;
190 } 193 }
191 194
192 var c = new self.Coordinates(0, 0); 195 var c = new self.Coordinates(0, 0);
193 var box = null; 196 var box = null;
194 var parent = null; 197 var parent = null;
195 198
196 var d = MochiKit.DOM._document; 199 var d = MochiKit.DOM._document;
197 var de = d.documentElement; 200 var de = d.documentElement;
198 var b = d.body; 201 var b = d.body;
199 202
200 if (!elem.parentNode && elem.x && elem.y) { 203 if (isCoordinates(elem)) {
201 /* it's just a MochiKit.Style.Coordinates object */ 204 /* it's just a MochiKit.Style.Coordinates object */
202 c.x += elem.x || 0; 205 c.x += elem.x || 0;
203 c.y += elem.y || 0; 206 c.y += elem.y || 0;
204 } else if (elem.getBoundingClientRect) { // IE shortcut 207 } else if (elem.getBoundingClientRect) { // IE shortcut
205 /* 208 /*
206 209
207 The IE shortcut can be off by two. We fix it. See: 210 The IE shortcut can be off by two. We fix it. See:
208 http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp 211 http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp
209 212
210 This is similar to the method used in 213 This is similar to the method used in
211 MochiKit.Signal.Event.mouse(). 214 MochiKit.Signal.Event.mouse().
212 215
213 */ 216 */
214 box = elem.getBoundingClientRect(); 217 box = elem.getBoundingClientRect();
215 218
216 c.x += box.left + 219 c.x += box.left +
217 (de.scrollLeft || b.scrollLeft) - 220 (de.scrollLeft || b.scrollLeft) -
218 (de.clientLeft || 0); 221 (de.clientLeft || 0);
219 222
220 c.y += box.top + 223 c.y += box.top +
221 (de.scrollTop || b.scrollTop) - 224 (de.scrollTop || b.scrollTop) -
222 (de.clientTop || 0); 225 (de.clientTop || 0);
223 226
224 } else if (elem.offsetParent) { 227 } else if (elem.offsetParent) {
225 c.x += elem.offsetLeft; 228 c.x += elem.offsetLeft;
226 c.y += elem.offsetTop; 229 c.y += elem.offsetTop;
227 parent = elem.offsetParent; 230 parent = elem.offsetParent;
228 231
229 if (parent != elem) { 232 if (parent != elem) {
230 while (parent) { 233 while (parent) {
231 c.x += parseInt(parent.style.borderLeftWidth) || 0; 234 c.x += parseInt(parent.style.borderLeftWidth, 10) || 0;
232 c.y += parseInt(parent.style.borderTopWidth) || 0; 235 c.y += parseInt(parent.style.borderTopWidth, 10) || 0;
233 c.x += parent.offsetLeft; 236 c.x += parent.offsetLeft;
234 c.y += parent.offsetTop; 237 c.y += parent.offsetTop;
235 parent = parent.offsetParent; 238 parent = parent.offsetParent;
236 } 239 }
237 } 240 }
238 241
239 /* 242 /*
240 243
241 Opera < 9 and old Safari (absolute) incorrectly account for 244 Opera < 9 and old Safari (absolute) incorrectly account for
242 body offsetTop and offsetLeft. 245 body offsetTop and offsetLeft.
243 246
244 */ 247 */
245 var ua = navigator.userAgent.toLowerCase(); 248 var ua = navigator.userAgent.toLowerCase();
246 if ((typeof(opera) != 'undefined' && 249 if ((typeof(opera) != 'undefined' &&
247 parseFloat(opera.version()) < 9) || 250 parseFloat(opera.version()) < 9) ||
248 (ua.indexOf('AppleWebKit') != -1 && 251 (ua.indexOf('AppleWebKit') != -1 &&
249 self.getStyle(elem, 'position') == 'absolute')) { 252 self.getStyle(elem, 'position') == 'absolute')) {
250 253
251 c.x -= b.offsetLeft; 254 c.x -= b.offsetLeft;
252 c.y -= b.offsetTop; 255 c.y -= b.offsetTop;
253 256
254 } 257 }
255 258
256 // Adjust position for strange Opera scroll bug 259 // Adjust position for strange Opera scroll bug
257 if (elem.parentNode) { 260 if (elem.parentNode) {
258 parent = elem.parentNode; 261 parent = elem.parentNode;
259 } else { 262 } else {
260 parent = null; 263 parent = null;
261 } 264 }
262 while (parent) { 265 while (parent) {
263 var tagName = parent.tagName.toUpperCase(); 266 var tagName = parent.tagName.toUpperCase();
264 if (tagName === 'BODY' || tagName === 'HTML') { 267 if (tagName === 'BODY' || tagName === 'HTML') {
265 break; 268 break;
266 } 269 }
267 var disp = self.getStyle(parent, 'display'); 270 var disp = self.getStyle(parent, 'display');
268 // Handle strange Opera bug for some display 271 // Handle strange Opera bug for some display
269 if (disp.search(/^inline|table-row.*$/i)) { 272 if (disp.search(/^inline|table-row.*$/i)) {
270 c.x -= parent.scrollLeft; 273 c.x -= parent.scrollLeft;
271 c.y -= parent.scrollTop; 274 c.y -= parent.scrollTop;
272 } 275 }
273 if (parent.parentNode) { 276 if (parent.parentNode) {
274 parent = parent.parentNode; 277 parent = parent.parentNode;
275 } else { 278 } else {
276 parent = null; 279 parent = null;
277 } 280 }
278 } 281 }
279 } 282 }
280 283
281 if (relativeTo) { 284 if (relativeTo) {
282 relativeTo = arguments.callee(relativeTo); 285 relativeTo = arguments.callee(relativeTo);
283 if (relativeTo) { 286 if (relativeTo) {
284 c.x -= (relativeTo.x || 0); 287 c.x -= (relativeTo.x || 0);
285 c.y -= (relativeTo.y || 0); 288 c.y -= (relativeTo.y || 0);
286 } 289 }
287 } 290 }
288 291
289 return c; 292 return c;
290 }, 293 },
291 294
292 /** @id MochiKit.Style.setElementPosition */ 295 /** @id MochiKit.Style.setElementPosition */
293 setElementPosition: function (elem, newPos/* optional */, units) { 296 setElementPosition: function (elem, newPos/* optional */, units) {
294 elem = MochiKit.DOM.getElement(elem); 297 elem = MochiKit.DOM.getElement(elem);
295 if (typeof(units) == 'undefined') { 298 if (typeof(units) == 'undefined') {
296 units = 'px'; 299 units = 'px';
297 } 300 }
298 var newStyle = {}; 301 var newStyle = {};
299 var isUndefNull = MochiKit.Base.isUndefinedOrNull; 302 var isUndefNull = MochiKit.Base.isUndefinedOrNull;
300 if (!isUndefNull(newPos.x)) { 303 if (!isUndefNull(newPos.x)) {
301 newStyle['left'] = newPos.x + units; 304 newStyle['left'] = newPos.x + units;
302 } 305 }
303 if (!isUndefNull(newPos.y)) { 306 if (!isUndefNull(newPos.y)) {
304 newStyle['top'] = newPos.y + units; 307 newStyle['top'] = newPos.y + units;
305 } 308 }
306 MochiKit.DOM.updateNodeAttributes(elem, {'style': newStyle}); 309 MochiKit.DOM.updateNodeAttributes(elem, {'style': newStyle});
307 }, 310 },
308 311
309 /** @id MochiKit.Style.makePositioned */ 312 /** @id MochiKit.Style.makePositioned */
310 makePositioned: function (element) { 313 makePositioned: function (element) {
311 element = MochiKit.DOM.getElement(element); 314 element = MochiKit.DOM.getElement(element);
312 var pos = MochiKit.Style.getStyle(element, 'position'); 315 var pos = MochiKit.Style.getStyle(element, 'position');
313 if (pos == 'static' || !pos) { 316 if (pos == 'static' || !pos) {
314 element.style.position = 'relative'; 317 element.style.position = 'relative';
315 // Opera returns the offset relative to the positioning context, 318 // Opera returns the offset relative to the positioning context,
316 // when an element is position relative but top and left have 319 // when an element is position relative but top and left have
317 // not been defined 320 // not been defined
318 if (/Opera/.test(navigator.userAgent)) { 321 if (/Opera/.test(navigator.userAgent)) {
319 element.style.top = 0; 322 element.style.top = 0;
320 element.style.left = 0; 323 element.style.left = 0;
321 } 324 }
322 } 325 }
323 }, 326 },
324 327
325 /** @id MochiKit.Style.undoPositioned */ 328 /** @id MochiKit.Style.undoPositioned */
326 undoPositioned: function (element) { 329 undoPositioned: function (element) {
327 element = MochiKit.DOM.getElement(element); 330 element = MochiKit.DOM.getElement(element);
328 if (element.style.position == 'relative') { 331 if (element.style.position == 'relative') {
329 element.style.position = element.style.top = element.style.left = element.style.bottom = element.style.right = ''; 332 element.style.position = element.style.top = element.style.left = element.style.bottom = element.style.right = '';
330 } 333 }
331 }, 334 },
332 335
333 /** @id MochiKit.Style.makeClipping */ 336 /** @id MochiKit.Style.makeClipping */
334 makeClipping: function (element) { 337 makeClipping: function (element) {
335 element = MochiKit.DOM.getElement(element); 338 element = MochiKit.DOM.getElement(element);
336 var s = element.style; 339 var s = element.style;
337 var oldOverflow = { 'overflow': s.overflow, 340 var oldOverflow = { 'overflow': s.overflow,
338 'overflow-x': s.overflowX, 341 'overflow-x': s.overflowX,
339 'overflow-y': s.overflowY }; 342 'overflow-y': s.overflowY };
340 if ((MochiKit.Style.getStyle(element, 'overflow') || 'visible') != 'hidden') { 343 if ((MochiKit.Style.getStyle(element, 'overflow') || 'visible') != 'hidden') {
341 element.style.overflow = 'hidden'; 344 element.style.overflow = 'hidden';
342 element.style.overflowX = 'hidden'; 345 element.style.overflowX = 'hidden';
343 element.style.overflowY = 'hidden'; 346 element.style.overflowY = 'hidden';
344 } 347 }
345 return oldOverflow; 348 return oldOverflow;
346 }, 349 },
347 350
348 /** @id MochiKit.Style.undoClipping */ 351 /** @id MochiKit.Style.undoClipping */
349 undoClipping: function (element, overflow) { 352 undoClipping: function (element, overflow) {
350 element = MochiKit.DOM.getElement(element); 353 element = MochiKit.DOM.getElement(element);
351 if (typeof(overflow) == 'string') { 354 if (typeof(overflow) == 'string') {
352 element.style.overflow = overflow; 355 element.style.overflow = overflow;
353 } else if (overflow != null) { 356 } else if (overflow != null) {
354 element.style.overflow = overflow['overflow']; 357 element.style.overflow = overflow['overflow'];
355 element.style.overflowX = overflow['overflow-x']; 358 element.style.overflowX = overflow['overflow-x'];
356 element.style.overflowY = overflow['overflow-y']; 359 element.style.overflowY = overflow['overflow-y'];
357 } 360 }
358 }, 361 },
359 362
360 /** @id MochiKit.Style.getElementDimensions */ 363 /** @id MochiKit.Style.getElementDimensions */
361 getElementDimensions: function (elem, contentSize/*optional*/) { 364 getElementDimensions: function (elem, contentSize/*optional*/) {
362 var self = MochiKit.Style; 365 var self = MochiKit.Style;
363 var dom = MochiKit.DOM; 366 var dom = MochiKit.DOM;
364 if (typeof(elem.w) == 'number' || typeof(elem.h) == 'number') { 367 if (typeof(elem.w) == 'number' || typeof(elem.h) == 'number') {
365 return new self.Dimensions(elem.w || 0, elem.h || 0); 368 return new self.Dimensions(elem.w || 0, elem.h || 0);
366 } 369 }
367 elem = dom.getElement(elem); 370 elem = dom.getElement(elem);
368 if (!elem) { 371 if (!elem) {
369 return undefined; 372 return undefined;
370 } 373 }
371 var disp = self.getStyle(elem, 'display'); 374 var disp = self.getStyle(elem, 'display');
372 // display can be empty/undefined on WebKit/KHTML 375 // display can be empty/undefined on WebKit/KHTML
373 if (disp == 'none' || disp == '' || typeof(disp) == 'undefined') { 376 if (disp == 'none' || disp == '' || typeof(disp) == 'undefined') {
374 var s = elem.style; 377 var s = elem.style;
375 var originalVisibility = s.visibility; 378 var originalVisibility = s.visibility;
376 var originalPosition = s.position; 379 var originalPosition = s.position;
377 var originalDisplay = s.display; 380 var originalDisplay = s.display;
378 s.visibility = 'hidden'; 381 s.visibility = 'hidden';
379 s.position = 'absolute'; 382 s.position = 'absolute';
380 s.display = self._getDefaultDisplay(elem); 383 s.display = self._getDefaultDisplay(elem);
381 var originalWidth = elem.offsetWidth; 384 var originalWidth = elem.offsetWidth;
382 var originalHeight = elem.offsetHeight; 385 var originalHeight = elem.offsetHeight;
383 s.display = originalDisplay; 386 s.display = originalDisplay;
384 s.position = originalPosition; 387 s.position = originalPosition;
385 s.visibility = originalVisibility; 388 s.visibility = originalVisibility;
386 } else { 389 } else {
387 originalWidth = elem.offsetWidth || 0; 390 originalWidth = elem.offsetWidth || 0;
388 originalHeight = elem.offsetHeight || 0; 391 originalHeight = elem.offsetHeight || 0;
389 } 392 }
390 if (contentSize) { 393 if (contentSize) {
391 var tableCell = 'colSpan' in elem && 'rowSpan' in elem; 394 var tableCell = 'colSpan' in elem && 'rowSpan' in elem;
392 var collapse = (tableCell && elem.parentNode && self.getStyle( 395 var collapse = (tableCell && elem.parentNode && self.getStyle(
393 elem.parentNode, 'borderCollapse') == 'collapse') 396 elem.parentNode, 'borderCollapse') == 'collapse');
394 if (collapse) { 397 if (collapse) {
395 if (/MSIE/.test(navigator.userAgent)) { 398 if (/MSIE/.test(navigator.userAgent)) {
396 var borderLeftQuota = elem.previousSibling? 0.5 : 1; 399 var borderLeftQuota = elem.previousSibling? 0.5 : 1;
397 var borderRightQuota = elem.nextSibling? 0.5 : 1; 400 var borderRightQuota = elem.nextSibling? 0.5 : 1;
398 } 401 }
399 else { 402 else {
400 var borderLeftQuota = 0.5; 403 var borderLeftQuota = 0.5;
401 var borderRightQuota = 0.5; 404 var borderRightQuota = 0.5;
402 } 405 }
403 } else { 406 } else {
404 var borderLeftQuota = 1; 407 var borderLeftQuota = 1;
405 var borderRightQuota = 1; 408 var borderRightQuota = 1;
406 } 409 }
407 originalWidth -= Math.round( 410 originalWidth -= Math.round(
408 (parseFloat(self.getStyle(elem, 'paddingLeft')) || 0) 411 (parseFloat(self.getStyle(elem, 'paddingLeft')) || 0)
409 + (parseFloat(self.getStyle(elem, 'paddingRight')) || 0) 412 + (parseFloat(self.getStyle(elem, 'paddingRight')) || 0)
410 + borderLeftQuota * 413 + borderLeftQuota *
411 (parseFloat(self.getStyle(elem, 'borderLeftWidth')) || 0) 414 (parseFloat(self.getStyle(elem, 'borderLeftWidth')) || 0)
412 + borderRightQuota * 415 + borderRightQuota *
413 (parseFloat(self.getStyle(elem, 'borderRightWidth')) || 0) 416 (parseFloat(self.getStyle(elem, 'borderRightWidth')) || 0)
414 ); 417 );
415 if (tableCell) { 418 if (tableCell) {
416 if (/Gecko|Opera/.test(navigator.userAgent) 419 if (/Gecko|Opera/.test(navigator.userAgent)
417 && !/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent)) { 420 && !/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent)) {
418 var borderHeightQuota = 0; 421 var borderHeightQuota = 0;
419 } else if (/MSIE/.test(navigator.userAgent)) { 422 } else if (/MSIE/.test(navigator.userAgent)) {
420 var borderHeightQuota = 1; 423 var borderHeightQuota = 1;
421 } else { 424 } else {
422 var borderHeightQuota = collapse? 0.5 : 1; 425 var borderHeightQuota = collapse? 0.5 : 1;
423 } 426 }
424 } else { 427 } else {
425 var borderHeightQuota = 1; 428 var borderHeightQuota = 1;
426 } 429 }
427 originalHeight -= Math.round( 430 originalHeight -= Math.round(
428 (parseFloat(self.getStyle(elem, 'paddingTop')) || 0) 431 (parseFloat(self.getStyle(elem, 'paddingTop')) || 0)
429 + (parseFloat(self.getStyle(elem, 'paddingBottom')) || 0) 432 + (parseFloat(self.getStyle(elem, 'paddingBottom')) || 0)
430 + borderHeightQuota * ( 433 + borderHeightQuota * (
431 (parseFloat(self.getStyle(elem, 'borderTopWidth')) || 0) 434 (parseFloat(self.getStyle(elem, 'borderTopWidth')) || 0)
432 + (parseFloat(self.getStyle(elem, 'borderBottomWidth')) || 0)) 435 + (parseFloat(self.getStyle(elem, 'borderBottomWidth')) || 0))
433 ); 436 );
434 } 437 }
435 return new self.Dimensions(originalWidth, originalHeight); 438 return new self.Dimensions(originalWidth, originalHeight);
436 }, 439 },
437 440
438 /** @id MochiKit.Style.setElementDimensions */ 441 /** @id MochiKit.Style.setElementDimensions */
439 setElementDimensions: function (elem, newSize/* optional */, units) { 442 setElementDimensions: function (elem, newSize/* optional */, units) {
440 elem = MochiKit.DOM.getElement(elem); 443 elem = MochiKit.DOM.getElement(elem);
441 if (typeof(units) == 'undefined') { 444 if (typeof(units) == 'undefined') {
442 units = 'px'; 445 units = 'px';
443 } 446 }
444 var newStyle = {}; 447 var newStyle = {};
445 var isUndefNull = MochiKit.Base.isUndefinedOrNull; 448 var isUndefNull = MochiKit.Base.isUndefinedOrNull;
446 if (!isUndefNull(newSize.w)) { 449 if (!isUndefNull(newSize.w)) {
447 newStyle['width'] = newSize.w + units; 450 newStyle['width'] = newSize.w + units;
448 } 451 }
449 if (!isUndefNull(newSize.h)) { 452 if (!isUndefNull(newSize.h)) {
450 newStyle['height'] = newSize.h + units; 453 newStyle['height'] = newSize.h + units;
451 } 454 }
452 MochiKit.DOM.updateNodeAttributes(elem, {'style': newStyle}); 455 MochiKit.DOM.updateNodeAttributes(elem, {'style': newStyle});
453 }, 456 },
454 457
455 _getDefaultDisplay: function (elem) { 458 _getDefaultDisplay: function (elem) {
456 var self = MochiKit.Style; 459 var self = MochiKit.Style;
457 var dom = MochiKit.DOM; 460 var dom = MochiKit.DOM;
458 elem = dom.getElement(elem); 461 elem = dom.getElement(elem);
459 if (!elem) { 462 if (!elem) {
460 return undefined; 463 return undefined;
461 } 464 }
462 var tagName = elem.tagName.toUpperCase(); 465 var tagName = elem.tagName.toUpperCase();
463 return self._defaultDisplay[tagName] || 'block'; 466 return self._defaultDisplay[tagName] || 'block';
464 }, 467 },
465 468
466 /** @id MochiKit.Style.setDisplayForElement */ 469 /** @id MochiKit.Style.setDisplayForElement */
467 setDisplayForElement: function (display, element/*, ...*/) { 470 setDisplayForElement: function (display, element/*, ...*/) {
468 var elements = MochiKit.Base.extend(null, arguments, 1); 471 var elements = MochiKit.Base.extend(null, arguments, 1);
469 var getElement = MochiKit.DOM.getElement; 472 var getElement = MochiKit.DOM.getElement;
470 for (var i = 0; i < elements.length; i++) { 473 for (var i = 0; i < elements.length; i++) {
471 element = getElement(elements[i]); 474 element = getElement(elements[i]);
472 if (element) { 475 if (element) {
473 element.style.display = display; 476 element.style.display = display;
474 } 477 }
475 } 478 }
476 }, 479 },
477 480
478 /** @id MochiKit.Style.getViewportDimensions */ 481 /** @id MochiKit.Style.getViewportDimensions */
479 getViewportDimensions: function () { 482 getViewportDimensions: function () {
480 var d = new MochiKit.Style.Dimensions(); 483 var d = new MochiKit.Style.Dimensions();
481 var w = MochiKit.DOM._window; 484 var w = MochiKit.DOM._window;
482 var b = MochiKit.DOM._document.body; 485 var b = MochiKit.DOM._document.body;
483 if (w.innerWidth) { 486 if (w.innerWidth) {
484 d.w = w.innerWidth; 487 d.w = w.innerWidth;
485 d.h = w.innerHeight; 488 d.h = w.innerHeight;
486 } else if (b && b.parentElement && b.parentElement.clientWidth) { 489 } else if (b && b.parentElement && b.parentElement.clientWidth) {
487 d.w = b.parentElement.clientWidth; 490 d.w = b.parentElement.clientWidth;
488 d.h = b.parentElement.clientHeight; 491 d.h = b.parentElement.clientHeight;
489 } else if (b && b.clientWidth) { 492 } else if (b && b.clientWidth) {
490 d.w = b.clientWidth; 493 d.w = b.clientWidth;
491 d.h = b.clientHeight; 494 d.h = b.clientHeight;
492 } 495 }
493 return d; 496 return d;
494 }, 497 },
495 498
496 /** @id MochiKit.Style.getViewportPosition */ 499 /** @id MochiKit.Style.getViewportPosition */
497 getViewportPosition: function () { 500 getViewportPosition: function () {
498 var c = new MochiKit.Style.Coordinates(0, 0); 501 var c = new MochiKit.Style.Coordinates(0, 0);
499 var d = MochiKit.DOM._document; 502 var d = MochiKit.DOM._document;
500 var de = d.documentElement; 503 var de = d.documentElement;
501 var db = d.body; 504 var db = d.body;
502 if (de && (de.scrollTop || de.scrollLeft)) { 505 if (de && (de.scrollTop || de.scrollLeft)) {
503 c.x = de.scrollLeft; 506 c.x = de.scrollLeft;
504 c.y = de.scrollTop; 507 c.y = de.scrollTop;
505 } else if (db) { 508 } else if (db) {
506 c.x = db.scrollLeft; 509 c.x = db.scrollLeft;
507 c.y = db.scrollTop; 510 c.y = db.scrollTop;
508 } 511 }
509 return c; 512 return c;
510 }, 513 },
511 514
512 __new__: function () { 515 __new__: function () {
513 var m = MochiKit.Base; 516 var m = MochiKit.Base;
514 517
515 var inlines = ['A','ABBR','ACRONYM','B','BASEFONT','BDO','BIG','BR', 518 var inlines = ['A','ABBR','ACRONYM','B','BASEFONT','BDO','BIG','BR',
516 'CITE','CODE','DFN','EM','FONT','I','IMG','KBD','LABEL', 519 'CITE','CODE','DFN','EM','FONT','I','IMG','KBD','LABEL',
517 'Q','S','SAMP','SMALL','SPAN','STRIKE','STRONG','SUB', 520 'Q','S','SAMP','SMALL','SPAN','STRIKE','STRONG','SUB',
518 'SUP','TEXTAREA','TT','U','VAR']; 521 'SUP','TEXTAREA','TT','U','VAR'];
519 this._defaultDisplay = { 'TABLE': 'table', 522 this._defaultDisplay = { 'TABLE': 'table',
520 'THEAD': 'table-header-group', 523 'THEAD': 'table-header-group',
521 'TBODY': 'table-row-group', 524 'TBODY': 'table-row-group',
522 'TFOOT': 'table-footer-group', 525 'TFOOT': 'table-footer-group',
523 'COLGROUP': 'table-column-group', 526 'COLGROUP': 'table-column-group',
524 'COL': 'table-column', 527 'COL': 'table-column',
525 'TR': 'table-row', 528 'TR': 'table-row',
526 'TD': 'table-cell', 529 'TD': 'table-cell',
527 'TH': 'table-cell', 530 'TH': 'table-cell',
528 'CAPTION': 'table-caption', 531 'CAPTION': 'table-caption',
529 'LI': 'list-item', 532 'LI': 'list-item',
530 'INPUT': 'inline-block', 533 'INPUT': 'inline-block',
531 'SELECT': 'inline-block' }; 534 'SELECT': 'inline-block' };
532 // CSS 'display' support in IE6/7 is just broken... 535 // CSS 'display' support in IE6/7 is just broken...
533 if (/MSIE/.test(navigator.userAgent)) { 536 if (/MSIE/.test(navigator.userAgent)) {
534 for (var k in this._defaultDisplay) { 537 for (var k in this._defaultDisplay) {
535 var v = this._defaultDisplay[k]; 538 var v = this._defaultDisplay[k];
536 if (v.indexOf('table') == 0) { 539 if (v.indexOf('table') == 0) {
537 this._defaultDisplay[k] = 'block'; 540 this._defaultDisplay[k] = 'block';
538 } 541 }
539 } 542 }
540 } 543 }
541 for (var i = 0; i < inlines.length; i++) { 544 for (var i = 0; i < inlines.length; i++) {
542 this._defaultDisplay[inlines[i]] = 'inline'; 545 this._defaultDisplay[inlines[i]] = 'inline';
543 } 546 }
544 547
545 // Backwards compatibility aliases 548 // Backwards compatibility aliases
546 m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3'); 549 m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3', true);
547 m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3'); 550 m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3', true);
548 551
549 this.hideElement = m.partial(this.setDisplayForElement, 'none'); 552 this.hideElement = m.partial(this.setDisplayForElement, 'none');
550 // TODO: showElement could be improved by using getDefaultDisplay. 553 // TODO: showElement could be improved by using getDefaultDisplay.
551 this.showElement = m.partial(this.setDisplayForElement, 'block'); 554 this.showElement = m.partial(this.setDisplayForElement, 'block');
552 555
553 m.nameFunctions(this); 556 m.nameFunctions(this);
554 } 557 }
555}); 558});
556 559
557MochiKit.Style.__new__(); 560MochiKit.Style.__new__();
558MochiKit.Base._exportSymbols(this, MochiKit.Style); 561MochiKit.Base._exportSymbols(this, MochiKit.Style);
diff --git a/frontend/gamma/js/MochiKit/Test.js b/frontend/gamma/js/MochiKit/Test.js
index 9520ab2..f29670f 100644
--- a/frontend/gamma/js/MochiKit/Test.js
+++ b/frontend/gamma/js/MochiKit/Test.js
@@ -1,144 +1,144 @@
1/*** 1/***
2 2
3MochiKit.Test 1.5 3MochiKit.Test 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito. All rights Reserved. 7(c) 2005 Bob Ippolito. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Test', '1.5', ['Base']); 11MochiKit.Base.module(MochiKit, 'Test', '1.5', ['Base']);
12 12
13MochiKit.Test.runTests = function (obj) { 13MochiKit.Test.runTests = function (obj) {
14 if (typeof(obj) == "string") { 14 if (typeof(obj) == "string") {
15 // TODO: Remove this temporary API change advertisement 15 // TODO: Remove this temporary API change advertisement
16 throw new TypeError("Automatic module import not supported, call runTests() with proper object: " + obj); 16 throw new TypeError("Automatic module import not supported, call runTests() with proper object: " + obj);
17 } 17 }
18 var suite = new MochiKit.Test.Suite(); 18 var suite = new MochiKit.Test.Suite();
19 suite.run(obj); 19 suite.run(obj);
20}; 20};
21 21
22MochiKit.Test.Suite = function () { 22MochiKit.Test.Suite = function () {
23 this.testIndex = 0; 23 this.testIndex = 0;
24 MochiKit.Base.bindMethods(this); 24 MochiKit.Base.bindMethods(this);
25}; 25};
26 26
27MochiKit.Test.Suite.prototype = { 27MochiKit.Test.Suite.prototype = {
28 run: function (obj) { 28 run: function (obj) {
29 try { 29 try {
30 obj(this); 30 obj(this);
31 } catch (e) { 31 } catch (e) {
32 this.traceback(e); 32 this.traceback(e);
33 } 33 }
34 }, 34 },
35 traceback: function (e) { 35 traceback: function (e) {
36 var items = MochiKit.Iter.sorted(MochiKit.Base.items(e)); 36 var items = MochiKit.Iter.sorted(MochiKit.Base.items(e));
37 print("not ok " + this.testIndex + " - Error thrown"); 37 print("not ok " + this.testIndex + " - Error thrown");
38 for (var i = 0; i < items.length; i++) { 38 for (var i = 0; i < items.length; i++) {
39 var kv = items[i]; 39 var kv = items[i];
40 if (kv[0] == "stack") { 40 if (kv[0] == "stack") {
41 kv[1] = kv[1].split(/\n/)[0]; 41 kv[1] = kv[1].split(/\n/)[0];
42 } 42 }
43 this.print("# " + kv.join(": ")); 43 this.print("# " + kv.join(": "));
44 } 44 }
45 }, 45 },
46 print: function (s) { 46 print: function (s) {
47 print(s); 47 print(s);
48 }, 48 },
49 is: function (got, expected, /* optional */message) { 49 is: function (got, expected, /* optional */message) {
50 var res = 1; 50 var res = 1;
51 var msg = null; 51 var msg = null;
52 try { 52 try {
53 res = MochiKit.Base.compare(got, expected); 53 res = MochiKit.Base.compare(got, expected);
54 } catch (e) { 54 } catch (e) {
55 msg = "Can not compare " + typeof(got) + ":" + typeof(expected); 55 msg = "Can not compare " + typeof(got) + ":" + typeof(expected);
56 } 56 }
57 if (res) { 57 if (res) {
58 msg = "Expected value did not compare equal"; 58 msg = "Expected value did not compare equal";
59 } 59 }
60 if (!res) { 60 if (!res) {
61 return this.testResult(true, message); 61 return this.testResult(true, message);
62 } 62 }
63 return this.testResult(false, message, 63 return this.testResult(false, message,
64 [[msg], ["got:", got], ["expected:", expected]]); 64 [[msg], ["got:", got], ["expected:", expected]]);
65 }, 65 },
66 66
67 testResult: function (pass, msg, failures) { 67 testResult: function (pass, msg, failures) {
68 this.testIndex += 1; 68 this.testIndex += 1;
69 if (pass) { 69 if (pass) {
70 this.print("ok " + this.testIndex + " - " + msg); 70 this.print("ok " + this.testIndex + " - " + msg);
71 return; 71 return;
72 } 72 }
73 this.print("not ok " + this.testIndex + " - " + msg); 73 this.print("not ok " + this.testIndex + " - " + msg);
74 if (failures) { 74 if (failures) {
75 for (var i = 0; i < failures.length; i++) { 75 for (var i = 0; i < failures.length; i++) {
76 this.print("# " + failures[i].join(" ")); 76 this.print("# " + failures[i].join(" "));
77 } 77 }
78 } 78 }
79 }, 79 },
80 80
81 isDeeply: function (got, expected, /* optional */message) { 81 isDeeply: function (got, expected, /* optional */message) {
82 var m = MochiKit.Base; 82 var m = MochiKit.Base;
83 var res = 1; 83 var res = 1;
84 try { 84 try {
85 res = m.compare(got, expected); 85 res = m.compare(got, expected);
86 } catch (e) { 86 } catch (e) {
87 // pass 87 // pass
88 } 88 }
89 if (res === 0) { 89 if (res === 0) {
90 return this.ok(true, message); 90 return this.ok(true, message);
91 } 91 }
92 var gk = m.keys(got); 92 var gk = m.keys(got);
93 var ek = m.keys(expected); 93 var ek = m.keys(expected);
94 gk.sort(); 94 gk.sort();
95 ek.sort(); 95 ek.sort();
96 if (m.compare(gk, ek)) { 96 if (m.compare(gk, ek)) {
97 // differing keys 97 // differing keys
98 var cmp = {}; 98 var cmp = {};
99 var i; 99 var i;
100 for (i = 0; i < gk.length; i++) { 100 for (i = 0; i < gk.length; i++) {
101 cmp[gk[i]] = "got"; 101 cmp[gk[i]] = "got";
102 } 102 }
103 for (i = 0; i < ek.length; i++) { 103 for (i = 0; i < ek.length; i++) {
104 if (ek[i] in cmp) { 104 if (ek[i] in cmp) {
105 delete cmp[ek[i]]; 105 delete cmp[ek[i]];
106 } else { 106 } else {
107 cmp[ek[i]] = "expected"; 107 cmp[ek[i]] = "expected";
108 } 108 }
109 } 109 }
110 var diffkeys = m.keys(cmp); 110 var diffkeys = m.keys(cmp);
111 diffkeys.sort(); 111 diffkeys.sort();
112 var gotkeys = []; 112 var gotkeys = [];
113 var expkeys = []; 113 var expkeys = [];
114 while (diffkeys.length) { 114 while (diffkeys.length) {
115 var k = diffkeys.shift(); 115 var k = diffkeys.shift();
116 if (k in Object.prototype) { 116 if (k in Object.prototype) {
117 continue; 117 continue;
118 } 118 }
119 (cmp[k] == "got" ? gotkeys : expkeys).push(k); 119 (cmp[k] == "got" ? gotkeys : expkeys).push(k);
120 } 120 }
121 121
122 122
123 } 123 }
124 124
125 return this.testResult((!res), msg, 125 return this.testResult((!res), msg,
126 (msg ? [["got:", got], ["expected:", expected]] : undefined) 126 (msg ? [["got:", got], ["expected:", expected]] : undefined)
127 ); 127 );
128 }, 128 },
129 129
130 ok: function (res, message) { 130 ok: function (res, message) {
131 return this.testResult(res, message); 131 return this.testResult(res, message);
132 } 132 }
133}; 133};
134 134
135MochiKit.Test.__new__ = function () { 135MochiKit.Test.__new__ = function () {
136 var m = MochiKit.Base; 136 var m = MochiKit.Base;
137 this.Suite.__export__ = false; 137 this.Suite.__export__ = false;
138 m.nameFunctions(this); 138 m.nameFunctions(this);
139 139
140}; 140};
141 141
142MochiKit.Test.__new__(); 142MochiKit.Test.__new__();
143 143
144MochiKit.Base._exportSymbols(this, MochiKit.Test); 144MochiKit.Base._exportSymbols(this, MochiKit.Test);
diff --git a/frontend/gamma/js/MochiKit/Text.js b/frontend/gamma/js/MochiKit/Text.js
index a44f7e4..ff6366d 100644
--- a/frontend/gamma/js/MochiKit/Text.js
+++ b/frontend/gamma/js/MochiKit/Text.js
@@ -1,577 +1,546 @@
1/*** 1/***
2 2
3MochiKit.Text 1.5 3MochiKit.Text 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2008 Per Cederberg. All rights Reserved. 7(c) 2008 Per Cederberg. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Text', '1.5', ['Base', 'Format']); 11MochiKit.Base.module(MochiKit, 'Text', '1.5', ['Base', 'Format']);
12 12
13/** 13/**
14 * Checks if a text string starts with the specified substring. If 14 * Checks if a text string starts with the specified substring. If
15 * either of the two strings is null, false will be returned. 15 * either of the two strings is null, false will be returned.
16 * 16 *
17 * @param {String} substr the substring to search for 17 * @param {String} substr the substring to search for
18 * @param {String} str the string to search in 18 * @param {String} str the string to search in
19 * 19 *
20 * @return {Boolean} true if the string starts with the substring, or 20 * @return {Boolean} true if the string starts with the substring, or
21 * false otherwise 21 * false otherwise
22 */ 22 */
23MochiKit.Text.startsWith = function (substr, str) { 23MochiKit.Text.startsWith = function (substr, str) {
24 return str != null && substr != null && str.indexOf(substr) == 0; 24 return str != null && substr != null && str.indexOf(substr) == 0;
25} 25};
26 26
27/** 27/**
28 * Checks if a text string ends with the specified substring. If 28 * Checks if a text string ends with the specified substring. If
29 * either of the two strings is null, false will be returned. 29 * either of the two strings is null, false will be returned.
30 * 30 *
31 * @param {String} substr the substring to search for 31 * @param {String} substr the substring to search for
32 * @param {String} str the string to search in 32 * @param {String} str the string to search in
33 * 33 *
34 * @return {Boolean} true if the string ends with the substring, or 34 * @return {Boolean} true if the string ends with the substring, or
35 * false otherwise 35 * false otherwise
36 */ 36 */
37MochiKit.Text.endsWith = function (substr, str) { 37MochiKit.Text.endsWith = function (substr, str) {
38 return str != null && substr != null && 38 return str != null && substr != null &&
39 str.lastIndexOf(substr) == Math.max(str.length - substr.length, 0); 39 str.lastIndexOf(substr) == Math.max(str.length - substr.length, 0);
40} 40};
41 41
42/** 42/**
43 * Checks if a text string contains the specified substring. If 43 * Checks if a text string contains the specified substring. If
44 * either of the two strings is null, false will be returned. 44 * either of the two strings is null, false will be returned.
45 * 45 *
46 * @param {String} substr the substring to search for 46 * @param {String} substr the substring to search for
47 * @param {String} str the string to search in 47 * @param {String} str the string to search in
48 * 48 *
49 * @return {Boolean} true if the string contains the substring, or 49 * @return {Boolean} true if the string contains the substring, or
50 * false otherwise 50 * false otherwise
51 */ 51 */
52MochiKit.Text.contains = function (substr, str) { 52MochiKit.Text.contains = function (substr, str) {
53 return str != null && substr != null && str.indexOf(substr) >= 0; 53 return str != null && substr != null && str.indexOf(substr) >= 0;
54} 54};
55 55
56/** 56/**
57 * Adds a character to the left-hand side of a string until it 57 * Adds a character to the left-hand side of a string until it
58 * reaches the specified minimum length. 58 * reaches the specified minimum length.
59 * 59 *
60 * @param {String} str the string to process 60 * @param {String} str the string to process
61 * @param {Number} minLength the requested minimum length 61 * @param {Number} minLength the requested minimum length
62 * @param {String} fillChar the padding character to add, defaults 62 * @param {String} fillChar the padding character to add, defaults
63 * to a space 63 * to a space
64 * 64 *
65 * @return {String} the padded string 65 * @return {String} the padded string
66 */ 66 */
67MochiKit.Text.padLeft = function (str, minLength, fillChar) { 67MochiKit.Text.padLeft = function (str, minLength, fillChar) {
68 str = str || ""; 68 str = str || "";
69 fillChar = fillChar || " "; 69 fillChar = fillChar || " ";
70 while (str.length < minLength) { 70 while (str.length < minLength) {
71 str = fillChar + str; 71 str = fillChar + str;
72 } 72 }
73 return str; 73 return str;
74} 74};
75 75
76/** 76/**
77 * Adds a character to the right-hand side of a string until it 77 * Adds a character to the right-hand side of a string until it
78 * reaches the specified minimum length. 78 * reaches the specified minimum length.
79 * 79 *
80 * @param {String} str the string to process 80 * @param {String} str the string to process
81 * @param {Number} minLength the requested minimum length 81 * @param {Number} minLength the requested minimum length
82 * @param {String} fillChar the padding character to add, defaults 82 * @param {String} fillChar the padding character to add, defaults
83 * to a space 83 * to a space
84 * 84 *
85 * @return {String} the padded string 85 * @return {String} the padded string
86 */ 86 */
87MochiKit.Text.padRight = function (str, minLength, fillChar) { 87MochiKit.Text.padRight = function (str, minLength, fillChar) {
88 str = str || ""; 88 str = str || "";
89 fillChar = fillChar || " "; 89 fillChar = fillChar || " ";
90 while (str.length < minLength) { 90 while (str.length < minLength) {
91 str += fillChar; 91 str += fillChar;
92 } 92 }
93 return str; 93 return str;
94} 94};
95 95
96/** 96/**
97 * Returns a truncated copy of a string. If the string is shorter 97 * Returns a truncated copy of a string. If the string is shorter
98 * than the specified maximum length, the object will be returned 98 * than the specified maximum length, the object will be returned
99 * unmodified. If an optional tail string is specified, additional 99 * unmodified. If an optional tail string is specified, additional
100 * elements will be removed in order to accomodate the tail (that 100 * elements will be removed in order to accomodate the tail (that
101 * will be appended). This function also works on arrays. 101 * will be appended). This function also works on arrays.
102 * 102 *
103 * @param {String} str the string to truncate 103 * @param {String} str the string to truncate
104 * @param {Number} maxLength the maximum length 104 * @param {Number} maxLength the maximum length
105 * @param {String} [tail] the tail to append on truncation 105 * @param {String} [tail] the tail to append on truncation
106 * 106 *
107 * @return {String} the truncated string 107 * @return {String} the truncated string
108 */ 108 */
109MochiKit.Text.truncate = function (str, maxLength, tail) { 109MochiKit.Text.truncate = function (str, maxLength, tail) {
110 if (str == null || str.length <= maxLength || maxLength < 0) { 110 if (str == null || str.length <= maxLength || maxLength < 0) {
111 return str; 111 return str;
112 } else if (tail != null) { 112 } else if (tail != null) {
113 str = str.slice(0, Math.max(0, maxLength - tail.length)); 113 str = str.slice(0, Math.max(0, maxLength - tail.length));
114 if (typeof(str) == "string") { 114 if (typeof(str) == "string") {
115 return str + tail; 115 return str + tail;
116 } else { 116 } else {
117 return MochiKit.Base.extend(str, tail); 117 return MochiKit.Base.extend(str, tail);
118 } 118 }
119 } else { 119 } else {
120 return str.slice(0, maxLength); 120 return str.slice(0, maxLength);
121 } 121 }
122} 122};
123 123
124/** 124/**
125 * Splits a text string, applies a function and joins the results 125 * Splits a text string using separator as the split point
126 * back together again. This is a convenience function for calling 126 * If max is given, at most max splits are done, giving at most
127 * split(), map() and join() separately. It can be used to easily 127 * max + 1 elements in the returned list.
128 * trim each line in a text string (using the strip function), or to
129 * translate a text word-by-word.
130 * 128 *
131 * @param {Function} func the function to apply
132 * @param {String} str the string to split 129 * @param {String} str the string to split
133 * @param {String} [separator] the separator character to use, 130 * @param {String/RegExp} [separator] the separator char or regexp to use,
134 * defaults to newline 131 * defaults to newline
132 * @param {Number} [max] the maximum number of parts to return
133 * @return {Array} an array of parts of the string
134 */
135MochiKit.Text.split = function (str, separator, max) {
136 if (str == null) {
137 return str;
138 }
139 separator = separator || '\n';
140 var bits = str.split(separator);
141 if ((typeof(max) == "undefined") || max >= bits.length - 1) {
142 return bits;
143 }
144 bits.splice(max, bits.length, bits.slice(max, bits.length).join(separator));
145 return bits;
146};
147
148/**
149 * Splits a text string using separator as the split point
150 * If max is given, at most max splits are done,
151 * using splits from the right
135 * 152 *
136 * @return {String} a string with the joined up results 153 * @param {String} str the string to split
154 * @param {String/RegExp} [separator] the separator char or regexp to use,
155 * defaults to newline
156 * @param {Number} [max] the maximum number of parts to return
157 * @return {Array} an array of parts of the string
137 */ 158 */
138MochiKit.Text.splitJoin = function (func, str, separator) { 159MochiKit.Text.rsplit = function (str, separator, max) {
139 if (str == null || str.length == 0) { 160 if (str == null) {
140 return str; 161 return str;
141 } 162 }
142 separator = separator || '\n' 163 separator = separator || '\n';
143 return MochiKit.Base.map(func, str.split(separator)).join(separator); 164 var bits = str.split(separator);
144} 165 if ((typeof(max) == "undefined") || max >= bits.length - 1){
166 return bits;
167 }
168 bits.splice(0, bits.length-max, bits.slice(0, bits.length-max).join(separator));
169 return bits;
170};
145 171
146/** 172/**
147 * Creates a formatter function for the specified formatter pattern 173 * Creates a formatter function for the specified formatter pattern
148 * and locale. The returned function takes as many arguments as the 174 * and locale. The returned function takes as many arguments as the
149 * formatter pattern requires. See separate documentation for 175 * formatter pattern requires. See separate documentation for
150 * information about the formatter pattern syntax. 176 * information about the formatter pattern syntax.
151 * 177 *
152 * @param {String} pattern the formatter pattern string 178 * @param {String} pattern the formatter pattern string
153 * @param {Object} [locale] the locale to use, defaults to 179 * @param {Object} [locale] the locale to use, defaults to
154 * LOCALE.en_US 180 * LOCALE.en_US
155 * 181 *
156 * @return {Function} the formatter function created 182 * @return {Function} the formatter function created
157 * 183 *
158 * @throws FormatPatternError if the format pattern was invalid 184 * @throws FormatPatternError if the format pattern was invalid
159 */ 185 */
160MochiKit.Text.formatter = function (pattern, locale) { 186MochiKit.Text.formatter = function (pattern, locale) {
161 if (typeof(locale) == "undefined") { 187 if (locale == null) {
162 locale = MochiKit.Format.formatLocale(); 188 locale = MochiKit.Format.formatLocale();
163 } else if (typeof(locale) == "string") { 189 } else if (typeof(locale) == "string") {
164 locale = MochiKit.Format.formatLocale(locale); 190 locale = MochiKit.Format.formatLocale(locale);
165 } 191 }
166 var parts = MochiKit.Text._parsePattern(pattern); 192 var parts = MochiKit.Text._parsePattern(pattern);
167 return function() { 193 return function() {
168 var values = MochiKit.Base.extend([], arguments); 194 var values = MochiKit.Base.extend([], arguments);
169 var res = []; 195 var res = [];
170 for (var i = 0; i < parts.length; i++) { 196 for (var i = 0; i < parts.length; i++) {
171 if (typeof(parts[i]) == "string") { 197 if (typeof(parts[i]) == "string") {
172 res.push(parts[i]); 198 res.push(parts[i]);
173 } else { 199 } else {
174 res.push(MochiKit.Text.formatValue(parts[i], values, locale)); 200 res.push(MochiKit.Text.formatValue(parts[i], values, locale));
175 } 201 }
176 } 202 }
177 return res.join(""); 203 return res.join("");
178 } 204 };
179} 205};
180 206
181/** 207/**
182 * Formats the specified arguments according to a formatter pattern. 208 * Formats the specified arguments according to a formatter pattern.
183 * See separate documentation for information about the formatter 209 * See separate documentation for information about the formatter
184 * pattern syntax. 210 * pattern syntax.
185 * 211 *
186 * @param {String} pattern the formatter pattern string 212 * @param {String} pattern the formatter pattern string
187 * @param {Object} [...] the optional values to format 213 * @param {Object} [...] the optional values to format
188 * 214 *
189 * @return {String} the formatted output string 215 * @return {String} the formatted output string
190 * 216 *
191 * @throws FormatPatternError if the format pattern was invalid 217 * @throws FormatPatternError if the format pattern was invalid
192 */ 218 */
193MochiKit.Text.format = function (pattern/*, ...*/) { 219MochiKit.Text.format = function (pattern/*, ...*/) {
194 var func = MochiKit.Text.formatter(pattern); 220 var func = MochiKit.Text.formatter(pattern);
195 return func.apply(this, MochiKit.Base.extend([], arguments, 1)); 221 return func.apply(this, MochiKit.Base.extend([], arguments, 1));
196} 222};
197 223
198/** 224/**
199 * Format a value with the specified format specifier. 225 * Format a value with the specified format specifier.
200 * 226 *
201 * @param {String/Object} spec the format specifier string or parsed 227 * @param {String/Object} spec the format specifier string or parsed
202 * format specifier object 228 * format specifier object
203 * @param {Object} value the value to format 229 * @param {Object} value the value to format
204 * @param {Object} [locale] the locale to use, defaults to 230 * @param {Object} [locale] the locale to use, defaults to
205 * LOCALE.en_US 231 * LOCALE.en_US
206 * 232 *
207 * @return {String} the formatted output string 233 * @return {String} the formatted output string
234 *
235 * @throws FormatPatternError if the format specifier was invalid
208 */ 236 */
209MochiKit.Text.formatValue = function (spec, value, locale) { 237MochiKit.Text.formatValue = function (spec, value, locale) {
210 var self = MochiKit.Text; 238 var self = MochiKit.Text;
211 if (typeof(spec) === "string") { 239 if (typeof(spec) === "string") {
212 spec = self._parseFormatFlags(spec, 0, spec.length - 1); 240 spec = self._parseFormatFlags(spec, 0, spec.length);
213 } 241 }
214 for (var i = 0; spec.path != null && i < spec.path.length; i++) { 242 for (var i = 0; spec.path != null && i < spec.path.length; i++) {
215 if (value != null) { 243 if (value != null) {
216 value = value[spec.path[i]]; 244 value = value[spec.path[i]];
217 } 245 }
218 } 246 }
219 if (typeof(locale) == "undefined") { 247 if (locale == null) {
220 locale = MochiKit.Format.formatLocale(); 248 locale = MochiKit.Format.formatLocale();
221 } else if (typeof(locale) == "string") { 249 } else if (typeof(locale) == "string") {
222 locale = MochiKit.Format.formatLocale(locale); 250 locale = MochiKit.Format.formatLocale(locale);
223 } 251 }
224 var str = ""; 252 var str = "";
225 if (spec.numeric) { 253 if (spec.type == "number") {
254 if (value instanceof Number) {
255 value = value.valueOf();
256 }
226 if (typeof(value) != "number" || isNaN(value)) { 257 if (typeof(value) != "number" || isNaN(value)) {
227 str = ""; 258 str = "";
228 } else if (value === Number.POSITIVE_INFINITY) { 259 } else if (value === Number.POSITIVE_INFINITY) {
229 str = "\u221e"; 260 str = "\u221e";
230 } else if (value === Number.NEGATIVE_INFINITY) { 261 } else if (value === Number.NEGATIVE_INFINITY) {
231 str = "-\u221e"; 262 str = "-\u221e";
232 } else { 263 } else {
233 var sign = (spec.sign === "-") ? "" : spec.sign; 264 var sign = (value < 0) ? "-" : spec.sign;
234 sign = (value < 0) ? "-" : sign;
235 value = Math.abs(value); 265 value = Math.abs(value);
236 if (spec.format === "%") { 266 if (spec.format === "%") {
237 str = self._truncToPercent(value, spec.precision); 267 str = self._truncToPercent(value, spec.precision);
238 } else if (spec.format === "d") { 268 } else if (spec.format === "d") {
239 str = MochiKit.Format.roundToFixed(value, 0); 269 str = MochiKit.Format.roundToFixed(value, 0);
240 } else if (spec.radix != 10) { 270 } else if (spec.radix != 10) {
241 str = Math.floor(value).toString(spec.radix); 271 str = Math.floor(value).toString(spec.radix);
242 if (spec.format === "x") { 272 if (spec.format === "x") {
243 str = str.toLowerCase(); 273 str = str.toLowerCase();
244 } else if (spec.format === "X") { 274 } else if (spec.format === "X") {
245 str = str.toUpperCase(); 275 str = str.toUpperCase();
246 } 276 }
247 } else if (spec.precision >= 0) { 277 } else if (spec.precision >= 0) {
248 str = MochiKit.Format.roundToFixed(value, spec.precision); 278 str = MochiKit.Format.roundToFixed(value, spec.precision);
249 } else { 279 } else {
250 str = value.toString(); 280 str = value.toString();
251 } 281 }
252 if (spec.padding === "0" && spec.format === "%") { 282 if (spec.padding === "0" && spec.format === "%") {
253 str = self.padLeft(str, spec.width - sign.length - 1, "0"); 283 str = self.padLeft(str, spec.width - sign.length - 1, "0");
254 } else if (spec.padding == "0") { 284 } else if (spec.padding == "0") {
255 str = self.padLeft(str, spec.width - sign.length, "0"); 285 str = self.padLeft(str, spec.width - sign.length, "0");
256 } 286 }
257 str = self._localizeNumber(str, locale, spec.grouping); 287 str = self._localizeNumber(str, locale, spec.group);
258 str = sign + str; 288 str = sign + str;
259 } 289 }
260 if (str !== "" && spec.format === "%") { 290 if (str !== "" && spec.format === "%") {
261 str = str + locale.percent; 291 str = str + locale.percent;
262 } 292 }
263 } else { 293 } else {
264 if (spec.format == "r") { 294 if (spec.format == "r") {
265 str = MochiKit.Base.repr(value); 295 str = MochiKit.Base.repr(value);
266 } else { 296 } else {
267 str = (value == null) ? "null" : value.toString(); 297 str = (value == null) ? "" : value.toString();
268 } 298 }
269 str = self.truncate(str, spec.precision); 299 str = self.truncate(str, spec.precision);
270 } 300 }
271 if (spec.align == "<") { 301 if (spec.align == "<") {
272 str = self.padRight(str, spec.width); 302 str = self.padRight(str, spec.width);
273 } else { 303 } else {
274 str = self.padLeft(str, spec.width); 304 str = self.padLeft(str, spec.width);
275 } 305 }
276 return str; 306 return str;
277} 307};
278 308
279/** 309/**
280 * Adjust an already formatted numeric string for locale-specific 310 * Adjust an already formatted numeric string for locale-specific
281 * grouping and decimal separators. The grouping is optional and 311 * grouping and decimal separators. The grouping is optional and
282 * will attempt to keep the number string length intact by removing 312 * will attempt to keep the number string length intact by removing
283 * padded zeros (if possible). 313 * padded zeros (if possible).
284 * 314 *
285 * @param {String} num the formatted number string 315 * @param {String} num the formatted number string
286 * @param {Object} locale the formatting locale to use 316 * @param {Object} locale the formatting locale to use
287 * @param {Boolean} grouping the grouping flag 317 * @param {Boolean} group the grouping flag
288 * 318 *
289 * @return {String} the localized number string 319 * @return {String} the localized number string
290 */ 320 */
291MochiKit.Text._localizeNumber = function (num, locale, grouping) { 321MochiKit.Text._localizeNumber = function (num, locale, group) {
292 var parts = num.split(/\./); 322 var parts = num.split(/\./);
293 var whole = parts[0]; 323 var whole = parts[0];
294 var frac = (parts.length == 1) ? "" : parts[1]; 324 var frac = (parts.length == 1) ? "" : parts[1];
295 var res = (frac.length > 0) ? locale.decimal : ""; 325 var res = (frac.length > 0) ? locale.decimal : "";
296 while (grouping && frac.length > 3) { 326 while (group && frac.length > 3) {
297 res = res + frac.substring(0, 3) + locale.separator; 327 res = res + frac.substring(0, 3) + locale.separator;
298 frac = frac.substring(3); 328 frac = frac.substring(3);
299 if (whole.charAt(0) == "0") { 329 if (whole.charAt(0) == "0") {
300 whole = whole.substring(1); 330 whole = whole.substring(1);
301 } 331 }
302 } 332 }
303 if (frac.length > 0) { 333 if (frac.length > 0) {
304 res += frac; 334 res = res + frac;
305 } 335 }
306 while (grouping && whole.length > 3) { 336 while (group && whole.length > 3) {
307 var pos = whole.length - 3; 337 var pos = whole.length - 3;
308 res = locale.separator + whole.substring(pos) + res; 338 res = locale.separator + whole.substring(pos) + res;
309 whole = whole.substring((whole.charAt(0) == "0") ? 1 : 0, pos); 339 whole = whole.substring((whole.charAt(0) == "0") ? 1 : 0, pos);
310 } 340 }
311 return whole + res; 341 return whole + res;
312} 342};
313 343
314/** 344/**
315 * Parses a format pattern and returns an array of constant strings 345 * Parses a format pattern and returns an array of constant strings
316 * and format info objects. 346 * and format info objects.
317 * 347 *
318 * @param {String} pattern the format pattern to analyze 348 * @param {String} pattern the format pattern to analyze
319 * 349 *
320 * @return {Array} an array of strings and format info objects 350 * @return {Array} an array of strings and format info objects
321 * 351 *
322 * @throws FormatPatternError if the format pattern was invalid 352 * @throws FormatPatternError if the format pattern was invalid
323 */ 353 */
324MochiKit.Text._parsePattern = function (pattern) { 354MochiKit.Text._parsePattern = function (pattern) {
325 var self = MochiKit.Text; 355 var self = MochiKit.Text;
326 var parts = []; 356 var parts = [];
327 var start = 0; 357 var re = /{[^{}]*}|{{?|}}?/g;
328 var pos = 0; 358 var lastPos = re.lastIndex = 0;
329 for (pos = 0; pos < pattern.length; pos++) { 359 var m;
330 if (pattern.charAt(pos) == "{") { 360 while ((m = re.exec(pattern)) != null) {
331 if (pos + 1 >= pattern.length) { 361 if (lastPos < m.index) {
332 var msg = "unescaped { char, should be escaped as {{"; 362 parts.push(pattern.substring(lastPos, m.index))
333 throw new self.FormatPatternError(pattern, pos, msg); 363 }
334 } else if (pattern.charAt(pos + 1) == "{") { 364 var str = m[0];
335 parts.push(pattern.substring(start, pos + 1)); 365 lastPos = m.index + str.length;
336 start = pos + 2; 366 if (self.startsWith("{", str) && self.endsWith("}", str)) {
337 pos++; 367 parts.push(self._parseFormat(pattern, m.index + 1, lastPos - 1));
338 } else { 368 } else if (self.startsWith("{{", str) || self.startsWith("}}", str)) {
339 if (start < pos) { 369 parts.push(str.substring(1));
340 parts.push(pattern.substring(start, pos)); 370 } else if (self.startsWith("{", str)) {
341 } 371 var msg = "unescaped { char, should be escaped as {{";
342 start = pattern.indexOf("}", pos) + 1; 372 throw new self.FormatPatternError(pattern, m.index, msg);
343 if (start <= 0) { 373 } else if (self.startsWith("}", str)) {
344 var msg = "unmatched { char, not followed by a } char"; 374 var msg = "unescaped } char, should be escaped as }}";
345 throw new self.FormatPatternError(pattern, pos, msg); 375 throw new self.FormatPatternError(pattern, m.index, msg);
346 }
347 parts.push(self._parseFormat(pattern, pos + 1, start - 1));
348 pos = start - 1;
349 }
350 } else if (pattern.charAt(pos) == "}") {
351 if (pos + 1 >= pattern.length || pattern.charAt(pos + 1) != "}") {
352 var msg = "unescaped } char, should be escaped as }}";
353 throw new self.FormatPatternError(pattern, pos, msg);
354 }
355 parts.push(pattern.substring(start, pos + 1));
356 start = pos + 2;
357 pos++;
358 } 376 }
359 } 377 }
360 if (start < pos) { 378 if (lastPos < pattern.length) {
361 parts.push(pattern.substring(start, pos)); 379 parts.push(pattern.substring(lastPos));
362 } 380 }
363 return parts; 381 return parts;
364} 382};
365 383
366/** 384/**
367 * Parses a format instruction and returns a format info object. 385 * Parses a format instruction and returns a format info object.
368 * 386 *
369 * @param {String} pattern the format pattern string 387 * @param {String} pattern the format pattern string
370 * @param {Number} startPos the first index of the format instruction 388 * @param {Number} startPos the first index of the format instruction
371 * @param {Number} endPos the last index of the format instruction 389 * @param {Number} endPos the last index of the format instruction
372 * 390 *
373 * @return {Object} the format info object 391 * @return {Object} the format info object
374 * 392 *
375 * @throws FormatPatternError if the format pattern was invalid 393 * @throws FormatPatternError if the format pattern was invalid
376 */ 394 */
377MochiKit.Text._parseFormat = function (pattern, startPos, endPos) { 395MochiKit.Text._parseFormat = function (pattern, startPos, endPos) {
378 var self = MochiKit.Text; 396 var self = MochiKit.Text;
379 var text = pattern.substring(startPos, endPos); 397 var text = pattern.substring(startPos, endPos);
380 var info; 398 var parts = self.split(text, ":", 1);
381 var pos = text.indexOf(":"); 399 var path = parts[0];
382 if (pos == 0) { 400 var flagsPos = startPos + path.length + ((parts.length == 1) ? 0 : 1);
383 info = self._parseFormatFlags(pattern, startPos + 1, endPos); 401 var info = self._parseFormatFlags(pattern, flagsPos, endPos);
384 info.path = [0]; 402 info.path = (path == "") ? [] : path.split(".");
385 } else if (pos > 0) {
386 info = self._parseFormatFlags(pattern, startPos + pos + 1, endPos);
387 info.path = text.substring(0, pos).split(".");
388 } else {
389 info = self._parseFormatFlags(pattern, endPos, endPos);
390 info.path = text.split(".");
391 }
392 var DIGITS = /^\d+$/;
393 for (var i = 0; i < info.path.length; i++) { 403 for (var i = 0; i < info.path.length; i++) {
394 var e = info.path[i]; 404 var v = info.path[i];
395 if (typeof(e) == "string") { 405 // TODO: replace with MochiKit.Format.strip?
396 // TODO: replace with MochiKit.Format.strip? 406 v = v.replace(/^\s+/, "").replace(/\s+$/, "");
397 e = e.replace(/^\s+/, "").replace(/\s+$/, ""); 407 if (v == "" && info.path.length == 1) {
398 if (e == "" && info.path.length == 1) { 408 v = 0;
399 e = 0; 409 } else if (v == "") {
400 } else if (e == "") { 410 var msg = "format value path contains blanks";
401 var msg = "format value path contains blanks"; 411 throw new self.FormatPatternError(pattern, startPos, msg);
402 throw new self.FormatPatternError(pattern, startPos, msg); 412 } else if (/^\d+$/.test(v)) {
403 } else if (DIGITS.test(e)) { 413 v = parseInt(v, 10);
404 e = parseInt(e);
405 }
406 } 414 }
407 info.path[i] = e; 415 info.path[i] = v;
408 } 416 }
409 if (info.path.length < 0 || typeof(info.path[0]) != "number") { 417 if (info.path.length <= 0 || typeof(info.path[0]) != "number") {
410 info.path.unshift(0); 418 info.path.unshift(0);
411 } 419 }
412 return info; 420 return info;
413} 421};
414 422
415/** 423/**
416 * Parses a string with format flags and returns a format info object. 424 * Parses a string with format flags and returns a format info object.
417 * 425 *
418 * @param {String} pattern the format pattern string 426 * @param {String} pattern the format pattern string
419 * @param {Number} startPos the first index of the format instruction 427 * @param {Number} startPos the first index of the format instruction
420 * @param {Number} endPos the last index of the format instruction 428 * @param {Number} endPos the last index of the format instruction
421 * 429 *
422 * @return {Object} the format info object 430 * @return {Object} the format info object
423 * 431 *
424 * @throws FormatPatternError if the format pattern was invalid 432 * @throws FormatPatternError if the format pattern was invalid
425 */ 433 */
426MochiKit.Text._parseFormatFlags = function (pattern, startPos, endPos) { 434MochiKit.Text._parseFormatFlags = function (pattern, startPos, endPos) {
427 var self = MochiKit.Text; 435 var update = MochiKit.Base.update;
428 var info = { numeric: false, format: "s", width: 0, precision: -1, 436 var info = { type: "string", format: "s", width: 0, precision: -1,
429 align: ">", sign: "-", padding: " ", grouping: false }; 437 align: ">", sign: "", padding: " ", group: false };
430 // TODO: replace with MochiKit.Format.rstrip? 438 // TODO: replace with MochiKit.Format.rstrip?
431 var flags = pattern.substring(startPos, endPos).replace(/\s+$/, ""); 439 var text = pattern.substring(startPos, endPos).replace(/\s+$/, "");
432 while (flags.length > 0) { 440 var m = /^([<>+ 0,-]+)?(\d+)?(\.\d*)?([srbdoxXf%])?(.*)$/.exec(text);
433 switch (flags.charAt(0)) { 441 var flags = m[1];
434 case ">": 442 var width = m[2];
435 case "<": 443 var precision = m[3];
436 info.align = flags.charAt(0); 444 var type = m[4];
437 flags = flags.substring(1); 445 var unmatched = m[5];
438 break; 446 for (var i = 0; flags && i < flags.length; i++) {
439 case "+": 447 var chr = flags.charAt(i);
440 case "-": 448 if (chr == "<" || chr == ">") {
441 case " ": 449 info.align = chr;
442 info.sign = flags.charAt(0); 450 } else if (chr == "+" || chr == "-" || chr == " ") {
443 flags = flags.substring(1); 451 info.sign = (chr == "-") ? "" : chr;
444 break; 452 } else if (chr == "0") {
445 case ",": 453 info.padding = chr;
446 info.grouping = true; 454 } else if (chr == ",") {
447 flags = flags.substring(1); 455 info.group = true;
448 break;
449 case ".":
450 var chars = /^\d*/.exec(flags.substring(1))[0];
451 info.precision = parseInt(chars);
452 flags = flags.substring(1 + chars.length);
453 break;
454 case "0":
455 info.padding = flags.charAt(0);
456 flags = flags.substring(1);
457 break;
458 case "1":
459 case "2":
460 case "3":
461 case "4":
462 case "5":
463 case "6":
464 case "7":
465 case "8":
466 case "9":
467 var chars = /^\d*/.exec(flags)[0];
468 info.width = parseInt(chars);
469 flags = flags.substring(chars.length);
470 break;
471 case "s":
472 case "r":
473 info.format = flags.charAt(0);
474 flags = flags.substring(1);
475 break;
476 case "b":
477 case "d":
478 case "o":
479 case "x":
480 case "X":
481 case "f":
482 case "%":
483 info.numeric = true;
484 info.format = flags.charAt(0);
485 info.radix = 10;
486 if (info.format === "b") {
487 info.radix = 2;
488 } else if (info.format === "o") {
489 info.radix = 8;
490 } else if (info.format === "x" || info.format === "X") {
491 info.radix = 16;
492 }
493 flags = flags.substring(1);
494 break;
495 default:
496 var msg = "unsupported format flag: " + flags.charAt(0);
497 throw new self.FormatPatternError(pattern, startPos, msg);
498 } 456 }
499 } 457 }
458 if (width) {
459 info.width = parseInt(width, 10);
460 }
461 if (precision && precision.length > 1) {
462 info.precision = parseInt(precision.substring(1), 10);
463 }
464 if (type == "s" || type == "r") {
465 info.format = type;
466 } else if (type == "b") {
467 update(info, { type: "number", format: type, radix: 2 });
468 } else if (type == "o") {
469 update(info, { type: "number", format: type, radix: 8 });
470 } else if (type == "x" || type == "X") {
471 update(info, { type: "number", format: type, radix: 16 });
472 } else if (type == "d" || type == "f" || type == "%") {
473 update(info, { type: "number", format: type, radix: 10 });
474 }
475 if (unmatched) {
476 var msg = "unsupported format flag: " + unmatched.charAt(0);
477 throw new MochiKit.Text.FormatPatternError(pattern, startPos, msg);
478 }
500 return info; 479 return info;
501} 480};
502 481
503/** 482/**
504 * Formats a value as a percentage. This method avoids multiplication 483 * Formats a value as a percentage. This method avoids multiplication
505 * by 100 since it leads to weird numeric rounding errors. Instead it 484 * by 100 since it leads to weird numeric rounding errors. Instead it
506 * just move the decimal separator in the text string. It is ugly, 485 * just move the decimal separator in the text string. It is ugly,
507 * but works... 486 * but works...
508 * 487 *
509 * @param {Number} value the value to format 488 * @param {Number} value the value to format
510 * @param {Number} precision the number of precision digits 489 * @param {Number} precision the number of precision digits
511 */ 490 */
512MochiKit.Text._truncToPercent = function (value, precision) { 491MochiKit.Text._truncToPercent = function (value, precision) {
513 // TODO: This can be simplified by using the same helper function 492 // TODO: This can be simplified by using MochiKit.Format._shiftNumber
514 // as roundToFixed now does. 493 // as roundToFixed does.
515 var str; 494 var str;
516 if (precision >= 0) { 495 if (precision >= 0) {
517 str = MochiKit.Format.roundToFixed(value, precision + 2); 496 str = MochiKit.Format.roundToFixed(value, precision + 2);
518 } else { 497 } else {
519 str = (value == null) ? "0" : value.toString(); 498 str = (value == null) ? "0" : value.toString();
520 } 499 }
521 var fracPos = str.indexOf("."); 500 var arr = MochiKit.Text.split(str, ".", 2);
522 if (fracPos < 0) { 501 var frac = MochiKit.Text.padRight(arr[1], 2, "0");
523 str = str + "00"; 502 var whole = arr[0] + frac.substring(0, 2);
524 } else if (fracPos + 3 >= str.length) { 503 frac = frac.substring(2);
525 var fraction = str.substring(fracPos + 1); 504 while (/^0[0-9]/.test(whole)) {
526 while (fraction.length < 2) { 505 whole = whole.substring(1);
527 fraction = fraction + "0";
528 }
529 str = str.substring(0, fracPos) + fraction;
530 } else {
531 var fraction = str.substring(fracPos + 1);
532 str = str.substring(0, fracPos) + fraction.substring(0, 2) +
533 "." + fraction.substring(2);
534 }
535 while (str.length > 1 && str.charAt(0) == "0" && str.charAt(1) != ".") {
536 str = str.substring(1);
537 } 506 }
538 return str; 507 return (frac.length <= 0) ? whole : whole + "." + frac;
539} 508};
540 509
541/** 510/**
542 * Creates a new format pattern error. 511 * Creates a new format pattern error.
543 * 512 *
544 * @param {String} pattern the format pattern string 513 * @param {String} pattern the format pattern string
545 * @param {Number} pos the position of the error 514 * @param {Number} pos the position of the error
546 * @param {String} message the error message text 515 * @param {String} message the error message text
547 * 516 *
548 * @return {Error} the format pattern error 517 * @return {Error} the format pattern error
549 * 518 *
550 * @class The format pattern error class. This error is thrown when 519 * @class The format pattern error class. This error is thrown when
551 * a syntax error is encountered inside a format string. 520 * a syntax error is encountered inside a format string.
552 * @property {String} pattern The format pattern string. 521 * @property {String} pattern The format pattern string.
553 * @property {Number} pos The position of the error. 522 * @property {Number} pos The position of the error.
554 * @property {String} message The error message text. 523 * @property {String} message The error message text.
555 * @extends MochiKit.Base.NamedError 524 * @extends MochiKit.Base.NamedError
556 */ 525 */
557MochiKit.Text.FormatPatternError = function (pattern, pos, message) { 526MochiKit.Text.FormatPatternError = function (pattern, pos, message) {
558 this.pattern = pattern; 527 this.pattern = pattern;
559 this.pos = pos; 528 this.pos = pos;
560 this.message = message; 529 this.message = message;
561} 530};
562MochiKit.Text.FormatPatternError.prototype =
563 new MochiKit.Base.NamedError("MochiKit.Text.FormatPatternError");
564 531
532MochiKit.Text.FormatPatternError.prototype = new MochiKit.Base.NamedError("MochiKit.Text.FormatPatternError");
533MochiKit.Text.FormatPatternError.constructor = MochiKit.Text.FormatPatternError;
565 534
566// 535//
567//XXX: Internet Explorer exception handling blows 536//XXX: Internet Explorer export fix
568// 537//
569if (MochiKit.__export__) { 538if (MochiKit.__export__) {
570 formatter = MochiKit.Text.formatter; 539 formatter = MochiKit.Text.formatter;
571 format = MochiKit.Text.format; 540 format = MochiKit.Text.format;
572 formatValue = MochiKit.Text.formatValue; 541 formatValue = MochiKit.Text.formatValue;
573} 542}
574 543
575 544
576MochiKit.Base.nameFunctions(MochiKit.Text); 545MochiKit.Base.nameFunctions(MochiKit.Text);
577MochiKit.Base._exportSymbols(this, MochiKit.Text); 546MochiKit.Base._exportSymbols(this, MochiKit.Text);
diff --git a/frontend/gamma/js/MochiKit/Visual.js b/frontend/gamma/js/MochiKit/Visual.js
index 648d82a..372d99a 100644
--- a/frontend/gamma/js/MochiKit/Visual.js
+++ b/frontend/gamma/js/MochiKit/Visual.js
@@ -1,922 +1,936 @@
1/*** 1/***
2 2
3MochiKit.Visual 1.5 3MochiKit.Visual 1.5
4 4
5See <http://mochikit.com/> for documentation, downloads, license, etc. 5See <http://mochikit.com/> for documentation, downloads, license, etc.
6 6
7(c) 2005 Bob Ippolito and others. All rights Reserved. 7(c) 2005 Bob Ippolito and others. All rights Reserved.
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('Visual', '1.5', ['Base', 'DOM', 'Style', 'Color', 'Position']); 11MochiKit.Base.module(MochiKit, 'Visual', '1.5', ['Base', 'DOM', 'Style', 'Color', 'Position']);
12 12
13MochiKit.Visual._RoundCorners = function (e, options) { 13MochiKit.Visual._RoundCorners = function (e, options) {
14 e = MochiKit.DOM.getElement(e); 14 e = MochiKit.DOM.getElement(e);
15 this._setOptions(options); 15 this._setOptions(options);
16 if (this.options.__unstable__wrapElement) { 16 if (this.options.__unstable__wrapElement) {
17 e = this._doWrap(e); 17 e = this._doWrap(e);
18 } 18 }
19 19
20 var color = this.options.color; 20 var color = this.options.color;
21 var C = MochiKit.Color.Color; 21 var C = MochiKit.Color.Color;
22 if (this.options.color === "fromElement") { 22 if (this.options.color === "fromElement") {
23 color = C.fromBackground(e); 23 color = C.fromBackground(e);
24 } else if (!(color instanceof C)) { 24 } else if (!(color instanceof C)) {
25 color = C.fromString(color); 25 color = C.fromString(color);
26 } 26 }
27 this.isTransparent = (color.asRGB().a <= 0); 27 this.isTransparent = (color.asRGB().a <= 0);
28 28
29 var bgColor = this.options.bgColor; 29 var bgColor = this.options.bgColor;
30 if (this.options.bgColor === "fromParent") { 30 if (this.options.bgColor === "fromParent") {
31 bgColor = C.fromBackground(e.offsetParent); 31 bgColor = C.fromBackground(e.offsetParent);
32 } else if (!(bgColor instanceof C)) { 32 } else if (!(bgColor instanceof C)) {
33 bgColor = C.fromString(bgColor); 33 bgColor = C.fromString(bgColor);
34 } 34 }
35 35
36 this._roundCornersImpl(e, color, bgColor); 36 this._roundCornersImpl(e, color, bgColor);
37}; 37};
38 38
39MochiKit.Visual._RoundCorners.prototype = { 39MochiKit.Visual._RoundCorners.prototype = {
40 _doWrap: function (e) { 40 _doWrap: function (e) {
41 var parent = e.parentNode; 41 var parent = e.parentNode;
42 var doc = MochiKit.DOM.currentDocument(); 42 var doc = MochiKit.DOM.currentDocument();
43 if (typeof(doc.defaultView) === "undefined" 43 if (typeof(doc.defaultView) === "undefined"
44 || doc.defaultView === null) { 44 || doc.defaultView === null) {
45 return e; 45 return e;
46 } 46 }
47 var style = doc.defaultView.getComputedStyle(e, null); 47 var style = doc.defaultView.getComputedStyle(e, null);
48 if (typeof(style) === "undefined" || style === null) { 48 if (typeof(style) === "undefined" || style === null) {
49 return e; 49 return e;
50 } 50 }
51 var wrapper = MochiKit.DOM.DIV({"style": { 51 var wrapper = MochiKit.DOM.DIV({"style": {
52 display: "block", 52 display: "block",
53 // convert padding to margin 53 // convert padding to margin
54 marginTop: style.getPropertyValue("padding-top"), 54 marginTop: style.getPropertyValue("padding-top"),
55 marginRight: style.getPropertyValue("padding-right"), 55 marginRight: style.getPropertyValue("padding-right"),
56 marginBottom: style.getPropertyValue("padding-bottom"), 56 marginBottom: style.getPropertyValue("padding-bottom"),
57 marginLeft: style.getPropertyValue("padding-left"), 57 marginLeft: style.getPropertyValue("padding-left"),
58 // remove padding so the rounding looks right 58 // remove padding so the rounding looks right
59 padding: "0px" 59 padding: "0px"
60 /* 60 /*
61 paddingRight: "0px", 61 paddingRight: "0px",
62 paddingLeft: "0px" 62 paddingLeft: "0px"
63 */ 63 */
64 }}); 64 }});
65 wrapper.innerHTML = e.innerHTML; 65 wrapper.innerHTML = e.innerHTML;
66 e.innerHTML = ""; 66 e.innerHTML = "";
67 e.appendChild(wrapper); 67 e.appendChild(wrapper);
68 return e; 68 return e;
69 }, 69 },
70 70
71 _roundCornersImpl: function (e, color, bgColor) { 71 _roundCornersImpl: function (e, color, bgColor) {
72 if (this.options.border) { 72 if (this.options.border) {
73 this._renderBorder(e, bgColor); 73 this._renderBorder(e, bgColor);
74 } 74 }
75 if (this._isTopRounded()) { 75 if (this._isTopRounded()) {
76 this._roundTopCorners(e, color, bgColor); 76 this._roundTopCorners(e, color, bgColor);
77 } 77 }
78 if (this._isBottomRounded()) { 78 if (this._isBottomRounded()) {
79 this._roundBottomCorners(e, color, bgColor); 79 this._roundBottomCorners(e, color, bgColor);
80 } 80 }
81 }, 81 },
82 82
83 _renderBorder: function (el, bgColor) { 83 _renderBorder: function (el, bgColor) {
84 var borderValue = "1px solid " + this._borderColor(bgColor); 84 var borderValue = "1px solid " + this._borderColor(bgColor);
85 var borderL = "border-left: " + borderValue; 85 var borderL = "border-left: " + borderValue;
86 var borderR = "border-right: " + borderValue; 86 var borderR = "border-right: " + borderValue;
87 var style = "style='" + borderL + ";" + borderR + "'"; 87 var style = "style='" + borderL + ";" + borderR + "'";
88 el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>"; 88 el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>";
89 }, 89 },
90 90
91 _roundTopCorners: function (el, color, bgColor) { 91 _roundTopCorners: function (el, color, bgColor) {
92 var corner = this._createCorner(bgColor); 92 var corner = this._createCorner(bgColor);
93 for (var i = 0; i < this.options.numSlices; i++) { 93 for (var i = 0; i < this.options.numSlices; i++) {
94 corner.appendChild( 94 corner.appendChild(
95 this._createCornerSlice(color, bgColor, i, "top") 95 this._createCornerSlice(color, bgColor, i, "top")
96 ); 96 );
97 } 97 }
98 el.style.paddingTop = 0; 98 el.style.paddingTop = 0;
99 el.insertBefore(corner, el.firstChild); 99 el.insertBefore(corner, el.firstChild);
100 }, 100 },
101 101
102 _roundBottomCorners: function (el, color, bgColor) { 102 _roundBottomCorners: function (el, color, bgColor) {
103 var corner = this._createCorner(bgColor); 103 var corner = this._createCorner(bgColor);
104 for (var i = (this.options.numSlices - 1); i >= 0; i--) { 104 for (var i = (this.options.numSlices - 1); i >= 0; i--) {
105 corner.appendChild( 105 corner.appendChild(
106 this._createCornerSlice(color, bgColor, i, "bottom") 106 this._createCornerSlice(color, bgColor, i, "bottom")
107 ); 107 );
108 } 108 }
109 el.style.paddingBottom = 0; 109 el.style.paddingBottom = 0;
110 el.appendChild(corner); 110 el.appendChild(corner);
111 }, 111 },
112 112
113 _createCorner: function (bgColor) { 113 _createCorner: function (bgColor) {
114 var dom = MochiKit.DOM; 114 var dom = MochiKit.DOM;
115 return dom.DIV({style: {backgroundColor: bgColor.toString()}}); 115 return dom.DIV({style: {backgroundColor: bgColor.toString()}});
116 }, 116 },
117 117
118 _createCornerSlice: function (color, bgColor, n, position) { 118 _createCornerSlice: function (color, bgColor, n, position) {
119 var slice = MochiKit.DOM.SPAN(); 119 var slice = MochiKit.DOM.SPAN();
120 120
121 var inStyle = slice.style; 121 var inStyle = slice.style;
122 inStyle.backgroundColor = color.toString(); 122 inStyle.backgroundColor = color.toString();
123 inStyle.display = "block"; 123 inStyle.display = "block";
124 inStyle.height = "1px"; 124 inStyle.height = "1px";
125 inStyle.overflow = "hidden"; 125 inStyle.overflow = "hidden";
126 inStyle.fontSize = "1px"; 126 inStyle.fontSize = "1px";
127 127
128 var borderColor = this._borderColor(color, bgColor); 128 var borderColor = this._borderColor(color, bgColor);
129 if (this.options.border && n === 0) { 129 if (this.options.border && n === 0) {
130 inStyle.borderTopStyle = "solid"; 130 inStyle.borderTopStyle = "solid";
131 inStyle.borderTopWidth = "1px"; 131 inStyle.borderTopWidth = "1px";
132 inStyle.borderLeftWidth = "0px"; 132 inStyle.borderLeftWidth = "0px";
133 inStyle.borderRightWidth = "0px"; 133 inStyle.borderRightWidth = "0px";
134 inStyle.borderBottomWidth = "0px"; 134 inStyle.borderBottomWidth = "0px";
135 // assumes css compliant box model 135 // assumes css compliant box model
136 inStyle.height = "0px"; 136 inStyle.height = "0px";
137 inStyle.borderColor = borderColor.toString(); 137 inStyle.borderColor = borderColor.toString();
138 } else if (borderColor) { 138 } else if (borderColor) {
139 inStyle.borderColor = borderColor.toString(); 139 inStyle.borderColor = borderColor.toString();
140 inStyle.borderStyle = "solid"; 140 inStyle.borderStyle = "solid";
141 inStyle.borderWidth = "0px 1px"; 141 inStyle.borderWidth = "0px 1px";
142 } 142 }
143 143
144 if (!this.options.compact && (n == (this.options.numSlices - 1))) { 144 if (!this.options.compact && (n == (this.options.numSlices - 1))) {
145 inStyle.height = "2px"; 145 inStyle.height = "2px";
146 } 146 }
147 147
148 this._setMargin(slice, n, position); 148 this._setMargin(slice, n, position);
149 this._setBorder(slice, n, position); 149 this._setBorder(slice, n, position);
150 150
151 return slice; 151 return slice;
152 }, 152 },
153 153
154 _setOptions: function (options) { 154 _setOptions: function (options) {
155 this.options = { 155 this.options = {
156 corners: "all", 156 corners: "all",
157 color: "fromElement", 157 color: "fromElement",
158 bgColor: "fromParent", 158 bgColor: "fromParent",
159 blend: true, 159 blend: true,
160 border: false, 160 border: false,
161 compact: false, 161 compact: false,
162 __unstable__wrapElement: false 162 __unstable__wrapElement: false
163 }; 163 };
164 MochiKit.Base.update(this.options, options); 164 MochiKit.Base.update(this.options, options);
165 165
166 this.options.numSlices = (this.options.compact ? 2 : 4); 166 this.options.numSlices = (this.options.compact ? 2 : 4);
167 }, 167 },
168 168
169 _whichSideTop: function () { 169 _whichSideTop: function () {
170 var corners = this.options.corners; 170 var corners = this.options.corners;
171 if (this._hasString(corners, "all", "top")) { 171 if (this._hasString(corners, "all", "top")) {
172 return ""; 172 return "";
173 } 173 }
174 174
175 var has_tl = (corners.indexOf("tl") != -1); 175 var has_tl = (corners.indexOf("tl") != -1);
176 var has_tr = (corners.indexOf("tr") != -1); 176 var has_tr = (corners.indexOf("tr") != -1);
177 if (has_tl && has_tr) { 177 if (has_tl && has_tr) {
178 return ""; 178 return "";
179 } 179 }
180 if (has_tl) { 180 if (has_tl) {
181 return "left"; 181 return "left";
182 } 182 }
183 if (has_tr) { 183 if (has_tr) {
184 return "right"; 184 return "right";
185 } 185 }
186 return ""; 186 return "";
187 }, 187 },
188 188
189 _whichSideBottom: function () { 189 _whichSideBottom: function () {
190 var corners = this.options.corners; 190 var corners = this.options.corners;
191 if (this._hasString(corners, "all", "bottom")) { 191 if (this._hasString(corners, "all", "bottom")) {
192 return ""; 192 return "";
193 } 193 }
194 194
195 var has_bl = (corners.indexOf('bl') != -1); 195 var has_bl = (corners.indexOf('bl') != -1);
196 var has_br = (corners.indexOf('br') != -1); 196 var has_br = (corners.indexOf('br') != -1);
197 if (has_bl && has_br) { 197 if (has_bl && has_br) {
198 return ""; 198 return "";
199 } 199 }
200 if (has_bl) { 200 if (has_bl) {
201 return "left"; 201 return "left";
202 } 202 }
203 if (has_br) { 203 if (has_br) {
204 return "right"; 204 return "right";
205 } 205 }
206 return ""; 206 return "";
207 }, 207 },
208 208
209 _borderColor: function (color, bgColor) { 209 _borderColor: function (color, bgColor) {
210 if (color == "transparent") { 210 if (color == "transparent") {
211 return bgColor; 211 return bgColor;
212 } else if (this.options.border) { 212 } else if (this.options.border) {
213 return this.options.border; 213 return this.options.border;
214 } else if (this.options.blend) { 214 } else if (this.options.blend) {
215 return bgColor.blendedColor(color); 215 return bgColor.blendedColor(color);
216 } 216 }
217 return ""; 217 return "";
218 }, 218 },
219 219
220 220
221 _setMargin: function (el, n, corners) { 221 _setMargin: function (el, n, corners) {
222 var marginSize = this._marginSize(n) + "px"; 222 var marginSize = this._marginSize(n) + "px";
223 var whichSide = ( 223 var whichSide = (
224 corners == "top" ? this._whichSideTop() : this._whichSideBottom() 224 corners == "top" ? this._whichSideTop() : this._whichSideBottom()
225 ); 225 );
226 var style = el.style; 226 var style = el.style;
227 227
228 if (whichSide == "left") { 228 if (whichSide == "left") {
229 style.marginLeft = marginSize; 229 style.marginLeft = marginSize;
230 style.marginRight = "0px"; 230 style.marginRight = "0px";
231 } else if (whichSide == "right") { 231 } else if (whichSide == "right") {
232 style.marginRight = marginSize; 232 style.marginRight = marginSize;
233 style.marginLeft = "0px"; 233 style.marginLeft = "0px";
234 } else { 234 } else {
235 style.marginLeft = marginSize; 235 style.marginLeft = marginSize;
236 style.marginRight = marginSize; 236 style.marginRight = marginSize;
237 } 237 }
238 }, 238 },
239 239
240 _setBorder: function (el, n, corners) { 240 _setBorder: function (el, n, corners) {
241 var borderSize = this._borderSize(n) + "px"; 241 var borderSize = this._borderSize(n) + "px";
242 var whichSide = ( 242 var whichSide = (
243 corners == "top" ? this._whichSideTop() : this._whichSideBottom() 243 corners == "top" ? this._whichSideTop() : this._whichSideBottom()
244 ); 244 );
245 245
246 var style = el.style; 246 var style = el.style;
247 if (whichSide == "left") { 247 if (whichSide == "left") {
248 style.borderLeftWidth = borderSize; 248 style.borderLeftWidth = borderSize;
249 style.borderRightWidth = "0px"; 249 style.borderRightWidth = "0px";
250 } else if (whichSide == "right") { 250 } else if (whichSide == "right") {
251 style.borderRightWidth = borderSize; 251 style.borderRightWidth = borderSize;
252 style.borderLeftWidth = "0px"; 252 style.borderLeftWidth = "0px";
253 } else { 253 } else {
254 style.borderLeftWidth = borderSize; 254 style.borderLeftWidth = borderSize;
255 style.borderRightWidth = borderSize; 255 style.borderRightWidth = borderSize;
256 } 256 }
257 }, 257 },
258 258
259 _marginSize: function (n) { 259 _marginSize: function (n) {
260 if (this.isTransparent) { 260 if (this.isTransparent) {
261 return 0; 261 return 0;
262 } 262 }
263 263
264 var o = this.options; 264 var o = this.options;
265 if (o.compact && o.blend) { 265 if (o.compact && o.blend) {
266 var smBlendedMarginSizes = [1, 0]; 266 var smBlendedMarginSizes = [1, 0];
267 return smBlendedMarginSizes[n]; 267 return smBlendedMarginSizes[n];
268 } else if (o.compact) { 268 } else if (o.compact) {
269 var compactMarginSizes = [2, 1]; 269 var compactMarginSizes = [2, 1];
270 return compactMarginSizes[n]; 270 return compactMarginSizes[n];
271 } else if (o.blend) { 271 } else if (o.blend) {
272 var blendedMarginSizes = [3, 2, 1, 0]; 272 var blendedMarginSizes = [3, 2, 1, 0];
273 return blendedMarginSizes[n]; 273 return blendedMarginSizes[n];
274 } else { 274 } else {
275 var marginSizes = [5, 3, 2, 1]; 275 var marginSizes = [5, 3, 2, 1];
276 return marginSizes[n]; 276 return marginSizes[n];
277 } 277 }
278 }, 278 },
279 279
280 _borderSize: function (n) { 280 _borderSize: function (n) {
281 var o = this.options; 281 var o = this.options;
282 var borderSizes; 282 var borderSizes;
283 if (o.compact && (o.blend || this.isTransparent)) { 283 if (o.compact && (o.blend || this.isTransparent)) {
284 return 1; 284 return 1;
285 } else if (o.compact) { 285 } else if (o.compact) {
286 borderSizes = [1, 0]; 286 borderSizes = [1, 0];
287 } else if (o.blend) { 287 } else if (o.blend) {
288 borderSizes = [2, 1, 1, 1]; 288 borderSizes = [2, 1, 1, 1];
289 } else if (o.border) { 289 } else if (o.border) {
290 borderSizes = [0, 2, 0, 0]; 290 borderSizes = [0, 2, 0, 0];
291 } else if (this.isTransparent) { 291 } else if (this.isTransparent) {
292 borderSizes = [5, 3, 2, 1]; 292 borderSizes = [5, 3, 2, 1];
293 } else { 293 } else {
294 return 0; 294 return 0;
295 } 295 }
296 return borderSizes[n]; 296 return borderSizes[n];
297 }, 297 },
298 298
299 _hasString: function (str) { 299 _hasString: function (str) {
300 for (var i = 1; i< arguments.length; i++) { 300 for (var i = 1; i< arguments.length; i++) {
301 if (str.indexOf(arguments[i]) != -1) { 301 if (str.indexOf(arguments[i]) != -1) {
302 return true; 302 return true;
303 } 303 }
304 } 304 }
305 return false; 305 return false;
306 }, 306 },
307 307
308 _isTopRounded: function () { 308 _isTopRounded: function () {
309 return this._hasString(this.options.corners, 309 return this._hasString(this.options.corners,
310 "all", "top", "tl", "tr" 310 "all", "top", "tl", "tr"
311 ); 311 );
312 }, 312 },
313 313
314 _isBottomRounded: function () { 314 _isBottomRounded: function () {
315 return this._hasString(this.options.corners, 315 return this._hasString(this.options.corners,
316 "all", "bottom", "bl", "br" 316 "all", "bottom", "bl", "br"
317 ); 317 );
318 }, 318 },
319 319
320 _hasSingleTextChild: function (el) { 320 _hasSingleTextChild: function (el) {
321 return (el.childNodes.length == 1 && el.childNodes[0].nodeType == 3); 321 return (el.childNodes.length == 1 && el.childNodes[0].nodeType == 3);
322 } 322 }
323}; 323};
324 324
325/** @id MochiKit.Visual.roundElement */ 325/** @id MochiKit.Visual.roundElement */
326MochiKit.Visual.roundElement = function (e, options) { 326MochiKit.Visual.roundElement = function (e, options) {
327 new MochiKit.Visual._RoundCorners(e, options); 327 new MochiKit.Visual._RoundCorners(e, options);
328}; 328};
329 329
330/** @id MochiKit.Visual.roundClass */ 330/** @id MochiKit.Visual.roundClass */
331MochiKit.Visual.roundClass = function (tagName, className, options) { 331MochiKit.Visual.roundClass = function (tagName, className, options) {
332 var elements = MochiKit.DOM.getElementsByTagAndClassName( 332 var elements = MochiKit.DOM.getElementsByTagAndClassName(
333 tagName, className 333 tagName, className
334 ); 334 );
335 for (var i = 0; i < elements.length; i++) { 335 for (var i = 0; i < elements.length; i++) {
336 MochiKit.Visual.roundElement(elements[i], options); 336 MochiKit.Visual.roundElement(elements[i], options);
337 } 337 }
338}; 338};
339 339
340/** @id MochiKit.Visual.tagifyText */ 340/** @id MochiKit.Visual.tagifyText */
341MochiKit.Visual.tagifyText = function (element, /* optional */tagifyStyle) { 341MochiKit.Visual.tagifyText = function (element, /* optional */tagifyStyle) {
342 /*** 342 /***
343 343
344 Change a node text to character in tags. 344 Change a node text to character in tags.
345 345
346 @param tagifyStyle: the style to apply to character nodes, default to 346 @param tagifyStyle: the style to apply to character nodes, default to
347 'position: relative'. 347 'position: relative'.
348 348
349 ***/ 349 ***/
350 tagifyStyle = tagifyStyle || 'position:relative'; 350 tagifyStyle = tagifyStyle || 'position:relative';
351 if (/MSIE/.test(navigator.userAgent)) { 351 if (/MSIE/.test(navigator.userAgent)) {
352 tagifyStyle += ';zoom:1'; 352 tagifyStyle += ';zoom:1';
353 } 353 }
354 element = MochiKit.DOM.getElement(element); 354 element = MochiKit.DOM.getElement(element);
355 var ma = MochiKit.Base.map; 355 var ma = MochiKit.Base.map;
356 ma(function (child) { 356 ma(function (child) {
357 if (child.nodeType == 3) { 357 if (child.nodeType == 3) {
358 ma(function (character) { 358 ma(function (character) {
359 element.insertBefore( 359 element.insertBefore(
360 MochiKit.DOM.SPAN({style: tagifyStyle}, 360 MochiKit.DOM.SPAN({style: tagifyStyle},
361 character == ' ' ? String.fromCharCode(160) : character), child); 361 character == ' ' ? String.fromCharCode(160) : character), child);
362 }, child.nodeValue.split('')); 362 }, child.nodeValue.split(''));
363 MochiKit.DOM.removeElement(child); 363 MochiKit.DOM.removeElement(child);
364 } 364 }
365 }, element.childNodes); 365 }, element.childNodes);
366}; 366};
367 367
368MochiKit.Visual._forceRerendering = function (element) { 368MochiKit.Visual._forceRerendering = function (element) {
369 try { 369 try {
370 element = MochiKit.DOM.getElement(element); 370 element = MochiKit.DOM.getElement(element);
371 var n = document.createTextNode(' '); 371 var n = document.createTextNode(' ');
372 element.appendChild(n); 372 element.appendChild(n);
373 element.removeChild(n); 373 element.removeChild(n);
374 } catch(e) { 374 } catch(e) {
375 } 375 }
376}; 376};
377 377
378/** @id MochiKit.Visual.multiple */ 378/** @id MochiKit.Visual.multiple */
379MochiKit.Visual.multiple = function (elements, effect, /* optional */options) { 379MochiKit.Visual.multiple = function (elements, effect, /* optional */options) {
380 /*** 380 /***
381 381
382 Launch the same effect subsequently on given elements. 382 Launch the same effect subsequently on given elements.
383 383
384 ***/ 384 ***/
385 options = MochiKit.Base.update({ 385 options = MochiKit.Base.update({
386 speed: 0.1, delay: 0.0 386 speed: 0.1, delay: 0.0
387 }, options); 387 }, options);
388 var masterDelay = options.delay; 388 var masterDelay = options.delay;
389 var index = 0; 389 var index = 0;
390 MochiKit.Base.map(function (innerelement) { 390 MochiKit.Base.map(function (innerelement) {
391 options.delay = index * options.speed + masterDelay; 391 options.delay = index * options.speed + masterDelay;
392 new effect(innerelement, options); 392 new effect(innerelement, options);
393 index += 1; 393 index += 1;
394 }, elements); 394 }, elements);
395}; 395};
396 396
397MochiKit.Visual.PAIRS = { 397MochiKit.Visual.PAIRS = {
398 'slide': ['slideDown', 'slideUp'], 398 'slide': ['slideDown', 'slideUp'],
399 'blind': ['blindDown', 'blindUp'], 399 'blind': ['blindDown', 'blindUp'],
400 'appear': ['appear', 'fade'], 400 'appear': ['appear', 'fade'],
401 'size': ['grow', 'shrink'] 401 'size': ['grow', 'shrink']
402}; 402};
403 403
404/** @id MochiKit.Visual.toggle */ 404/** @id MochiKit.Visual.toggle */
405MochiKit.Visual.toggle = function (element, /* optional */effect, /* optional */options) { 405MochiKit.Visual.toggle = function (element, /* optional */effect, /* optional */options) {
406 /*** 406 /***
407 407
408 Toggle an item between two state depending of its visibility, making 408 Toggle an item between two state depending of its visibility, making
409 a effect between these states. Default effect is 'appear', can be 409 a effect between these states. Default effect is 'appear', can be
410 'slide' or 'blind'. 410 'slide' or 'blind'.
411 411
412 ***/ 412 ***/
413 element = MochiKit.DOM.getElement(element); 413 element = MochiKit.DOM.getElement(element);
414 effect = (effect || 'appear').toLowerCase(); 414 effect = (effect || 'appear').toLowerCase();
415 options = MochiKit.Base.update({ 415 options = MochiKit.Base.update({
416 queue: {position: 'end', scope: (element.id || 'global'), limit: 1} 416 queue: {position: 'end', scope: (element.id || 'global'), limit: 1}
417 }, options); 417 }, options);
418 var v = MochiKit.Visual; 418 var v = MochiKit.Visual;
419 v[MochiKit.Style.getStyle(element, 'display') != 'none' ? 419 v[MochiKit.Style.getStyle(element, 'display') != 'none' ?
420 v.PAIRS[effect][1] : v.PAIRS[effect][0]](element, options); 420 v.PAIRS[effect][1] : v.PAIRS[effect][0]](element, options);
421}; 421};
422 422
423/*** 423/***
424 424
425Transitions: define functions calculating variations depending of a position. 425Transitions: define functions calculating variations depending of a position.
426 426
427***/ 427***/
428 428
429MochiKit.Visual.Transitions = { __export__: false }; 429MochiKit.Visual.Transitions = { __export__: false };
430 430
431/** @id MochiKit.Visual.Transitions.linear */ 431/** @id MochiKit.Visual.Transitions.linear */
432MochiKit.Visual.Transitions.linear = function (pos) { 432MochiKit.Visual.Transitions.linear = function (pos) {
433 return pos; 433 return pos;
434}; 434};
435 435
436/** @id MochiKit.Visual.Transitions.sinoidal */ 436/** @id MochiKit.Visual.Transitions.sinoidal */
437MochiKit.Visual.Transitions.sinoidal = function (pos) { 437MochiKit.Visual.Transitions.sinoidal = function (pos) {
438 return 0.5 - Math.cos(pos*Math.PI)/2; 438 return 0.5 - Math.cos(pos*Math.PI)/2;
439}; 439};
440 440
441/** @id MochiKit.Visual.Transitions.reverse */ 441/** @id MochiKit.Visual.Transitions.reverse */
442MochiKit.Visual.Transitions.reverse = function (pos) { 442MochiKit.Visual.Transitions.reverse = function (pos) {
443 return 1 - pos; 443 return 1 - pos;
444}; 444};
445 445
446/** @id MochiKit.Visual.Transitions.flicker */ 446/** @id MochiKit.Visual.Transitions.flicker */
447MochiKit.Visual.Transitions.flicker = function (pos) { 447MochiKit.Visual.Transitions.flicker = function (pos) {
448 return 0.25 - Math.cos(pos*Math.PI)/4 + Math.random()/2; 448 return 0.25 - Math.cos(pos*Math.PI)/4 + Math.random()/2;
449}; 449};
450 450
451/** @id MochiKit.Visual.Transitions.wobble */ 451/** @id MochiKit.Visual.Transitions.wobble */
452MochiKit.Visual.Transitions.wobble = function (pos) { 452MochiKit.Visual.Transitions.wobble = function (pos) {
453 return 0.5 - Math.cos(9*pos*Math.PI)/2; 453 return 0.5 - Math.cos(9*pos*Math.PI)/2;
454}; 454};
455 455
456/** @id MochiKit.Visual.Transitions.pulse */ 456/** @id MochiKit.Visual.Transitions.pulse */
457MochiKit.Visual.Transitions.pulse = function (pos, pulses) { 457MochiKit.Visual.Transitions.pulse = function (pos, pulses) {
458 if (pulses) { 458 if (pulses) {
459 pos *= 2 * pulses; 459 pos *= 2 * pulses;
460 } else { 460 } else {
461 pos *= 10; 461 pos *= 10;
462 } 462 }
463 var decimals = pos - Math.floor(pos); 463 var decimals = pos - Math.floor(pos);
464 return (Math.floor(pos) % 2 == 0) ? decimals : 1 - decimals; 464 return (Math.floor(pos) % 2 == 0) ? decimals : 1 - decimals;
465}; 465};
466 466
467/** @id MochiKit.Visual.Transitions.parabolic */ 467/** @id MochiKit.Visual.Transitions.parabolic */
468MochiKit.Visual.Transitions.parabolic = function (pos) { 468MochiKit.Visual.Transitions.parabolic = function (pos) {
469 return pos * pos; 469 return pos * pos;
470}; 470};
471 471
472/** @id MochiKit.Visual.Transitions.spring */
473MochiKit.Visual.Transitions.spring = function (pos) {
474 return 1 - (Math.cos(pos * 2.5 * Math.PI) * Math.exp(-pos * 6));
475};
476
472/** @id MochiKit.Visual.Transitions.none */ 477/** @id MochiKit.Visual.Transitions.none */
473MochiKit.Visual.Transitions.none = function (pos) { 478MochiKit.Visual.Transitions.none = function (pos) {
474 return 0; 479 return 0;
475}; 480};
476 481
477/** @id MochiKit.Visual.Transitions.full */ 482/** @id MochiKit.Visual.Transitions.full */
478MochiKit.Visual.Transitions.full = function (pos) { 483MochiKit.Visual.Transitions.full = function (pos) {
479 return 1; 484 return 1;
480}; 485};
481 486
482/*** 487/***
483 488
484Core effects 489Core effects
485 490
486***/ 491***/
487 492
488MochiKit.Visual.ScopedQueue = function () { 493MochiKit.Visual.ScopedQueue = function () {
489 var cls = arguments.callee; 494 var cls = arguments.callee;
490 if (!(this instanceof cls)) { 495 if (!(this instanceof cls)) {
491 return new cls(); 496 return new cls();
492 } 497 }
493 this.__init__(); 498 this.__init__();
494}; 499};
495MochiKit.Visual.ScopedQueue.__export__ = false; 500MochiKit.Visual.ScopedQueue.__export__ = false;
496 501
497MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, { 502MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, {
498 __init__: function () { 503 __init__: function () {
499 this.effects = []; 504 this.effects = [];
500 this.interval = null; 505 this.interval = null;
501 }, 506 },
502 507
503 /** @id MochiKit.Visual.ScopedQueue.prototype.add */ 508 /** @id MochiKit.Visual.ScopedQueue.prototype.add */
504 add: function (effect) { 509 add: function (effect) {
505 var timestamp = new Date().getTime(); 510 var timestamp = new Date().getTime();
506 511
507 var position = (typeof(effect.options.queue) == 'string') ? 512 var position = (typeof(effect.options.queue) == 'string') ?
508 effect.options.queue : effect.options.queue.position; 513 effect.options.queue : effect.options.queue.position;
509 514
510 var ma = MochiKit.Base.map; 515 var ma = MochiKit.Base.map;
511 switch (position) { 516 switch (position) {
512 case 'front': 517 case 'front':
513 // move unstarted effects after this effect 518 // move unstarted effects after this effect
514 ma(function (e) { 519 ma(function (e) {
515 if (e.state == 'idle') { 520 if (e.state == 'idle') {
516 e.startOn += effect.finishOn; 521 e.startOn += effect.finishOn;
517 e.finishOn += effect.finishOn; 522 e.finishOn += effect.finishOn;
518 } 523 }
519 }, this.effects); 524 }, this.effects);
520 break; 525 break;
521 case 'end': 526 case 'end':
522 var finish; 527 var finish;
523 // start effect after last queued effect has finished 528 // start effect after last queued effect has finished
524 ma(function (e) { 529 ma(function (e) {
525 var i = e.finishOn; 530 var i = e.finishOn;
526 if (i >= (finish || i)) { 531 if (i >= (finish || i)) {
527 finish = i; 532 finish = i;
528 } 533 }
529 }, this.effects); 534 }, this.effects);
530 timestamp = finish || timestamp; 535 timestamp = finish || timestamp;
531 break; 536 break;
532 case 'break': 537 case 'break':
533 ma(function (e) { 538 ma(function (e) {
534 e.finalize(); 539 e.finalize();
535 }, this.effects); 540 }, this.effects);
536 break; 541 break;
542 case 'replace':
543 ma(function (e) {
544 e.cancel();
545 }, this.effects);
546 break;
537 } 547 }
538 548
539 effect.startOn += timestamp; 549 effect.startOn += timestamp;
540 effect.finishOn += timestamp; 550 effect.finishOn += timestamp;
541 if (!effect.options.queue.limit || 551 if (!effect.options.queue.limit ||
542 this.effects.length < effect.options.queue.limit) { 552 this.effects.length < effect.options.queue.limit) {
543 this.effects.push(effect); 553 this.effects.push(effect);
544 } 554 }
545 555
546 if (!this.interval) { 556 if (!this.interval) {
547 this.interval = this.startLoop(MochiKit.Base.bind(this.loop, this), 557 this.interval = this.startLoop(MochiKit.Base.bind(this.loop, this),
548 40); 558 40);
549 } 559 }
550 }, 560 },
551 561
552 /** @id MochiKit.Visual.ScopedQueue.prototype.startLoop */ 562 /** @id MochiKit.Visual.ScopedQueue.prototype.startLoop */
553 startLoop: function (func, interval) { 563 startLoop: function (func, interval) {
554 return setInterval(func, interval); 564 return setInterval(func, interval);
555 }, 565 },
556 566
557 /** @id MochiKit.Visual.ScopedQueue.prototype.remove */ 567 /** @id MochiKit.Visual.ScopedQueue.prototype.remove */
558 remove: function (effect) { 568 remove: function (effect) {
559 this.effects = MochiKit.Base.filter(function (e) { 569 this.effects = MochiKit.Base.filter(function (e) {
560 return e != effect; 570 return e != effect;
561 }, this.effects); 571 }, this.effects);
562 if (!this.effects.length) { 572 if (!this.effects.length) {
563 this.stopLoop(this.interval); 573 this.stopLoop(this.interval);
564 this.interval = null; 574 this.interval = null;
565 } 575 }
566 }, 576 },
567 577
568 /** @id MochiKit.Visual.ScopedQueue.prototype.stopLoop */ 578 /** @id MochiKit.Visual.ScopedQueue.prototype.stopLoop */
569 stopLoop: function (interval) { 579 stopLoop: function (interval) {
570 clearInterval(interval); 580 clearInterval(interval);
571 }, 581 },
572 582
573 /** @id MochiKit.Visual.ScopedQueue.prototype.loop */ 583 /** @id MochiKit.Visual.ScopedQueue.prototype.loop */
574 loop: function () { 584 loop: function () {
575 var timePos = new Date().getTime(); 585 var timePos = new Date().getTime();
576 MochiKit.Base.map(function (effect) { 586 MochiKit.Base.map(function (effect) {
577 effect.loop(timePos); 587 effect.loop(timePos);
578 }, this.effects); 588 }, this.effects);
579 } 589 }
580}); 590});
581 591
582MochiKit.Visual.Queues = { 592MochiKit.Visual.Queues = {
583 __export__: false, 593 __export__: false,
584 instances: {}, 594 instances: {},
585 get: function (queueName) { 595 get: function (queueName) {
586 if (typeof(queueName) != 'string') { 596 if (typeof(queueName) != 'string') {
587 return queueName; 597 return queueName;
588 } 598 }
589 599
590 if (!this.instances[queueName]) { 600 if (!this.instances[queueName]) {
591 this.instances[queueName] = new MochiKit.Visual.ScopedQueue(); 601 this.instances[queueName] = new MochiKit.Visual.ScopedQueue();
592 } 602 }
593 return this.instances[queueName]; 603 return this.instances[queueName];
594 } 604 }
595}; 605};
596 606
597MochiKit.Visual.Queue = MochiKit.Visual.Queues.get('global'); 607MochiKit.Visual.Queue = MochiKit.Visual.Queues.get('global');
598MochiKit.Visual.Queue.__export__ = false; 608MochiKit.Visual.Queue.__export__ = false;
599 609
600MochiKit.Visual.DefaultOptions = { 610MochiKit.Visual.DefaultOptions = {
601 __export__: false, 611 __export__: false,
602 transition: MochiKit.Visual.Transitions.sinoidal, 612 transition: MochiKit.Visual.Transitions.sinoidal,
603 duration: 1.0, // seconds 613 duration: 1.0, // seconds
604 fps: 25.0, // max. 25fps due to MochiKit.Visual.Queue implementation 614 fps: 25.0, // max. 25fps due to MochiKit.Visual.Queue implementation
605 sync: false, // true for combining 615 sync: false, // true for combining
606 from: 0.0, 616 from: 0.0,
607 to: 1.0, 617 to: 1.0,
608 delay: 0.0, 618 delay: 0.0,
609 queue: 'parallel' 619 queue: 'parallel'
610}; 620};
611 621
612MochiKit.Visual.Base = function () {}; 622MochiKit.Visual.Base = function () {};
613 623
614MochiKit.Visual.Base.prototype = { 624MochiKit.Visual.Base.prototype = {
615 /*** 625 /***
616 626
617 Basic class for all Effects. Define a looping mechanism called for each step 627 Basic class for all Effects. Define a looping mechanism called for each step
618 of an effect. Don't instantiate it, only subclass it. 628 of an effect. Don't instantiate it, only subclass it.
619 629
620 ***/ 630 ***/
621 631
622 __class__ : MochiKit.Visual.Base, 632 __class__ : MochiKit.Visual.Base,
623 633
624 /** @id MochiKit.Visual.Base.prototype.start */ 634 /** @id MochiKit.Visual.Base.prototype.start */
625 start: function (options) { 635 start: function (options) {
626 var v = MochiKit.Visual; 636 var v = MochiKit.Visual;
627 this.options = MochiKit.Base.setdefault(options, 637 this.options = MochiKit.Base.setdefault(options,
628 v.DefaultOptions); 638 v.DefaultOptions);
629 this.currentFrame = 0; 639 this.currentFrame = 0;
630 this.state = 'idle'; 640 this.state = 'idle';
631 this.startOn = this.options.delay*1000; 641 this.startOn = this.options.delay*1000;
632 this.finishOn = this.startOn + (this.options.duration*1000); 642 this.finishOn = this.startOn + (this.options.duration*1000);
633 this.event('beforeStart'); 643 this.event('beforeStart');
634 if (!this.options.sync) { 644 if (!this.options.sync) {
635 v.Queues.get(typeof(this.options.queue) == 'string' ? 645 v.Queues.get(typeof(this.options.queue) == 'string' ?
636 'global' : this.options.queue.scope).add(this); 646 'global' : this.options.queue.scope).add(this);
637 } 647 }
638 }, 648 },
639 649
640 /** @id MochiKit.Visual.Base.prototype.loop */ 650 /** @id MochiKit.Visual.Base.prototype.loop */
641 loop: function (timePos) { 651 loop: function (timePos) {
642 if (timePos >= this.startOn) { 652 if (timePos >= this.startOn) {
643 if (timePos >= this.finishOn) { 653 if (timePos >= this.finishOn) {
644 return this.finalize(); 654 return this.finalize();
645 } 655 }
646 var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); 656 var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
647 var frame = 657 var frame =
648 Math.round(pos * this.options.fps * this.options.duration); 658 Math.round(pos * this.options.fps * this.options.duration);
649 if (frame > this.currentFrame) { 659 if (frame > this.currentFrame) {
650 this.render(pos); 660 this.render(pos);
651 this.currentFrame = frame; 661 this.currentFrame = frame;
652 } 662 }
653 } 663 }
654 }, 664 },
655 665
656 /** @id MochiKit.Visual.Base.prototype.render */ 666 /** @id MochiKit.Visual.Base.prototype.render */
657 render: function (pos) { 667 render: function (pos) {
658 if (this.state == 'idle') { 668 if (this.state == 'idle') {
659 this.state = 'running'; 669 this.state = 'running';
660 this.event('beforeSetup'); 670 this.event('beforeSetup');
661 this.setup(); 671 this.setup();
662 this.event('afterSetup'); 672 this.event('afterSetup');
663 } 673 }
664 if (this.state == 'running') { 674 if (this.state == 'running') {
665 if (this.options.transition) { 675 var trans = this.options.transition;
666 pos = this.options.transition(pos); 676 if (typeof(trans) == "string") {
677 trans = MochiKit.Visual.Transitions[trans];
678 }
679 if (typeof(trans) == "function") {
680 pos = trans(pos);
667 } 681 }
668 pos *= (this.options.to - this.options.from); 682 pos *= (this.options.to - this.options.from);
669 pos += this.options.from; 683 pos += this.options.from;
670 this.event('beforeUpdate'); 684 this.event('beforeUpdate');
671 this.update(pos); 685 this.update(pos);
672 this.event('afterUpdate'); 686 this.event('afterUpdate');
673 } 687 }
674 }, 688 },
675 689
676 /** @id MochiKit.Visual.Base.prototype.cancel */ 690 /** @id MochiKit.Visual.Base.prototype.cancel */
677 cancel: function () { 691 cancel: function () {
678 if (!this.options.sync) { 692 if (!this.options.sync) {
679 MochiKit.Visual.Queues.get(typeof(this.options.queue) == 'string' ? 693 MochiKit.Visual.Queues.get(typeof(this.options.queue) == 'string' ?
680 'global' : this.options.queue.scope).remove(this); 694 'global' : this.options.queue.scope).remove(this);
681 } 695 }
682 this.state = 'finished'; 696 this.state = 'finished';
683 }, 697 },
684 698
685 /** @id MochiKit.Visual.Base.prototype.finalize */ 699 /** @id MochiKit.Visual.Base.prototype.finalize */
686 finalize: function () { 700 finalize: function () {
687 this.render(1.0); 701 this.render(1.0);
688 this.cancel(); 702 this.cancel();
689 this.event('beforeFinish'); 703 this.event('beforeFinish');
690 this.finish(); 704 this.finish();
691 this.event('afterFinish'); 705 this.event('afterFinish');
692 }, 706 },
693 707
694 setup: function () { 708 setup: function () {
695 }, 709 },
696 710
697 finish: function () { 711 finish: function () {
698 }, 712 },
699 713
700 update: function (position) { 714 update: function (position) {
701 }, 715 },
702 716
703 /** @id MochiKit.Visual.Base.prototype.event */ 717 /** @id MochiKit.Visual.Base.prototype.event */
704 event: function (eventName) { 718 event: function (eventName) {
705 if (this.options[eventName + 'Internal']) { 719 if (this.options[eventName + 'Internal']) {
706 this.options[eventName + 'Internal'](this); 720 this.options[eventName + 'Internal'](this);
707 } 721 }
708 if (this.options[eventName]) { 722 if (this.options[eventName]) {
709 this.options[eventName](this); 723 this.options[eventName](this);
710 } 724 }
711 }, 725 },
712 726
713 /** @id MochiKit.Visual.Base.prototype.repr */ 727 /** @id MochiKit.Visual.Base.prototype.repr */
714 repr: function () { 728 repr: function () {
715 return '[' + this.__class__.NAME + ', options:' + 729 return '[' + this.__class__.NAME + ', options:' +
716 MochiKit.Base.repr(this.options) + ']'; 730 MochiKit.Base.repr(this.options) + ']';
717 } 731 }
718}; 732};
719 733
720/** @id MochiKit.Visual.Parallel */ 734/** @id MochiKit.Visual.Parallel */
721MochiKit.Visual.Parallel = function (effects, options) { 735MochiKit.Visual.Parallel = function (effects, options) {
722 var cls = arguments.callee; 736 var cls = arguments.callee;
723 if (!(this instanceof cls)) { 737 if (!(this instanceof cls)) {
724 return new cls(effects, options); 738 return new cls(effects, options);
725 } 739 }
726 740
727 this.__init__(effects, options); 741 this.__init__(effects, options);
728}; 742};
729 743
730MochiKit.Visual.Parallel.prototype = new MochiKit.Visual.Base(); 744MochiKit.Visual.Parallel.prototype = new MochiKit.Visual.Base();
731 745
732MochiKit.Base.update(MochiKit.Visual.Parallel.prototype, { 746MochiKit.Base.update(MochiKit.Visual.Parallel.prototype, {
733 /*** 747 /***
734 748
735 Run multiple effects at the same time. 749 Run multiple effects at the same time.
736 750
737 ***/ 751 ***/
738 752
739 __class__ : MochiKit.Visual.Parallel, 753 __class__ : MochiKit.Visual.Parallel,
740 754
741 __init__: function (effects, options) { 755 __init__: function (effects, options) {
742 this.effects = effects || []; 756 this.effects = effects || [];
743 this.start(options); 757 this.start(options);
744 }, 758 },
745 759
746 /** @id MochiKit.Visual.Parallel.prototype.update */ 760 /** @id MochiKit.Visual.Parallel.prototype.update */
747 update: function (position) { 761 update: function (position) {
748 MochiKit.Base.map(function (effect) { 762 MochiKit.Base.map(function (effect) {
749 effect.render(position); 763 effect.render(position);
750 }, this.effects); 764 }, this.effects);
751 }, 765 },
752 766
753 /** @id MochiKit.Visual.Parallel.prototype.finish */ 767 /** @id MochiKit.Visual.Parallel.prototype.finish */
754 finish: function () { 768 finish: function () {
755 MochiKit.Base.map(function (effect) { 769 MochiKit.Base.map(function (effect) {
756 effect.finalize(); 770 effect.finalize();
757 }, this.effects); 771 }, this.effects);
758 } 772 }
759}); 773});
760 774
761/** @id MochiKit.Visual.Sequence */ 775/** @id MochiKit.Visual.Sequence */
762MochiKit.Visual.Sequence = function (effects, options) { 776MochiKit.Visual.Sequence = function (effects, options) {
763 var cls = arguments.callee; 777 var cls = arguments.callee;
764 if (!(this instanceof cls)) { 778 if (!(this instanceof cls)) {
765 return new cls(effects, options); 779 return new cls(effects, options);
766 } 780 }
767 this.__init__(effects, options); 781 this.__init__(effects, options);
768}; 782};
769 783
770MochiKit.Visual.Sequence.prototype = new MochiKit.Visual.Base(); 784MochiKit.Visual.Sequence.prototype = new MochiKit.Visual.Base();
771 785
772MochiKit.Base.update(MochiKit.Visual.Sequence.prototype, { 786MochiKit.Base.update(MochiKit.Visual.Sequence.prototype, {
773 787
774 __class__ : MochiKit.Visual.Sequence, 788 __class__ : MochiKit.Visual.Sequence,
775 789
776 __init__: function (effects, options) { 790 __init__: function (effects, options) {
777 var defs = { transition: MochiKit.Visual.Transitions.linear, 791 var defs = { transition: MochiKit.Visual.Transitions.linear,
778 duration: 0 }; 792 duration: 0 };
779 this.effects = effects || []; 793 this.effects = effects || [];
780 MochiKit.Base.map(function (effect) { 794 MochiKit.Base.map(function (effect) {
781 defs.duration += effect.options.duration; 795 defs.duration += effect.options.duration;
782 }, this.effects); 796 }, this.effects);
783 MochiKit.Base.setdefault(options, defs); 797 MochiKit.Base.setdefault(options, defs);
784 this.start(options); 798 this.start(options);
785 }, 799 },
786 800
787 /** @id MochiKit.Visual.Sequence.prototype.update */ 801 /** @id MochiKit.Visual.Sequence.prototype.update */
788 update: function (position) { 802 update: function (position) {
789 var time = position * this.options.duration; 803 var time = position * this.options.duration;
790 for (var i = 0; i < this.effects.length; i++) { 804 for (var i = 0; i < this.effects.length; i++) {
791 var effect = this.effects[i]; 805 var effect = this.effects[i];
792 if (time <= effect.options.duration) { 806 if (time <= effect.options.duration) {
793 effect.render(time / effect.options.duration); 807 effect.render(time / effect.options.duration);
794 break; 808 break;
795 } else { 809 } else {
796 time -= effect.options.duration; 810 time -= effect.options.duration;
797 } 811 }
798 } 812 }
799 }, 813 },
800 814
801 /** @id MochiKit.Visual.Sequence.prototype.finish */ 815 /** @id MochiKit.Visual.Sequence.prototype.finish */
802 finish: function () { 816 finish: function () {
803 MochiKit.Base.map(function (effect) { 817 MochiKit.Base.map(function (effect) {
804 effect.finalize(); 818 effect.finalize();
805 }, this.effects); 819 }, this.effects);
806 } 820 }
807}); 821});
808 822
809/** @id MochiKit.Visual.Opacity */ 823/** @id MochiKit.Visual.Opacity */
810MochiKit.Visual.Opacity = function (element, options) { 824MochiKit.Visual.Opacity = function (element, options) {
811 var cls = arguments.callee; 825 var cls = arguments.callee;
812 if (!(this instanceof cls)) { 826 if (!(this instanceof cls)) {
813 return new cls(element, options); 827 return new cls(element, options);
814 } 828 }
815 this.__init__(element, options); 829 this.__init__(element, options);
816}; 830};
817 831
818MochiKit.Visual.Opacity.prototype = new MochiKit.Visual.Base(); 832MochiKit.Visual.Opacity.prototype = new MochiKit.Visual.Base();
819 833
820MochiKit.Base.update(MochiKit.Visual.Opacity.prototype, { 834MochiKit.Base.update(MochiKit.Visual.Opacity.prototype, {
821 /*** 835 /***
822 836
823 Change the opacity of an element. 837 Change the opacity of an element.
824 838
825 @param options: 'from' and 'to' change the starting and ending opacities. 839 @param options: 'from' and 'to' change the starting and ending opacities.
826 Must be between 0.0 and 1.0. Default to current opacity and 1.0. 840 Must be between 0.0 and 1.0. Default to current opacity and 1.0.
827 841
828 ***/ 842 ***/
829 843
830 __class__ : MochiKit.Visual.Opacity, 844 __class__ : MochiKit.Visual.Opacity,
831 845
832 __init__: function (element, /* optional */options) { 846 __init__: function (element, /* optional */options) {
833 var b = MochiKit.Base; 847 var b = MochiKit.Base;
834 var s = MochiKit.Style; 848 var s = MochiKit.Style;
835 this.element = MochiKit.DOM.getElement(element); 849 this.element = MochiKit.DOM.getElement(element);
836 // make this work on IE on elements without 'layout' 850 // make this work on IE on elements without 'layout'
837 if (this.element.currentStyle && 851 if (this.element.currentStyle &&
838 (!this.element.currentStyle.hasLayout)) { 852 (!this.element.currentStyle.hasLayout)) {
839 s.setStyle(this.element, {zoom: 1}); 853 s.setStyle(this.element, {zoom: 1});
840 } 854 }
841 options = b.update({ 855 options = b.update({
842 from: s.getStyle(this.element, 'opacity') || 0.0, 856 from: s.getStyle(this.element, 'opacity') || 0.0,
843 to: 1.0 857 to: 1.0
844 }, options); 858 }, options);
845 this.start(options); 859 this.start(options);
846 }, 860 },
847 861
848 /** @id MochiKit.Visual.Opacity.prototype.update */ 862 /** @id MochiKit.Visual.Opacity.prototype.update */
849 update: function (position) { 863 update: function (position) {
850 MochiKit.Style.setStyle(this.element, {'opacity': position}); 864 MochiKit.Style.setStyle(this.element, {'opacity': position});
851 } 865 }
852}); 866});
853 867
854/** @id MochiKit.Visual.Move.prototype */ 868/** @id MochiKit.Visual.Move.prototype */
855MochiKit.Visual.Move = function (element, options) { 869MochiKit.Visual.Move = function (element, options) {
856 var cls = arguments.callee; 870 var cls = arguments.callee;
857 if (!(this instanceof cls)) { 871 if (!(this instanceof cls)) {
858 return new cls(element, options); 872 return new cls(element, options);
859 } 873 }
860 this.__init__(element, options); 874 this.__init__(element, options);
861}; 875};
862 876
863MochiKit.Visual.Move.prototype = new MochiKit.Visual.Base(); 877MochiKit.Visual.Move.prototype = new MochiKit.Visual.Base();
864 878
865MochiKit.Base.update(MochiKit.Visual.Move.prototype, { 879MochiKit.Base.update(MochiKit.Visual.Move.prototype, {
866 /*** 880 /***
867 881
868 Move an element between its current position to a defined position 882 Move an element between its current position to a defined position
869 883
870 @param options: 'x' and 'y' for final positions, default to 0, 0. 884 @param options: 'x' and 'y' for final positions, default to 0, 0.
871 885
872 ***/ 886 ***/
873 887
874 __class__ : MochiKit.Visual.Move, 888 __class__ : MochiKit.Visual.Move,
875 889
876 __init__: function (element, /* optional */options) { 890 __init__: function (element, /* optional */options) {
877 this.element = MochiKit.DOM.getElement(element); 891 this.element = MochiKit.DOM.getElement(element);
878 options = MochiKit.Base.update({ 892 options = MochiKit.Base.update({
879 x: 0, 893 x: 0,
880 y: 0, 894 y: 0,
881 mode: 'relative' 895 mode: 'relative'
882 }, options); 896 }, options);
883 this.start(options); 897 this.start(options);
884 }, 898 },
885 899
886 /** @id MochiKit.Visual.Move.prototype.setup */ 900 /** @id MochiKit.Visual.Move.prototype.setup */
887 setup: function () { 901 setup: function () {
888 // Bug in Opera: Opera returns the 'real' position of a static element 902 // Bug in Opera: Opera returns the 'real' position of a static element
889 // or relative element that does not have top/left explicitly set. 903 // or relative element that does not have top/left explicitly set.
890 // ==> Always set top and left for position relative elements in your 904 // ==> Always set top and left for position relative elements in your
891 // stylesheets (to 0 if you do not need them) 905 // stylesheets (to 0 if you do not need them)
892 MochiKit.Style.makePositioned(this.element); 906 MochiKit.Style.makePositioned(this.element);
893 907
894 var s = this.element.style; 908 var s = this.element.style;
895 var originalVisibility = s.visibility; 909 var originalVisibility = s.visibility;
896 var originalDisplay = s.display; 910 var originalDisplay = s.display;
897 if (originalDisplay == 'none') { 911 if (originalDisplay == 'none') {
898 s.visibility = 'hidden'; 912 s.visibility = 'hidden';
899 s.display = ''; 913 s.display = '';
900 } 914 }
901 915
902 this.originalLeft = parseFloat(MochiKit.Style.getStyle(this.element, 'left') || '0'); 916 this.originalLeft = parseFloat(MochiKit.Style.getStyle(this.element, 'left') || '0');
903 this.originalTop = parseFloat(MochiKit.Style.getStyle(this.element, 'top') || '0'); 917 this.originalTop = parseFloat(MochiKit.Style.getStyle(this.element, 'top') || '0');
904 918
905 if (this.options.mode == 'absolute') { 919 if (this.options.mode == 'absolute') {
906 // absolute movement, so we need to calc deltaX and deltaY 920 // absolute movement, so we need to calc deltaX and deltaY
907 this.options.x -= this.originalLeft; 921 this.options.x -= this.originalLeft;
908 this.options.y -= this.originalTop; 922 this.options.y -= this.originalTop;
909 } 923 }
910 if (originalDisplay == 'none') { 924 if (originalDisplay == 'none') {
911 s.visibility = originalVisibility; 925 s.visibility = originalVisibility;
912 s.display = originalDisplay; 926 s.display = originalDisplay;
913 } 927 }
914 }, 928 },
915 929
916 /** @id MochiKit.Visual.Move.prototype.update */ 930 /** @id MochiKit.Visual.Move.prototype.update */
917 update: function (position) { 931 update: function (position) {
918 MochiKit.Style.setStyle(this.element, { 932 MochiKit.Style.setStyle(this.element, {
919 left: Math.round(this.options.x * position + this.originalLeft) + 'px', 933 left: Math.round(this.options.x * position + this.originalLeft) + 'px',
920 top: Math.round(this.options.y * position + this.originalTop) + 'px' 934 top: Math.round(this.options.y * position + this.originalTop) + 'px'
921 }); 935 });
922 } 936 }
@@ -1433,543 +1447,530 @@ MochiKit.Visual.blindDown = function (element, /* optional */ options) {
1433 scaleMode: {originalHeight: elementDimensions.h, 1447 scaleMode: {originalHeight: elementDimensions.h,
1434 originalWidth: elementDimensions.w}, 1448 originalWidth: elementDimensions.w},
1435 restoreAfterFinish: true, 1449 restoreAfterFinish: true,
1436 afterSetupInternal: function (effect) { 1450 afterSetupInternal: function (effect) {
1437 elemClip = s.makeClipping(effect.element); 1451 elemClip = s.makeClipping(effect.element);
1438 s.setStyle(effect.element, {height: '0px'}); 1452 s.setStyle(effect.element, {height: '0px'});
1439 s.showElement(effect.element); 1453 s.showElement(effect.element);
1440 }, 1454 },
1441 afterFinishInternal: function (effect) { 1455 afterFinishInternal: function (effect) {
1442 s.undoClipping(effect.element, elemClip); 1456 s.undoClipping(effect.element, elemClip);
1443 } 1457 }
1444 }, options); 1458 }, options);
1445 return new MochiKit.Visual.Scale(element, 100, options); 1459 return new MochiKit.Visual.Scale(element, 100, options);
1446}; 1460};
1447 1461
1448/** @id MochiKit.Visual.switchOff */ 1462/** @id MochiKit.Visual.switchOff */
1449MochiKit.Visual.switchOff = function (element, /* optional */ options) { 1463MochiKit.Visual.switchOff = function (element, /* optional */ options) {
1450 /*** 1464 /***
1451 1465
1452 Apply a switch-off-like effect. 1466 Apply a switch-off-like effect.
1453 1467
1454 ***/ 1468 ***/
1455 var d = MochiKit.DOM; 1469 var d = MochiKit.DOM;
1456 var s = MochiKit.Style; 1470 var s = MochiKit.Style;
1457 element = d.getElement(element); 1471 element = d.getElement(element);
1458 var elementDimensions = s.getElementDimensions(element, true); 1472 var elementDimensions = s.getElementDimensions(element, true);
1459 var oldOpacity = s.getStyle(element, 'opacity'); 1473 var oldOpacity = s.getStyle(element, 'opacity');
1460 var elemClip; 1474 var elemClip;
1461 options = MochiKit.Base.update({ 1475 options = MochiKit.Base.update({
1462 duration: 0.7, 1476 duration: 0.7,
1463 restoreAfterFinish: true, 1477 restoreAfterFinish: true,
1464 beforeSetupInternal: function (effect) { 1478 beforeSetupInternal: function (effect) {
1465 s.makePositioned(element); 1479 s.makePositioned(element);
1466 elemClip = s.makeClipping(element); 1480 elemClip = s.makeClipping(element);
1467 }, 1481 },
1468 afterFinishInternal: function (effect) { 1482 afterFinishInternal: function (effect) {
1469 s.hideElement(element); 1483 s.hideElement(element);
1470 s.undoClipping(element, elemClip); 1484 s.undoClipping(element, elemClip);
1471 s.undoPositioned(element); 1485 s.undoPositioned(element);
1472 s.setStyle(element, {'opacity': oldOpacity}); 1486 s.setStyle(element, {'opacity': oldOpacity});
1473 } 1487 }
1474 }, options); 1488 }, options);
1475 var v = MochiKit.Visual; 1489 var v = MochiKit.Visual;
1476 return new v.Sequence( 1490 return new v.Sequence(
1477 [new v.appear(element, 1491 [new v.appear(element,
1478 { sync: true, duration: 0.57 * options.duration, 1492 { sync: true, duration: 0.57 * options.duration,
1479 from: 0, transition: v.Transitions.flicker }), 1493 from: 0, transition: v.Transitions.flicker }),
1480 new v.Scale(element, 1, 1494 new v.Scale(element, 1,
1481 { sync: true, duration: 0.43 * options.duration, 1495 { sync: true, duration: 0.43 * options.duration,
1482 scaleFromCenter: true, scaleX: false, 1496 scaleFromCenter: true, scaleX: false,
1483 scaleMode: {originalHeight: elementDimensions.h, 1497 scaleMode: {originalHeight: elementDimensions.h,
1484 originalWidth: elementDimensions.w}, 1498 originalWidth: elementDimensions.w},
1485 scaleContent: false, restoreAfterFinish: true })], 1499 scaleContent: false, restoreAfterFinish: true })],
1486 options); 1500 options);
1487}; 1501};
1488 1502
1489/** @id MochiKit.Visual.dropOut */ 1503/** @id MochiKit.Visual.dropOut */
1490MochiKit.Visual.dropOut = function (element, /* optional */ options) { 1504MochiKit.Visual.dropOut = function (element, /* optional */ options) {
1491 /*** 1505 /***
1492 1506
1493 Make an element fall and disappear. 1507 Make an element fall and disappear.
1494 1508
1495 ***/ 1509 ***/
1496 var d = MochiKit.DOM; 1510 var d = MochiKit.DOM;
1497 var s = MochiKit.Style; 1511 var s = MochiKit.Style;
1498 element = d.getElement(element); 1512 element = d.getElement(element);
1499 var oldStyle = { 1513 var oldStyle = {
1500 top: s.getStyle(element, 'top'), 1514 top: s.getStyle(element, 'top'),
1501 left: s.getStyle(element, 'left'), 1515 left: s.getStyle(element, 'left'),
1502 opacity: s.getStyle(element, 'opacity') 1516 opacity: s.getStyle(element, 'opacity')
1503 }; 1517 };
1504 1518
1505 options = MochiKit.Base.update({ 1519 options = MochiKit.Base.update({
1506 duration: 0.5, 1520 duration: 0.5,
1507 distance: 100, 1521 distance: 100,
1508 beforeSetupInternal: function (effect) { 1522 beforeSetupInternal: function (effect) {
1509 s.makePositioned(effect.effects[0].element); 1523 s.makePositioned(effect.effects[0].element);
1510 }, 1524 },
1511 afterFinishInternal: function (effect) { 1525 afterFinishInternal: function (effect) {
1512 s.hideElement(effect.effects[0].element); 1526 s.hideElement(effect.effects[0].element);
1513 s.undoPositioned(effect.effects[0].element); 1527 s.undoPositioned(effect.effects[0].element);
1514 s.setStyle(effect.effects[0].element, oldStyle); 1528 s.setStyle(effect.effects[0].element, oldStyle);
1515 } 1529 }
1516 }, options); 1530 }, options);
1517 var v = MochiKit.Visual; 1531 var v = MochiKit.Visual;
1518 return new v.Parallel( 1532 return new v.Parallel(
1519 [new v.Move(element, {x: 0, y: options.distance, sync: true}), 1533 [new v.Move(element, {x: 0, y: options.distance, sync: true}),
1520 new v.Opacity(element, {sync: true, to: 0.0})], 1534 new v.Opacity(element, {sync: true, to: 0.0})],
1521 options); 1535 options);
1522}; 1536};
1523 1537
1524/** @id MochiKit.Visual.shake */ 1538/** @id MochiKit.Visual.shake */
1525MochiKit.Visual.shake = function (element, /* optional */ options) { 1539MochiKit.Visual.shake = function (element, /* optional */ options) {
1526 /*** 1540 /***
1527 1541
1528 Move an element from left to right several times. 1542 Move an element from left to right several times.
1529 1543
1530 ***/ 1544 ***/
1531 var d = MochiKit.DOM; 1545 var d = MochiKit.DOM;
1532 var v = MochiKit.Visual; 1546 var v = MochiKit.Visual;
1533 var s = MochiKit.Style; 1547 var s = MochiKit.Style;
1534 element = d.getElement(element); 1548 element = d.getElement(element);
1535 var oldStyle = { 1549 var oldStyle = {
1536 top: s.getStyle(element, 'top'), 1550 top: s.getStyle(element, 'top'),
1537 left: s.getStyle(element, 'left') 1551 left: s.getStyle(element, 'left')
1538 }; 1552 };
1539 options = MochiKit.Base.update({ 1553 options = MochiKit.Base.update({
1540 duration: 0.5, 1554 duration: 0.5,
1541 afterFinishInternal: function (effect) { 1555 afterFinishInternal: function (effect) {
1542 s.undoPositioned(element); 1556 s.undoPositioned(element);
1543 s.setStyle(element, oldStyle); 1557 s.setStyle(element, oldStyle);
1544 } 1558 }
1545 }, options); 1559 }, options);
1546 return new v.Sequence( 1560 return new v.Sequence(
1547 [new v.Move(element, { sync: true, duration: 0.1 * options.duration, 1561 [new v.Move(element, { sync: true, duration: 0.1 * options.duration,
1548 x: 20, y: 0 }), 1562 x: 20, y: 0 }),
1549 new v.Move(element, { sync: true, duration: 0.2 * options.duration, 1563 new v.Move(element, { sync: true, duration: 0.2 * options.duration,
1550 x: -40, y: 0 }), 1564 x: -40, y: 0 }),
1551 new v.Move(element, { sync: true, duration: 0.2 * options.duration, 1565 new v.Move(element, { sync: true, duration: 0.2 * options.duration,
1552 x: 40, y: 0 }), 1566 x: 40, y: 0 }),
1553 new v.Move(element, { sync: true, duration: 0.2 * options.duration, 1567 new v.Move(element, { sync: true, duration: 0.2 * options.duration,
1554 x: -40, y: 0 }), 1568 x: -40, y: 0 }),
1555 new v.Move(element, { sync: true, duration: 0.2 * options.duration, 1569 new v.Move(element, { sync: true, duration: 0.2 * options.duration,
1556 x: 40, y: 0 }), 1570 x: 40, y: 0 }),
1557 new v.Move(element, { sync: true, duration: 0.1 * options.duration, 1571 new v.Move(element, { sync: true, duration: 0.1 * options.duration,
1558 x: -20, y: 0 })], 1572 x: -20, y: 0 })],
1559 options); 1573 options);
1560}; 1574};
1561 1575
1562/** @id MochiKit.Visual.slideDown */ 1576/** @id MochiKit.Visual.slideDown */
1563MochiKit.Visual.slideDown = function (element, /* optional */ options) { 1577MochiKit.Visual.slideDown = function (element, /* optional */ options) {
1564 /*** 1578 /***
1565 1579
1566 Slide an element down. 1580 Slide an element down.
1567 It needs to have the content of the element wrapped in a container 1581 It needs to have the content of the element wrapped in a container
1568 element with fixed height. 1582 element with fixed height.
1569 1583
1570 ***/ 1584 ***/
1571 var d = MochiKit.DOM; 1585 var d = MochiKit.DOM;
1572 var b = MochiKit.Base; 1586 var b = MochiKit.Base;
1573 var s = MochiKit.Style; 1587 var s = MochiKit.Style;
1574 element = d.getElement(element); 1588 element = d.getElement(element);
1575 if (!element.firstChild) { 1589 if (!element.firstChild) {
1576 throw new Error("MochiKit.Visual.slideDown must be used on a element with a child"); 1590 throw new Error("MochiKit.Visual.slideDown must be used on a element with a child");
1577 } 1591 }
1578 d.removeEmptyTextNodes(element); 1592 d.removeEmptyTextNodes(element);
1579 var oldInnerBottom = s.getStyle(element.firstChild, 'bottom') || 0; 1593 var oldInnerBottom = s.getStyle(element.firstChild, 'bottom') || 0;
1580 var elementDimensions = s.getElementDimensions(element, true); 1594 var elementDimensions = s.getElementDimensions(element, true);
1581 var elemClip; 1595 var elemClip;
1582 options = b.update({ 1596 options = b.update({
1583 scaleContent: false, 1597 scaleContent: false,
1584 scaleX: false, 1598 scaleX: false,
1585 scaleFrom: 0, 1599 scaleFrom: 0,
1586 scaleMode: {originalHeight: elementDimensions.h, 1600 scaleMode: {originalHeight: elementDimensions.h,
1587 originalWidth: elementDimensions.w}, 1601 originalWidth: elementDimensions.w},
1588 restoreAfterFinish: true, 1602 restoreAfterFinish: true,
1589 afterSetupInternal: function (effect) { 1603 afterSetupInternal: function (effect) {
1590 s.makePositioned(effect.element); 1604 s.makePositioned(effect.element);
1591 s.makePositioned(effect.element.firstChild); 1605 s.makePositioned(effect.element.firstChild);
1592 if (/Opera/.test(navigator.userAgent)) { 1606 if (/Opera/.test(navigator.userAgent)) {
1593 s.setStyle(effect.element, {top: ''}); 1607 s.setStyle(effect.element, {top: ''});
1594 } 1608 }
1595 elemClip = s.makeClipping(effect.element); 1609 elemClip = s.makeClipping(effect.element);
1596 s.setStyle(effect.element, {height: '0px'}); 1610 s.setStyle(effect.element, {height: '0px'});
1597 s.showElement(effect.element); 1611 s.showElement(effect.element);
1598 }, 1612 },
1599 afterUpdateInternal: function (effect) { 1613 afterUpdateInternal: function (effect) {
1600 var elementDimensions = s.getElementDimensions(effect.element, true); 1614 var elementDimensions = s.getElementDimensions(effect.element, true);
1601 s.setStyle(effect.element.firstChild, 1615 s.setStyle(effect.element.firstChild,
1602 {bottom: (effect.dims[0] - elementDimensions.h) + 'px'}); 1616 {bottom: (effect.dims[0] - elementDimensions.h) + 'px'});
1603 }, 1617 },
1604 afterFinishInternal: function (effect) { 1618 afterFinishInternal: function (effect) {
1605 s.undoClipping(effect.element, elemClip); 1619 s.undoClipping(effect.element, elemClip);
1606 // IE will crash if child is undoPositioned first 1620 // IE will crash if child is undoPositioned first
1607 if (/MSIE/.test(navigator.userAgent)) { 1621 if (/MSIE/.test(navigator.userAgent)) {
1608 s.undoPositioned(effect.element); 1622 s.undoPositioned(effect.element);
1609 s.undoPositioned(effect.element.firstChild); 1623 s.undoPositioned(effect.element.firstChild);
1610 } else { 1624 } else {
1611 s.undoPositioned(effect.element.firstChild); 1625 s.undoPositioned(effect.element.firstChild);
1612 s.undoPositioned(effect.element); 1626 s.undoPositioned(effect.element);
1613 } 1627 }
1614 s.setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); 1628 s.setStyle(effect.element.firstChild, {bottom: oldInnerBottom});
1615 } 1629 }
1616 }, options); 1630 }, options);
1617 1631
1618 return new MochiKit.Visual.Scale(element, 100, options); 1632 return new MochiKit.Visual.Scale(element, 100, options);
1619}; 1633};
1620 1634
1621/** @id MochiKit.Visual.slideUp */ 1635/** @id MochiKit.Visual.slideUp */
1622MochiKit.Visual.slideUp = function (element, /* optional */ options) { 1636MochiKit.Visual.slideUp = function (element, /* optional */ options) {
1623 /*** 1637 /***
1624 1638
1625 Slide an element up. 1639 Slide an element up.
1626 It needs to have the content of the element wrapped in a container 1640 It needs to have the content of the element wrapped in a container
1627 element with fixed height. 1641 element with fixed height.
1628 1642
1629 ***/ 1643 ***/
1630 var d = MochiKit.DOM; 1644 var d = MochiKit.DOM;
1631 var b = MochiKit.Base; 1645 var b = MochiKit.Base;
1632 var s = MochiKit.Style; 1646 var s = MochiKit.Style;
1633 element = d.getElement(element); 1647 element = d.getElement(element);
1634 if (!element.firstChild) { 1648 if (!element.firstChild) {
1635 throw new Error("MochiKit.Visual.slideUp must be used on a element with a child"); 1649 throw new Error("MochiKit.Visual.slideUp must be used on a element with a child");
1636 } 1650 }
1637 d.removeEmptyTextNodes(element); 1651 d.removeEmptyTextNodes(element);
1638 var oldInnerBottom = s.getStyle(element.firstChild, 'bottom'); 1652 var oldInnerBottom = s.getStyle(element.firstChild, 'bottom');
1639 var elementDimensions = s.getElementDimensions(element, true); 1653 var elementDimensions = s.getElementDimensions(element, true);
1640 var elemClip; 1654 var elemClip;
1641 options = b.update({ 1655 options = b.update({
1642 scaleContent: false, 1656 scaleContent: false,
1643 scaleX: false, 1657 scaleX: false,
1644 scaleMode: {originalHeight: elementDimensions.h, 1658 scaleMode: {originalHeight: elementDimensions.h,
1645 originalWidth: elementDimensions.w}, 1659 originalWidth: elementDimensions.w},
1646 scaleFrom: 100, 1660 scaleFrom: 100,
1647 restoreAfterFinish: true, 1661 restoreAfterFinish: true,
1648 beforeStartInternal: function (effect) { 1662 beforeStartInternal: function (effect) {
1649 s.makePositioned(effect.element); 1663 s.makePositioned(effect.element);
1650 s.makePositioned(effect.element.firstChild); 1664 s.makePositioned(effect.element.firstChild);
1651 if (/Opera/.test(navigator.userAgent)) { 1665 if (/Opera/.test(navigator.userAgent)) {
1652 s.setStyle(effect.element, {top: ''}); 1666 s.setStyle(effect.element, {top: ''});
1653 } 1667 }
1654 elemClip = s.makeClipping(effect.element); 1668 elemClip = s.makeClipping(effect.element);
1655 s.showElement(effect.element); 1669 s.showElement(effect.element);
1656 }, 1670 },
1657 afterUpdateInternal: function (effect) { 1671 afterUpdateInternal: function (effect) {
1658 var elementDimensions = s.getElementDimensions(effect.element, true); 1672 var elementDimensions = s.getElementDimensions(effect.element, true);
1659 s.setStyle(effect.element.firstChild, 1673 s.setStyle(effect.element.firstChild,
1660 {bottom: (effect.dims[0] - elementDimensions.h) + 'px'}); 1674 {bottom: (effect.dims[0] - elementDimensions.h) + 'px'});
1661 }, 1675 },
1662 afterFinishInternal: function (effect) { 1676 afterFinishInternal: function (effect) {
1663 s.hideElement(effect.element); 1677 s.hideElement(effect.element);
1664 s.undoClipping(effect.element, elemClip); 1678 s.undoClipping(effect.element, elemClip);
1665 s.undoPositioned(effect.element.firstChild); 1679 s.undoPositioned(effect.element.firstChild);
1666 s.undoPositioned(effect.element); 1680 s.undoPositioned(effect.element);
1667 s.setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); 1681 s.setStyle(effect.element.firstChild, {bottom: oldInnerBottom});
1668 } 1682 }
1669 }, options); 1683 }, options);
1670 return new MochiKit.Visual.Scale(element, 0, options); 1684 return new MochiKit.Visual.Scale(element, 0, options);
1671}; 1685};
1672 1686
1673// Bug in opera makes the TD containing this element expand for a instance 1687// Bug in opera makes the TD containing this element expand for a instance
1674// after finish 1688// after finish
1675/** @id MochiKit.Visual.squish */ 1689/** @id MochiKit.Visual.squish */
1676MochiKit.Visual.squish = function (element, /* optional */ options) { 1690MochiKit.Visual.squish = function (element, /* optional */ options) {
1677 /*** 1691 /***
1678 1692
1679 Reduce an element and make it disappear. 1693 Reduce an element and make it disappear.
1680 1694
1681 ***/ 1695 ***/
1682 var d = MochiKit.DOM; 1696 var d = MochiKit.DOM;
1683 var b = MochiKit.Base; 1697 var b = MochiKit.Base;
1684 var s = MochiKit.Style; 1698 var s = MochiKit.Style;
1685 var elementDimensions = s.getElementDimensions(element, true); 1699 var elementDimensions = s.getElementDimensions(element, true);
1686 var elemClip; 1700 var elemClip;
1687 options = b.update({ 1701 options = b.update({
1688 restoreAfterFinish: true, 1702 restoreAfterFinish: true,
1689 scaleMode: {originalHeight: elementDimensions.w, 1703 scaleMode: {originalHeight: elementDimensions.h,
1690 originalWidth: elementDimensions.h}, 1704 originalWidth: elementDimensions.w},
1691 beforeSetupInternal: function (effect) { 1705 beforeSetupInternal: function (effect) {
1692 elemClip = s.makeClipping(effect.element); 1706 elemClip = s.makeClipping(effect.element);
1693 }, 1707 },
1694 afterFinishInternal: function (effect) { 1708 afterFinishInternal: function (effect) {
1695 s.hideElement(effect.element); 1709 s.hideElement(effect.element);
1696 s.undoClipping(effect.element, elemClip); 1710 s.undoClipping(effect.element, elemClip);
1697 } 1711 }
1698 }, options); 1712 }, options);
1699 1713
1700 return new MochiKit.Visual.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, options); 1714 return new MochiKit.Visual.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, options);
1701}; 1715};
1702 1716
1703/** @id MochiKit.Visual.grow */ 1717/** @id MochiKit.Visual.grow */
1704MochiKit.Visual.grow = function (element, /* optional */ options) { 1718MochiKit.Visual.grow = function (element, /* optional */ options) {
1705 /*** 1719 /***
1706 1720
1707 Grow an element to its original size. Make it zero-sized before 1721 Grow an element to its original size. Make it zero-sized before
1708 if necessary. 1722 if necessary.
1709 1723
1710 ***/ 1724 ***/
1711 var d = MochiKit.DOM; 1725 var d = MochiKit.DOM;
1712 var v = MochiKit.Visual; 1726 var v = MochiKit.Visual;
1713 var s = MochiKit.Style; 1727 var s = MochiKit.Style;
1714 element = d.getElement(element); 1728 element = d.getElement(element);
1715 options = MochiKit.Base.update({ 1729 options = MochiKit.Base.update({
1716 direction: 'center', 1730 direction: 'center',
1717 moveTransition: v.Transitions.sinoidal, 1731 moveTransition: v.Transitions.sinoidal,
1718 scaleTransition: v.Transitions.sinoidal, 1732 scaleTransition: v.Transitions.sinoidal,
1719 opacityTransition: v.Transitions.full, 1733 opacityTransition: v.Transitions.full,
1720 scaleContent: true, 1734 scaleContent: true,
1721 scaleFromCenter: false 1735 scaleFromCenter: false
1722 }, options); 1736 }, options);
1723 var oldStyle = { 1737 var oldStyle = {
1724 top: element.style.top, 1738 top: element.style.top,
1725 left: element.style.left, 1739 left: element.style.left,
1726 height: element.style.height, 1740 height: element.style.height,
1727 width: element.style.width, 1741 width: element.style.width,
1728 opacity: s.getStyle(element, 'opacity') 1742 opacity: s.getStyle(element, 'opacity')
1729 }; 1743 };
1730 var dims = s.getElementDimensions(element, true); 1744 var dims = s.getElementDimensions(element, true);
1731 var initialMoveX, initialMoveY; 1745 var initialMoveX, initialMoveY;
1732 var moveX, moveY; 1746 var moveX, moveY;
1733 1747
1734 switch (options.direction) { 1748 switch (options.direction) {
1735 case 'top-left': 1749 case 'top-left':
1736 initialMoveX = initialMoveY = moveX = moveY = 0; 1750 initialMoveX = initialMoveY = moveX = moveY = 0;
1737 break; 1751 break;
1738 case 'top-right': 1752 case 'top-right':
1739 initialMoveX = dims.w; 1753 initialMoveX = dims.w;
1740 initialMoveY = moveY = 0; 1754 initialMoveY = moveY = 0;
1741 moveX = -dims.w; 1755 moveX = -dims.w;
1742 break; 1756 break;
1743 case 'bottom-left': 1757 case 'bottom-left':
1744 initialMoveX = moveX = 0; 1758 initialMoveX = moveX = 0;
1745 initialMoveY = dims.h; 1759 initialMoveY = dims.h;
1746 moveY = -dims.h; 1760 moveY = -dims.h;
1747 break; 1761 break;
1748 case 'bottom-right': 1762 case 'bottom-right':
1749 initialMoveX = dims.w; 1763 initialMoveX = dims.w;
1750 initialMoveY = dims.h; 1764 initialMoveY = dims.h;
1751 moveX = -dims.w; 1765 moveX = -dims.w;
1752 moveY = -dims.h; 1766 moveY = -dims.h;
1753 break; 1767 break;
1754 case 'center': 1768 case 'center':
1755 initialMoveX = dims.w / 2; 1769 initialMoveX = dims.w / 2;
1756 initialMoveY = dims.h / 2; 1770 initialMoveY = dims.h / 2;
1757 moveX = -dims.w / 2; 1771 moveX = -dims.w / 2;
1758 moveY = -dims.h / 2; 1772 moveY = -dims.h / 2;
1759 break; 1773 break;
1760 } 1774 }
1761 1775
1762 var optionsParallel = MochiKit.Base.update({ 1776 var optionsParallel = MochiKit.Base.update({
1763 beforeSetupInternal: function (effect) { 1777 beforeSetupInternal: function (effect) {
1764 s.setStyle(effect.effects[0].element, {height: '0px'}); 1778 s.setStyle(effect.effects[0].element, {height: '0px'});
1765 s.showElement(effect.effects[0].element); 1779 s.showElement(effect.effects[0].element);
1766 }, 1780 },
1767 afterFinishInternal: function (effect) { 1781 afterFinishInternal: function (effect) {
1768 s.undoClipping(effect.effects[0].element); 1782 s.undoClipping(effect.effects[0].element);
1769 s.undoPositioned(effect.effects[0].element); 1783 s.undoPositioned(effect.effects[0].element);
1770 s.setStyle(effect.effects[0].element, oldStyle); 1784 s.setStyle(effect.effects[0].element, oldStyle);
1771 } 1785 }
1772 }, options); 1786 }, options);
1773 1787
1774 return new v.Move(element, { 1788 return new v.Move(element, {
1775 x: initialMoveX, 1789 x: initialMoveX,
1776 y: initialMoveY, 1790 y: initialMoveY,
1777 duration: 0.01, 1791 duration: 0.01,
1778 beforeSetupInternal: function (effect) { 1792 beforeSetupInternal: function (effect) {
1779 s.hideElement(effect.element); 1793 s.hideElement(effect.element);
1780 s.makeClipping(effect.element); 1794 s.makeClipping(effect.element);
1781 s.makePositioned(effect.element); 1795 s.makePositioned(effect.element);
1782 }, 1796 },
1783 afterFinishInternal: function (effect) { 1797 afterFinishInternal: function (effect) {
1784 new v.Parallel( 1798 new v.Parallel(
1785 [new v.Opacity(effect.element, { 1799 [new v.Opacity(effect.element, {
1786 sync: true, to: 1.0, from: 0.0, 1800 sync: true, to: 1.0, from: 0.0,
1787 transition: options.opacityTransition 1801 transition: options.opacityTransition
1788 }), 1802 }),
1789 new v.Move(effect.element, { 1803 new v.Move(effect.element, {
1790 x: moveX, y: moveY, sync: true, 1804 x: moveX, y: moveY, sync: true,
1791 transition: options.moveTransition 1805 transition: options.moveTransition
1792 }), 1806 }),
1793 new v.Scale(effect.element, 100, { 1807 new v.Scale(effect.element, 100, {
1794 scaleMode: {originalHeight: dims.h, 1808 scaleMode: {originalHeight: dims.h,
1795 originalWidth: dims.w}, 1809 originalWidth: dims.w},
1796 sync: true, 1810 sync: true,
1797 scaleFrom: /Opera/.test(navigator.userAgent) ? 1 : 0, 1811 scaleFrom: /Opera/.test(navigator.userAgent) ? 1 : 0,
1798 transition: options.scaleTransition, 1812 transition: options.scaleTransition,
1799 scaleContent: options.scaleContent, 1813 scaleContent: options.scaleContent,
1800 scaleFromCenter: options.scaleFromCenter, 1814 scaleFromCenter: options.scaleFromCenter,
1801 restoreAfterFinish: true 1815 restoreAfterFinish: true
1802 }) 1816 })
1803 ], optionsParallel 1817 ], optionsParallel
1804 ); 1818 );
1805 } 1819 }
1806 }); 1820 });
1807}; 1821};
1808 1822
1809/** @id MochiKit.Visual.shrink */ 1823/** @id MochiKit.Visual.shrink */
1810MochiKit.Visual.shrink = function (element, /* optional */ options) { 1824MochiKit.Visual.shrink = function (element, /* optional */ options) {
1811 /*** 1825 /***
1812 1826
1813 Shrink an element and make it disappear. 1827 Shrink an element and make it disappear.
1814 1828
1815 ***/ 1829 ***/
1816 var d = MochiKit.DOM; 1830 var d = MochiKit.DOM;
1817 var v = MochiKit.Visual; 1831 var v = MochiKit.Visual;
1818 var s = MochiKit.Style; 1832 var s = MochiKit.Style;
1819 element = d.getElement(element); 1833 element = d.getElement(element);
1820 options = MochiKit.Base.update({ 1834 options = MochiKit.Base.update({
1821 direction: 'center', 1835 direction: 'center',
1822 moveTransition: v.Transitions.sinoidal, 1836 moveTransition: v.Transitions.sinoidal,
1823 scaleTransition: v.Transitions.sinoidal, 1837 scaleTransition: v.Transitions.sinoidal,
1824 opacityTransition: v.Transitions.none, 1838 opacityTransition: v.Transitions.none,
1825 scaleContent: true, 1839 scaleContent: true,
1826 scaleFromCenter: false 1840 scaleFromCenter: false
1827 }, options); 1841 }, options);
1828 var oldStyle = { 1842 var oldStyle = {
1829 top: element.style.top, 1843 top: element.style.top,
1830 left: element.style.left, 1844 left: element.style.left,
1831 height: element.style.height, 1845 height: element.style.height,
1832 width: element.style.width, 1846 width: element.style.width,
1833 opacity: s.getStyle(element, 'opacity') 1847 opacity: s.getStyle(element, 'opacity')
1834 }; 1848 };
1835 1849
1836 var dims = s.getElementDimensions(element, true); 1850 var dims = s.getElementDimensions(element, true);
1837 var moveX, moveY; 1851 var moveX, moveY;
1838 1852
1839 switch (options.direction) { 1853 switch (options.direction) {
1840 case 'top-left': 1854 case 'top-left':
1841 moveX = moveY = 0; 1855 moveX = moveY = 0;
1842 break; 1856 break;
1843 case 'top-right': 1857 case 'top-right':
1844 moveX = dims.w; 1858 moveX = dims.w;
1845 moveY = 0; 1859 moveY = 0;
1846 break; 1860 break;
1847 case 'bottom-left': 1861 case 'bottom-left':
1848 moveX = 0; 1862 moveX = 0;
1849 moveY = dims.h; 1863 moveY = dims.h;
1850 break; 1864 break;
1851 case 'bottom-right': 1865 case 'bottom-right':
1852 moveX = dims.w; 1866 moveX = dims.w;
1853 moveY = dims.h; 1867 moveY = dims.h;
1854 break; 1868 break;
1855 case 'center': 1869 case 'center':
1856 moveX = dims.w / 2; 1870 moveX = dims.w / 2;
1857 moveY = dims.h / 2; 1871 moveY = dims.h / 2;
1858 break; 1872 break;
1859 } 1873 }
1860 var elemClip; 1874 var elemClip;
1861 1875
1862 var optionsParallel = MochiKit.Base.update({ 1876 var optionsParallel = MochiKit.Base.update({
1863 beforeStartInternal: function (effect) { 1877 beforeStartInternal: function (effect) {
1864 s.makePositioned(effect.effects[0].element); 1878 s.makePositioned(effect.effects[0].element);
1865 elemClip = s.makeClipping(effect.effects[0].element); 1879 elemClip = s.makeClipping(effect.effects[0].element);
1866 }, 1880 },
1867 afterFinishInternal: function (effect) { 1881 afterFinishInternal: function (effect) {
1868 s.hideElement(effect.effects[0].element); 1882 s.hideElement(effect.effects[0].element);
1869 s.undoClipping(effect.effects[0].element, elemClip); 1883 s.undoClipping(effect.effects[0].element, elemClip);
1870 s.undoPositioned(effect.effects[0].element); 1884 s.undoPositioned(effect.effects[0].element);
1871 s.setStyle(effect.effects[0].element, oldStyle); 1885 s.setStyle(effect.effects[0].element, oldStyle);
1872 } 1886 }
1873 }, options); 1887 }, options);
1874 1888
1875 return new v.Parallel( 1889 return new v.Parallel(
1876 [new v.Opacity(element, { 1890 [new v.Opacity(element, {
1877 sync: true, to: 0.0, from: 1.0, 1891 sync: true, to: 0.0, from: 1.0,
1878 transition: options.opacityTransition 1892 transition: options.opacityTransition
1879 }), 1893 }),
1880 new v.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, { 1894 new v.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, {
1881 scaleMode: {originalHeight: dims.h, originalWidth: dims.w}, 1895 scaleMode: {originalHeight: dims.h, originalWidth: dims.w},
1882 sync: true, transition: options.scaleTransition, 1896 sync: true, transition: options.scaleTransition,
1883 scaleContent: options.scaleContent, 1897 scaleContent: options.scaleContent,
1884 scaleFromCenter: options.scaleFromCenter, 1898 scaleFromCenter: options.scaleFromCenter,
1885 restoreAfterFinish: true 1899 restoreAfterFinish: true
1886 }), 1900 }),
1887 new v.Move(element, { 1901 new v.Move(element, {
1888 x: moveX, y: moveY, sync: true, transition: options.moveTransition 1902 x: moveX, y: moveY, sync: true, transition: options.moveTransition
1889 }) 1903 })
1890 ], optionsParallel 1904 ], optionsParallel
1891 ); 1905 );
1892}; 1906};
1893 1907
1894/** @id MochiKit.Visual.pulsate */ 1908/** @id MochiKit.Visual.pulsate */
1895MochiKit.Visual.pulsate = function (element, /* optional */ options) { 1909MochiKit.Visual.pulsate = function (element, /* optional */ options) {
1896 /*** 1910 /***
1897 1911
1898 Pulse an element between appear/fade. 1912 Pulse an element between appear/fade.
1899 1913
1900 ***/ 1914 ***/
1901 var d = MochiKit.DOM; 1915 var d = MochiKit.DOM;
1902 var v = MochiKit.Visual; 1916 var v = MochiKit.Visual;
1903 var b = MochiKit.Base; 1917 var b = MochiKit.Base;
1904 var oldOpacity = MochiKit.Style.getStyle(element, 'opacity'); 1918 var oldOpacity = MochiKit.Style.getStyle(element, 'opacity');
1905 options = b.update({ 1919 options = b.update({
1906 duration: 3.0, 1920 duration: 3.0,
1907 from: 0, 1921 from: 0,
1908 afterFinishInternal: function (effect) { 1922 afterFinishInternal: function (effect) {
1909 MochiKit.Style.setStyle(effect.element, {'opacity': oldOpacity}); 1923 MochiKit.Style.setStyle(effect.element, {'opacity': oldOpacity});
1910 } 1924 }
1911 }, options); 1925 }, options);
1912 var transition = options.transition || v.Transitions.sinoidal; 1926 var transition = options.transition || v.Transitions.sinoidal;
1913 options.transition = function (pos) { 1927 options.transition = function (pos) {
1914 return transition(1 - v.Transitions.pulse(pos, options.pulses)); 1928 return transition(1 - v.Transitions.pulse(pos, options.pulses));
1915 }; 1929 };
1916 return new v.Opacity(element, options); 1930 return new v.Opacity(element, options);
1917}; 1931};
1918 1932
1919/** @id MochiKit.Visual.fold */ 1933/** @id MochiKit.Visual.fold */
1920MochiKit.Visual.fold = function (element, /* optional */ options) { 1934MochiKit.Visual.fold = function (element, /* optional */ options) {
1921 /*** 1935 /***
1922 1936
1923 Fold an element, first vertically, then horizontally. 1937 Fold an element, first vertically, then horizontally.
1924 1938
1925 ***/ 1939 ***/
1926 var d = MochiKit.DOM; 1940 var d = MochiKit.DOM;
1927 var v = MochiKit.Visual; 1941 var v = MochiKit.Visual;
1928 var s = MochiKit.Style; 1942 var s = MochiKit.Style;
1929 element = d.getElement(element); 1943 element = d.getElement(element);
1930 var elementDimensions = s.getElementDimensions(element, true); 1944 var elementDimensions = s.getElementDimensions(element, true);
1931 var oldStyle = { 1945 var oldStyle = {
1932 top: element.style.top, 1946 top: element.style.top,
1933 left: element.style.left, 1947 left: element.style.left,
1934 width: element.style.width, 1948 width: element.style.width,
1935 height: element.style.height 1949 height: element.style.height
1936 }; 1950 };
1937 var elemClip = s.makeClipping(element); 1951 var elemClip = s.makeClipping(element);
1938 options = MochiKit.Base.update({ 1952 options = MochiKit.Base.update({
1939 scaleContent: false, 1953 scaleContent: false,
1940 scaleX: false, 1954 scaleX: false,
1941 scaleMode: {originalHeight: elementDimensions.h, 1955 scaleMode: {originalHeight: elementDimensions.h,
1942 originalWidth: elementDimensions.w}, 1956 originalWidth: elementDimensions.w},
1943 afterFinishInternal: function (effect) { 1957 afterFinishInternal: function (effect) {
1944 new v.Scale(element, 1, { 1958 new v.Scale(element, 1, {
1945 scaleContent: false, 1959 scaleContent: false,
1946 scaleY: false, 1960 scaleY: false,
1947 scaleMode: {originalHeight: elementDimensions.h, 1961 scaleMode: {originalHeight: elementDimensions.h,
1948 originalWidth: elementDimensions.w}, 1962 originalWidth: elementDimensions.w},
1949 afterFinishInternal: function (effect) { 1963 afterFinishInternal: function (effect) {
1950 s.hideElement(effect.element); 1964 s.hideElement(effect.element);
1951 s.undoClipping(effect.element, elemClip); 1965 s.undoClipping(effect.element, elemClip);
1952 s.setStyle(effect.element, oldStyle); 1966 s.setStyle(effect.element, oldStyle);
1953 } 1967 }
1954 }); 1968 });
1955 } 1969 }
1956 }, options); 1970 }, options);
1957 return new v.Scale(element, 5, options); 1971 return new v.Scale(element, 5, options);
1958}; 1972};
1959 1973
1960 1974
1961/* end of Rico adaptation */ 1975MochiKit.Base.nameFunctions(MochiKit.Visual);
1962
1963MochiKit.Visual.__new__ = function () {
1964 var m = MochiKit.Base;
1965
1966 // Backwards compatibility aliases
1967 m._deprecated(this, 'Color', 'MochiKit.Color.Color', '1.1');
1968 m._deprecated(this, 'getElementsComputedStyle', 'MochiKit.Style.getStyle', '1.1');
1969
1970 m.nameFunctions(this);
1971};
1972
1973MochiKit.Visual.__new__();
1974
1975MochiKit.Base._exportSymbols(this, MochiKit.Visual); 1976MochiKit.Base._exportSymbols(this, MochiKit.Visual);
diff --git a/frontend/gamma/js/MochiKit/__package__.js b/frontend/gamma/js/MochiKit/__package__.js
deleted file mode 100644
index 8d644b1..0000000
--- a/frontend/gamma/js/MochiKit/__package__.js
+++ b/dev/null
@@ -1,18 +0,0 @@
1dojo.kwCompoundRequire({
2 "common": [
3 "MochiKit.Base",
4 "MochiKit.Iter",
5 "MochiKit.Logging",
6 "MochiKit.DateTime",
7 "MochiKit.Format",
8 "MochiKit.Async",
9 "MochiKit.DOM",
10 "MochiKit.Style",
11 "MochiKit.LoggingPane",
12 "MochiKit.Color",
13 "MochiKit.Signal",
14 "MochiKit.Position",
15 "MochiKit.Visual"
16 ]
17});
18dojo.provide("MochiKit.*");
diff --git a/frontend/gamma/js/main.js b/frontend/gamma/js/main.js
index a9fd65e..934b325 100644
--- a/frontend/gamma/js/main.js
+++ b/frontend/gamma/js/main.js
@@ -1,93 +1,93 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24*/ 24*/
25 25
26function _pm_logEvent(anEvent) { 26function _pm_logEvent(anEvent) {
27 //console.log("####", anEvent); 27 //console.log("####", anEvent);
28 28
29 anEvent.preventDefault(); 29 anEvent.preventDefault();
30} 30}
31 31
32function handleGenericDeferredError(anError) { 32function handleGenericDeferredError(anError) {
33 var result; 33 var result;
34 34
35 if (anError instanceof MochiKit.Async.CancelledError) { 35 if (anError instanceof MochiKit.Async.CancelledError) {
36 result = anError; 36 result = anError;
37 } else { 37 } else {
38MochiKit.Logging.logError("## MainController - GENERIC ERROR" + "\n" + "==>> " + anError + " <<==\n" + anError.stack); 38MochiKit.Logging.logError("## MainController - GENERIC ERROR" + "\n" + "==>> " + anError + " <<==\n" + anError.stack);
39//console.log(anError); 39//console.log(anError);
40 result = new MochiKit.Async.CancelledError(anError); 40 result = new MochiKit.Async.CancelledError(anError);
41 } 41 }
42 42
43 return result; 43 return result;
44} 44}
45 45
46 46
47Clipperz.PM.RunTime = {}; 47Clipperz.PM.RunTime = {};
48 48
49 49
50function run() { 50function run() {
51 var shouldShowRegistrationForm; 51 var shouldShowRegistrationForm;
52 var useCompactDesign; 52 var useCompactDesign;
53 var controllerParameters; 53 var controllerParameters;
54 54
55 controllerParameters = {}; 55 controllerParameters = {};
56 56
57 //MochiKit.DOM.removeElement('javaScriptAlert'); 57 //MochiKit.DOM.removeElement('javaScriptAlert');
58 Clipperz.PM.Strings.Languages.initSetup(); 58 Clipperz.PM.Strings.Languages.initSetup();
59 59
60 if (window.location.search.indexOf('registration') != -1) { 60 if (window.location.search.indexOf('registration') != -1) {
61 shouldShowRegistrationForm = true; 61 shouldShowRegistrationForm = true;
62 } else { 62 } else {
63 shouldShowRegistrationForm = false; 63 shouldShowRegistrationForm = false;
64 } 64 }
65 65
66 if (window.location.search.indexOf('autocomplete') != -1) { 66 if (window.location.search.indexOf('autocomplete') != -1) {
67 controllerParameters['autocomplete'] = 'on' 67 controllerParameters['autocomplete'] = 'on'
68 } 68 }
69 69
70 if (window.location.search.indexOf('compact') != -1) { 70 if (window.location.search.indexOf('compact') != -1) {
71 useCompactDesign = true; 71 useCompactDesign = true;
72 } else { 72 } else {
73 useCompactDesign = false; 73 useCompactDesign = false;
74 } 74 }
75 75
76 if (useCompactDesign == true) { 76 if (useCompactDesign == true) {
77 Clipperz.PM.RunTime.mainController = new Clipperz.PM.UI.Compact.Controllers.MainController(controllerParameters); 77 Clipperz.PM.RunTime.mainController = new Clipperz.PM.UI.Compact.Controllers.MainController(controllerParameters);
78 } else { 78 } else {
79 Clipperz.PM.RunTime.mainController = new Clipperz.PM.UI.Web.Controllers.MainController(controllerParameters); 79 Clipperz.PM.RunTime.mainController = new Clipperz.PM.UI.Web.Controllers.MainController(controllerParameters);
80 } 80 }
81 81
82 Clipperz.PM.RunTime.mainController.run(shouldShowRegistrationForm); 82 Clipperz.PM.RunTime.mainController.run(shouldShowRegistrationForm);
83 83
84//Clipperz.log("HASH: " + window.location.hash); 84 //Clipperz.log("HASH: " + window.location.hash);
85if (window.location.hash != "") { 85 //if (window.location.hash != "") {
86 window.location.hash = "" 86 // window.location.hash = ""
87} 87 //}
88//Clipperz.log("HASH cleaned"); 88 //Clipperz.log("HASH cleaned");
89 //#credentials=base64encoded({username:'joe', passphrase:'clipperz'}) 89 //#credentials=base64encoded({username:'joe', passphrase:'clipperz'})
90 //MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'doLogin', {username:'joe', passphrase:'clipperz'}); 90 //MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'doLogin', {username:'joe', passphrase:'clipperz'});
91} 91}
92 92
93MochiKit.DOM.addLoadEvent(run); 93MochiKit.DOM.addLoadEvent(run);
diff --git a/frontend/gamma/properties/gamma.properties.json b/frontend/gamma/properties/gamma.properties.json
index 8f2d98e..0a513e8 100644
--- a/frontend/gamma/properties/gamma.properties.json
+++ b/frontend/gamma/properties/gamma.properties.json
@@ -1,188 +1,191 @@
1{ 1{
2 "copyright.values": { 2 "copyright.values": {
3 "mochikit.repository": "http://svn.mochikit.com/mochikit/trunk/", 3 "mochikit.repository": "https://github.com/mochi/mochikit.git",
4 "mochikit.version": "1506" 4 "mochikit.version": "fe8d17bb9ac0a4e5ad4a8d5c2c94a6fac1c92d75"
5 }, 5 },
6
7 "html.template": "index_template.html",
8
6 "js": [ 9 "js": [
7 "MochiKit/Base.js", 10 "MochiKit/Base.js",
8 "MochiKit/Iter.js", 11 "MochiKit/Iter.js",
9 "MochiKit/Logging.js", 12 "MochiKit/Logging.js",
10 "-- MochiKit/DateTime.js", 13 "-- MochiKit/DateTime.js",
11 "MochiKit/Format.js", 14 "MochiKit/Format.js",
12 "MochiKit/Async.js", 15 "MochiKit/Async.js",
13 "MochiKit/DOM.js", 16 "MochiKit/DOM.js",
14 "MochiKit/Style.js", 17 "MochiKit/Style.js",
15 "MochiKit/LoggingPane.js", 18 "MochiKit/LoggingPane.js",
16 "MochiKit/Color.js", 19 "MochiKit/Color.js",
17 "MochiKit/Signal.js", 20 "MochiKit/Signal.js",
18 "MochiKit/Position.js", 21 "MochiKit/Position.js",
19 "MochiKit/Selector.js", 22 "MochiKit/Selector.js",
20 "MochiKit/Visual.js", 23 "MochiKit/Visual.js",
21 24
22 "JSON/json2.js", 25 "JSON/json2.js",
23 26
24 "Clipperz/YUI/Utils.js", 27 "Clipperz/YUI/Utils.js",
25 "Clipperz/YUI/DomHelper.js", 28 "Clipperz/YUI/DomHelper.js",
26 29
27 "Clipperz/ByteArray.js", 30 "Clipperz/ByteArray.js",
28 "Clipperz/Base.js", 31 "Clipperz/Base.js",
29 "Clipperz/Async.js", 32 "Clipperz/Async.js",
30 "Clipperz/CSVProcessor.js", 33 "Clipperz/CSVProcessor.js",
31 "Clipperz/KeePassExportProcessor.js", 34 "Clipperz/KeePassExportProcessor.js",
32 "Clipperz/Date.js", 35 "Clipperz/Date.js",
33 "Clipperz/DOM.js", 36 "Clipperz/DOM.js",
34 "Clipperz/Logging.js", 37 "Clipperz/Logging.js",
35 "Clipperz/Signal.js", 38 "Clipperz/Signal.js",
36 "Clipperz/Style.js", 39 "Clipperz/Style.js",
37 "Clipperz/Visual.js", 40 "Clipperz/Visual.js",
38 "Clipperz/Set.js", 41 "Clipperz/Set.js",
39 "-- Clipperz/Profile.js", 42 "-- Clipperz/Profile.js",
40 "Clipperz/KeyValueObjectStore.js", 43 "Clipperz/KeyValueObjectStore.js",
41 44
42 "Clipperz/Crypto/SHA.js", 45 "Clipperz/Crypto/SHA.js",
43 "Clipperz/Crypto/AES.js", 46 "Clipperz/Crypto/AES.js",
44 "Clipperz/Crypto/PRNG.js", 47 "Clipperz/Crypto/PRNG.js",
45 "Clipperz/Crypto/BigInt.js", 48 "Clipperz/Crypto/BigInt.js",
46 "Clipperz/Crypto/Base.js", 49 "Clipperz/Crypto/Base.js",
47 "Clipperz/Crypto/SRP.js", 50 "Clipperz/Crypto/SRP.js",
48 "Clipperz/Crypto/RSA.js", 51 "Clipperz/Crypto/RSA.js",
49 52
50 "Clipperz/PM/Strings/Strings_defaults.js", 53 "Clipperz/PM/Strings/Strings_defaults.js",
51 "Clipperz/PM/Strings/Strings_en-US.js", 54 "Clipperz/PM/Strings/Strings_en-US.js",
52 "-- # Clipperz/PM/Strings/Strings_en-GB.js", 55 "-- # Clipperz/PM/Strings/Strings_en-GB.js",
53 "-- # Clipperz/PM/Strings/Strings_en-CA.js", 56 "-- # Clipperz/PM/Strings/Strings_en-CA.js",
54 "-- Clipperz/PM/Strings/Strings_it-IT.js", 57 "-- Clipperz/PM/Strings/Strings_it-IT.js",
55 "-- Clipperz/PM/Strings/Strings_pt-BR.js", 58 "-- Clipperz/PM/Strings/Strings_pt-BR.js",
56 "-- # Clipperz/PM/Strings/Strings_pt-PT.js", 59 "-- # Clipperz/PM/Strings/Strings_pt-PT.js",
57 "-- Clipperz/PM/Strings/Strings_ja-JP.js", 60 "-- Clipperz/PM/Strings/Strings_ja-JP.js",
58 "-- Clipperz/PM/Strings/Strings_zh-CN.js", 61 "-- Clipperz/PM/Strings/Strings_zh-CN.js",
59 "-- Clipperz/PM/Strings/Strings_es-ES.js", 62 "-- Clipperz/PM/Strings/Strings_es-ES.js",
60 "-- Clipperz/PM/Strings/Strings_fr-FR.js", 63 "-- Clipperz/PM/Strings/Strings_fr-FR.js",
61 "-- # Clipperz/PM/Strings/Strings_de-DE.js", 64 "-- # Clipperz/PM/Strings/Strings_de-DE.js",
62 "-- # Clipperz/PM/Strings/Strings_el-GR.js", 65 "-- # Clipperz/PM/Strings/Strings_el-GR.js",
63 "-- # Clipperz/PM/Strings/Strings_ru-RU.js", 66 "-- # Clipperz/PM/Strings/Strings_ru-RU.js",
64 "-- # Clipperz/PM/Strings/Strings_he-IL.js", 67 "-- # Clipperz/PM/Strings/Strings_he-IL.js",
65 "Clipperz/PM/Strings.js", 68 "Clipperz/PM/Strings.js",
66 "-- Clipperz/PM/Strings/MessagePanelConfigurations.js", 69 "-- Clipperz/PM/Strings/MessagePanelConfigurations.js",
67 70
68 "Clipperz/PM/Date.js", 71 "Clipperz/PM/Date.js",
69 72
70 "Clipperz/PM/Toll.js", 73 "Clipperz/PM/Toll.js",
71 "Clipperz/PM/Proxy.js", 74 "Clipperz/PM/Proxy.js",
72 "Clipperz/PM/Proxy/Proxy.JSON.js", 75 "Clipperz/PM/Proxy/Proxy.JSON.js",
73 "Clipperz/PM/Proxy/Proxy.Offline.js", 76 "Clipperz/PM/Proxy/Proxy.Offline.js",
74 "Clipperz/PM/Proxy/Proxy.Offline.DataStore.js", 77 "Clipperz/PM/Proxy/Proxy.Offline.DataStore.js",
75 "Clipperz/PM/Connection.js", 78 "Clipperz/PM/Connection.js",
76 "Clipperz/PM/Crypto.js", 79 "Clipperz/PM/Crypto.js",
77 "Clipperz/PM/BookmarkletProcessor.js", 80 "Clipperz/PM/BookmarkletProcessor.js",
78 81
79 "Clipperz/PM/DataModel/EncryptedRemoteObject.js", 82 "Clipperz/PM/DataModel/EncryptedRemoteObject.js",
80 "Clipperz/PM/DataModel/User.js", 83 "Clipperz/PM/DataModel/User.js",
81 "Clipperz/PM/DataModel/User.Header.Legacy.js", 84 "Clipperz/PM/DataModel/User.Header.Legacy.js",
82 "Clipperz/PM/DataModel/User.Header.RecordIndex.js", 85 "Clipperz/PM/DataModel/User.Header.RecordIndex.js",
83 "Clipperz/PM/DataModel/User.Header.Preferences.js", 86 "Clipperz/PM/DataModel/User.Header.Preferences.js",
84 "Clipperz/PM/DataModel/User.Header.OneTimePasswords.js", 87 "Clipperz/PM/DataModel/User.Header.OneTimePasswords.js",
85 "Clipperz/PM/DataModel/Record.js", 88 "Clipperz/PM/DataModel/Record.js",
86 "Clipperz/PM/DataModel/Record.Version.js", 89 "Clipperz/PM/DataModel/Record.Version.js",
87 "Clipperz/PM/DataModel/Record.Version.Field.js", 90 "Clipperz/PM/DataModel/Record.Version.Field.js",
88 "Clipperz/PM/DataModel/DirectLogin.js", 91 "Clipperz/PM/DataModel/DirectLogin.js",
89 "Clipperz/PM/DataModel/DirectLoginInput.js", 92 "Clipperz/PM/DataModel/DirectLoginInput.js",
90 "Clipperz/PM/DataModel/DirectLoginBinding.js", 93 "Clipperz/PM/DataModel/DirectLoginBinding.js",
91 "Clipperz/PM/DataModel/DirectLoginFormValue.js", 94 "Clipperz/PM/DataModel/DirectLoginFormValue.js",
92 "Clipperz/PM/DataModel/OneTimePassword.js", 95 "Clipperz/PM/DataModel/OneTimePassword.js",
93 96
94 "Clipperz/PM/UI/Canvas/Marks/exclamationMark.js", 97 "Clipperz/PM/UI/Canvas/Marks/exclamationMark.js",
95 "Clipperz/PM/UI/Canvas/Marks/questionMark.js", 98 "Clipperz/PM/UI/Canvas/Marks/questionMark.js",
96 "Clipperz/PM/UI/Canvas/Marks/info.js", 99 "Clipperz/PM/UI/Canvas/Marks/info.js",
97 100
98 "Clipperz/PM/UI/Canvas/Features/store.js", 101 "Clipperz/PM/UI/Canvas/Features/store.js",
99 "Clipperz/PM/UI/Canvas/Features/protect.js", 102 "Clipperz/PM/UI/Canvas/Features/protect.js",
100 "Clipperz/PM/UI/Canvas/Features/directLogin.js", 103 "Clipperz/PM/UI/Canvas/Features/directLogin.js",
101 "Clipperz/PM/UI/Canvas/Features/share.js", 104 "Clipperz/PM/UI/Canvas/Features/share.js",
102 105
103 "Clipperz/PM/UI/Canvas/Star/normal.js", 106 "Clipperz/PM/UI/Canvas/Star/normal.js",
104 107
105 "Clipperz/PM/UI/Canvas/CoverActions/look.js", 108 "Clipperz/PM/UI/Canvas/CoverActions/look.js",
106 "Clipperz/PM/UI/Canvas/CoverActions/download.js", 109 "Clipperz/PM/UI/Canvas/CoverActions/download.js",
107 110
108 "Clipperz/PM/UI/Canvas/Tips/open.js", 111 "Clipperz/PM/UI/Canvas/Tips/open.js",
109 "Clipperz/PM/UI/Canvas/Tips/close.js", 112 "Clipperz/PM/UI/Canvas/Tips/close.js",
110 113
111 "Clipperz/PM/UI/Canvas/RegisterButton/normal.js", 114 "Clipperz/PM/UI/Canvas/RegisterButton/normal.js",
112 115
113 "Clipperz/PM/UI/Canvas/Logo/normal.js", 116 "Clipperz/PM/UI/Canvas/Logo/normal.js",
114 117
115 "Clipperz/PM/UI/Canvas/GraphicFunctions.js", 118 "Clipperz/PM/UI/Canvas/GraphicFunctions.js",
116 119
117 "Clipperz/PM/UI/Common/Components/BaseComponent.js", 120 "Clipperz/PM/UI/Common/Components/BaseComponent.js",
118 "Clipperz/PM/UI/Common/Components/Button.js", 121 "Clipperz/PM/UI/Common/Components/Button.js",
119 "Clipperz/PM/UI/Common/Components/ComponentSlot.js", 122 "Clipperz/PM/UI/Common/Components/ComponentSlot.js",
120 "Clipperz/PM/UI/Common/Components/FaviconComponent.js", 123 "Clipperz/PM/UI/Common/Components/FaviconComponent.js",
121 "Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js", 124 "Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js",
122 "Clipperz/PM/UI/Common/Components/ProgressBar.js", 125 "Clipperz/PM/UI/Common/Components/ProgressBar.js",
123 "Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js", 126 "Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js",
124 "Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js", 127 "Clipperz/PM/UI/Common/Components/MessagePanelWithProgressBar.js",
125 "Clipperz/PM/UI/Common/Components/TabPanelComponent.js", 128 "Clipperz/PM/UI/Common/Components/TabPanelComponent.js",
126 "Clipperz/PM/UI/Common/Components/Tooltip.js", 129 "Clipperz/PM/UI/Common/Components/Tooltip.js",
127 "Clipperz/PM/UI/Common/Components/TranslatorWidget.js", 130 "Clipperz/PM/UI/Common/Components/TranslatorWidget.js",
128 131
129 "Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js", 132 "Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js",
130 "Clipperz/PM/UI/Common/Controllers/ProgressBarController.js", 133 "Clipperz/PM/UI/Common/Controllers/ProgressBarController.js",
131 "Clipperz/PM/UI/Common/Controllers/TabPanelController.js", 134 "Clipperz/PM/UI/Common/Controllers/TabPanelController.js",
132 "Clipperz/PM/UI/Common/Controllers/WizardController.js", 135 "Clipperz/PM/UI/Common/Controllers/WizardController.js",
133 136
134 "Clipperz/PM/UI/Web/Components/Page.js", 137 "Clipperz/PM/UI/Web/Components/Page.js",
135 "Clipperz/PM/UI/Web/Components/PageHeader.js", 138 "Clipperz/PM/UI/Web/Components/PageHeader.js",
136 "Clipperz/PM/UI/Web/Components/PageFooter.js", 139 "Clipperz/PM/UI/Web/Components/PageFooter.js",
137 "Clipperz/PM/UI/Web/Components/LoginPage.js", 140 "Clipperz/PM/UI/Web/Components/LoginPage.js",
138 "Clipperz/PM/UI/Web/Components/LoginForm.js", 141 "Clipperz/PM/UI/Web/Components/LoginForm.js",
139 "Clipperz/PM/UI/Web/Components/LoginProgress.js", 142 "Clipperz/PM/UI/Web/Components/LoginProgress.js",
140 "Clipperz/PM/UI/Web/Components/AppPage.js", 143 "Clipperz/PM/UI/Web/Components/AppPage.js",
141 "Clipperz/PM/UI/Web/Components/UserInfoBox.js", 144 "Clipperz/PM/UI/Web/Components/UserInfoBox.js",
142 "Clipperz/PM/UI/Web/Components/TabSidePanel.js", 145 "Clipperz/PM/UI/Web/Components/TabSidePanel.js",
143 "Clipperz/PM/UI/Web/Components/GridComponent.js", 146 "Clipperz/PM/UI/Web/Components/GridComponent.js",
144 147
145 "Clipperz/PM/UI/Web/Components/ColumnManager.js", 148 "Clipperz/PM/UI/Web/Components/ColumnManager.js",
146 "Clipperz/PM/UI/Web/Components/TextColumnManager.js", 149 "Clipperz/PM/UI/Web/Components/TextColumnManager.js",
147 "Clipperz/PM/UI/Web/Components/FaviconColumnManager.js", 150 "Clipperz/PM/UI/Web/Components/FaviconColumnManager.js",
148 "Clipperz/PM/UI/Web/Components/ImageColumnManager.js", 151 "Clipperz/PM/UI/Web/Components/ImageColumnManager.js",
149 "Clipperz/PM/UI/Web/Components/DateColumnManager.js", 152 "Clipperz/PM/UI/Web/Components/DateColumnManager.js",
150 "Clipperz/PM/UI/Web/Components/LinkColumnManager.js", 153 "Clipperz/PM/UI/Web/Components/LinkColumnManager.js",
151 "Clipperz/PM/UI/Web/Components/DirectLoginColumnManager.js", 154 "Clipperz/PM/UI/Web/Components/DirectLoginColumnManager.js",
152 "Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js", 155 "Clipperz/PM/UI/Web/Components/DirectLoginsColumnManager.js",
153 "Clipperz/PM/UI/Web/Components/DeleteObjectColumnManager.js", 156 "Clipperz/PM/UI/Web/Components/DeleteObjectColumnManager.js",
154 "Clipperz/PM/UI/Web/Components/CreateNewCardSplashComponent.js", 157 "Clipperz/PM/UI/Web/Components/CreateNewCardSplashComponent.js",
155 158
156 "Clipperz/PM/UI/Web/Components/AccountPanel.js", 159 "Clipperz/PM/UI/Web/Components/AccountPanel.js",
157 "Clipperz/PM/UI/Web/Components/DataPanel.js", 160 "Clipperz/PM/UI/Web/Components/DataPanel.js",
158 "Clipperz/PM/UI/Web/Components/ToolsPanel.js", 161 "Clipperz/PM/UI/Web/Components/ToolsPanel.js",
159 "Clipperz/PM/UI/Web/Components/RulerComponent.js", 162 "Clipperz/PM/UI/Web/Components/RulerComponent.js",
160 "Clipperz/PM/UI/Web/Components/CardDialogComponent.js", 163 "Clipperz/PM/UI/Web/Components/CardDialogComponent.js",
161 "Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js", 164 "Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js",
162 "Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js", 165 "Clipperz/PM/UI/Web/Components/CardDialogRecordDirectLoginComponent.js",
163 "Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js", 166 "Clipperz/PM/UI/Web/Components/DirectLoginEditingComponent.js",
164 "Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js", 167 "Clipperz/PM/UI/Web/Components/DirectLoginEditingBindingComponent.js",
165 "Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js", 168 "Clipperz/PM/UI/Web/Components/DirectLoginEditingFormValueComponent.js",
166 "Clipperz/PM/UI/Web/Components/BookmarkletComponent.js", 169 "Clipperz/PM/UI/Web/Components/BookmarkletComponent.js",
167 "Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js", 170 "Clipperz/PM/UI/Web/Components/UnlockPasswordComponent.js",
168 "Clipperz/PM/UI/Web/Components/NewUserCreationComponent.js", 171 "Clipperz/PM/UI/Web/Components/NewUserCreationComponent.js",
169 "Clipperz/PM/UI/Web/Components/PasswordTooltip.js", 172 "Clipperz/PM/UI/Web/Components/PasswordTooltip.js",
170 173
171 "Clipperz/PM/UI/Web/Controllers/MainController.js", 174 "Clipperz/PM/UI/Web/Controllers/MainController.js",
172 "Clipperz/PM/UI/Web/Controllers/LoginController.js", 175 "Clipperz/PM/UI/Web/Controllers/LoginController.js",
173 "Clipperz/PM/UI/Web/Controllers/AppController.js", 176 "Clipperz/PM/UI/Web/Controllers/AppController.js",
174 "Clipperz/PM/UI/Web/Controllers/FilterController.js", 177 "Clipperz/PM/UI/Web/Controllers/FilterController.js",
175 "Clipperz/PM/UI/Web/Controllers/GridController.js", 178 "Clipperz/PM/UI/Web/Controllers/GridController.js",
176 "Clipperz/PM/UI/Web/Controllers/CardsController.js", 179 "Clipperz/PM/UI/Web/Controllers/CardsController.js",
177 "Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js", 180 "Clipperz/PM/UI/Web/Controllers/DirectLoginsController.js",
178 "Clipperz/PM/UI/Web/Controllers/CardDialogController.js", 181 "Clipperz/PM/UI/Web/Controllers/CardDialogController.js",
179 "Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js", 182 "Clipperz/PM/UI/Web/Controllers/DirectLoginWizardController.js",
180 "Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js", 183 "Clipperz/PM/UI/Web/Controllers/NewUserWizardController.js",
181 184
182 "main.js" 185 "main.js"
183 ], 186 ],
184 187
185 "css": [ 188 "css": [
186 "web.css" 189 "web.css"
187 ] 190 ]
188} \ No newline at end of file 191} \ No newline at end of file
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/AES.html b/frontend/gamma/tests/tests/Clipperz/Crypto/AES.html
index 828ccb8..16f64d0 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/AES.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/AES.html
@@ -1,287 +1,286 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.Crypto.AES_v3 - TEST</title> 28 <title>Clipperz.Crypto.AES_v3 - TEST</title>
29 29
30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
31 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
32 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
33 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
34 33
35 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script> 34 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
36 35
37 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
41 40
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
44 43
45</head> 44</head>
46<body> 45<body>
47<pre id="test"> 46<pre id="test">
48<script type="text/javascript"> 47<script type="text/javascript">
49 48
50try { 49try {
51 var block; 50 var block;
52 var keyValue; 51 var keyValue;
53 varkey; 52 varkey;
54 var encryptedBlock; 53 var encryptedBlock;
55 var startTime, endTime; 54 var startTime, endTime;
56 55
57 startTime = new Date(); 56 startTime = new Date();
58 57
59 keyValue = new Clipperz.ByteArray("0x00010203050607080a0b0c0d0f10111214151617191a1b1c1e1f202123242526"); 58 keyValue = new Clipperz.ByteArray("0x00010203050607080a0b0c0d0f10111214151617191a1b1c1e1f202123242526");
60 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 59 key = new Clipperz.Crypto.AES.Key({key:keyValue});
61 block = new Clipperz.ByteArray("0x834eadfccac7e1b30664b1aba44815ab"); 60 block = new Clipperz.ByteArray("0x834eadfccac7e1b30664b1aba44815ab");
62 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 61 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
63 is(encryptedBlock.toHexString(), "0x1946dabf6a03a2a2c3d0b05080aed6fc", "Test 1"); 62 is(encryptedBlock.toHexString(), "0x1946dabf6a03a2a2c3d0b05080aed6fc", "Test 1");
64 63
65 keyValue = new Clipperz.ByteArray("0x28292a2b2d2e2f30323334353738393a3c3d3e3f41424344464748494b4c4d4e"); 64 keyValue = new Clipperz.ByteArray("0x28292a2b2d2e2f30323334353738393a3c3d3e3f41424344464748494b4c4d4e");
66 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 65 key = new Clipperz.Crypto.AES.Key({key:keyValue});
67 block = new Clipperz.ByteArray("0xd9dc4dba3021b05d67c0518f72b62bf1"); 66 block = new Clipperz.ByteArray("0xd9dc4dba3021b05d67c0518f72b62bf1");
68 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 67 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
69 is(encryptedBlock.toHexString(), "0x5ed301d747d3cc715445ebdec62f2fb4", "Test 2"); 68 is(encryptedBlock.toHexString(), "0x5ed301d747d3cc715445ebdec62f2fb4", "Test 2");
70 69
71 keyValue = new Clipperz.ByteArray("0x50515253555657585a5b5c5d5f60616264656667696a6b6c6e6f707173747576"); 70 keyValue = new Clipperz.ByteArray("0x50515253555657585a5b5c5d5f60616264656667696a6b6c6e6f707173747576");
72 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 71 key = new Clipperz.Crypto.AES.Key({key:keyValue});
73 block = new Clipperz.ByteArray("0xa291d86301a4a739f7392173aa3c604c"); 72 block = new Clipperz.ByteArray("0xa291d86301a4a739f7392173aa3c604c");
74 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 73 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
75 is(encryptedBlock.toHexString(), "0x6585c8f43d13a6beab6419fc5935b9d0", "Test 3"); 74 is(encryptedBlock.toHexString(), "0x6585c8f43d13a6beab6419fc5935b9d0", "Test 3");
76 75
77 keyValue = new Clipperz.ByteArray("0x78797a7b7d7e7f80828384858788898a8c8d8e8f91929394969798999b9c9d9e"); 76 keyValue = new Clipperz.ByteArray("0x78797a7b7d7e7f80828384858788898a8c8d8e8f91929394969798999b9c9d9e");
78 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 77 key = new Clipperz.Crypto.AES.Key({key:keyValue});
79 block = new Clipperz.ByteArray("0x4264b2696498de4df79788a9f83e9390"); 78 block = new Clipperz.ByteArray("0x4264b2696498de4df79788a9f83e9390");
80 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 79 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
81 is(encryptedBlock.toHexString(), "0x2a5b56a596680fcc0e05f5e0f151ecae", "Test 4"); 80 is(encryptedBlock.toHexString(), "0x2a5b56a596680fcc0e05f5e0f151ecae", "Test 4");
82 81
83 keyValue = new Clipperz.ByteArray("0xa0a1a2a3a5a6a7a8aaabacadafb0b1b2b4b5b6b7b9babbbcbebfc0c1c3c4c5c6"); 82 keyValue = new Clipperz.ByteArray("0xa0a1a2a3a5a6a7a8aaabacadafb0b1b2b4b5b6b7b9babbbcbebfc0c1c3c4c5c6");
84 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 83 key = new Clipperz.Crypto.AES.Key({key:keyValue});
85 block = new Clipperz.ByteArray("0xee9932b3721804d5a83ef5949245b6f6"); 84 block = new Clipperz.ByteArray("0xee9932b3721804d5a83ef5949245b6f6");
86 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 85 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
87 is(encryptedBlock.toHexString(), "0xf5d6ff414fd2c6181494d20c37f2b8c4", "Test 5"); 86 is(encryptedBlock.toHexString(), "0xf5d6ff414fd2c6181494d20c37f2b8c4", "Test 5");
88 87
89 keyValue = new Clipperz.ByteArray("0xc8c9cacbcdcecfd0d2d3d4d5d7d8d9dadcdddedfe1e2e3e4e6e7e8e9ebecedee"); 88 keyValue = new Clipperz.ByteArray("0xc8c9cacbcdcecfd0d2d3d4d5d7d8d9dadcdddedfe1e2e3e4e6e7e8e9ebecedee");
90 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 89 key = new Clipperz.Crypto.AES.Key({key:keyValue});
91 block = new Clipperz.ByteArray("0xe6248f55c5fdcbca9cbbb01c88a2ea77"); 90 block = new Clipperz.ByteArray("0xe6248f55c5fdcbca9cbbb01c88a2ea77");
92 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 91 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
93 is(encryptedBlock.toHexString(), "0x85399c01f59fffb5204f19f8482f00b8", "Test 6"); 92 is(encryptedBlock.toHexString(), "0x85399c01f59fffb5204f19f8482f00b8", "Test 6");
94 93
95 keyValue = new Clipperz.ByteArray("0xf0f1f2f3f5f6f7f8fafbfcfdfe01000204050607090a0b0c0e0f101113141516"); 94 keyValue = new Clipperz.ByteArray("0xf0f1f2f3f5f6f7f8fafbfcfdfe01000204050607090a0b0c0e0f101113141516");
96 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 95 key = new Clipperz.Crypto.AES.Key({key:keyValue});
97 block = new Clipperz.ByteArray("0xb8358e41b9dff65fd461d55a99266247"); 96 block = new Clipperz.ByteArray("0xb8358e41b9dff65fd461d55a99266247");
98 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 97 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
99 is(encryptedBlock.toHexString(), "0x92097b4c88a041ddf98144bc8d22e8e7", "Test 7"); 98 is(encryptedBlock.toHexString(), "0x92097b4c88a041ddf98144bc8d22e8e7", "Test 7");
100 99
101 keyValue = new Clipperz.ByteArray("0x18191a1b1d1e1f20222324252728292a2c2d2e2f31323334363738393b3c3d3e"); 100 keyValue = new Clipperz.ByteArray("0x18191a1b1d1e1f20222324252728292a2c2d2e2f31323334363738393b3c3d3e");
102 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 101 key = new Clipperz.Crypto.AES.Key({key:keyValue});
103 block = new Clipperz.ByteArray("0xf0e2d72260af58e21e015ab3a4c0d906"); 102 block = new Clipperz.ByteArray("0xf0e2d72260af58e21e015ab3a4c0d906");
104 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 103 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
105 is(encryptedBlock.toHexString(), "0x89bd5b73b356ab412aef9f76cea2d65c", "Test 8"); 104 is(encryptedBlock.toHexString(), "0x89bd5b73b356ab412aef9f76cea2d65c", "Test 8");
106 105
107 keyValue = new Clipperz.ByteArray("0x40414243454647484a4b4c4d4f50515254555657595a5b5c5e5f606163646566"); 106 keyValue = new Clipperz.ByteArray("0x40414243454647484a4b4c4d4f50515254555657595a5b5c5e5f606163646566");
108 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 107 key = new Clipperz.Crypto.AES.Key({key:keyValue});
109 block = new Clipperz.ByteArray("0x475b8b823ce8893db3c44a9f2a379ff7"); 108 block = new Clipperz.ByteArray("0x475b8b823ce8893db3c44a9f2a379ff7");
110 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 109 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
111 is(encryptedBlock.toHexString(), "0x2536969093c55ff9454692f2fac2f530", "Test 9"); 110 is(encryptedBlock.toHexString(), "0x2536969093c55ff9454692f2fac2f530", "Test 9");
112 111
113 keyValue = new Clipperz.ByteArray("0x68696a6b6d6e6f70727374757778797a7c7d7e7f81828384868788898b8c8d8e"); 112 keyValue = new Clipperz.ByteArray("0x68696a6b6d6e6f70727374757778797a7c7d7e7f81828384868788898b8c8d8e");
114 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 113 key = new Clipperz.Crypto.AES.Key({key:keyValue});
115 block = new Clipperz.ByteArray("0x688f5281945812862f5f3076cf80412f"); 114 block = new Clipperz.ByteArray("0x688f5281945812862f5f3076cf80412f");
116 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues())); 115 encryptedBlock = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(key, block.arrayValues()));
117 is(encryptedBlock.toHexString(), "0x07fc76a872843f3f6e0081ee9396d637", "Test 10"); 116 is(encryptedBlock.toHexString(), "0x07fc76a872843f3f6e0081ee9396d637", "Test 10");
118 117
119 //------------------------------------------------------------------------- 118 //-------------------------------------------------------------------------
120 // 119 //
121 // Key expansion 120 // Key expansion
122 // 121 //
123 //------------------------------------------------------------------------- 122 //-------------------------------------------------------------------------
124 //test vector: http://en.wikipedia.org/wiki/Rijndael_key_schedule#Test_vectors 123 //test vector: http://en.wikipedia.org/wiki/Rijndael_key_schedule#Test_vectors
125 124
126 keyValue = new Clipperz.ByteArray("0x0000000000000000000000000000000012345678"); 125 keyValue = new Clipperz.ByteArray("0x0000000000000000000000000000000012345678");
127 try { 126 try {
128 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 127 key = new Clipperz.Crypto.AES.Key({key:keyValue});
129 is(true, false, "Unsupported key size"); 128 is(true, false, "Unsupported key size");
130 } catch (exception) { 129 } catch (exception) {
131 is(true, true, "Unsupported key size"); 130 is(true, true, "Unsupported key size");
132 } 131 }
133 132
134 keyValue = new Clipperz.ByteArray("0x00000000000000000000000000000000"); 133 keyValue = new Clipperz.ByteArray("0x00000000000000000000000000000000");
135 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 134 key = new Clipperz.Crypto.AES.Key({key:keyValue});
136 is(key.stretchedKey().toHexString(), 135 is(key.stretchedKey().toHexString(),
137 "0x" +"00000000000000000000000000000000" + 136 "0x" +"00000000000000000000000000000000" +
138 "62636363626363636263636362636363" + 137 "62636363626363636263636362636363" +
139 "9b9898c9f9fbfbaa9b9898c9f9fbfbaa" + 138 "9b9898c9f9fbfbaa9b9898c9f9fbfbaa" +
140 "90973450696ccffaf2f457330b0fac99" + 139 "90973450696ccffaf2f457330b0fac99" +
141 "ee06da7b876a1581759e42b27e91ee2b" + 140 "ee06da7b876a1581759e42b27e91ee2b" +
142 "7f2e2b88f8443e098dda7cbbf34b9290" + 141 "7f2e2b88f8443e098dda7cbbf34b9290" +
143 "ec614b851425758c99ff09376ab49ba7" + 142 "ec614b851425758c99ff09376ab49ba7" +
144 "217517873550620bacaf6b3cc61bf09b" + 143 "217517873550620bacaf6b3cc61bf09b" +
145 "0ef903333ba9613897060a04511dfa9f" + 144 "0ef903333ba9613897060a04511dfa9f" +
146 "b1d4d8e28a7db9da1d7bb3de4c664941" + 145 "b1d4d8e28a7db9da1d7bb3de4c664941" +
147 "b4ef5bcb3e92e21123e951cf6f8f188e", 146 "b4ef5bcb3e92e21123e951cf6f8f188e",
148 "Stretched empty key"); 147 "Stretched empty key");
149 148
150 149
151 keyValue = new Clipperz.ByteArray("0x0000000000000000000000000000000000000000000000000000000000000000"); 150 keyValue = new Clipperz.ByteArray("0x0000000000000000000000000000000000000000000000000000000000000000");
152 key = new Clipperz.Crypto.AES.Key({key:keyValue}); 151 key = new Clipperz.Crypto.AES.Key({key:keyValue});
153 is(key.stretchedKey().toHexString(), 152 is(key.stretchedKey().toHexString(),
154 "0x" +"00000000000000000000000000000000" + 153 "0x" +"00000000000000000000000000000000" +
155 "00000000000000000000000000000000" + 154 "00000000000000000000000000000000" +
156 "62636363626363636263636362636363" + 155 "62636363626363636263636362636363" +
157 "aafbfbfbaafbfbfbaafbfbfbaafbfbfb" + 156 "aafbfbfbaafbfbfbaafbfbfbaafbfbfb" +
158 "6f6c6ccf0d0f0fac6f6c6ccf0d0f0fac" + 157 "6f6c6ccf0d0f0fac6f6c6ccf0d0f0fac" +
159 "7d8d8d6ad77676917d8d8d6ad7767691" + 158 "7d8d8d6ad77676917d8d8d6ad7767691" +
160 "5354edc15e5be26d31378ea23c38810e" + 159 "5354edc15e5be26d31378ea23c38810e" +
161 "968a81c141fcf7503c717a3aeb070cab" + 160 "968a81c141fcf7503c717a3aeb070cab" +
162 "9eaa8f28c0f16d45f1c6e3e7cdfe62e9" + 161 "9eaa8f28c0f16d45f1c6e3e7cdfe62e9" +
163 "2b312bdf6acddc8f56bca6b5bdbbaa1e" + 162 "2b312bdf6acddc8f56bca6b5bdbbaa1e" +
164 "6406fd52a4f79017553173f098cf1119" + 163 "6406fd52a4f79017553173f098cf1119" +
165 "6dbba90b0776758451cad331ec71792f" + 164 "6dbba90b0776758451cad331ec71792f" +
166 "e7b0e89c4347788b16760b7b8eb91a62" + 165 "e7b0e89c4347788b16760b7b8eb91a62" +
167 "74ed0ba1739b7e252251ad14ce20d43b" + 166 "74ed0ba1739b7e252251ad14ce20d43b" +
168 "10f80a1753bf729c45c979e7cb706385", 167 "10f80a1753bf729c45c979e7cb706385",
169 "Stretched empty key"); 168 "Stretched empty key");
170 169
171 var roundIndex; 170 var roundIndex;
172 171
173 roundIndex = 0; 172 roundIndex = 0;
174 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x00000000000000000000000000000000", "empty key, subKeyAtRound(0)"); 173 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x00000000000000000000000000000000", "empty key, subKeyAtRound(0)");
175 roundIndex = 1; 174 roundIndex = 1;
176 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x00000000000000000000000000000000", "empty key, subKeyAtRound(1)"); 175 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x00000000000000000000000000000000", "empty key, subKeyAtRound(1)");
177 roundIndex = 2; 176 roundIndex = 2;
178 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x62636363626363636263636362636363", "empty key, subKeyAtRound(2)"); 177 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x62636363626363636263636362636363", "empty key, subKeyAtRound(2)");
179 roundIndex = 3; 178 roundIndex = 3;
180 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0xaafbfbfbaafbfbfbaafbfbfbaafbfbfb", "empty key, subKeyAtRound(3)"); 179 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0xaafbfbfbaafbfbfbaafbfbfbaafbfbfb", "empty key, subKeyAtRound(3)");
181 roundIndex = 4; 180 roundIndex = 4;
182 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6f6c6ccf0d0f0fac6f6c6ccf0d0f0fac", "empty key, subKeyAtRound(4)"); 181 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6f6c6ccf0d0f0fac6f6c6ccf0d0f0fac", "empty key, subKeyAtRound(4)");
183 roundIndex = 5; 182 roundIndex = 5;
184 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x7d8d8d6ad77676917d8d8d6ad7767691", "empty key, subKeyAtRound(5)"); 183 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x7d8d8d6ad77676917d8d8d6ad7767691", "empty key, subKeyAtRound(5)");
185 roundIndex = 6; 184 roundIndex = 6;
186 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x5354edc15e5be26d31378ea23c38810e", "empty key, subKeyAtRound(6)"); 185 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x5354edc15e5be26d31378ea23c38810e", "empty key, subKeyAtRound(6)");
187 roundIndex = 7; 186 roundIndex = 7;
188 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x968a81c141fcf7503c717a3aeb070cab", "empty key, subKeyAtRound(7)"); 187 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x968a81c141fcf7503c717a3aeb070cab", "empty key, subKeyAtRound(7)");
189 roundIndex = 8; 188 roundIndex = 8;
190 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x9eaa8f28c0f16d45f1c6e3e7cdfe62e9", "empty key, subKeyAtRound(8)"); 189 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x9eaa8f28c0f16d45f1c6e3e7cdfe62e9", "empty key, subKeyAtRound(8)");
191 roundIndex = 9; 190 roundIndex = 9;
192 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x2b312bdf6acddc8f56bca6b5bdbbaa1e", "empty key, subKeyAtRound(9)"); 191 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x2b312bdf6acddc8f56bca6b5bdbbaa1e", "empty key, subKeyAtRound(9)");
193 roundIndex = 10; 192 roundIndex = 10;
194 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6406fd52a4f79017553173f098cf1119", "empty key, subKeyAtRound(10)"); 193 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6406fd52a4f79017553173f098cf1119", "empty key, subKeyAtRound(10)");
195 roundIndex = 11; 194 roundIndex = 11;
196 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6dbba90b0776758451cad331ec71792f", "empty key, subKeyAtRound(11)"); 195 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x6dbba90b0776758451cad331ec71792f", "empty key, subKeyAtRound(11)");
197 roundIndex = 12; 196 roundIndex = 12;
198 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0xe7b0e89c4347788b16760b7b8eb91a62", "empty key, subKeyAtRound(12)"); 197 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0xe7b0e89c4347788b16760b7b8eb91a62", "empty key, subKeyAtRound(12)");
199 roundIndex = 13; 198 roundIndex = 13;
200 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x74ed0ba1739b7e252251ad14ce20d43b", "empty key, subKeyAtRound(13)"); 199 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x74ed0ba1739b7e252251ad14ce20d43b", "empty key, subKeyAtRound(13)");
201 roundIndex = 14; 200 roundIndex = 14;
202 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x10f80a1753bf729c45c979e7cb706385", "empty key, subKeyAtRound(14)"); 201 is(key.stretchedKey().split(roundIndex*16, roundIndex*16 + 16).toHexString(), "0x10f80a1753bf729c45c979e7cb706385", "empty key, subKeyAtRound(14)");
203 202
204 203
205 //------------------------------------------------------------------------- 204 //-------------------------------------------------------------------------
206 // 205 //
207 // Encrypt / decrypt 206 // Encrypt / decrypt
208 // 207 //
209 //------------------------------------------------------------------------- 208 //-------------------------------------------------------------------------
210 // Test vectors:http://www.zvon.org/tmRFC/RFC3686/Output/chapter6.html 209 // Test vectors:http://www.zvon.org/tmRFC/RFC3686/Output/chapter6.html
211 // http://www.cs.utsa.edu/~wagner/laws/AEStestRuns.html 210 // http://www.cs.utsa.edu/~wagner/laws/AEStestRuns.html
212 // http://www.ietf.org/rfc/rfc3686.txt 211 // http://www.ietf.org/rfc/rfc3686.txt
213 212
214 { 213 {
215 // 214 //
216 // http://www.cs.utsa.edu/~wagner/laws/AEStestRuns.html 215 // http://www.cs.utsa.edu/~wagner/laws/AEStestRuns.html
217 // 216 //
218 var key; 217 var key;
219 var plainText; 218 var plainText;
220 var cipherText; 219 var cipherText;
221 var result; 220 var result;
222 221
223 // 222 //
224 //256-bit key size 223 //256-bit key size
225 // 224 //
226 225
227 //Gladman's Test Data, 256-bit key - encrypt 226 //Gladman's Test Data, 256-bit key - encrypt
228 key = new Clipperz.ByteArray("0x2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe", 16); 227 key = new Clipperz.ByteArray("0x2b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfe", 16);
229 plainText = new Clipperz.ByteArray("0x3243f6a8885a308d313198a2e0370734", 16); 228 plainText = new Clipperz.ByteArray("0x3243f6a8885a308d313198a2e0370734", 16);
230 cipherText = new Clipperz.ByteArray("0x1a6e6c2c662e7da6501ffb62bc9e93f3", 16); 229 cipherText = new Clipperz.ByteArray("0x1a6e6c2c662e7da6501ffb62bc9e93f3", 16);
231 230
232 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues())); 231 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
233 is(result.toHexString(), cipherText.toHexString(), "Gladman's Test Data, 256-bit key - encrypt"); 232 is(result.toHexString(), cipherText.toHexString(), "Gladman's Test Data, 256-bit key - encrypt");
234 233
235 //AES Specification Test Data, 256-bit key - encrypt 234 //AES Specification Test Data, 256-bit key - encrypt
236 key = new Clipperz.ByteArray("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", 16); 235 key = new Clipperz.ByteArray("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", 16);
237 plainText = new Clipperz.ByteArray("0x00112233445566778899aabbccddeeff", 16); 236 plainText = new Clipperz.ByteArray("0x00112233445566778899aabbccddeeff", 16);
238 cipherText = new Clipperz.ByteArray("0x8ea2b7ca516745bfeafc49904b496089", 16); 237 cipherText = new Clipperz.ByteArray("0x8ea2b7ca516745bfeafc49904b496089", 16);
239 238
240 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues())); 239 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
241 is(result.toHexString(), cipherText.toHexString(), "AES Specification Test Data, 256-bit key - encrypt"); 240 is(result.toHexString(), cipherText.toHexString(), "AES Specification Test Data, 256-bit key - encrypt");
242 241
243 // 242 //
244 //128-bit key size 243 //128-bit key size
245 // 244 //
246 245
247 //Gladman's Test Data, 128-bit key - encrypt 246 //Gladman's Test Data, 128-bit key - encrypt
248 key = new Clipperz.ByteArray("0x2b7e151628aed2a6abf7158809cf4f3c", 16); 247 key = new Clipperz.ByteArray("0x2b7e151628aed2a6abf7158809cf4f3c", 16);
249 plainText = new Clipperz.ByteArray("0x3243f6a8885a308d313198a2e0370734", 16); 248 plainText = new Clipperz.ByteArray("0x3243f6a8885a308d313198a2e0370734", 16);
250 cipherText = new Clipperz.ByteArray("0x3925841d02dc09fbdc118597196a0b32", 16); 249 cipherText = new Clipperz.ByteArray("0x3925841d02dc09fbdc118597196a0b32", 16);
251 250
252 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues())); 251 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
253 is(result.toHexString(), cipherText.toHexString(), "Gladman's Test Data, 128-bit key - encrypt"); 252 is(result.toHexString(), cipherText.toHexString(), "Gladman's Test Data, 128-bit key - encrypt");
254 253
255 //AES Specification Test Data, 128-bit key - encrypt 254 //AES Specification Test Data, 128-bit key - encrypt
256 key = new Clipperz.ByteArray("0x000102030405060708090a0b0c0d0e0f", 16); 255 key = new Clipperz.ByteArray("0x000102030405060708090a0b0c0d0e0f", 16);
257 plainText = new Clipperz.ByteArray("0x00112233445566778899aabbccddeeff", 16); 256 plainText = new Clipperz.ByteArray("0x00112233445566778899aabbccddeeff", 16);
258 cipherText = new Clipperz.ByteArray("0x69c4e0d86a7b0430d8cdb78070b4c55a", 16); 257 cipherText = new Clipperz.ByteArray("0x69c4e0d86a7b0430d8cdb78070b4c55a", 16);
259 258
260 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues())); 259 result = new Clipperz.ByteArray(Clipperz.Crypto.AES.encryptBlock(new Clipperz.Crypto.AES.Key({key:key}), plainText.arrayValues()));
261 is(result.toHexString(), cipherText.toHexString(), "AES Specification Test Data, 128-bit key - encrypt"); 260 is(result.toHexString(), cipherText.toHexString(), "AES Specification Test Data, 128-bit key - encrypt");
262 261
263 } 262 }
264 263
265 264
266 endTime = new Date(); 265 endTime = new Date();
267 MochiKit.Logging.logDebug("elapsed time: " + (endTime - startTime)); 266 MochiKit.Logging.logDebug("elapsed time: " + (endTime - startTime));
268 267
269//############################################################################# 268//#############################################################################
270 269
271} catch (err) { 270} catch (err) {
272 271
273 var s = "test suite failure!\n"; 272 var s = "test suite failure!\n";
274 var o = {}; 273 var o = {};
275 var k = null; 274 var k = null;
276 for (k in err) { 275 for (k in err) {
277 // ensure unique keys?! 276 // ensure unique keys?!
278 if (!o[k]) { 277 if (!o[k]) {
279 s += k + ": " + err[k] + "\n"; 278 s += k + ": " + err[k] + "\n";
280 o[k] = err[k]; 279 o[k] = err[k];
281 } 280 }
282 } 281 }
283 ok ( false, s ); 282 ok ( false, s );
284} 283}
285 284
286</script> 285</script>
287</pre> 286</pre>
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/AES.performance.html b/frontend/gamma/tests/tests/Clipperz/Crypto/AES.performance.html
index 4817096..a90d815 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/AES.performance.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/AES.performance.html
@@ -1,291 +1,290 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.Crypto.AES_performance - TEST</title> 28 <title>Clipperz.Crypto.AES_performance - TEST</title>
29 29
30 <script> 30 <script>
31 jslog_config_enabled = true; 31 jslog_config_enabled = true;
32 </script> 32 </script>
33 33
34 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 34 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
35 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
36 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 35 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
37 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 36 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
38 37
39 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script> 38 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
40 39
41 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
44 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
46 45
47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 46 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
48 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
49 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 48 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
50 49
51 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 50 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
52 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script> 51 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
53 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script> 52 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
54 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script> 53 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
55 54
56</head> 55</head>
57<body> 56<body>
58<pre id="test"> 57<pre id="test">
59<script type="text/javascript"> 58<script type="text/javascript">
60Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose(); 59Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
61 60
62try { 61try {
63 62
64 var password; 63 var password;
65 varplainText; 64 varplainText;
66 varencryptedText; 65 varencryptedText;
67 var decryptedText; 66 var decryptedText;
68 /* 67 /*
69 password = "trustno1"; 68 password = "trustno1";
70 plainText = "The quick brown fox jumps over the lazy dog"; 69 plainText = "The quick brown fox jumps over the lazy dog";
71//console.profile("encrypt"); 70//console.profile("encrypt");
72 encryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].encrypt(password, plainText); 71 encryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].encrypt(password, plainText);
73//console.profileEnd(); 72//console.profileEnd();
74//console.profile("decrypt"); 73//console.profile("decrypt");
75 decryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].decrypt(password, encryptedText); 74 decryptedText = Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].decrypt(password, encryptedText);
76//console.profileEnd(); 75//console.profileEnd();
77 is(decryptedText, plainText, "simple string encrypted/decrypted"); 76 is(decryptedText, plainText, "simple string encrypted/decrypted");
78*/ 77*/
79 78
80 password = "L7bd9fQMhborMbYcHtlr"; 79 password = "L7bd9fQMhborMbYcHtlr";
81 plainText = {"records":{"f1aac97154a0e52c5e33508afa82df5a9d6dcde24883a240b8c072a3238da0b6":{"label":"imap4all [no]", "key":"f54b5033d1152456acb67974c45ee6771f8411e300c9533359dfacacf60dcbbd", "notes":""}, "c9dae2b7a60b300008306f5ec731b60050250df8f8ff34f7d9cce92762121b99":{"label":"Il manifesto", "key":"6e0ef134503110e72f444e7d102a4b1cc6ae28f2e0b1287c2b1875ff052fc16c", "notes":""}, "70d536c89a86b1aa9e077d6f9c717306a5d6c8d5549789e42dfb4f981484f116":{"label":"OmniGroup applications", "key":"7b432b7dae39ff5951db31947fa721dc012af0da4055760c6df3b02e776ef22c", "notes":"url: http://www.omnigroup.com\n\nLicence owner: Giulio Cesare Solaroli\n\nOmniWeb: EQGP-EMKH-LKWP-MUHQ-OUHL-LDF\nOmniGraffle:\nOmniOutliner:\nOmniDiskSweeper:"}, "111855cedd650dfcbbce597d764583c6b040df4b71f5fa0161fb8d10514ee48f":{"label":"R@cine", "key":"57295772c84669b0a224f435e9b75c797ae5999a2d9473ab50f9384ae54f49d6", "notes":""}, "378a790452de46e1079a99eba2e15094a096b418cccd0262b8b20244eb94d2df":{"label":"NewsGator", "key":"6ee16f6932ee02000c49dbcc685c84074b40d7956e5f4bc1100030a0f9a41f1a", "notes":""}, "30c4f575799fc6908765fc8b54f4a9a483cb32e12aa89feae545976870a9102e":{"label":"GMail - giulio.cesare", "key":"0395efd852b00700bcf78b65350ec15932430df71201d2c53a11b0269b557d1a", "notes":""}, "b2836a864ff081b6f053c3f5f13dfb29c81af33d25a316cdd82af747ea71bea0":{"label":"GMail - clipperz.com", "key":"90d6ae70d89c8211404b6f9d6c70b6b9c113fff74f474a67b34acd9c1c048d1f", "notes":""}, "6ad2cda35f97743cfddf2133cdf3142fe6419e683484531f1ef1e67431f44284":{"label":"Aruba - hosting", "key":"5c7472d24d57391c63ea99ed1fc9de179d225abd335fa65702018cfea6083d47", "notes":""}, "741ce1d21839c69db754309b04ce02fbb4104f6cb87572c056ae4af918420700":{"label":"Aruba - sql hosting", "key":"f6bd942ac3b0b7065771e5197c7499b345a10f7a4843d00c3ba3809d0ea059dc", "notes":""}, "1cef440eecea59f47554aa04b94e18c1d9fc761246b911f89a7da72d544cac48":{"label":"Amazon", "key":"1ae022b4d14b642f113703b2a98931bd892dec2da785ab5ff6fc1d0aac7537f1", "notes":""}, "d34c13773b5d8154355c2605024a1dfaf66279ba0fbe3ac19fc1cbc642278fe4":{"label":"YouTube [no]", "key":"4c6593d4f6448137939b364b84c81501fadb60f7871fe5fa63c93e97bb5c4648", "notes":""}, "5054f0b94cd97610a1bc0ed8671b6fb5b25bf7a5582677059fcaaea75fac27bc":{"label":"DynDns - gcsolaroli", "key":"f8ed9e7a3630deed046eda37ebc63ecb4d63668a2f97224d7628fdc53b242467", "notes":""}, "73fb52ed51533657d6ebb020d5026fb4deb601dadce802de58f7fff4b56e1495":{"label":"DynDns - clipperz", "key":"d8bc295177383a523e67b61b166e0ca956ab4c2ee86800559a009d2716064f6d", "notes":""}, "48d4c0546c032be26ecce4da41e020129afa7fc34cfe164ea72e1c9953d2e6bb":{"label":"Bol.it", "key":"cada5dadeebd8d12190954d21f1a944c8799d034f028be195b448935fcf970c7", "notes":""}, "d62d420db34720ccc054df06b88725ea79020ffa9389ca15e70137fb4dfd0883":{"label":"Freenigma - clipperz.com", "key":"f09cb3790c1110794b834702b8c487c1a42b2508fbe6450a8468477d93790b2e", "notes":""}, "ccd44ae294e7694ea53009c7198506cc0fe3121ad5d9fe2635d247e2afdab2ae":{"label":"Freenigma", "key":"4b05738f6faebc147eac5e425054a91d3cc59dd63844e82d1f0864c0ac8efec7", "notes":""}, "bd5a587bb977a2c728fcd0fa6093dd63a4e62138cf89721115fe45e0396ba5d2":{"label":"clipperz.com - blog", "key":"9cc24328bbce18e8713962428d8123e309a12f7e1d9537bc252e134501734003", "notes":""}, "c2b99939e40d100218baa3ed1cb2a25a5cf726485b0336a0989b104a94157b5f":{"label":"Apple", "key":"75f2651af400629c4e5dd8bcdc3a6c691150d23d6e1a4eb263ff810926d1228f", "notes":""}, "b5bd38d8eb5e23b1354884cc519e05580864fadf74d0a19d2c691cd0c7054d77":{"label":".mac", "key":"5934ae96d2e01282effb368d9086c2ba5d1d856ad91dd6f04f5bace26a1c0cbe", "notes":""}, "ff79a2282cf246add520a3c06e835cf6ffaaae95067d45e8e2e8f44da2501380":{"label":"3nity", "key":"33d84c4a91ab053cbf8115c689ede7e504b81199884de449acc257bea534f57f", "notes":""}, "7b2f2a59ebb34b5a49f20b99b546f08b9f4f62cbefdce9699f8ef7e74aeb0552":{"label":"ACM", "key":"b4976bb0892baba81d628513d191de100d89acd58efbb07c823a5bb4abe48a7a", "notes":""}, "b83a6bac0da3a27eb909d34cbad183e77088952f01d8d5321613b7b01635a020":{"label":"Adobe", "key":"d162bc404994a79ec97e0106c3a4edf2f83aca25def130242e11e95e74bd0aaa", "notes":""}, "befc571e9cda1a7dfb1d15200240ca5170386280ee7be6a12716904cb6d0ea44":{"label":"Adobe Photoshop Elements 3", "key":"18a62c3c2065399819707322f467ff4be030d7939acbe5182c8194599845c428", "notes":"Photoshop Elements 2:\n1057-4312-5223-2206-9509-6837"}, "0424f72608fedc969d64a6d5b4a16dd3ce860a230cd6d87d936439f4dd2aafc7":{"label":"Agatra", "key":"c35158a21b2af75d414232b742ab738d042314e00209f8fca94c8c704c891f23", "notes":""}, "e5e17c29fd598acb4f4c7d621dbdcb045d4d0cabf7d8a19e24420c440cdc3935":{"label":"AIM", "key":"8561ac421d845921978387b5e6b362750b57ed08feda8ec12b9378b69f67ceff", "notes":""}, "de890eb76a4b0cabd4ffd490adad1ff1b73238c7b5ee6dde1a2aeab2d03ebe93":{"label":"Anna Vespignani", "key":"79a970af0d2d30643dc2db4d16757395c1f22c311919036c2a22b7581982144a", "notes":""}, "0dc8d3989d0b35d672c012057d3eb7b111f16e79329e08a9ffb31ac7accbab21":{"label":"Bloglines", "key":"fe81f4df8c42fd81c830f9af408e9b074e77fd430e26d0ee285844fe3b092aec", "notes":""}, "85a40a322a59c80cb46519900269dcc7cf6947213d03dfc9371dd1930373a65b":{"label":"Bow.it", "key":"64a1a9fec99c9238dc8180a01484a1ccf5f50fcd6e9a95a52b8b49fb9ca00bdc", "notes":""}, "60308062a1848a301641a74712d220eef191a280ba0a8355992f0e61ed793811":{"label":"GMail - feedback", "key":"fad310cb2e6152c3faf78b7183c99f3044f5d31ee364068b80580c271a7784ef", "notes":""}, "257ac2da79ee1cd46dfa214d91f5ece213b6bbade28d1ee71495c81a3d7e033a":{"label":"Fineco", "key":"8f99de2635b5dad7987180bc0bff49947eb37cc75d6a5d1ee1f13ed7567465a3", "notes":""}, "78261622810232b6da5efcd52b1c9b0bd87c62517bf4df25323ca6a0b49d84ec":{"label":"mon.itor.us", "key":"d2aa7164007c5deac8bb73580a6ab0d051f747e801ecd30284eff725d0ffaba2", "notes":""}, "4b78dc0376d07e57d77b4c7318d2f222956adb6ff7360b73e60b8bb8b85f3d11":{"label":"Lamba Probe - forum", "key":"f73906817fddba4d8f816334cb2fd0cd5ae91bc29bce6a69fdd5cf98fc96911f", "notes":""}, "78ca2c85908275d788c2f7dd0306ca5e03b83637bb3812272b697e12e9dbf941":{"label":"MeasureMap", "key":"2385ce9536ebb7863b6a4c8b1f5c428587e4d6420a4bbcd31b935cb00bbd768e", "notes":""}, "4c2c7f0d733b647e6f388c9a4590a2a864cd2de259b66aba9b3cf92bdc3cf9bc":{"label":"NGI - Squillo", "key":"96f20c212be02fb38c8b2dfc83d8e864dd84dcb95297a7fecf9280e1e4dcffe3", "notes":""}, "eaeadf6d36f8ee6916c33b9e5bf480b663dc90c0c7f370ff5a1f2fd998cf1143":{"label":"NGI - F5", "key":"00347769244b208647c24e6a64f8fa4213e97eb2135ecfcb277b341c28616a59", "notes":""}, "19654392222206d60547073209672dde1c743ea371ddc20a2bd8254e561a4ec0":{"label":"CVSdude", "key":"ed0ab5080a29eb1b20927142d21ab8f67b61c2c7b19623bb610af030dfd42c02", "notes":""}, "6b10514d50e745f1dab5a40e8629ecf1a8c78a5d6e3895f3637fb67d2d3f9993":{"label":"Yahoo", "key":"6380a7655cd790d1f1e6f482e92ae04201568ff0cab887e65102e9396df1b86e", "notes":"note"}}, "directLogins":{"eac496e0b1ec75ea403f821fedc7f51f98dac639713ebe577f969f607a8943f5":{"record":"111855cedd650dfcbbce597d764583c6b040df4b71f5fa0161fb8d10514ee48f", "label":"R@cine - WebMail", "favicon":"http://www.racine.ra.it/favicon.ico"}, "ef564a022630d4395a9ecac854f3b127b3518cec362323ccc605079c0749c152":{"record":"1cef440eecea59f47554aa04b94e18c1d9fc761246b911f89a7da72d544cac48", "label":"Amazon sign in", "favicon":"http://www.amazon.com/favicon.ico"}, "4f14b88a4055ff23a00d625382650888ce9284fe869304775e43e3e33ee5bbb6":{"record":"6ad2cda35f97743cfddf2133cdf3142fe6419e683484531f1ef1e67431f44284", "label":"Aruba - hosting", "favicon":"http://hosting.aruba.it/favicon.ico"}, "e94c0d12d1db0badc31a8bbbbc4b08d2065a39f458462bbff9756f7b5eb7fedf":{"record":"741ce1d21839c69db754309b04ce02fbb4104f6cb87572c056ae4af918420700", "label":"Aruba - sql hosting", "favicon":"http://mysql.aruba.it/favicon.ico"}, "7299249153ef93a44e2f248ca3a73badde56e71d70919bb5637093c2abbe2c9a":{"record":"bd5a587bb977a2c728fcd0fa6093dd63a4e62138cf89721115fe45e0396ba5d2", "label":"clipperz.com - blog", "favicon":"http://www.clipperz.com/favicon.ico"}, "66876dbae68778d4c104bc12f01adcb21d47d9eace8db30ef95f74f461afcb59":{"record":"73fb52ed51533657d6ebb020d5026fb4deb601dadce802de58f7fff4b56e1495", "label":"DynDns - clipperz", "favicon":"http://www.dyndns.com/favicon.ico"}, "a60c65030a1797abde3e2089c3e5de9648f66bf71cebf0b58c26e729ad8d6a45":{"record":"5054f0b94cd97610a1bc0ed8671b6fb5b25bf7a5582677059fcaaea75fac27bc", "label":"DynDns - gcsolaroli", "favicon":"http://www.dyndns.com/favicon.ico"}, "08d6c5dff9fed4a2f237c32dd0a93ac46b2c45370d07f56fa76064be3b8fecbf":{"record":"30c4f575799fc6908765fc8b54f4a9a483cb32e12aa89feae545976870a9102e", "label":"GMail - giulio.cesare", "favicon":"http://www.google.com/favicon.ico"}, "9e75e12f0f52f248cc7ae517869dd7b02303037d32d9fb4fa0ab0e013923c304":{"record":"c9dae2b7a60b300008306f5ec731b60050250df8f8ff34f7d9cce92762121b99", "label":"Il manifesto", "favicon":"http://abbonati.ilmanifesto.it/favicon.ico"}, "935bf9553fbcb85b8bd5b98c6901d7cccb2566b395f192cbea71e7822979aaf2":{"record":"f1aac97154a0e52c5e33508afa82df5a9d6dcde24883a240b8c072a3238da0b6", "label":"Imap4All.com - account", "favicon":"http://www.imap4all.com/favicon.ico"}, "9504205ec29b89e6ccd0f3afc7a447d8891da0c71a0222f1860f98a8f8bc6677":{"record":"f1aac97154a0e52c5e33508afa82df5a9d6dcde24883a240b8c072a3238da0b6", "label":"Imap4all.com - WebMail", "favicon":"http://webmail.imap4all.com/favicon.ico"}, "3d8dd32d2290ca98789c914580ac2436ece97234217a07d752726d2ac48a4ebf":{"record":"d34c13773b5d8154355c2605024a1dfaf66279ba0fbe3ac19fc1cbc642278fe4", "label":"YouTube [no]", "favicon":"http://www.youtube.com/favicon.ico"}, "7c4b6b5a16984c43ed6d99b04ddfa7e00b624de729ec8aaa3d0f539fb67587e2":{"record":"c2b99939e40d100218baa3ed1cb2a25a5cf726485b0336a0989b104a94157b5f", "label":"Apple Store - Italia", "favicon":"http://store.apple.com/favicon.ico"}, "0b9a98262b50f0ebae5af077467bc627619738873690238fd61093ce9922c9f9":{"record":"ff79a2282cf246add520a3c06e835cf6ffaaae95067d45e8e2e8f44da2501380", "label":"3nity", "favicon":"http://www.3nity.de/favicon.ico"}, "aadeb3388629cfc3b15954f26cf284f52e084191dcdf75752dc4c53d2006c5be":{"record":"7b2f2a59ebb34b5a49f20b99b546f08b9f4f62cbefdce9699f8ef7e74aeb0552", "label":"ACM Web Account", "favicon":"http://portal.acm.org/favicon.ico"}, "3d21c71f2e284ec76f1ae0bb990b683979918f758635bb7d008150f4d7b1447d":{"record":"b83a6bac0da3a27eb909d34cbad183e77088952f01d8d5321613b7b01635a020", "label":"Adobe - Sign In", "favicon":"http://www.adobe.com/favicon.ico"}, "e61a331c998804d46044d4c2acaf96c2fce806f6549e1e16c7d2334872a70953":{"record":"0424f72608fedc969d64a6d5b4a16dd3ce860a230cd6d87d936439f4dd2aafc7", "label":"Agatra [no]", "favicon":"http://www.agatra.com/favicon.ico"}, "9bcd99564fda778061246439fa098dcc79de75b16c542f61e6de7d36dbaf97dc":{"record":"e5e17c29fd598acb4f4c7d621dbdcb045d4d0cabf7d8a19e24420c440cdc3935", "label":"AIM [no]", "favicon":"http://my.screenname.aol.com/favicon.ico"}, "c7093f4663c6e0eba941c557cb86da83fc68cbea36c922e168d0867e6cabe9fe":{"record":"0dc8d3989d0b35d672c012057d3eb7b111f16e79329e08a9ffb31ac7accbab21", "label":"Bloglines", "favicon":"http://www.bloglines.com/favicon.ico"}, "915f2e9460f6e54c6137f3876f9179fc8d2162c59f26e12899c2db6b0e70a68f":{"record":"85a40a322a59c80cb46519900269dcc7cf6947213d03dfc9371dd1930373a65b", "label":"Bow.it", "favicon":"http://www.bow.it/favicon.ico"}, "779701af1beb2a91735ba1a2e471b948f0d985bb0df256f5e089291ce3405bd2":{"record":"b2836a864ff081b6f053c3f5f13dfb29c81af33d25a316cdd82af747ea71bea0", "label":"GMail - Clipperz", "favicon":"http://www.google.com/favicon.ico"}, "1c300539a98c874d52134b6b5a591172acc00c0947692f3da284447f7d511eaf":{"record":"60308062a1848a301641a74712d220eef191a280ba0a8355992f0e61ed793811", "label":"GMail - feedback", "favicon":"http://www.google.com/favicon.ico"}, "f9dccdf7a98735fd7a6b5d04c09177005c0de14f8f92b04007f06a281ecdf31e":{"record":"30c4f575799fc6908765fc8b54f4a9a483cb32e12aa89feae545976870a9102e", "label":"Blogger", "favicon":"http://www.google.com/favicon.ico"}, "48497a89f3bfd567758977e1c32b4497d28c843880667ee52fa4cfcb53c5f9e4":{"record":"378a790452de46e1079a99eba2e15094a096b418cccd0262b8b20244eb94d2df", "label":"NewsGator", "favicon":"http://www.newsgator.com/favicon.ico"}, "134cd28f150df4f2a089f4807bb7a35fb7ece22ec41244f72e63f8b43637a4cd":{"record":"4b78dc0376d07e57d77b4c7318d2f222956adb6ff7360b73e60b8bb8b85f3d11", "label":"Lambda Probe - forum", "favicon":"http://www.lambdaprobe.org/favicon.ico"}, "2ab6106a81513b70f1ba0d7c5c3ef54fa6f4bcadf01d2eeaa2b31b9299551398":{"record":"78ca2c85908275d788c2f7dd0306ca5e03b83637bb3812272b697e12e9dbf941", "label":"Measure Map", "favicon":"http://alpha.measuremap.com/favicon.ico"}, "53ccdc41b43da9b018847f9faa8effb35e7a6c6e78a54e9ee7816fc02f0ea63b":{"record":"4c2c7f0d733b647e6f388c9a4590a2a864cd2de259b66aba9b3cf92bdc3cf9bc", "label":"NGI - Squillo", "favicon":"http://www.ngi.it/favicon.ico"}, "ca520e7081fba1df3ef79c3d00266cffc8e4567def29d67ae812b7ed6283fb12":{"record":"eaeadf6d36f8ee6916c33b9e5bf480b663dc90c0c7f370ff5a1f2fd998cf1143", "label":"NGI - F5", "favicon":"http://www.ngi.it/favicon.ico"}, "80e63e135d7abd2b2990f42af4f8d1f8e8b1146aed44dc36975061fbf360a983":{"record":"6b10514d50e745f1dab5a40e8629ecf1a8c78a5d6e3895f3637fb67d2d3f9993", "label":"Yahoo! Mail", "favicon":"http://login.yahoo.com/favicon.ico"}}, "preferences":{"preferredLanguage":"en-US"}}; 80 plainText = {"records":{"f1aac97154a0e52c5e33508afa82df5a9d6dcde24883a240b8c072a3238da0b6":{"label":"imap4all [no]", "key":"f54b5033d1152456acb67974c45ee6771f8411e300c9533359dfacacf60dcbbd", "notes":""}, "c9dae2b7a60b300008306f5ec731b60050250df8f8ff34f7d9cce92762121b99":{"label":"Il manifesto", "key":"6e0ef134503110e72f444e7d102a4b1cc6ae28f2e0b1287c2b1875ff052fc16c", "notes":""}, "70d536c89a86b1aa9e077d6f9c717306a5d6c8d5549789e42dfb4f981484f116":{"label":"OmniGroup applications", "key":"7b432b7dae39ff5951db31947fa721dc012af0da4055760c6df3b02e776ef22c", "notes":"url: http://www.omnigroup.com\n\nLicence owner: Giulio Cesare Solaroli\n\nOmniWeb: EQGP-EMKH-LKWP-MUHQ-OUHL-LDF\nOmniGraffle:\nOmniOutliner:\nOmniDiskSweeper:"}, "111855cedd650dfcbbce597d764583c6b040df4b71f5fa0161fb8d10514ee48f":{"label":"R@cine", "key":"57295772c84669b0a224f435e9b75c797ae5999a2d9473ab50f9384ae54f49d6", "notes":""}, "378a790452de46e1079a99eba2e15094a096b418cccd0262b8b20244eb94d2df":{"label":"NewsGator", "key":"6ee16f6932ee02000c49dbcc685c84074b40d7956e5f4bc1100030a0f9a41f1a", "notes":""}, "30c4f575799fc6908765fc8b54f4a9a483cb32e12aa89feae545976870a9102e":{"label":"GMail - giulio.cesare", "key":"0395efd852b00700bcf78b65350ec15932430df71201d2c53a11b0269b557d1a", "notes":""}, "b2836a864ff081b6f053c3f5f13dfb29c81af33d25a316cdd82af747ea71bea0":{"label":"GMail - clipperz.com", "key":"90d6ae70d89c8211404b6f9d6c70b6b9c113fff74f474a67b34acd9c1c048d1f", "notes":""}, "6ad2cda35f97743cfddf2133cdf3142fe6419e683484531f1ef1e67431f44284":{"label":"Aruba - hosting", "key":"5c7472d24d57391c63ea99ed1fc9de179d225abd335fa65702018cfea6083d47", "notes":""}, "741ce1d21839c69db754309b04ce02fbb4104f6cb87572c056ae4af918420700":{"label":"Aruba - sql hosting", "key":"f6bd942ac3b0b7065771e5197c7499b345a10f7a4843d00c3ba3809d0ea059dc", "notes":""}, "1cef440eecea59f47554aa04b94e18c1d9fc761246b911f89a7da72d544cac48":{"label":"Amazon", "key":"1ae022b4d14b642f113703b2a98931bd892dec2da785ab5ff6fc1d0aac7537f1", "notes":""}, "d34c13773b5d8154355c2605024a1dfaf66279ba0fbe3ac19fc1cbc642278fe4":{"label":"YouTube [no]", "key":"4c6593d4f6448137939b364b84c81501fadb60f7871fe5fa63c93e97bb5c4648", "notes":""}, "5054f0b94cd97610a1bc0ed8671b6fb5b25bf7a5582677059fcaaea75fac27bc":{"label":"DynDns - gcsolaroli", "key":"f8ed9e7a3630deed046eda37ebc63ecb4d63668a2f97224d7628fdc53b242467", "notes":""}, "73fb52ed51533657d6ebb020d5026fb4deb601dadce802de58f7fff4b56e1495":{"label":"DynDns - clipperz", "key":"d8bc295177383a523e67b61b166e0ca956ab4c2ee86800559a009d2716064f6d", "notes":""}, "48d4c0546c032be26ecce4da41e020129afa7fc34cfe164ea72e1c9953d2e6bb":{"label":"Bol.it", "key":"cada5dadeebd8d12190954d21f1a944c8799d034f028be195b448935fcf970c7", "notes":""}, "d62d420db34720ccc054df06b88725ea79020ffa9389ca15e70137fb4dfd0883":{"label":"Freenigma - clipperz.com", "key":"f09cb3790c1110794b834702b8c487c1a42b2508fbe6450a8468477d93790b2e", "notes":""}, "ccd44ae294e7694ea53009c7198506cc0fe3121ad5d9fe2635d247e2afdab2ae":{"label":"Freenigma", "key":"4b05738f6faebc147eac5e425054a91d3cc59dd63844e82d1f0864c0ac8efec7", "notes":""}, "bd5a587bb977a2c728fcd0fa6093dd63a4e62138cf89721115fe45e0396ba5d2":{"label":"clipperz.com - blog", "key":"9cc24328bbce18e8713962428d8123e309a12f7e1d9537bc252e134501734003", "notes":""}, "c2b99939e40d100218baa3ed1cb2a25a5cf726485b0336a0989b104a94157b5f":{"label":"Apple", "key":"75f2651af400629c4e5dd8bcdc3a6c691150d23d6e1a4eb263ff810926d1228f", "notes":""}, "b5bd38d8eb5e23b1354884cc519e05580864fadf74d0a19d2c691cd0c7054d77":{"label":".mac", "key":"5934ae96d2e01282effb368d9086c2ba5d1d856ad91dd6f04f5bace26a1c0cbe", "notes":""}, "ff79a2282cf246add520a3c06e835cf6ffaaae95067d45e8e2e8f44da2501380":{"label":"3nity", "key":"33d84c4a91ab053cbf8115c689ede7e504b81199884de449acc257bea534f57f", "notes":""}, "7b2f2a59ebb34b5a49f20b99b546f08b9f4f62cbefdce9699f8ef7e74aeb0552":{"label":"ACM", "key":"b4976bb0892baba81d628513d191de100d89acd58efbb07c823a5bb4abe48a7a", "notes":""}, "b83a6bac0da3a27eb909d34cbad183e77088952f01d8d5321613b7b01635a020":{"label":"Adobe", "key":"d162bc404994a79ec97e0106c3a4edf2f83aca25def130242e11e95e74bd0aaa", "notes":""}, "befc571e9cda1a7dfb1d15200240ca5170386280ee7be6a12716904cb6d0ea44":{"label":"Adobe Photoshop Elements 3", "key":"18a62c3c2065399819707322f467ff4be030d7939acbe5182c8194599845c428", "notes":"Photoshop Elements 2:\n1057-4312-5223-2206-9509-6837"}, "0424f72608fedc969d64a6d5b4a16dd3ce860a230cd6d87d936439f4dd2aafc7":{"label":"Agatra", "key":"c35158a21b2af75d414232b742ab738d042314e00209f8fca94c8c704c891f23", "notes":""}, "e5e17c29fd598acb4f4c7d621dbdcb045d4d0cabf7d8a19e24420c440cdc3935":{"label":"AIM", "key":"8561ac421d845921978387b5e6b362750b57ed08feda8ec12b9378b69f67ceff", "notes":""}, "de890eb76a4b0cabd4ffd490adad1ff1b73238c7b5ee6dde1a2aeab2d03ebe93":{"label":"Anna Vespignani", "key":"79a970af0d2d30643dc2db4d16757395c1f22c311919036c2a22b7581982144a", "notes":""}, "0dc8d3989d0b35d672c012057d3eb7b111f16e79329e08a9ffb31ac7accbab21":{"label":"Bloglines", "key":"fe81f4df8c42fd81c830f9af408e9b074e77fd430e26d0ee285844fe3b092aec", "notes":""}, "85a40a322a59c80cb46519900269dcc7cf6947213d03dfc9371dd1930373a65b":{"label":"Bow.it", "key":"64a1a9fec99c9238dc8180a01484a1ccf5f50fcd6e9a95a52b8b49fb9ca00bdc", "notes":""}, "60308062a1848a301641a74712d220eef191a280ba0a8355992f0e61ed793811":{"label":"GMail - feedback", "key":"fad310cb2e6152c3faf78b7183c99f3044f5d31ee364068b80580c271a7784ef", "notes":""}, "257ac2da79ee1cd46dfa214d91f5ece213b6bbade28d1ee71495c81a3d7e033a":{"label":"Fineco", "key":"8f99de2635b5dad7987180bc0bff49947eb37cc75d6a5d1ee1f13ed7567465a3", "notes":""}, "78261622810232b6da5efcd52b1c9b0bd87c62517bf4df25323ca6a0b49d84ec":{"label":"mon.itor.us", "key":"d2aa7164007c5deac8bb73580a6ab0d051f747e801ecd30284eff725d0ffaba2", "notes":""}, "4b78dc0376d07e57d77b4c7318d2f222956adb6ff7360b73e60b8bb8b85f3d11":{"label":"Lamba Probe - forum", "key":"f73906817fddba4d8f816334cb2fd0cd5ae91bc29bce6a69fdd5cf98fc96911f", "notes":""}, "78ca2c85908275d788c2f7dd0306ca5e03b83637bb3812272b697e12e9dbf941":{"label":"MeasureMap", "key":"2385ce9536ebb7863b6a4c8b1f5c428587e4d6420a4bbcd31b935cb00bbd768e", "notes":""}, "4c2c7f0d733b647e6f388c9a4590a2a864cd2de259b66aba9b3cf92bdc3cf9bc":{"label":"NGI - Squillo", "key":"96f20c212be02fb38c8b2dfc83d8e864dd84dcb95297a7fecf9280e1e4dcffe3", "notes":""}, "eaeadf6d36f8ee6916c33b9e5bf480b663dc90c0c7f370ff5a1f2fd998cf1143":{"label":"NGI - F5", "key":"00347769244b208647c24e6a64f8fa4213e97eb2135ecfcb277b341c28616a59", "notes":""}, "19654392222206d60547073209672dde1c743ea371ddc20a2bd8254e561a4ec0":{"label":"CVSdude", "key":"ed0ab5080a29eb1b20927142d21ab8f67b61c2c7b19623bb610af030dfd42c02", "notes":""}, "6b10514d50e745f1dab5a40e8629ecf1a8c78a5d6e3895f3637fb67d2d3f9993":{"label":"Yahoo", "key":"6380a7655cd790d1f1e6f482e92ae04201568ff0cab887e65102e9396df1b86e", "notes":"note"}}, "directLogins":{"eac496e0b1ec75ea403f821fedc7f51f98dac639713ebe577f969f607a8943f5":{"record":"111855cedd650dfcbbce597d764583c6b040df4b71f5fa0161fb8d10514ee48f", "label":"R@cine - WebMail", "favicon":"http://www.racine.ra.it/favicon.ico"}, "ef564a022630d4395a9ecac854f3b127b3518cec362323ccc605079c0749c152":{"record":"1cef440eecea59f47554aa04b94e18c1d9fc761246b911f89a7da72d544cac48", "label":"Amazon sign in", "favicon":"http://www.amazon.com/favicon.ico"}, "4f14b88a4055ff23a00d625382650888ce9284fe869304775e43e3e33ee5bbb6":{"record":"6ad2cda35f97743cfddf2133cdf3142fe6419e683484531f1ef1e67431f44284", "label":"Aruba - hosting", "favicon":"http://hosting.aruba.it/favicon.ico"}, "e94c0d12d1db0badc31a8bbbbc4b08d2065a39f458462bbff9756f7b5eb7fedf":{"record":"741ce1d21839c69db754309b04ce02fbb4104f6cb87572c056ae4af918420700", "label":"Aruba - sql hosting", "favicon":"http://mysql.aruba.it/favicon.ico"}, "7299249153ef93a44e2f248ca3a73badde56e71d70919bb5637093c2abbe2c9a":{"record":"bd5a587bb977a2c728fcd0fa6093dd63a4e62138cf89721115fe45e0396ba5d2", "label":"clipperz.com - blog", "favicon":"http://www.clipperz.com/favicon.ico"}, "66876dbae68778d4c104bc12f01adcb21d47d9eace8db30ef95f74f461afcb59":{"record":"73fb52ed51533657d6ebb020d5026fb4deb601dadce802de58f7fff4b56e1495", "label":"DynDns - clipperz", "favicon":"http://www.dyndns.com/favicon.ico"}, "a60c65030a1797abde3e2089c3e5de9648f66bf71cebf0b58c26e729ad8d6a45":{"record":"5054f0b94cd97610a1bc0ed8671b6fb5b25bf7a5582677059fcaaea75fac27bc", "label":"DynDns - gcsolaroli", "favicon":"http://www.dyndns.com/favicon.ico"}, "08d6c5dff9fed4a2f237c32dd0a93ac46b2c45370d07f56fa76064be3b8fecbf":{"record":"30c4f575799fc6908765fc8b54f4a9a483cb32e12aa89feae545976870a9102e", "label":"GMail - giulio.cesare", "favicon":"http://www.google.com/favicon.ico"}, "9e75e12f0f52f248cc7ae517869dd7b02303037d32d9fb4fa0ab0e013923c304":{"record":"c9dae2b7a60b300008306f5ec731b60050250df8f8ff34f7d9cce92762121b99", "label":"Il manifesto", "favicon":"http://abbonati.ilmanifesto.it/favicon.ico"}, "935bf9553fbcb85b8bd5b98c6901d7cccb2566b395f192cbea71e7822979aaf2":{"record":"f1aac97154a0e52c5e33508afa82df5a9d6dcde24883a240b8c072a3238da0b6", "label":"Imap4All.com - account", "favicon":"http://www.imap4all.com/favicon.ico"}, "9504205ec29b89e6ccd0f3afc7a447d8891da0c71a0222f1860f98a8f8bc6677":{"record":"f1aac97154a0e52c5e33508afa82df5a9d6dcde24883a240b8c072a3238da0b6", "label":"Imap4all.com - WebMail", "favicon":"http://webmail.imap4all.com/favicon.ico"}, "3d8dd32d2290ca98789c914580ac2436ece97234217a07d752726d2ac48a4ebf":{"record":"d34c13773b5d8154355c2605024a1dfaf66279ba0fbe3ac19fc1cbc642278fe4", "label":"YouTube [no]", "favicon":"http://www.youtube.com/favicon.ico"}, "7c4b6b5a16984c43ed6d99b04ddfa7e00b624de729ec8aaa3d0f539fb67587e2":{"record":"c2b99939e40d100218baa3ed1cb2a25a5cf726485b0336a0989b104a94157b5f", "label":"Apple Store - Italia", "favicon":"http://store.apple.com/favicon.ico"}, "0b9a98262b50f0ebae5af077467bc627619738873690238fd61093ce9922c9f9":{"record":"ff79a2282cf246add520a3c06e835cf6ffaaae95067d45e8e2e8f44da2501380", "label":"3nity", "favicon":"http://www.3nity.de/favicon.ico"}, "aadeb3388629cfc3b15954f26cf284f52e084191dcdf75752dc4c53d2006c5be":{"record":"7b2f2a59ebb34b5a49f20b99b546f08b9f4f62cbefdce9699f8ef7e74aeb0552", "label":"ACM Web Account", "favicon":"http://portal.acm.org/favicon.ico"}, "3d21c71f2e284ec76f1ae0bb990b683979918f758635bb7d008150f4d7b1447d":{"record":"b83a6bac0da3a27eb909d34cbad183e77088952f01d8d5321613b7b01635a020", "label":"Adobe - Sign In", "favicon":"http://www.adobe.com/favicon.ico"}, "e61a331c998804d46044d4c2acaf96c2fce806f6549e1e16c7d2334872a70953":{"record":"0424f72608fedc969d64a6d5b4a16dd3ce860a230cd6d87d936439f4dd2aafc7", "label":"Agatra [no]", "favicon":"http://www.agatra.com/favicon.ico"}, "9bcd99564fda778061246439fa098dcc79de75b16c542f61e6de7d36dbaf97dc":{"record":"e5e17c29fd598acb4f4c7d621dbdcb045d4d0cabf7d8a19e24420c440cdc3935", "label":"AIM [no]", "favicon":"http://my.screenname.aol.com/favicon.ico"}, "c7093f4663c6e0eba941c557cb86da83fc68cbea36c922e168d0867e6cabe9fe":{"record":"0dc8d3989d0b35d672c012057d3eb7b111f16e79329e08a9ffb31ac7accbab21", "label":"Bloglines", "favicon":"http://www.bloglines.com/favicon.ico"}, "915f2e9460f6e54c6137f3876f9179fc8d2162c59f26e12899c2db6b0e70a68f":{"record":"85a40a322a59c80cb46519900269dcc7cf6947213d03dfc9371dd1930373a65b", "label":"Bow.it", "favicon":"http://www.bow.it/favicon.ico"}, "779701af1beb2a91735ba1a2e471b948f0d985bb0df256f5e089291ce3405bd2":{"record":"b2836a864ff081b6f053c3f5f13dfb29c81af33d25a316cdd82af747ea71bea0", "label":"GMail - Clipperz", "favicon":"http://www.google.com/favicon.ico"}, "1c300539a98c874d52134b6b5a591172acc00c0947692f3da284447f7d511eaf":{"record":"60308062a1848a301641a74712d220eef191a280ba0a8355992f0e61ed793811", "label":"GMail - feedback", "favicon":"http://www.google.com/favicon.ico"}, "f9dccdf7a98735fd7a6b5d04c09177005c0de14f8f92b04007f06a281ecdf31e":{"record":"30c4f575799fc6908765fc8b54f4a9a483cb32e12aa89feae545976870a9102e", "label":"Blogger", "favicon":"http://www.google.com/favicon.ico"}, "48497a89f3bfd567758977e1c32b4497d28c843880667ee52fa4cfcb53c5f9e4":{"record":"378a790452de46e1079a99eba2e15094a096b418cccd0262b8b20244eb94d2df", "label":"NewsGator", "favicon":"http://www.newsgator.com/favicon.ico"}, "134cd28f150df4f2a089f4807bb7a35fb7ece22ec41244f72e63f8b43637a4cd":{"record":"4b78dc0376d07e57d77b4c7318d2f222956adb6ff7360b73e60b8bb8b85f3d11", "label":"Lambda Probe - forum", "favicon":"http://www.lambdaprobe.org/favicon.ico"}, "2ab6106a81513b70f1ba0d7c5c3ef54fa6f4bcadf01d2eeaa2b31b9299551398":{"record":"78ca2c85908275d788c2f7dd0306ca5e03b83637bb3812272b697e12e9dbf941", "label":"Measure Map", "favicon":"http://alpha.measuremap.com/favicon.ico"}, "53ccdc41b43da9b018847f9faa8effb35e7a6c6e78a54e9ee7816fc02f0ea63b":{"record":"4c2c7f0d733b647e6f388c9a4590a2a864cd2de259b66aba9b3cf92bdc3cf9bc", "label":"NGI - Squillo", "favicon":"http://www.ngi.it/favicon.ico"}, "ca520e7081fba1df3ef79c3d00266cffc8e4567def29d67ae812b7ed6283fb12":{"record":"eaeadf6d36f8ee6916c33b9e5bf480b663dc90c0c7f370ff5a1f2fd998cf1143", "label":"NGI - F5", "favicon":"http://www.ngi.it/favicon.ico"}, "80e63e135d7abd2b2990f42af4f8d1f8e8b1146aed44dc36975061fbf360a983":{"record":"6b10514d50e745f1dab5a40e8629ecf1a8c78a5d6e3895f3637fb67d2d3f9993", "label":"Yahoo! Mail", "favicon":"http://login.yahoo.com/favicon.ico"}}, "preferences":{"preferredLanguage":"en-US"}};
82/* */ 81/* */
83 plainText = { 82 plainText = {
84 "records": { 83 "records": {
85 "1": { 84 "1": {
86 "label":"imap4all [no]", 85 "label":"imap4all [no]",
87 "key":"f54b5033d1152456acb67974c45ee6771f8411e300c9533359dfacacf60dcbbd", 86 "key":"f54b5033d1152456acb67974c45ee6771f8411e300c9533359dfacacf60dcbbd",
88 "notes":"" 87 "notes":""
89 }, 88 },
90 "2": { 89 "2": {
91 "label":"Il manifesto", 90 "label":"Il manifesto",
92 "key":"6e0ef134503110e72f444e7d102a4b1cc6ae28f2e0b1287c2b1875ff052fc16c", 91 "key":"6e0ef134503110e72f444e7d102a4b1cc6ae28f2e0b1287c2b1875ff052fc16c",
93 "notes":"" 92 "notes":""
94 }, 93 },
95 "3": { 94 "3": {
96 "label": "OmniGroup applications", 95 "label": "OmniGroup applications",
97 "key": "7b432b7dae39ff5951db31947fa721dc012af0da4055760c6df3b02e776ef22c", 96 "key": "7b432b7dae39ff5951db31947fa721dc012af0da4055760c6df3b02e776ef22c",
98 "notes": "url: http://www.omnigroup.com\n\nLicence owner: Giulio Cesare Solaroli\n\nOmniWeb: EQGP-EMKH-LKWP-MUHQ-OUHL-LDF\nOmniGraffle:\nOmniOutliner:\nOmniDiskSweeper:" 97 "notes": "url: http://www.omnigroup.com\n\nLicence owner: Giulio Cesare Solaroli\n\nOmniWeb: EQGP-EMKH-LKWP-MUHQ-OUHL-LDF\nOmniGraffle:\nOmniOutliner:\nOmniDiskSweeper:"
99 }, 98 },
100 "4": { 99 "4": {
101 "label": "R@cine", 100 "label": "R@cine",
102 "key": "57295772c84669b0a224f435e9b75c797ae5999a2d9473ab50f9384ae54f49d6", 101 "key": "57295772c84669b0a224f435e9b75c797ae5999a2d9473ab50f9384ae54f49d6",
103 "notes": "" 102 "notes": ""
104 }, 103 },
105 "5": { 104 "5": {
106 "label": "NewsGator", 105 "label": "NewsGator",
107 "key": "6ee16f6932ee02000c49dbcc685c84074b40d7956e5f4bc1100030a0f9a41f1a", 106 "key": "6ee16f6932ee02000c49dbcc685c84074b40d7956e5f4bc1100030a0f9a41f1a",
108 "notes": "" 107 "notes": ""
109 }, 108 },
110 "6": { 109 "6": {
111 "label": "GMail - giulio.cesare", 110 "label": "GMail - giulio.cesare",
112 "key": "0395efd852b00700bcf78b65350ec15932430df71201d2c53a11b0269b557d1a", 111 "key": "0395efd852b00700bcf78b65350ec15932430df71201d2c53a11b0269b557d1a",
113 "notes": "" 112 "notes": ""
114 }, 113 },
115 "7": { 114 "7": {
116 "label": "GMail - clipperz.com", 115 "label": "GMail - clipperz.com",
117 "key": "90d6ae70d89c8211404b6f9d6c70b6b9c113fff74f474a67b34acd9c1c048d1f", 116 "key": "90d6ae70d89c8211404b6f9d6c70b6b9c113fff74f474a67b34acd9c1c048d1f",
118 "notes": "" 117 "notes": ""
119 }, 118 },
120 "8": { 119 "8": {
121 "label": "Aruba - hosting", 120 "label": "Aruba - hosting",
122 "key": "5c7472d24d57391c63ea99ed1fc9de179d225abd335fa65702018cfea6083d47", 121 "key": "5c7472d24d57391c63ea99ed1fc9de179d225abd335fa65702018cfea6083d47",
123 "notes": "" 122 "notes": ""
124 }, 123 },
125 "9": { 124 "9": {
126 "label": "Aruba - sql hosting", 125 "label": "Aruba - sql hosting",
127 "key": "f6bd942ac3b0b7065771e5197c7499b345a10f7a4843d00c3ba3809d0ea059dc", 126 "key": "f6bd942ac3b0b7065771e5197c7499b345a10f7a4843d00c3ba3809d0ea059dc",
128 "notes": "" 127 "notes": ""
129 }, 128 },
130 "10": { 129 "10": {
131 "label": "Amazon", 130 "label": "Amazon",
132 "key": "1ae022b4d14b642f113703b2a98931bd892dec2da785ab5ff6fc1d0aac7537f1", 131 "key": "1ae022b4d14b642f113703b2a98931bd892dec2da785ab5ff6fc1d0aac7537f1",
133 "notes": "" 132 "notes": ""
134 }, 133 },
135 "11": { 134 "11": {
136 "label": "YouTube [no]", 135 "label": "YouTube [no]",
137 "key": "4c6593d4f6448137939b364b84c81501fadb60f7871fe5fa63c93e97bb5c4648", 136 "key": "4c6593d4f6448137939b364b84c81501fadb60f7871fe5fa63c93e97bb5c4648",
138 "notes": "" 137 "notes": ""
139 }, 138 },
140 "12": { 139 "12": {
141 "label": "DynDns - gcsolaroli", 140 "label": "DynDns - gcsolaroli",
142 "key": "f8ed9e7a3630deed046eda37ebc63ecb4d63668a2f97224d7628fdc53b242467", 141 "key": "f8ed9e7a3630deed046eda37ebc63ecb4d63668a2f97224d7628fdc53b242467",
143 "notes": "" 142 "notes": ""
144 }, 143 },
145 "13": { 144 "13": {
146 "label": "DynDns - clipperz", 145 "label": "DynDns - clipperz",
147 "key": "d8bc295177383a523e67b61b166e0ca956ab4c2ee86800559a009d2716064f6d", 146 "key": "d8bc295177383a523e67b61b166e0ca956ab4c2ee86800559a009d2716064f6d",
148 "notes": "" 147 "notes": ""
149 }, 148 },
150 "14": { 149 "14": {
151 "label": "Bol.it", 150 "label": "Bol.it",
152 "key": "cada5dadeebd8d12190954d21f1a944c8799d034f028be195b448935fcf970c7", 151 "key": "cada5dadeebd8d12190954d21f1a944c8799d034f028be195b448935fcf970c7",
153 "notes": "" 152 "notes": ""
154 }, 153 },
155 "15": { 154 "15": {
156 "label": "Freenigma - clipperz.com", 155 "label": "Freenigma - clipperz.com",
157 "key": "f09cb3790c1110794b834702b8c487c1a42b2508fbe6450a8468477d93790b2e", 156 "key": "f09cb3790c1110794b834702b8c487c1a42b2508fbe6450a8468477d93790b2e",
158 "notes": "" 157 "notes": ""
159 }, 158 },
160 "16": { 159 "16": {
161 "label": "Freenigma", 160 "label": "Freenigma",
162 "key": "4b05738f6faebc147eac5e425054a91d3cc59dd63844e82d1f0864c0ac8efec7", 161 "key": "4b05738f6faebc147eac5e425054a91d3cc59dd63844e82d1f0864c0ac8efec7",
163 "notes": "" 162 "notes": ""
164 }, 163 },
165 "17": { 164 "17": {
166 "label": "clipperz.com - blog", 165 "label": "clipperz.com - blog",
167 "key": "9cc24328bbce18e8713962428d8123e309a12f7e1d9537bc252e134501734003", 166 "key": "9cc24328bbce18e8713962428d8123e309a12f7e1d9537bc252e134501734003",
168 "notes": "" 167 "notes": ""
169 }, 168 },
170 "18": { 169 "18": {
171 "label": "Apple", 170 "label": "Apple",
172 "key": "75f2651af400629c4e5dd8bcdc3a6c691150d23d6e1a4eb263ff810926d1228f", 171 "key": "75f2651af400629c4e5dd8bcdc3a6c691150d23d6e1a4eb263ff810926d1228f",
173 "notes": "" 172 "notes": ""
174 }, 173 },
175 "19": { 174 "19": {
176 "label": ".mac", 175 "label": ".mac",
177 "key": "5934ae96d2e01282effb368d9086c2ba5d1d856ad91dd6f04f5bace26a1c0cbe", 176 "key": "5934ae96d2e01282effb368d9086c2ba5d1d856ad91dd6f04f5bace26a1c0cbe",
178 "notes": "" 177 "notes": ""
179 }, 178 },
180 "20": { 179 "20": {
181 "label": "3nity", 180 "label": "3nity",
182 "key": "33d84c4a91ab053cbf8115c689ede7e504b81199884de449acc257bea534f57f", 181 "key": "33d84c4a91ab053cbf8115c689ede7e504b81199884de449acc257bea534f57f",
183 "notes": "" 182 "notes": ""
184 }, 183 },
185 "21": { 184 "21": {
186 "label": "ACM", 185 "label": "ACM",
187 "key": "b4976bb0892baba81d628513d191de100d89acd58efbb07c823a5bb4abe48a7a", 186 "key": "b4976bb0892baba81d628513d191de100d89acd58efbb07c823a5bb4abe48a7a",
188 "notes": "" 187 "notes": ""
189 }, 188 },
190 "22": { 189 "22": {
191 "label": "Adobe", 190 "label": "Adobe",
192 "key": "d162bc404994a79ec97e0106c3a4edf2f83aca25def130242e11e95e74bd0aaa", 191 "key": "d162bc404994a79ec97e0106c3a4edf2f83aca25def130242e11e95e74bd0aaa",
193 "notes": "" 192 "notes": ""
194 }, 193 },
195 "23": { 194 "23": {
196 "label": "Adobe Photoshop Elements 3", 195 "label": "Adobe Photoshop Elements 3",
197 "key": "18a62c3c2065399819707322f467ff4be030d7939acbe5182c8194599845c428", 196 "key": "18a62c3c2065399819707322f467ff4be030d7939acbe5182c8194599845c428",
198 "notes": "Photoshop Elements 2:\n1057-4312-5223-2206-9509-6837" 197 "notes": "Photoshop Elements 2:\n1057-4312-5223-2206-9509-6837"
199 }, 198 },
200 "24": { 199 "24": {
201 "label": "Agatra", 200 "label": "Agatra",
202 "key": "c35158a21b2af75d414232b742ab738d042314e00209f8fca94c8c704c891f23", 201 "key": "c35158a21b2af75d414232b742ab738d042314e00209f8fca94c8c704c891f23",
203 "notes": "" 202 "notes": ""
204 }, 203 },
205 "25": { 204 "25": {
206 "label": "AIM", 205 "label": "AIM",
207 "key": "8561ac421d845921978387b5e6b362750b57ed08feda8ec12b9378b69f67ceff", 206 "key": "8561ac421d845921978387b5e6b362750b57ed08feda8ec12b9378b69f67ceff",
208 "notes": "" 207 "notes": ""
209 }, 208 },
210 "26": { 209 "26": {
211 "label": "Anna Vespignani", 210 "label": "Anna Vespignani",
212 "key": "79a970af0d2d30643dc2db4d16757395c1f22c311919036c2a22b7581982144a", 211 "key": "79a970af0d2d30643dc2db4d16757395c1f22c311919036c2a22b7581982144a",
213 "notes": "" 212 "notes": ""
214 }, 213 },
215 "27": { 214 "27": {
216 "label": "Bloglines", 215 "label": "Bloglines",
217 "key": "fe81f4df8c42fd81c830f9af408e9b074e77fd430e26d0ee285844fe3b092aec", 216 "key": "fe81f4df8c42fd81c830f9af408e9b074e77fd430e26d0ee285844fe3b092aec",
218 "notes": "" 217 "notes": ""
219 }, 218 },
220 "28": { 219 "28": {
221 "label": "Bow.it", 220 "label": "Bow.it",
222 "key": "64a1a9fec99c9238dc8180a01484a1ccf5f50fcd6e9a95a52b8b49fb9ca00bdc", 221 "key": "64a1a9fec99c9238dc8180a01484a1ccf5f50fcd6e9a95a52b8b49fb9ca00bdc",
223 "notes": "" 222 "notes": ""
224 }, 223 },
225 "29": { 224 "29": {
226 "label": "GMail - feedback", 225 "label": "GMail - feedback",
227 "key": "fad310cb2e6152c3faf78b7183c99f3044f5d31ee364068b80580c271a7784ef", 226 "key": "fad310cb2e6152c3faf78b7183c99f3044f5d31ee364068b80580c271a7784ef",
228 "notes": "" 227 "notes": ""
229 }, 228 },
230 "30": { 229 "30": {
231 "label": "Fineco", 230 "label": "Fineco",
232 "key": "8f99de2635b5dad7987180bc0bff49947eb37cc75d6a5d1ee1f13ed7567465a3", 231 "key": "8f99de2635b5dad7987180bc0bff49947eb37cc75d6a5d1ee1f13ed7567465a3",
233 "notes": "" 232 "notes": ""
234 }, 233 },
235 "31": { 234 "31": {
236 "label": "mon.itor.us", 235 "label": "mon.itor.us",
237 "key": "d2aa7164007c5deac8bb73580a6ab0d051f747e801ecd30284eff725d0ffaba2", 236 "key": "d2aa7164007c5deac8bb73580a6ab0d051f747e801ecd30284eff725d0ffaba2",
238 "notes": "" 237 "notes": ""
239 }, 238 },
240 "32": { 239 "32": {
241 "label": "Lamba Probe - forum", 240 "label": "Lamba Probe - forum",
242 "key": "f73906817fddba4d8f816334cb2fd0cd5ae91bc29bce6a69fdd5cf98fc96911f", 241 "key": "f73906817fddba4d8f816334cb2fd0cd5ae91bc29bce6a69fdd5cf98fc96911f",
243 "notes": "" 242 "notes": ""
244 }, 243 },
245 "33": { 244 "33": {
246 "label": "MeasureMap", 245 "label": "MeasureMap",
247 "key": "2385ce9536ebb7863b6a4c8b1f5c428587e4d6420a4bbcd31b935cb00bbd768e", 246 "key": "2385ce9536ebb7863b6a4c8b1f5c428587e4d6420a4bbcd31b935cb00bbd768e",
248 "notes": "" 247 "notes": ""
249 }, 248 },
250 "34": { 249 "34": {
251 "label": "NGI - Squillo", 250 "label": "NGI - Squillo",
252 "key": "96f20c212be02fb38c8b2dfc83d8e864dd84dcb95297a7fecf9280e1e4dcffe3", 251 "key": "96f20c212be02fb38c8b2dfc83d8e864dd84dcb95297a7fecf9280e1e4dcffe3",
253 "notes": "" 252 "notes": ""
254 }, 253 },
255 "35": { 254 "35": {
256 "label": "NGI - F5", 255 "label": "NGI - F5",
257 "key": "00347769244b208647c24e6a64f8fa4213e97eb2135ecfcb277b341c28616a59", 256 "key": "00347769244b208647c24e6a64f8fa4213e97eb2135ecfcb277b341c28616a59",
258 "notes": "" 257 "notes": ""
259 }, 258 },
260 "36": { 259 "36": {
261 "label": "CVSdude", 260 "label": "CVSdude",
262 "key": "ed0ab5080a29eb1b20927142d21ab8f67b61c2c7b19623bb610af030dfd42c02", 261 "key": "ed0ab5080a29eb1b20927142d21ab8f67b61c2c7b19623bb610af030dfd42c02",
263 "notes": "" 262 "notes": ""
264 }, 263 },
265 "37": { 264 "37": {
266 "label": "Yahoo", 265 "label": "Yahoo",
267 "key": "6380a7655cd790d1f1e6f482e92ae04201568ff0cab887e65102e9396df1b86e", 266 "key": "6380a7655cd790d1f1e6f482e92ae04201568ff0cab887e65102e9396df1b86e",
268 "notes": "note" 267 "notes": "note"
269 } 268 }
270 }, 269 },
271 "directLogins": { 270 "directLogins": {
272 "1": { "record": "1", "label": "R@cine - WebMail", "favicon": "http://www.racine.ra.it/favicon.ico" }, 271 "1": { "record": "1", "label": "R@cine - WebMail", "favicon": "http://www.racine.ra.it/favicon.ico" },
273 "2": { "record": "2", "label": "Amazon sign in", "favicon": "http://www.amazon.com/favicon.ico" }, 272 "2": { "record": "2", "label": "Amazon sign in", "favicon": "http://www.amazon.com/favicon.ico" },
274 "3": { "record": "3", "label": "Aruba - hosting", "favicon": "http://hosting.aruba.it/favicon.ico" }, 273 "3": { "record": "3", "label": "Aruba - hosting", "favicon": "http://hosting.aruba.it/favicon.ico" },
275 "4": { "record": "4", "label": "Aruba - sql hosting", "favicon":"http://mysql.aruba.it/favicon.ico" }, 274 "4": { "record": "4", "label": "Aruba - sql hosting", "favicon":"http://mysql.aruba.it/favicon.ico" },
276 "5": { "record": "5", "label":"clipperz.com - blog", "favicon":"http://www.clipperz.com/favicon.ico" }, 275 "5": { "record": "5", "label":"clipperz.com - blog", "favicon":"http://www.clipperz.com/favicon.ico" },
277 "6": { "record":"6", "label":"DynDns - clipperz", "favicon":"http://www.dyndns.com/favicon.ico" }, 276 "6": { "record":"6", "label":"DynDns - clipperz", "favicon":"http://www.dyndns.com/favicon.ico" },
278 "7": { "record":"7", "label":"DynDns - gcsolaroli", "favicon":"http://www.dyndns.com/favicon.ico" }, 277 "7": { "record":"7", "label":"DynDns - gcsolaroli", "favicon":"http://www.dyndns.com/favicon.ico" },
279 "8":{"record":"8", "label":"GMail - giulio.cesare", "favicon":"http://www.google.com/favicon.ico" }, 278 "8":{"record":"8", "label":"GMail - giulio.cesare", "favicon":"http://www.google.com/favicon.ico" },
280 "9":{"record":"9", "label":"Il manifesto", "favicon":"http://abbonati.ilmanifesto.it/favicon.ico" }, 279 "9":{"record":"9", "label":"Il manifesto", "favicon":"http://abbonati.ilmanifesto.it/favicon.ico" },
281 "10":{"record":"10", "label":"Imap4All.com - account", "favicon":"http://www.imap4all.com/favicon.ico" }, 280 "10":{"record":"10", "label":"Imap4All.com - account", "favicon":"http://www.imap4all.com/favicon.ico" },
282 "11":{"record":"12", "label":"Imap4all.com - WebMail", "favicon":"http://webmail.imap4all.com/favicon.ico" }, 281 "11":{"record":"12", "label":"Imap4all.com - WebMail", "favicon":"http://webmail.imap4all.com/favicon.ico" },
283 "13":{"record":"13", "label":"YouTube [no]", "favicon":"http://www.youtube.com/favicon.ico" }, 282 "13":{"record":"13", "label":"YouTube [no]", "favicon":"http://www.youtube.com/favicon.ico" },
284 "14":{"record":"14", "label":"Apple Store - Italia", "favicon":"http://store.apple.com/favicon.ico" }, 283 "14":{"record":"14", "label":"Apple Store - Italia", "favicon":"http://store.apple.com/favicon.ico" },
285 "15":{"record":"15", "label":"3nity", "favicon":"http://www.3nity.de/favicon.ico" }, 284 "15":{"record":"15", "label":"3nity", "favicon":"http://www.3nity.de/favicon.ico" },
286 "16":{"record":"16", "label":"ACM Web Account", "favicon":"http://portal.acm.org/favicon.ico" }, 285 "16":{"record":"16", "label":"ACM Web Account", "favicon":"http://portal.acm.org/favicon.ico" },
287 "17":{"record":"17", "label":"Adobe - Sign In", "favicon":"http://www.adobe.com/favicon.ico" }, 286 "17":{"record":"17", "label":"Adobe - Sign In", "favicon":"http://www.adobe.com/favicon.ico" },
288 "18":{"record":"18", "label":"Agatra [no]", "favicon":"http://www.agatra.com/favicon.ico" }, 287 "18":{"record":"18", "label":"Agatra [no]", "favicon":"http://www.agatra.com/favicon.ico" },
289 "19":{"record":"19", "label":"AIM [no]", "favicon":"http://my.screenname.aol.com/favicon.ico" }, 288 "19":{"record":"19", "label":"AIM [no]", "favicon":"http://my.screenname.aol.com/favicon.ico" },
290 "20":{"record":"20", "label":"Bloglines", "favicon":"http://www.bloglines.com/favicon.ico" }, 289 "20":{"record":"20", "label":"Bloglines", "favicon":"http://www.bloglines.com/favicon.ico" },
291 "21":{"record":"21", "label":"Bow.it", "favicon":"http://www.bow.it/favicon.ico" }, 290 "21":{"record":"21", "label":"Bow.it", "favicon":"http://www.bow.it/favicon.ico" },
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/Base.html b/frontend/gamma/tests/tests/Clipperz/Crypto/Base.html
index 0ffcdb8..83f0766 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/Base.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/Base.html
@@ -1,285 +1,284 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
35 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
36 35
37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
41 40
42</head> 41</head>
43<body> 42<body>
44<pre id="test"> 43<pre id="test">
45<script type="text/javascript"> 44<script type="text/javascript">
46try { 45try {
47 var secretKey; 46 var secretKey;
48 varpublicKey; 47 varpublicKey;
49 varplainString; 48 varplainString;
50 varencryptedString; 49 varencryptedString;
51 50
52 51
53 secretKey = "s3cr37k39"; 52 secretKey = "s3cr37k39";
54 plainString = "The Quick Brown Fox Jumps Over The Lazy Dog"; 53 plainString = "The Quick Brown Fox Jumps Over The Lazy Dog";
55 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString); 54 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
56 55
57 //------------------------------------------------------------------------- 56 //-------------------------------------------------------------------------
58 // 57 //
59 //Secret key encryption / decryption 58 //Secret key encryption / decryption
60 // 59 //
61 is (isUndefinedOrNull(encryptedString), false, "An encrypted string should not be empty"); 60 is (isUndefinedOrNull(encryptedString), false, "An encrypted string should not be empty");
62 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely"); 61 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
63 62
64 try { 63 try {
65 vardecryptedText; 64 vardecryptedText;
66 65
67 decryptedText = Clipperz.Crypto.Base.decryptUsingSecretKey("anotherKey", encryptedString); 66 decryptedText = Clipperz.Crypto.Base.decryptUsingSecretKey("anotherKey", encryptedString);
68 ok( false, "It should not be possible to decrypt a text with a different passphrase (decrypted text: " + decryptedText + ")" ); 67 ok( false, "It should not be possible to decrypt a text with a different passphrase (decrypted text: " + decryptedText + ")" );
69 } catch (e) { 68 } catch (e) {
70 ok( e instanceof Error, "Trying to decrypt a message with the wrong passphrase raised an error" ); 69 ok( e instanceof Error, "Trying to decrypt a message with the wrong passphrase raised an error" );
71 } 70 }
72 71
73 is (encryptedString == Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString), false, "Two consecutive encryption of the same text should return different values"); 72 is (encryptedString == Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString), false, "Two consecutive encryption of the same text should return different values");
74 73
75 secretKey = "trustno1"; 74 secretKey = "trustno1";
76 plainString = "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1"; 75 plainString = "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1";
77 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString); 76 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
78 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely"); 77 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
79 78
80 secretKey = "trustno1"; 79 secretKey = "trustno1";
81 plainString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed pede. Curabitur a mi id nisi euismod rutrum. Phasellus gravida. Ut luctus. Praesent quis leo sit amet orci imperdiet malesuada. Aenean molestie mauris euismod odio. Suspendisse ullamcorper facilisis nisl. Fusce vestibulum consectetuer risus. Curabitur ut turpis eget arcu facilisis ultricies. Morbi elementum, erat vitae dictum imperdiet, nisi purus rutrum odio, eget ornare ipsum nisl in tortor. Duis vestibulum, nulla et bibendum volutpat, mauris metus facilisis elit, vel gravida tortor leo at enim. Vivamus pulvinar lorem vitae tortor. Morbi rhoncus suscipit urna. Praesent placerat tempus augue. Fusce varius dui a nisi consequat ultricies. Curabitur at nisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas."; 80 plainString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed pede. Curabitur a mi id nisi euismod rutrum. Phasellus gravida. Ut luctus. Praesent quis leo sit amet orci imperdiet malesuada. Aenean molestie mauris euismod odio. Suspendisse ullamcorper facilisis nisl. Fusce vestibulum consectetuer risus. Curabitur ut turpis eget arcu facilisis ultricies. Morbi elementum, erat vitae dictum imperdiet, nisi purus rutrum odio, eget ornare ipsum nisl in tortor. Duis vestibulum, nulla et bibendum volutpat, mauris metus facilisis elit, vel gravida tortor leo at enim. Vivamus pulvinar lorem vitae tortor. Morbi rhoncus suscipit urna. Praesent placerat tempus augue. Fusce varius dui a nisi consequat ultricies. Curabitur at nisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.";
82 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString); 81 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
83 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely"); 82 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
84 83
85 secretKey = "trustno1"; 84 secretKey = "trustno1";
86 plainString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed pede. Curabitur a mi id nisi euismod rutrum. Phasellus gravida. Ut luctus. Praesent quis leo sit amet orci imperdiet malesuada. Aenean molestie mauris euismod odio. Suspendisse ullamcorper facilisis nisl. Fusce vestibulum consectetuer risus. Curabitur ut turpis eget arcu facilisis ultricies. Morbi elementum, erat vitae dictum imperdiet, nisi purus rutrum odio, eget ornare ipsum nisl in tortor. Duis vestibulum, nulla et bibendum volutpat, mauris metus facilisis elit, vel gravida tortor leo at enim. Vivamus pulvinar lorem vitae tortor. Morbi rhoncus suscipit urna. Praesent placerat tempus augue. Fusce varius dui a nisi consequat ultricies. Curabitur at nisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas./n/n/nMorbi vel leo non justo condimentum convallis. Vestibulum posuere aliquam nunc. Donec magna magna, euismod nec, pharetra fringilla, tristique mattis, turpis. Duis condimentum lacus eu felis. Sed ultricies. Nullam lacinia ante id diam. Ut quis enim. Fusce at felis quis neque vehicula tempor. Sed feugiat sodales sem. Duis cursus massa in ligula. Vestibulum volutpat, risus in ornare porta, tortor orci vestibulum felis, et eleifend risus odio nec eros. Integer lorem turpis, imperdiet eu, tempor eu, ultricies nec, est. Ut congue. Morbi lacinia vehicula pede. Cras neque sapien, feugiat ac, eleifend eget, mattis et, nisl. Morbi at augue vitae massa laoreet gravida./n/n/nSuspendisse vehicula convallis sem. Sed vel urna. Proin dolor diam, malesuada in, aliquet a, sagittis et, magna. Cras at dui eu mi porta fermentum. Donec pharetra purus sed velit. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque euismod ornare neque. In odio nisi, bibendum non, vulputate ut, tincidunt a, ante. Sed risus arcu, tempus laoreet, euismod id, laoreet mollis, arcu. Ut tempor orci in nibh. Suspendisse potenti. Maecenas accumsan augue at nisl. Donec elementum diam nec metus. Sed vitae lacus sed libero varius semper. Aenean hendrerit tristique arcu. Praesent adipiscing ornare purus. Vestibulum quis eros nec risus accumsan laoreet. Duis consequat ante ut turpis. Curabitur aliquam suscipit ligula. Vivamus adipiscing./n/n/nCurabitur facilisis neque sit amet erat. Aliquam odio augue, vulputate lobortis, rutrum ut, tristique id, leo. Vivamus eu magna. Maecenas et libero. Integer porta, lorem at mollis ullamcorper, purus metus vestibulum erat, ut fringilla dui ante id mi. Morbi vitae ligula. Praesent ornare sapien sed massa. Mauris rhoncus fermentum dolor. Mauris gravida, justo et mollis malesuada, dolor erat fermentum nulla, vel suscipit leo ligula vel augue. Praesent magna enim, dignissim sed, aliquet quis, fermentum viverra, nisi. Vivamus condimentum, nisi quis posuere viverra, enim nunc faucibus lectus, mollis aliquam ipsum enim vel lacus. Suspendisse eget ligula. Aliquam ut metus et justo consectetuer ornare. Donec dapibus tristique pede. Vestibulum interdum ultricies tortor./n/n/nNunc nonummy dictum tortor. Quisque at elit a arcu nonummy elementum. Quisque auctor, risus et sodales euismod, turpis tellus consectetuer ante, quis egestas justo enim quis mi. Nunc fermentum sodales felis. Vivamus odio mi, dignissim vitae, auctor nec, tempus eget, lacus. Ut sapien massa, hendrerit eget, sagittis at, eleifend condimentum, arcu. Curabitur purus orci, facilisis vel, dapibus id, varius rutrum, tortor. Fusce accumsan viverra sem. Quisque tincidunt venenatis risus. Sed tortor justo, volutpat malesuada, sodales ut, vehicula id, magna. Nunc placerat, nibh et imperdiet ultricies, urna nulla luctus sapien, et porta mi odio ac neque. Morbi dignissim. Sed risus pede, adipiscing gravida, pharetra sit amet, convallis non, orci. Morbi adipiscing mauris id massa. Nullam fermentum. Suspendisse eget est"; 85 plainString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed pede. Curabitur a mi id nisi euismod rutrum. Phasellus gravida. Ut luctus. Praesent quis leo sit amet orci imperdiet malesuada. Aenean molestie mauris euismod odio. Suspendisse ullamcorper facilisis nisl. Fusce vestibulum consectetuer risus. Curabitur ut turpis eget arcu facilisis ultricies. Morbi elementum, erat vitae dictum imperdiet, nisi purus rutrum odio, eget ornare ipsum nisl in tortor. Duis vestibulum, nulla et bibendum volutpat, mauris metus facilisis elit, vel gravida tortor leo at enim. Vivamus pulvinar lorem vitae tortor. Morbi rhoncus suscipit urna. Praesent placerat tempus augue. Fusce varius dui a nisi consequat ultricies. Curabitur at nisi. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas./n/n/nMorbi vel leo non justo condimentum convallis. Vestibulum posuere aliquam nunc. Donec magna magna, euismod nec, pharetra fringilla, tristique mattis, turpis. Duis condimentum lacus eu felis. Sed ultricies. Nullam lacinia ante id diam. Ut quis enim. Fusce at felis quis neque vehicula tempor. Sed feugiat sodales sem. Duis cursus massa in ligula. Vestibulum volutpat, risus in ornare porta, tortor orci vestibulum felis, et eleifend risus odio nec eros. Integer lorem turpis, imperdiet eu, tempor eu, ultricies nec, est. Ut congue. Morbi lacinia vehicula pede. Cras neque sapien, feugiat ac, eleifend eget, mattis et, nisl. Morbi at augue vitae massa laoreet gravida./n/n/nSuspendisse vehicula convallis sem. Sed vel urna. Proin dolor diam, malesuada in, aliquet a, sagittis et, magna. Cras at dui eu mi porta fermentum. Donec pharetra purus sed velit. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque euismod ornare neque. In odio nisi, bibendum non, vulputate ut, tincidunt a, ante. Sed risus arcu, tempus laoreet, euismod id, laoreet mollis, arcu. Ut tempor orci in nibh. Suspendisse potenti. Maecenas accumsan augue at nisl. Donec elementum diam nec metus. Sed vitae lacus sed libero varius semper. Aenean hendrerit tristique arcu. Praesent adipiscing ornare purus. Vestibulum quis eros nec risus accumsan laoreet. Duis consequat ante ut turpis. Curabitur aliquam suscipit ligula. Vivamus adipiscing./n/n/nCurabitur facilisis neque sit amet erat. Aliquam odio augue, vulputate lobortis, rutrum ut, tristique id, leo. Vivamus eu magna. Maecenas et libero. Integer porta, lorem at mollis ullamcorper, purus metus vestibulum erat, ut fringilla dui ante id mi. Morbi vitae ligula. Praesent ornare sapien sed massa. Mauris rhoncus fermentum dolor. Mauris gravida, justo et mollis malesuada, dolor erat fermentum nulla, vel suscipit leo ligula vel augue. Praesent magna enim, dignissim sed, aliquet quis, fermentum viverra, nisi. Vivamus condimentum, nisi quis posuere viverra, enim nunc faucibus lectus, mollis aliquam ipsum enim vel lacus. Suspendisse eget ligula. Aliquam ut metus et justo consectetuer ornare. Donec dapibus tristique pede. Vestibulum interdum ultricies tortor./n/n/nNunc nonummy dictum tortor. Quisque at elit a arcu nonummy elementum. Quisque auctor, risus et sodales euismod, turpis tellus consectetuer ante, quis egestas justo enim quis mi. Nunc fermentum sodales felis. Vivamus odio mi, dignissim vitae, auctor nec, tempus eget, lacus. Ut sapien massa, hendrerit eget, sagittis at, eleifend condimentum, arcu. Curabitur purus orci, facilisis vel, dapibus id, varius rutrum, tortor. Fusce accumsan viverra sem. Quisque tincidunt venenatis risus. Sed tortor justo, volutpat malesuada, sodales ut, vehicula id, magna. Nunc placerat, nibh et imperdiet ultricies, urna nulla luctus sapien, et porta mi odio ac neque. Morbi dignissim. Sed risus pede, adipiscing gravida, pharetra sit amet, convallis non, orci. Morbi adipiscing mauris id massa. Nullam fermentum. Suspendisse eget est";
87 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString); 86 encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
88 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely"); 87 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
89 88
90 //secretKey = "trustno1"; 89 //secretKey = "trustno1";
91 //plainString = "{}"; 90 //plainString = "{}";
92 // plainString = "{'tags': {'personal': ['ref_1', 'ref_3'], 'business': ['ref_2', 'ref_3']}, 'records': {'ref_1': {'label': 'record_1', 'key': 'key_1'}, 'ref_2': {'label': 'record_2', 'key': 'key_2'}, 'ref_3': {'label': 'record_3', 'key': 'key_3'}}}"; 91 // plainString = "{'tags': {'personal': ['ref_1', 'ref_3'], 'business': ['ref_2', 'ref_3']}, 'records': {'ref_1': {'label': 'record_1', 'key': 'key_1'}, 'ref_2': {'label': 'record_2', 'key': 'key_2'}, 'ref_3': {'label': 'record_3', 'key': 'key_3'}}}";
93 //plainString = "{'tags': {}, 'records': {'07a5a92fcb334f757998ba14f3251f126d038318b3ac5e584bd712804c548084': {'label': 'Un bel record', 'key': '2a3f261c20a6a98dcc82b13fba013130b759f20602b4b13c5760879e087482a4'}}}"; 92 //plainString = "{'tags': {}, 'records': {'07a5a92fcb334f757998ba14f3251f126d038318b3ac5e584bd712804c548084': {'label': 'Un bel record', 'key': '2a3f261c20a6a98dcc82b13fba013130b759f20602b4b13c5760879e087482a4'}}}";
94 //encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString); 93 //encryptedString = Clipperz.Crypto.Base.encryptUsingSecretKey(secretKey, plainString);
95 //is(encryptedString, "{}", "encrypted value"); 94 //is(encryptedString, "{}", "encrypted value");
96 95
97 96
98 //secretKey = "trustno1"; 97 //secretKey = "trustno1";
99 //encryptedString = "0d43a4544424ffa519f2e43b7a46f703884fd94ff9879479563f6f252a573b253d3e77bc4f5f30f17bd11d2907718921ab8c9e1faccbe4314793fa323eb85eaf1bfbce5f7deea601e15b781782181cbff3c649dafef39abb70e8573e4f9be220f2286b01c3bd51d5c4a79b9d44a27be3b0994667302e301ca3dc074fb1bc7abc03d12b9e58ba0249435a120858c96e8ae99570718541499ab958a8fb92b63390be070ff61fc6ef107061693ab14c1915118cc6671ab7cf99b9cca553d6b5a7c314bffcd933e0a59f056d842a47cfe8571110b4764c5225443210d99b43b80a23c20fe953de3e1329d72cfb20139fe1ca"; 98 //encryptedString = "0d43a4544424ffa519f2e43b7a46f703884fd94ff9879479563f6f252a573b253d3e77bc4f5f30f17bd11d2907718921ab8c9e1faccbe4314793fa323eb85eaf1bfbce5f7deea601e15b781782181cbff3c649dafef39abb70e8573e4f9be220f2286b01c3bd51d5c4a79b9d44a27be3b0994667302e301ca3dc074fb1bc7abc03d12b9e58ba0249435a120858c96e8ae99570718541499ab958a8fb92b63390be070ff61fc6ef107061693ab14c1915118cc6671ab7cf99b9cca553d6b5a7c314bffcd933e0a59f056d842a47cfe8571110b4764c5225443210d99b43b80a23c20fe953de3e1329d72cfb20139fe1ca";
100 //plainString = Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString); 99 //plainString = Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString);
101 //is(plainString, "{}", "decrypted value"); 100 //is(plainString, "{}", "decrypted value");
102 101
103 //------------------------------------------------------------------------- 102 //-------------------------------------------------------------------------
104 // 103 //
105 //Java secret key encryption / JavaScript decryption 104 //Java secret key encryption / JavaScript decryption
106 // 105 //
107 secretKey = "s3cr37k39"; 106 secretKey = "s3cr37k39";
108 plainString = "The Quick Brown Fox Jumps Over The Lazy Dog"; 107 plainString = "The Quick Brown Fox Jumps Over The Lazy Dog";
109 encryptedString = "9be538c3dde4dfab9384c0ef71dc624299fbbe71be8d1fe8991fd6cae88a883cf459d7cd56913a2b69815782cf74d7ce5c2c08034661f7f8aa59cf420e913086896840ebb45102d44d733d32de2a7dc8"; 108 encryptedString = "9be538c3dde4dfab9384c0ef71dc624299fbbe71be8d1fe8991fd6cae88a883cf459d7cd56913a2b69815782cf74d7ce5c2c08034661f7f8aa59cf420e913086896840ebb45102d44d733d32de2a7dc8";
110 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely"); 109 is (plainString, Clipperz.Crypto.Base.decryptUsingSecretKey(secretKey, encryptedString), "I should be able to encrypt and then decrypt safely");
111 110
112 //------------------------------------------------------------------------- 111 //-------------------------------------------------------------------------
113 // 112 //
114 //Public key encryption -> Private key decryption 113 //Public key encryption -> Private key decryption
115 // 114 //
116 { 115 {
117 varcleanKey; 116 varcleanKey;
118 vart1, t2; 117 vart1, t2;
119/* 118/*
120 // 119 //
121 // 128 120 // 128
122 // 121 //
123 cleanKey = "248d6a61d20638b8e5c026930c3e6039"; //a33ce45964ff2167f6ecedd419db06c1"; 122 cleanKey = "248d6a61d20638b8e5c026930c3e6039"; //a33ce45964ff2167f6ecedd419db06c1";
124 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 123 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
125 "10001", 124 "10001",
126 "202700adbd85e2d7182720c3a0ee19c1", 125 "202700adbd85e2d7182720c3a0ee19c1",
127 "30db31542ace0f7d37a629ee5eba28cb" 126 "30db31542ace0f7d37a629ee5eba28cb"
128 ); 127 );
129 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey); 128 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
130 129
131 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 128"); 130 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 128");
132 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 128"); 131 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 128");
133 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 128"); 132 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 128");
134*/ 133*/
135/* 134/*
136 // 135 //
137 // 256 136 // 256
138 // 137 //
139 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; 138 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
140 cleanKey = "a3c2863242653caf566b02d8be5d6eb6c816ac212378bcec7ff2bdce8e2ec709"; 139 cleanKey = "a3c2863242653caf566b02d8be5d6eb6c816ac212378bcec7ff2bdce8e2ec709";
141 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 140 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
142 "10001", 141 "10001",
143 "8064edb1f26944f6bec2b68789db7ffd08b074d0953b76feca71dc8265c60e9", 142 "8064edb1f26944f6bec2b68789db7ffd08b074d0953b76feca71dc8265c60e9",
144 "2687f5ac6c70f9cab32fcbded7059502f4c7cc95fc3e09a560c68975ac4bf5e3" 143 "2687f5ac6c70f9cab32fcbded7059502f4c7cc95fc3e09a560c68975ac4bf5e3"
145 ); 144 );
146 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey); 145 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
147 146
148 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 256"); 147 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 256");
149 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 256"); 148 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 256");
150 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 256"); 149 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 256");
151*/ 150*/
152/* 151/*
153 // 152 //
154 //512 153 //512
155 // 154 //
156 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; 155 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
157 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 156 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
158 "10001", 157 "10001",
159 "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1", 158 "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1",
160 "8de7066f67be16fcacd05d319b6729cd85fe698c07cec504776146eb7a041d9e3cacbf0fcd86441981c0083eed1f8f1b18393f0b186e47ce1b7b4981417b491" 159 "8de7066f67be16fcacd05d319b6729cd85fe698c07cec504776146eb7a041d9e3cacbf0fcd86441981c0083eed1f8f1b18393f0b186e47ce1b7b4981417b491"
161 ); 160 );
162t1 = new Date().getTime(); 161t1 = new Date().getTime();
163 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey); 162 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
164t2 = new Date().getTime(); 163t2 = new Date().getTime();
165//is("Encrypting with public key (512)", (t2 - t1)); 164//is("Encrypting with public key (512)", (t2 - t1));
166 165
167 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 512"); 166 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 512");
168t1 = new Date().getTime(); 167t1 = new Date().getTime();
169 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 512"); 168 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 512");
170t2 = new Date().getTime(); 169t2 = new Date().getTime();
171//is("Decrypting with private key (512)", (t2 - t1)); 170//is("Decrypting with private key (512)", (t2 - t1));
172 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 512"); 171 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 512");
173*/ 172*/
174/* 173/*
175 // 174 //
176 //1024 175 //1024
177 // 176 //
178 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; 177 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
179 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 178 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
180 "10001", 179 "10001",
181 "12e8da920d4599458e84ec5ef1656161807f427d05eb79182b7418259d6f6c14364d1f5caf9130c8d9d9d6ea71d1bdbc87781a46a16bcb9e672814fed3b9c96ddffe0a1b0955ae68055c8f92fef518a04fc32a2ea8390e617cc5556a251f9ae9eee70a32e579cb3e9f298848a9b3aaf634f5930ffbf74473f7cb6c0cefee1751", 180 "12e8da920d4599458e84ec5ef1656161807f427d05eb79182b7418259d6f6c14364d1f5caf9130c8d9d9d6ea71d1bdbc87781a46a16bcb9e672814fed3b9c96ddffe0a1b0955ae68055c8f92fef518a04fc32a2ea8390e617cc5556a251f9ae9eee70a32e579cb3e9f298848a9b3aaf634f5930ffbf74473f7cb6c0cefee1751",
182 "130ebebd67b16a9ab2c53a437badbf8f01a80c750095a7fcfe95742c3d5ed1abb318babc5cb5d9350fee4da65ee074f65e1758117e6945f0fcfc8137528053ce9d1da8618890dee24e5e0bf8c87795bb1d09eddd544640824ee0dd0ea9fd908d27b0f8a1ae5c37f3647fbf2f5795500ad76c195b3387d0458a8f51b701472301" 181 "130ebebd67b16a9ab2c53a437badbf8f01a80c750095a7fcfe95742c3d5ed1abb318babc5cb5d9350fee4da65ee074f65e1758117e6945f0fcfc8137528053ce9d1da8618890dee24e5e0bf8c87795bb1d09eddd544640824ee0dd0ea9fd908d27b0f8a1ae5c37f3647fbf2f5795500ad76c195b3387d0458a8f51b701472301"
183 ); 182 );
184t1 = new Date().getTime(); 183t1 = new Date().getTime();
185 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey); 184 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
186t2 = new Date().getTime(); 185t2 = new Date().getTime();
187is("Encrypting with public key (1024)", (t2 - t1)); 186is("Encrypting with public key (1024)", (t2 - t1));
188 187
189 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 1024"); 188 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 1024");
190t1 = new Date().getTime(); 189t1 = new Date().getTime();
191 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 1024"); 190 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 1024");
192t2 = new Date().getTime(); 191t2 = new Date().getTime();
193is("Decrypting with private key (1024)", (t2 - t1)); 192is("Decrypting with private key (1024)", (t2 - t1));
194 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 1024"); 193 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 1024");
195*/ 194*/
196/* 195/*
197 // 196 //
198 //2048 197 //2048
199 // 198 //
200 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; 199 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
201 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 200 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
202 "10001", 201 "10001",
203 "409c6fe2b6474762b5c07f4e55ef80d174814dc1fb0fb58e979691116fb3dc433f759ff8a88d1a0f0666862b0b3758c54b7355fa87ee827369381e1f97c5d74944e032c7186b51a956fb49d6deb3aee0b2c7e65fc53bfd46d217764850667ed0363de143f3f3d06d5a0018693ad3dacdf78a18d037ceeccb7508776f27b30852b8b505666a8dca5bfbb455d2f85918f8b5295061c97673c78802c5f5cf4581c7215dc32af8dfb6fc10e9ba51fb5a88abab94157ccecf615e104a91a45e9bee072fe7b388344c1bbad4a8f7d5daeccbadf778d59eff2a491a067bba5343c5a094c61b575fe367ecfcc01c3d208c2f8c05b9496a929b2b72e70160d07d07f248f1", 202 "409c6fe2b6474762b5c07f4e55ef80d174814dc1fb0fb58e979691116fb3dc433f759ff8a88d1a0f0666862b0b3758c54b7355fa87ee827369381e1f97c5d74944e032c7186b51a956fb49d6deb3aee0b2c7e65fc53bfd46d217764850667ed0363de143f3f3d06d5a0018693ad3dacdf78a18d037ceeccb7508776f27b30852b8b505666a8dca5bfbb455d2f85918f8b5295061c97673c78802c5f5cf4581c7215dc32af8dfb6fc10e9ba51fb5a88abab94157ccecf615e104a91a45e9bee072fe7b388344c1bbad4a8f7d5daeccbadf778d59eff2a491a067bba5343c5a094c61b575fe367ecfcc01c3d208c2f8c05b9496a929b2b72e70160d07d07f248f1",
204 "9800012b1e533c2c28187424e1289fd4f7fe67487058f5ac7f27f18476c6c93db20b6d2c63d04ff310c1e7211cf8014adc006176529abc53fd1780274fc2629cf51d627c7465c3cbf4f110c3560e2128b97c4ea8a431f0b2a326fc31899790515ad45874ca75c68ee6695558736490ea895d598b8525bccab3156104d360b115ae25e99e9d899a2219136bad0336eeee0c6d725aa9c3b6b923c1ad95a9057b9deb7b563e05614acc800d9d8ec5de405d74feea722c5146feb80829508180ab5c80bf792b83f07c04c73ce0b3cf0d9f74aa92a4704819d103e58f5d4b8ca750148ba1cbab8eb55f92775b18da427c3a0b592809f3853274841a44b7129ec6a623" 203 "9800012b1e533c2c28187424e1289fd4f7fe67487058f5ac7f27f18476c6c93db20b6d2c63d04ff310c1e7211cf8014adc006176529abc53fd1780274fc2629cf51d627c7465c3cbf4f110c3560e2128b97c4ea8a431f0b2a326fc31899790515ad45874ca75c68ee6695558736490ea895d598b8525bccab3156104d360b115ae25e99e9d899a2219136bad0336eeee0c6d725aa9c3b6b923c1ad95a9057b9deb7b563e05614acc800d9d8ec5de405d74feea722c5146feb80829508180ab5c80bf792b83f07c04c73ce0b3cf0d9f74aa92a4704819d103e58f5d4b8ca750148ba1cbab8eb55f92775b18da427c3a0b592809f3853274841a44b7129ec6a623"
205 ); 204 );
206t1 = new Date().getTime(); 205t1 = new Date().getTime();
207 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey); 206 encryptedString = Clipperz.Crypto.Base.encryptUsingPublicKey(publicKey, cleanKey);
208t2 = new Date().getTime(); 207t2 = new Date().getTime();
209is("Encrypting with public key (2048)", (t2 - t1)); 208is("Encrypting with public key (2048)", (t2 - t1));
210 209
211 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 2048"); 210 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PUBLIC 2048");
212t1 = new Date().getTime(); 211t1 = new Date().getTime();
213 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 2048"); 212 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PUBLIC 2048");
214t2 = new Date().getTime(); 213t2 = new Date().getTime();
215is("Decrypting with private key (2048)", (t2 - t1)); 214is("Decrypting with private key (2048)", (t2 - t1));
216 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 2048"); 215 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PUBLIC 2048");
217*/ 216*/
218 } 217 }
219 218
220 //------------------------------------------------------------------------- 219 //-------------------------------------------------------------------------
221 // 220 //
222 //Private key encryption -> Public key decryption 221 //Private key encryption -> Public key decryption
223 // 222 //
224 { 223 {
225 varcleanKey; 224 varcleanKey;
226 vart1, t2; 225 vart1, t2;
227/* 226/*
228 // 227 //
229 // 128 228 // 128
230 // 229 //
231 cleanKey = "248d6a61d20638b8e5c026930c3e6039"; //a33ce45964ff2167f6ecedd419db06c1"; 230 cleanKey = "248d6a61d20638b8e5c026930c3e6039"; //a33ce45964ff2167f6ecedd419db06c1";
232 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 231 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
233 "10001", 232 "10001",
234 "202700adbd85e2d7182720c3a0ee19c1", 233 "202700adbd85e2d7182720c3a0ee19c1",
235 "30db31542ace0f7d37a629ee5eba28cb" 234 "30db31542ace0f7d37a629ee5eba28cb"
236 ); 235 );
237 encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey); 236 encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
238 237
239 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 128"); 238 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 128");
240 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 128"); 239 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 128");
241 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again the private key - PRIVATE 128"); 240 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again the private key - PRIVATE 128");
242*/ 241*/
243/* 242/*
244 // 243 //
245 // 256 244 // 256
246 // 245 //
247 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; 246 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
248 cleanKey = "a3c2863242653caf566b02d8be5d6eb6c816ac212378bcec7ff2bdce8e2ec709"; 247 cleanKey = "a3c2863242653caf566b02d8be5d6eb6c816ac212378bcec7ff2bdce8e2ec709";
249 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 248 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
250 "10001", 249 "10001",
251 "8064edb1f26944f6bec2b68789db7ffd08b074d0953b76feca71dc8265c60e9", 250 "8064edb1f26944f6bec2b68789db7ffd08b074d0953b76feca71dc8265c60e9",
252 "2687f5ac6c70f9cab32fcbded7059502f4c7cc95fc3e09a560c68975ac4bf5e3" 251 "2687f5ac6c70f9cab32fcbded7059502f4c7cc95fc3e09a560c68975ac4bf5e3"
253 ); 252 );
254 encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey); 253 encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
255 254
256 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 256"); 255 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 256");
257 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 256"); 256 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 256");
258 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again the private key - PRIVATE 256"); 257 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again the private key - PRIVATE 256");
259*/ 258*/
260/* 259/*
261 // 260 //
262 //512 261 //512
263 // 262 //
264 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"; 263 cleanKey = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
265 publicKey = Clipperz.Crypto.Base.publicKeyWithValues( 264 publicKey = Clipperz.Crypto.Base.publicKeyWithValues(
266 "10001", 265 "10001",
267 "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1", 266 "59fed719f8959a468de367f77a33a7536d53b8e4d25ed49ccc89a94cd6899da90415623fb73386e9635034fb65ad5f248445a1c66703f760d64a8271ad342b1",
268 "8de7066f67be16fcacd05d319b6729cd85fe698c07cec504776146eb7a041d9e3cacbf0fcd86441981c0083eed1f8f1b18393f0b186e47ce1b7b4981417b491" 267 "8de7066f67be16fcacd05d319b6729cd85fe698c07cec504776146eb7a041d9e3cacbf0fcd86441981c0083eed1f8f1b18393f0b186e47ce1b7b4981417b491"
269 ); 268 );
270t1 = new Date().getTime(); 269t1 = new Date().getTime();
271 encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey); 270 encryptedString = Clipperz.Crypto.Base.encryptUsingPrivateKey(publicKey, cleanKey);
272t2 = new Date().getTime(); 271t2 = new Date().getTime();
273//is("Encrypting with private key (512)", (t2 - t1)); 272//is("Encrypting with private key (512)", (t2 - t1));
274 273
275 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 512"); 274 is (isUndefinedOrNull(encryptedString), false, "An encrypted string is not empty - PRIVATE 512");
276t1 = new Date().getTime(); 275t1 = new Date().getTime();
277 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 512"); 276 is (cleanKey, Clipperz.Crypto.Base.decryptUsingPublicKey(publicKey, encryptedString), "I can encrypt and then decrypt safely - PRIVATE 512");
278t2 = new Date().getTime(); 277t2 = new Date().getTime();
279//is("Decrypting with public key (512)", (t2 - t1)); 278//is("Decrypting with public key (512)", (t2 - t1));
280 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PRIVATE 512"); 279 isnt (cleanKey, Clipperz.Crypto.Base.decryptUsingPrivateKey(publicKey, encryptedString), "I should not be able to decrypt using again th public key - PRIVATE 512");
281*/ 280*/
282/* 281/*
283 // 282 //
284 //1024 283 //1024
285 // 284 //
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/BigInt.html b/frontend/gamma/tests/tests/Clipperz/Crypto/BigInt.html
index b970a9a..f4db3b7 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/BigInt.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/BigInt.html
@@ -1,285 +1,284 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
35 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
37 36
38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
41</head> 40</head>
42<body> 41<body>
43<pre id="test"> 42<pre id="test">
44<script type="text/javascript"> 43<script type="text/javascript">
45try { 44try {
46 varbigInt_1; 45 varbigInt_1;
47 varbigInt_2; 46 varbigInt_2;
48 varresult; 47 varresult;
49 varexpectedResult; 48 varexpectedResult;
50 49
51 // 50 //
52 //Constructur and equality test 51 //Constructur and equality test
53 // 52 //
54 bigInt_1 = new Clipperz.Crypto.BigInt("110"); 53 bigInt_1 = new Clipperz.Crypto.BigInt("110");
55 is (bigInt_1.equals(bigInt_1), true, ""); 54 is (bigInt_1.equals(bigInt_1), true, "");
56 55
57 bigInt_1 = new Clipperz.Crypto.BigInt("110"); 56 bigInt_1 = new Clipperz.Crypto.BigInt("110");
58 bigInt_2 = new Clipperz.Crypto.BigInt("110", 10); 57 bigInt_2 = new Clipperz.Crypto.BigInt("110", 10);
59 is (bigInt_1.equals(bigInt_2), true, ""); 58 is (bigInt_1.equals(bigInt_2), true, "");
60 59
61 bigInt_1 = new Clipperz.Crypto.BigInt("110"); 60 bigInt_1 = new Clipperz.Crypto.BigInt("110");
62 bigInt_2 = new Clipperz.Crypto.BigInt(110); 61 bigInt_2 = new Clipperz.Crypto.BigInt(110);
63 is (bigInt_1.equals(bigInt_2), true, ""); 62 is (bigInt_1.equals(bigInt_2), true, "");
64 63
65 bigInt_1 = new Clipperz.Crypto.BigInt(6); 64 bigInt_1 = new Clipperz.Crypto.BigInt(6);
66 bigInt_2 = new Clipperz.Crypto.BigInt("110", 2); 65 bigInt_2 = new Clipperz.Crypto.BigInt("110", 2);
67 is (bigInt_1.equals(bigInt_2), true, ""); 66 is (bigInt_1.equals(bigInt_2), true, "");
68 67
69 bigInt_1 = new Clipperz.Crypto.BigInt(6); 68 bigInt_1 = new Clipperz.Crypto.BigInt(6);
70 bigInt_2 = new Clipperz.Crypto.BigInt("110", 3); 69 bigInt_2 = new Clipperz.Crypto.BigInt("110", 3);
71 is (bigInt_1.equals(bigInt_2), false, ""); 70 is (bigInt_1.equals(bigInt_2), false, "");
72 71
73 72
74 // 73 //
75 //Addition test 74 //Addition test
76 // 75 //
77 bigInt_1 = new Clipperz.Crypto.BigInt(6); 76 bigInt_1 = new Clipperz.Crypto.BigInt(6);
78 bigInt_2 = new Clipperz.Crypto.BigInt(110); 77 bigInt_2 = new Clipperz.Crypto.BigInt(110);
79 result = bigInt_1.add(bigInt_2); 78 result = bigInt_1.add(bigInt_2);
80 expectedResult = new Clipperz.Crypto.BigInt(116); 79 expectedResult = new Clipperz.Crypto.BigInt(116);
81 is (result.equals(expectedResult), true, ""); 80 is (result.equals(expectedResult), true, "");
82 is (result.equals(Clipperz.Crypto.BigInt.add(bigInt_1, bigInt_2)), true, "instance method === static function"); 81 is (result.equals(Clipperz.Crypto.BigInt.add(bigInt_1, bigInt_2)), true, "instance method === static function");
83 82
84 bigInt_1 = new Clipperz.Crypto.BigInt(6); 83 bigInt_1 = new Clipperz.Crypto.BigInt(6);
85 result = bigInt_1.add(6); 84 result = bigInt_1.add(6);
86 expectedResult = new Clipperz.Crypto.BigInt(12); 85 expectedResult = new Clipperz.Crypto.BigInt(12);
87 is (result.equals(expectedResult), true, ""); 86 is (result.equals(expectedResult), true, "");
88 87
89 bigInt_1 = new Clipperz.Crypto.BigInt("16161616161616161616161616161616161616161616161616161"); 88 bigInt_1 = new Clipperz.Crypto.BigInt("16161616161616161616161616161616161616161616161616161");
90 bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424"); 89 bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424");
91 result = bigInt_1.add(bigInt_2); 90 result = bigInt_1.add(bigInt_2);
92 expectedResult = new Clipperz.Crypto.BigInt("58585858585858585858585858585858585858585858585858585"); 91 expectedResult = new Clipperz.Crypto.BigInt("58585858585858585858585858585858585858585858585858585");
93 is (result.equals(expectedResult), true, ""); 92 is (result.equals(expectedResult), true, "");
94 93
95 bigInt_1 = new Clipperz.Crypto.BigInt("16161616161616161616161616161616161616161616161616161"); 94 bigInt_1 = new Clipperz.Crypto.BigInt("16161616161616161616161616161616161616161616161616161");
96 bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424"); 95 bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424");
97 result = bigInt_1.add(bigInt_2); 96 result = bigInt_1.add(bigInt_2);
98 expectedResult = new Clipperz.Crypto.BigInt("58585858585858585858585851585858585858585858585858585"); 97 expectedResult = new Clipperz.Crypto.BigInt("58585858585858585858585851585858585858585858585858585");
99 is (result.equals(expectedResult), false, ""); 98 is (result.equals(expectedResult), false, "");
100 99
101 bigInt_1 = new Clipperz.Crypto.BigInt("86161616161616161616161616161616161616161616161616161"); 100 bigInt_1 = new Clipperz.Crypto.BigInt("86161616161616161616161616161616161616161616161616161");
102 bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424"); 101 bigInt_2 = new Clipperz.Crypto.BigInt("42424242424242424242424242424242424242424242424242424");
103 result = bigInt_1.add(bigInt_2); 102 result = bigInt_1.add(bigInt_2);
104 expectedResult = new Clipperz.Crypto.BigInt("128585858585858585858585858585858585858585858585858585"); 103 expectedResult = new Clipperz.Crypto.BigInt("128585858585858585858585858585858585858585858585858585");
105 is (result.equals(expectedResult), true, ""); 104 is (result.equals(expectedResult), true, "");
106 105
107 bigInt_1 = new Clipperz.Crypto.BigInt("6541652165410321654063516540621063540654" + 106 bigInt_1 = new Clipperz.Crypto.BigInt("6541652165410321654063516540621063540654" +
108 "0654065106540654165416521654103216540635" + 107 "0654065106540654165416521654103216540635" +
109 "1654062106354065406540651065406541"); 108 "1654062106354065406540651065406541");
110 bigInt_2 = new Clipperz.Crypto.BigInt("3046540351035403510354035103510351351351" + 109 bigInt_2 = new Clipperz.Crypto.BigInt("3046540351035403510354035103510351351351" +
111 "0351350435103213540634132135401351035403" + 110 "0351350435103213540634132135401351035403" +
112 "5403540354103540"); 111 "5403540354103540");
113 result = bigInt_1.add(bigInt_2); 112 result = bigInt_1.add(bigInt_2);
114 expectedResult = new Clipperz.Crypto.BigInt("6541652165410321657110056891656467051008" + 113 expectedResult = new Clipperz.Crypto.BigInt("6541652165410321657110056891656467051008" +
115 "1005100210054167675767872089206430081269" + 114 "1005100210054167675767872089206430081269" +
116 "2975416119864419441944191419510081"); 115 "2975416119864419441944191419510081");
117 is (result.equals(expectedResult), true, ""); 116 is (result.equals(expectedResult), true, "");
118 117
119 118
120 // 119 //
121 //Moltiplication test 120 //Moltiplication test
122 // 121 //
123 bigInt_1 = new Clipperz.Crypto.BigInt(6); 122 bigInt_1 = new Clipperz.Crypto.BigInt(6);
124 bigInt_2 = new Clipperz.Crypto.BigInt(110); 123 bigInt_2 = new Clipperz.Crypto.BigInt(110);
125 result = bigInt_1.multiply(bigInt_2); 124 result = bigInt_1.multiply(bigInt_2);
126 expectedResult = new Clipperz.Crypto.BigInt(660); 125 expectedResult = new Clipperz.Crypto.BigInt(660);
127 is (result.equals(expectedResult), true, ""); 126 is (result.equals(expectedResult), true, "");
128 127
129 bigInt_1 = new Clipperz.Crypto.BigInt(6); 128 bigInt_1 = new Clipperz.Crypto.BigInt(6);
130 result = bigInt_1.multiply(5); 129 result = bigInt_1.multiply(5);
131 expectedResult = new Clipperz.Crypto.BigInt(30); 130 expectedResult = new Clipperz.Crypto.BigInt(30);
132 is (result.equals(expectedResult), true, ""); 131 is (result.equals(expectedResult), true, "");
133 132
134 bigInt_1 = new Clipperz.Crypto.BigInt("5465465165465465132743540354354032135463" + 133 bigInt_1 = new Clipperz.Crypto.BigInt("5465465165465465132743540354354032135463" +
135 "5435135403513516843052413543054035"); 134 "5435135403513516843052413543054035");
136 bigInt_2 = new Clipperz.Crypto.BigInt("3543513543543213543032135435413054365430" + 135 bigInt_2 = new Clipperz.Crypto.BigInt("3543513543543213543032135435413054365430" +
137 "5130513540351354354305435403"); 136 "5130513540351354354305435403");
138 result = bigInt_1.multiply(bigInt_2); 137 result = bigInt_1.multiply(bigInt_2);
139 expectedResult = new Clipperz.Crypto.BigInt("1936694983559052629352223965314822970014" + 138 expectedResult = new Clipperz.Crypto.BigInt("1936694983559052629352223965314822970014" +
140 "6364423657014976098029153153101751605574" + 139 "6364423657014976098029153153101751605574" +
141 "5077086464435601381095664357540911830059" + 140 "5077086464435601381095664357540911830059" +
142 "9503335163757031001105"); 141 "9503335163757031001105");
143 is (result.equals(expectedResult), true, ""); 142 is (result.equals(expectedResult), true, "");
144 143
145 // 144 //
146 //Module test 145 //Module test
147 // 146 //
148 bigInt_1 = new Clipperz.Crypto.BigInt(106); 147 bigInt_1 = new Clipperz.Crypto.BigInt(106);
149 bigInt_2 = new Clipperz.Crypto.BigInt(10); 148 bigInt_2 = new Clipperz.Crypto.BigInt(10);
150 result = bigInt_1.module(bigInt_2); 149 result = bigInt_1.module(bigInt_2);
151 expectedResult = new Clipperz.Crypto.BigInt(6); 150 expectedResult = new Clipperz.Crypto.BigInt(6);
152 is (result.equals(expectedResult), true, ""); 151 is (result.equals(expectedResult), true, "");
153 152
154 bigInt_1 = new Clipperz.Crypto.BigInt(106); 153 bigInt_1 = new Clipperz.Crypto.BigInt(106);
155 result = bigInt_1.module(10); 154 result = bigInt_1.module(10);
156 expectedResult = new Clipperz.Crypto.BigInt(6); 155 expectedResult = new Clipperz.Crypto.BigInt(6);
157 is (result.equals(expectedResult), true, ""); 156 is (result.equals(expectedResult), true, "");
158 157
159 bigInt_1 = new Clipperz.Crypto.BigInt("5465465465468468465468463541358438543513" + 158 bigInt_1 = new Clipperz.Crypto.BigInt("5465465465468468465468463541358438543513" +
160 "8543135435135423545624354235123512531235" + 159 "8543135435135423545624354235123512531235" +
161 "1356463543840351351305135435121354305413" + 160 "1356463543840351351305135435121354305413" +
162 "543"); 161 "543");
163 162
164 163
165 bigInt_2 = new Clipperz.Crypto.BigInt("3543543213543213540543545463542354385768" + 164 bigInt_2 = new Clipperz.Crypto.BigInt("3543543213543213540543545463542354385768" +
166 "512584354354215"); 165 "512584354354215");
167 result = bigInt_1.module(bigInt_2); 166 result = bigInt_1.module(bigInt_2);
168 expectedResult = new Clipperz.Crypto.BigInt("52689987206612998786765715819079250963638640081836513"); 167 expectedResult = new Clipperz.Crypto.BigInt("52689987206612998786765715819079250963638640081836513");
169 is (result.equals(expectedResult), true, ""); 168 is (result.equals(expectedResult), true, "");
170 169
171 // 170 //
172 //Power (Module) test 171 //Power (Module) test
173 // 172 //
174 bigInt_1 = new Clipperz.Crypto.BigInt(6); 173 bigInt_1 = new Clipperz.Crypto.BigInt(6);
175 bigInt_2 = new Clipperz.Crypto.BigInt(3); 174 bigInt_2 = new Clipperz.Crypto.BigInt(3);
176 result = bigInt_1.powerModule(bigInt_2, new Clipperz.Crypto.BigInt(1000)); 175 result = bigInt_1.powerModule(bigInt_2, new Clipperz.Crypto.BigInt(1000));
177 expectedResult = new Clipperz.Crypto.BigInt(216); 176 expectedResult = new Clipperz.Crypto.BigInt(216);
178 is (result.equals(expectedResult), true, ""); 177 is (result.equals(expectedResult), true, "");
179 178
180 bigInt_1 = new Clipperz.Crypto.BigInt(6); 179 bigInt_1 = new Clipperz.Crypto.BigInt(6);
181 result = bigInt_1.powerModule(3, 1000); 180 result = bigInt_1.powerModule(3, 1000);
182 expectedResult = new Clipperz.Crypto.BigInt(216); 181 expectedResult = new Clipperz.Crypto.BigInt(216);
183 is (result.equals(expectedResult), true, ""); 182 is (result.equals(expectedResult), true, "");
184 183
185 bigInt_1 = new Clipperz.Crypto.BigInt("354354354354687638546846846846846576876468746846846846"); 184 bigInt_1 = new Clipperz.Crypto.BigInt("354354354354687638546846846846846576876468746846846846");
186 bigInt_2 = new Clipperz.Crypto.BigInt("354"); 185 bigInt_2 = new Clipperz.Crypto.BigInt("354");
187 result = bigInt_1.powerModule(bigInt_2, new Clipperz.Crypto.BigInt("3543541354354354354354351354354351354354354354354354")); 186 result = bigInt_1.powerModule(bigInt_2, new Clipperz.Crypto.BigInt("3543541354354354354354351354354351354354354354354354"));
188 expectedResult = new Clipperz.Crypto.BigInt("1957028940698171231089373321334263118681605242465644"); 187 expectedResult = new Clipperz.Crypto.BigInt("1957028940698171231089373321334263118681605242465644");
189 is (result.equals(expectedResult), true, ""); 188 is (result.equals(expectedResult), true, "");
190 189
191 bigInt_1 = new Clipperz.Crypto.BigInt("e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", 16); 190 bigInt_1 = new Clipperz.Crypto.BigInt("e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", 16);
192 //is(bigInt_1.toString(16), "e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", "IE bug"); 191 //is(bigInt_1.toString(16), "e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", "IE bug");
193 is(bigInt_1.asString(16), "e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", "fix for IE bug"); 192 is(bigInt_1.asString(16), "e0f6c73cf1d3715a0d77dc3a4eb9c66c01d913c91bc22d9672d83958445424a1", "fix for IE bug");
194 193
195 194
196 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 195 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
197 is(bigInt_1.asString(16, 64), "000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", "fix to ensure the string representation has a minimum fixed length"); 196 is(bigInt_1.asString(16, 64), "000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", "fix to ensure the string representation has a minimum fixed length");
198 197
199/* 198/*
200 // 199 //
201 //Comparison 200 //Comparison
202 // 201 //
203 bigInt_1 = new Clipperz.Crypto.BigInt("0", 10); 202 bigInt_1 = new Clipperz.Crypto.BigInt("0", 10);
204 bigInt_2 = new Clipperz.Crypto.BigInt("0", 10); 203 bigInt_2 = new Clipperz.Crypto.BigInt("0", 10);
205 is (bigInt_1.equals(bigInt_2), true, "bigInt(0) = bigInt(0)"); 204 is (bigInt_1.equals(bigInt_2), true, "bigInt(0) = bigInt(0)");
206 is (bigInt_1.equals(0), true, "bigInt(0) = 0"); 205 is (bigInt_1.equals(0), true, "bigInt(0) = 0");
207 206
208 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 207 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
209 is (bigInt_1.equals(bigInt_2), false, "bigInt(xxxxxx) != bigInt(0)"); 208 is (bigInt_1.equals(bigInt_2), false, "bigInt(xxxxxx) != bigInt(0)");
210 is (bigInt_1.equals(0), false, "bigInt(xxxxx) != 0"); 209 is (bigInt_1.equals(0), false, "bigInt(xxxxx) != 0");
211 210
212 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 211 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
213 bigInt_2 = new Clipperz.Crypto.BigInt("0", 16); 212 bigInt_2 = new Clipperz.Crypto.BigInt("0", 16);
214 is(bigInt_1.compare(bigInt_2), 1, "bigInt(xxxxxx) > bigInt(0)"); 213 is(bigInt_1.compare(bigInt_2), 1, "bigInt(xxxxxx) > bigInt(0)");
215 is(bigInt_2.compare(bigInt_1), -1, "bigInt(0) < bigInt(xxxx)"); 214 is(bigInt_2.compare(bigInt_1), -1, "bigInt(0) < bigInt(xxxx)");
216 215
217 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 216 bigInt_1 = new Clipperz.Crypto.BigInt("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
218 bigInt_2 = new Clipperz.Crypto.BigInt("05", 16); 217 bigInt_2 = new Clipperz.Crypto.BigInt("05", 16);
219 is(bigInt_1.compare(bigInt_2), 1, "bigInt(xxxxxx) > bigInt(05)"); 218 is(bigInt_1.compare(bigInt_2), 1, "bigInt(xxxxxx) > bigInt(05)");
220 is(bigInt_2.compare(bigInt_1), -1, "bigInt(05) < bigInt(xxxx)"); 219 is(bigInt_2.compare(bigInt_1), -1, "bigInt(05) < bigInt(xxxx)");
221 220
222 bigInt_1 = new Clipperz.Crypto.BigInt("-10", 10); 221 bigInt_1 = new Clipperz.Crypto.BigInt("-10", 10);
223 bigInt_2 = new Clipperz.Crypto.BigInt("10", 10); 222 bigInt_2 = new Clipperz.Crypto.BigInt("10", 10);
224 is(bigInt_1.equals(bigInt_2), true, "bigInt(-10) - bigInt(10). No negative number are managed"); 223 is(bigInt_1.equals(bigInt_2), true, "bigInt(-10) - bigInt(10). No negative number are managed");
225 224
226 // 225 //
227 //XOR 226 //XOR
228 // 227 //
229 bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 228 bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
230 bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 229 bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
231 result = bigInt_1.xor(bigInt_2); 230 result = bigInt_1.xor(bigInt_2);
232 expectedResult = new Clipperz.Crypto.BigInt(0); 231 expectedResult = new Clipperz.Crypto.BigInt(0);
233 is(result.asString(16), expectedResult.asString(16), "a xor a = 0"); 232 is(result.asString(16), expectedResult.asString(16), "a xor a = 0");
234 233
235 // 234 //
236 bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 235 bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
237 bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855", 16); 236 bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855", 16);
238 result = bigInt_1.xor(bigInt_2); 237 result = bigInt_1.xor(bigInt_2);
239 expectedResult = new Clipperz.Crypto.BigInt('295147905179352825856'); 238 expectedResult = new Clipperz.Crypto.BigInt('295147905179352825856');
240 is(result.asString(16), expectedResult.asString(16), "single bit difference"); 239 is(result.asString(16), expectedResult.asString(16), "single bit difference");
241 240
242 // 241 //
243 bigInt_1 = new Clipperz.Crypto.BigInt("01", 16); 242 bigInt_1 = new Clipperz.Crypto.BigInt("01", 16);
244 bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855", 16); 243 bigInt_2 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855", 16);
245 result = bigInt_1.xor(bigInt_2); 244 result = bigInt_1.xor(bigInt_2);
246 expectedResult = new Clipperz.Crypto.BigInt('102987336249554097029535212322581322789799900648198034993674544906295017912404'); 245 expectedResult = new Clipperz.Crypto.BigInt('102987336249554097029535212322581322789799900648198034993674544906295017912404');
247 is(result.asString(16), expectedResult.asString(16), "01 xor value"); 246 is(result.asString(16), expectedResult.asString(16), "01 xor value");
248 247
249 // 248 //
250 bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 249 bigInt_1 = new Clipperz.Crypto.BigInt("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
251 bigInt_2 = new Clipperz.Crypto.BigInt("f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 250 bigInt_2 = new Clipperz.Crypto.BigInt("f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
252 result = bigInt_1.xor(bigInt_2); 251 result = bigInt_1.xor(bigInt_2);
253 expectedResult = new Clipperz.Crypto.BigInt('7237005577332262213973186563042994240829374041602535252466099000494570602496'); 252 expectedResult = new Clipperz.Crypto.BigInt('7237005577332262213973186563042994240829374041602535252466099000494570602496');
254 is(result.asString(16), expectedResult.asString(16), "first bit difference xor"); 253 is(result.asString(16), expectedResult.asString(16), "first bit difference xor");
255 254
256 255
257 // 256 //
258 //isBitSet 257 //isBitSet
259 // 258 //
260 bigInt_1 = new Clipperz.Crypto.BigInt("ff", 16); 259 bigInt_1 = new Clipperz.Crypto.BigInt("ff", 16);
261 result = bigInt_1.isBitSet(1); 260 result = bigInt_1.isBitSet(1);
262 expectedResult = true; 261 expectedResult = true;
263 is(result, expectedResult, "'ff'.isBitSet(1)"); 262 is(result, expectedResult, "'ff'.isBitSet(1)");
264 263
265 bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16); 264 bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16);
266 result = bigInt_1.isBitSet(1); 265 result = bigInt_1.isBitSet(1);
267 expectedResult = false; 266 expectedResult = false;
268 is(result, expectedResult, "'f0'.isBitSet(1)"); 267 is(result, expectedResult, "'f0'.isBitSet(1)");
269 268
270 bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16); 269 bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16);
271 result = bigInt_1.isBitSet(3); 270 result = bigInt_1.isBitSet(3);
272 expectedResult = false; 271 expectedResult = false;
273 is(result, expectedResult, "'f0'.isBitSet(3)"); 272 is(result, expectedResult, "'f0'.isBitSet(3)");
274 273
275 bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16); 274 bigInt_1 = new Clipperz.Crypto.BigInt("f0", 16);
276 result = bigInt_1.isBitSet(4); 275 result = bigInt_1.isBitSet(4);
277 expectedResult = true; 276 expectedResult = true;
278 is(result, expectedResult, "'f0'.isBitSet(4)"); 277 is(result, expectedResult, "'f0'.isBitSet(4)");
279 278
280 bigInt_1 = new Clipperz.Crypto.BigInt("ff00", 16); 279 bigInt_1 = new Clipperz.Crypto.BigInt("ff00", 16);
281 result = bigInt_1.isBitSet(7); 280 result = bigInt_1.isBitSet(7);
282 expectedResult = false; 281 expectedResult = false;
283 is(result, expectedResult, "'ff00'.isBitSet(7)"); 282 is(result, expectedResult, "'ff00'.isBitSet(7)");
284 283
285 bigInt_1 = new Clipperz.Crypto.BigInt("ff00", 16); 284 bigInt_1 = new Clipperz.Crypto.BigInt("ff00", 16);
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.B283.html b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.B283.html
index 6024021..93d8695 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.B283.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.B283.html
@@ -1,206 +1,205 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
35 34
36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
38<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>--> 37<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>-->
39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
44</head> 43</head>
45<body> 44<body>
46<pre id="test"> 45<pre id="test">
47<script type="text/javascript"> 46<script type="text/javascript">
48try { 47try {
49 // 48 //
50 //ECC.BinaryFiniteField 49 //ECC.BinaryFiniteField
51 // 50 //
52 varf2m; 51 varf2m;
53 varf2m_improved; 52 varf2m_improved;
54 var a, a1, b; 53 var a, a1, b;
55 var result; 54 var result;
56 var result_improved; 55 var result_improved;
57 var expectedResul; 56 var expectedResul;
58 57
59 f2m = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16)}) 58 f2m = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:new Clipperz.Crypto.ECC.BinaryField.Value('08000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 000010a1', 16)})
60 f2m_improved = Clipperz.Crypto.ECC.StandardCurves.B283().finiteField(); 59 f2m_improved = Clipperz.Crypto.ECC.StandardCurves.B283().finiteField();
61 a = new Clipperz.Crypto.ECC.BinaryField.Value("05c91e41 d9ca17ef 9d8a33c1 a44eba6d 368fde02 1c492077 1a46eb01 a481e5f7 f430749d", 16); 60 a = new Clipperz.Crypto.ECC.BinaryField.Value("05c91e41 d9ca17ef 9d8a33c1 a44eba6d 368fde02 1c492077 1a46eb01 a481e5f7 f430749d", 16);
62 b = new Clipperz.Crypto.ECC.BinaryField.Value("07377071 2de7d57b a803f65f 45786c06 876b8066 db75ec47 81c053b0 a0f78e2c a6ab5187", 16); 61 b = new Clipperz.Crypto.ECC.BinaryField.Value("07377071 2de7d57b a803f65f 45786c06 876b8066 db75ec47 81c053b0 a0f78e2c a6ab5187", 16);
63 62
64 // 63 //
65 //addition 64 //addition
66 // 65 //
67 result = f2m.add(a, b); 66 result = f2m.add(a, b);
68 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16); 67 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16);
69 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.add"); 68 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.add");
70 69
71 70
72 // 71 //
73 //negation 72 //negation
74 // 73 //
75 result = f2m.negate(a); 74 result = f2m.negate(a);
76 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16); 75 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16);
77 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.negate"); 76 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.negate");
78 77
79 78
80 // 79 //
81 //multiplication 80 //multiplication
82 // 81 //
83 result = f2m.multiply(a, b); 82 result = f2m.multiply(a, b);
84 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2bacb89668741f6d1f7fd7d3df2f045814086adba11d8bb5f12f3f9851e3b66fbe283cb", 16); 83 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2bacb89668741f6d1f7fd7d3df2f045814086adba11d8bb5f12f3f9851e3b66fbe283cb", 16);
85 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.multiply"); 84 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.multiply");
86 85
87 86
88 // 87 //
89 //fast multiplication 88 //fast multiplication
90 // 89 //
91 result = f2m.fastMultiply(a, b); 90 result = f2m.fastMultiply(a, b);
92 expectedResult = f2m.multiply(a, b); 91 expectedResult = f2m.multiply(a, b);
93 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply"); 92 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply");
94 93
95 a = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16); 94 a = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16);
96 b = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16); 95 b = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16);
97 result = f2m.fastMultiply(a, b); 96 result = f2m.fastMultiply(a, b);
98 expectedResult = f2m.multiply(a, b); 97 expectedResult = f2m.multiply(a, b);
99 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.B283.fastMultiply"); 98 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.B283.fastMultiply");
100 99
101 // 100 //
102 //square 101 //square
103 // 102 //
104 a = new Clipperz.Crypto.ECC.BinaryField.Value("1111", 16); 103 a = new Clipperz.Crypto.ECC.BinaryField.Value("1111", 16);
105 result = f2m.square(a); 104 result = f2m.square(a);
106 expectedResult = f2m.multiply(a, a); 105 expectedResult = f2m.multiply(a, a);
107 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square"); 106 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
108 107
109 a = new Clipperz.Crypto.ECC.BinaryField.Value("11111111", 16); 108 a = new Clipperz.Crypto.ECC.BinaryField.Value("11111111", 16);
110 result = f2m.square(a); 109 result = f2m.square(a);
111 expectedResult = f2m.multiply(a, a); 110 expectedResult = f2m.multiply(a, a);
112 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square"); 111 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
113 112
114 a = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16); 113 a = new Clipperz.Crypto.ECC.BinaryField.Value("5c91e41d9ca17ef9d8a33c1a44eba6d368fde021c4920771a46eb01a481e5f7f430749d", 16);
115 result = f2m.square(a); 114 result = f2m.square(a);
116 expectedResult = f2m.multiply(a, a); 115 expectedResult = f2m.multiply(a, a);
117 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square"); 116 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
118 117
119 118
120 // 119 //
121 //inverse 120 //inverse
122 // 121 //
123 a = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16); 122 a = new Clipperz.Crypto.ECC.BinaryField.Value("2fe6e30f42dc2943589c59ee136d66bb1e45e64c73ccc309b86b8b104766bdb529b251a", 16);
124 result = f2m.inverse(a); 123 result = f2m.inverse(a);
125 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("3812fc574f3728c60384e141c0e2a808e21adec22dcd407b9e25dd13c6d1bf22defd84a", 16); 124 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("3812fc574f3728c60384e141c0e2a808e21adec22dcd407b9e25dd13c6d1bf22defd84a", 16);
126 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.inverse"); 125 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.inverse");
127 126
128 127
129 // 128 //
130 //module 129 //module
131 // 130 //
132 131
133 a = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 132 a = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
134 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 133 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
135 result = f2m.module(a); 134 result = f2m.module(a);
136 result_improved = f2m_improved.module(a1); 135 result_improved = f2m_improved.module(a1);
137 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2bacb89668741f6d1f7fd7d3df2f045814086adba11d8bb5f12f3f9851e3b66fbe283cb", 16); 136 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("2bacb89668741f6d1f7fd7d3df2f045814086adba11d8bb5f12f3f9851e3b66fbe283cb", 16);
138 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module"); 137 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module");
139 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved)"); 138 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved)");
140 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods"); 139 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods");
141 140
142 141
143 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16); 142 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
144 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16); 143 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
145 result = f2m.module(a); 144 result = f2m.module(a);
146 result_improved = f2m_improved.module(a1); 145 result_improved = f2m_improved.module(a1);
147 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("15e2097d116e745ac47480807cb5eb99dad902728aaf5692241063bc70a5b372dbce798", 16); 146 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("15e2097d116e745ac47480807cb5eb99dad902728aaf5692241063bc70a5b372dbce798", 16);
148 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (2)"); 147 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (2)");
149 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (2)"); 148 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (2)");
150 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (2)"); 149 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (2)");
151 150
152 151
153 a = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 152 a = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
154 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 153 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
155 result = f2m.module(a); 154 result = f2m.module(a);
156 result_improved = f2m_improved.module(a1); 155 result_improved = f2m_improved.module(a1);
157 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("40f04cec8fe9caedf82adeff7e1aa06dcb9d08e097db8be2ad54b2ddc2e752152395623", 16); 156 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("40f04cec8fe9caedf82adeff7e1aa06dcb9d08e097db8be2ad54b2ddc2e752152395623", 16);
158 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (3)"); 157 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (3)");
159 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (3)"); 158 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (3)");
160 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (3)"); 159 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (3)");
161 160
162 161
163 a = new Clipperz.Crypto.ECC.BinaryField.Value("02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16); 162 a = new Clipperz.Crypto.ECC.BinaryField.Value("02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16);
164 is(a.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value as expected (4)") 163 is(a.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value as expected (4)")
165 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16); 164 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16);
166 result = f2m.module(a); 165 result = f2m.module(a);
167 result_improved = f2m_improved.module(a1); 166 result_improved = f2m_improved.module(a1);
168 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16); 167 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16);
169 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (4)"); 168 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (4)");
170 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (4)"); 169 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (4)");
171 is(result_improved.asString(16), "ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", "ECC.BinaryFinetField.module (static check) (4)"); 170 is(result_improved.asString(16), "ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", "ECC.BinaryFinetField.module (static check) (4)");
172 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (4)"); 171 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (4)");
173 172
174 is(a.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value preserved by standard method (4)") 173 is(a.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value preserved by standard method (4)")
175 is(a1.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value preserved by improved method (4)") 174 is(a1.asString(16), "02f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", "ECC.BinaryFiniteField - original value preserved by improved method (4)")
176 175
177 176
178 a = new Clipperz.Crypto.ECC.BinaryField.Value("2f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16); 177 a = new Clipperz.Crypto.ECC.BinaryField.Value("2f4bf57710a7e0826a80a339e59e34476c343e75452e4bf4355847e6b41e655ecb08f4c418b172d7963c525c26fdc84ac294a348d3907652f0fcbff3e4c8e2238a478e4277489ce", 16);
179 result_improved = f2m_improved.module(a); 178 result_improved = f2m_improved.module(a);
180 result = f2m.module(a); 179 result = f2m.module(a);
181 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16); 180 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", 16);
182 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (5)"); 181 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (5)");
183 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (5)"); 182 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFiniteField.module (improved) (5)");
184 is(result_improved.asString(16), "ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", "ECC.BinaryFinetField.module (static check) (5)"); 183 is(result_improved.asString(16), "ba35032a24eb81238251d85824998bebae3b3e09f4d3845256c87585cf62416ee43191", "ECC.BinaryFinetField.module (static check) (5)");
185 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (5)"); 184 is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods (5)");
186 185
187 //------------------------------------------------------------------------- 186 //-------------------------------------------------------------------------
188} catch (err) { 187} catch (err) {
189 188
190 var s = "test suite failure!\n"; 189 var s = "test suite failure!\n";
191 var o = {}; 190 var o = {};
192 var k = null; 191 var k = null;
193 for (k in err) { 192 for (k in err) {
194 // ensure unique keys?! 193 // ensure unique keys?!
195 if (!o[k]) { 194 if (!o[k]) {
196 s += k + ": " + err[k] + "\n"; 195 s += k + ": " + err[k] + "\n";
197 o[k] = err[k]; 196 o[k] = err[k];
198 } 197 }
199 } 198 }
200 ok ( false, s ); 199 ok ( false, s );
201} 200}
202 201
203</script> 202</script>
204</pre> 203</pre>
205</body> 204</body>
206</html> 205</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.html b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.html
index 5a7a4f7..658c402 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.FiniteField.html
@@ -1,180 +1,179 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
35 34
36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
38<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>--> 37<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>-->
39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
44</head> 43</head>
45<body> 44<body>
46<pre id="test"> 45<pre id="test">
47<script type="text/javascript"> 46<script type="text/javascript">
48try { 47try {
49 // 48 //
50 //ECC.BinaryFiniteField 49 //ECC.BinaryFiniteField
51 // 50 //
52 varf2m; 51 varf2m;
53 varf2m_improved; 52 varf2m_improved;
54 var a, b; 53 var a, b;
55 var result; 54 var result;
56 var result_improved; 55 var result_improved;
57 var expectedResul; 56 var expectedResul;
58 57
59 f2m = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:new Clipperz.Crypto.ECC.BinaryField.Value('80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425', 16)}) 58 f2m = new Clipperz.Crypto.ECC.BinaryField.FiniteField({modulus:new Clipperz.Crypto.ECC.BinaryField.Value('80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425', 16)})
60 f2m_improved = Clipperz.Crypto.ECC.StandardCurves.B571().finiteField(); 59 f2m_improved = Clipperz.Crypto.ECC.StandardCurves.B571().finiteField();
61 a = new Clipperz.Crypto.ECC.BinaryField.Value("01401ca8 7b8f1446 84a2c58a e9308c23 7789e4bf 1f36dd11 7c150b7d 6076dd1d a6197fe4 c5225a06 4db0e422 2589d5ca 50eb6bb6 b7147a03 f6152843 8a8767c6 a6c4a688 3fd6f067", 16); 60 a = new Clipperz.Crypto.ECC.BinaryField.Value("01401ca8 7b8f1446 84a2c58a e9308c23 7789e4bf 1f36dd11 7c150b7d 6076dd1d a6197fe4 c5225a06 4db0e422 2589d5ca 50eb6bb6 b7147a03 f6152843 8a8767c6 a6c4a688 3fd6f067", 16);
62 b = new Clipperz.Crypto.ECC.BinaryField.Value("0112f5c9 7e74737b 38925faf e22cea3e 12b868d4 ddea5b33 41db8fc2 e788cab7 4f0a7a3c c27087a8 93659453 69938650 a99217d5 66e13f80 dc87f082 73f7411b 6b01ef1d 399c772a", 16); 61 b = new Clipperz.Crypto.ECC.BinaryField.Value("0112f5c9 7e74737b 38925faf e22cea3e 12b868d4 ddea5b33 41db8fc2 e788cab7 4f0a7a3c c27087a8 93659453 69938650 a99217d5 66e13f80 dc87f082 73f7411b 6b01ef1d 399c772a", 16);
63 62
64 // 63 //
65 //addition 64 //addition
66 // 65 //
67 result = f2m.add(a, b); 66 result = f2m.add(a, b);
68 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("52e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d", 16); 67 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("52e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d", 16);
69 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.add"); 68 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.add");
70 69
71 70
72 // 71 //
73 //negation 72 //negation
74 // 73 //
75 result = f2m.negate(a); 74 result = f2m.negate(a);
76 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 75 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
77 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.negate"); 76 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.negate");
78 77
79 78
80 // 79 //
81 //multiplication 80 //multiplication
82 // 81 //
83 result = f2m.multiply(a, b); 82 result = f2m.multiply(a, b);
84 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("4f8e4c0ae7664b284d3b4cb1b3f9568a1ce6e6e96b5381e184fe0822cb3d5c3a3f01ffd0206355d9e5c4853472bb33cf6b2d861d6b48c39d33a360e9a63ad2f7102f92e68a12312", 16); 83 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("4f8e4c0ae7664b284d3b4cb1b3f9568a1ce6e6e96b5381e184fe0822cb3d5c3a3f01ffd0206355d9e5c4853472bb33cf6b2d861d6b48c39d33a360e9a63ad2f7102f92e68a12312", 16);
85 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.multiply"); 84 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.multiply");
86 85
87 86
88 // 87 //
89 //fast multiplication 88 //fast multiplication
90 // 89 //
91 result = f2m.fastMultiply(a, b); 90 result = f2m.fastMultiply(a, b);
92 expectedResult = f2m.multiply(a, b); 91 expectedResult = f2m.multiply(a, b);
93 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply"); 92 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply");
94 93
95 a = new Clipperz.Crypto.ECC.BinaryField.Value("52e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d", 16); 94 a = new Clipperz.Crypto.ECC.BinaryField.Value("52e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d", 16);
96 b = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 95 b = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
97 result = f2m.fastMultiply(a, b); 96 result = f2m.fastMultiply(a, b);
98 expectedResult = f2m.multiply(a, b); 97 expectedResult = f2m.multiply(a, b);
99 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply"); 98 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.fastMultiply");
100 99
101 // 100 //
102 //square 101 //square
103 // 102 //
104 a = new Clipperz.Crypto.ECC.BinaryField.Value("1111", 16); 103 a = new Clipperz.Crypto.ECC.BinaryField.Value("1111", 16);
105 result = f2m.square(a); 104 result = f2m.square(a);
106 expectedResult = f2m.multiply(a, a); 105 expectedResult = f2m.multiply(a, a);
107 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square"); 106 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
108 107
109 a = new Clipperz.Crypto.ECC.BinaryField.Value("11111111", 16); 108 a = new Clipperz.Crypto.ECC.BinaryField.Value("11111111", 16);
110 result = f2m.square(a); 109 result = f2m.square(a);
111 expectedResult = f2m.multiply(a, a); 110 expectedResult = f2m.multiply(a, a);
112 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square"); 111 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
113 112
114 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 113 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
115 result = f2m.square(a); 114 result = f2m.square(a);
116 expectedResult = f2m.multiply(a, a); 115 expectedResult = f2m.multiply(a, a);
117 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square"); 116 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.square");
118 117
119 118
120 // 119 //
121 //inverse 120 //inverse
122 // 121 //
123 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 122 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
124 result = f2m.inverse(a); 123 result = f2m.inverse(a);
125 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1f898c60983c4e807e619b9cbe528585fc33aaae419d5e5cb2107269ccdcf21d5ad5b5d78d37fa435a0d0a8a75f2506240c325c6a2eee1a03008f9e1b9c6c0a511b730cdaf9b97e", 16); 124 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1f898c60983c4e807e619b9cbe528585fc33aaae419d5e5cb2107269ccdcf21d5ad5b5d78d37fa435a0d0a8a75f2506240c325c6a2eee1a03008f9e1b9c6c0a511b730cdaf9b97e", 16);
126 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.inverse"); 125 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.inverse");
127 126
128 127
129 // 128 //
130 //module 129 //module
131 // 130 //
132 131
133 a = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 132 a = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
134 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 133 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("015655ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f060a0aa6c29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
135 result = f2m.module(a); 134 result = f2m.module(a);
136 result_improved = f2m_improved.module(a1); 135 result_improved = f2m_improved.module(a1);
137 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("4f8e4c0ae7664b284d3b4cb1b3f9568a1ce6e6e96b5381e184fe0822cb3d5c3a3f01ffd0206355d9e5c4853472bb33cf6b2d861d6b48c39d33a360e9a63ad2f7102f92e68a12312", 16); 136 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("4f8e4c0ae7664b284d3b4cb1b3f9568a1ce6e6e96b5381e184fe0822cb3d5c3a3f01ffd0206355d9e5c4853472bb33cf6b2d861d6b48c39d33a360e9a63ad2f7102f92e68a12312", 16);
138 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module"); 137 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module");
139 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved)"); 138 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved)");
140 //is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods"); 139 //is(result.asString(16), result_improved.asString(16), "standard vs improved 'module' methods");
141 140
142 141
143 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16); 142 a = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
144 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16); 143 a1 = new Clipperz.Crypto.ECC.BinaryField.Value("1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
145 result = f2m.module(a); 144 result = f2m.module(a);
146 result_improved = f2m_improved.module(a1); 145 result_improved = f2m_improved.module(a1);
147 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1704018ce75dc462a5ccd1eb18b8002ecb8536c616ec625f440f6888f8c32387e53a5cb3b6050688e9b64a32215a385ee98c518d6a484d5ac0ceeafa825743c84b075bdfabc341b", 16); 146 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("1704018ce75dc462a5ccd1eb18b8002ecb8536c616ec625f440f6888f8c32387e53a5cb3b6050688e9b64a32215a385ee98c518d6a484d5ac0ceeafa825743c84b075bdfabc341b", 16);
148 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (2)"); 147 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (2)");
149 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved) (2)"); 148 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved) (2)");
150 is(a.asString(16), "1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", "ECC.BinaryFinetField.module (2)"); 149 is(a.asString(16), "1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", "ECC.BinaryFinetField.module (2)");
151 is(a1.asString(16), "1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", "ECC.BinaryFinetField.module (2)"); 150 is(a1.asString(16), "1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", "ECC.BinaryFinetField.module (2)");
152 151
153 152
154 a = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 153 a = new Clipperz.Crypto.ECC.BinaryField.Value("112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a1401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
155 result = f2m.module(a); 154 result = f2m.module(a);
156 result_improved = f2m_improved.module(a); 155 result_improved = f2m_improved.module(a);
157 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("e160dd4a436e63877e1343d06576beaa66e06863ffe4335be38d6a37460a62d11133584a5bc6ac0590e18942e1fa88bb64a4d9fc6c1fd7b55d7e57b50b70a9e7cb2ed904ad77f4", 16); 156 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("e160dd4a436e63877e1343d06576beaa66e06863ffe4335be38d6a37460a62d11133584a5bc6ac0590e18942e1fa88bb64a4d9fc6c1fd7b55d7e57b50b70a9e7cb2ed904ad77f4", 16);
158 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (2)"); 157 is(result.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (2)");
159 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved) (2)"); 158 is(result_improved.asString(16), expectedResult.asString(16), "ECC.BinaryFinetField.module (improved) (2)");
160 159
161 //------------------------------------------------------------------------- 160 //-------------------------------------------------------------------------
162} catch (err) { 161} catch (err) {
163 162
164 var s = "test suite failure!\n"; 163 var s = "test suite failure!\n";
165 var o = {}; 164 var o = {};
166 var k = null; 165 var k = null;
167 for (k in err) { 166 for (k in err) {
168 // ensure unique keys?! 167 // ensure unique keys?!
169 if (!o[k]) { 168 if (!o[k]) {
170 s += k + ": " + err[k] + "\n"; 169 s += k + ": " + err[k] + "\n";
171 o[k] = err[k]; 170 o[k] = err[k];
172 } 171 }
173 } 172 }
174 ok ( false, s ); 173 ok ( false, s );
175} 174}
176 175
177</script> 176</script>
178</pre> 177</pre>
179</body> 178</body>
180</html> 179</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.Value.html b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.Value.html
index c58cf42..0d0903d 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.Value.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/ECC.BinaryField.Value.html
@@ -1,285 +1,284 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
35 34
36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
38<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>--> 37<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC.js'></script>-->
39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Value.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Point.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/FiniteField.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/ECC/BinaryField/Curve.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Functions.js'></script>
44</head> 43</head>
45<body> 44<body>
46<pre id="test"> 45<pre id="test">
47<script type="text/javascript"> 46<script type="text/javascript">
48try { 47try {
49 var value_1; 48 var value_1;
50 var value_2; 49 var value_2;
51 50
52 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("a", 16); 51 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("a", 16);
53 is(value_1.asString(16), "0a"); 52 is(value_1.asString(16), "0a");
54 53
55 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ffff", 16); 54 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ffff", 16);
56 is(value_1.asString(16), "ffff"); 55 is(value_1.asString(16), "ffff");
57 56
58 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("7fff", 16); 57 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("7fff", 16);
59 is(value_1.asString(16), "7fff"); 58 is(value_1.asString(16), "7fff");
60 59
61 is(parseInt("ffff", 16), 65535); 60 is(parseInt("ffff", 16), 65535);
62 is(parseInt("ffffff", 16), 16777215); 61 is(parseInt("ffffff", 16), 16777215);
63 is(parseInt("ffffffff", 16), 4294967295); 62 is(parseInt("ffffffff", 16), 4294967295);
64 is(parseInt("ffffffffff", 16), 1099511627775); 63 is(parseInt("ffffffffff", 16), 1099511627775);
65 is(parseInt("ffffffffffff", 16), 281474976710655); 64 is(parseInt("ffffffffffff", 16), 281474976710655);
66 is(parseInt("ffffffffffffff", 16), 72057594037927940); 65 is(parseInt("ffffffffffffff", 16), 72057594037927940);
67 is(parseInt("ffffffffffffffff", 16), 18446744073709552000); 66 is(parseInt("ffffffffffffffff", 16), 18446744073709552000);
68 is(parseInt("10000000000000000", 16), 18446744073709552001); 67 is(parseInt("10000000000000000", 16), 18446744073709552001);
69 is(parseInt("10000000000000001", 16), 18446744073709552002); 68 is(parseInt("10000000000000001", 16), 18446744073709552002);
70 is(parseInt("10000000000000009", 16), 18446744073709552010); 69 is(parseInt("10000000000000009", 16), 18446744073709552010);
71 70
72 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 71 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
73 is(value_1.wordSize(), 8, "check the number of words of a 64 char hex string using the 'wordSize' method"); 72 is(value_1.wordSize(), 8, "check the number of words of a 64 char hex string using the 'wordSize' method");
74 73
75 // 000108cb bacda1f0 3ea93603 01045434 ec7d82ba 150936df 08a229cb b4832ce1 74 // 000108cb bacda1f0 3ea93603 01045434 ec7d82ba 150936df 08a229cb b4832ce1
76 is(value_1.value()[0], parseInt("b4832ce1", 16), "word[0]"); 75 is(value_1.value()[0], parseInt("b4832ce1", 16), "word[0]");
77 is(value_1.value()[1], parseInt("08a229cb", 16), "word[1]"); 76 is(value_1.value()[1], parseInt("08a229cb", 16), "word[1]");
78 is(value_1.value()[2], parseInt("150936df", 16), "word[2]"); 77 is(value_1.value()[2], parseInt("150936df", 16), "word[2]");
79 is(value_1.value()[3], parseInt("ec7d82ba", 16), "word[3]"); 78 is(value_1.value()[3], parseInt("ec7d82ba", 16), "word[3]");
80 is(value_1.value()[4], parseInt("01045434", 16), "word[4]"); 79 is(value_1.value()[4], parseInt("01045434", 16), "word[4]");
81 is(value_1.value()[5], parseInt("3ea93603", 16), "word[5]"); 80 is(value_1.value()[5], parseInt("3ea93603", 16), "word[5]");
82 is(value_1.value()[6], parseInt("bacda1f0", 16), "word[6]"); 81 is(value_1.value()[6], parseInt("bacda1f0", 16), "word[6]");
83 is(value_1.value()[7], parseInt("000108cb", 16), "word[7]"); 82 is(value_1.value()[7], parseInt("000108cb", 16), "word[7]");
84 83
85 is(value_1.asString(16), "0108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", "asString(16)"); 84 is(value_1.asString(16), "0108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", "asString(16)");
86 85
87 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('10 00000000 00000000', 16); 86 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('10 00000000 00000000', 16);
88 is(value_1.wordSize(), 3, "check the number of words of a value with only a bit set on the first slot of byte at position 17"); 87 is(value_1.wordSize(), 3, "check the number of words of a value with only a bit set on the first slot of byte at position 17");
89 is(value_1.value()[0], parseInt("00000000", 16), "word[0]"); 88 is(value_1.value()[0], parseInt("00000000", 16), "word[0]");
90 is(value_1.value()[1], parseInt("00000000", 16), "word[1]"); 89 is(value_1.value()[1], parseInt("00000000", 16), "word[1]");
91 is(value_1.value()[2], parseInt("10", 16), "word[2]"); 90 is(value_1.value()[2], parseInt("10", 16), "word[2]");
92 is(value_1.asString(16), "100000000000000000", "2^17 asString(16)"); 91 is(value_1.asString(16), "100000000000000000", "2^17 asString(16)");
93 92
94 // 93 //
95 //XOR 94 //XOR
96 // 95 //
97 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16); 96 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
98 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16); 97 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
99 result = value_1.xor(value_2); 98 result = value_1.xor(value_2);
100 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('0', 16); 99 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('0', 16);
101 is(result.asString(16), expectedResult.asString(16), "a xor a = 0"); 100 is(result.asString(16), expectedResult.asString(16), "a xor a = 0");
102 101
103 // 102 //
104 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855', 16); 103 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855', 16);
105 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b935c a495991b 7852b855', 16); 104 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b935c a495991b 7852b855', 16);
106 result = value_1.xor(value_2); 105 result = value_1.xor(value_2);
107 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('10 00000000 00000000', 16); 106 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('10 00000000 00000000', 16);
108 is(result.asString(16), expectedResult.asString(16), "single bit difference"); 107 is(result.asString(16), expectedResult.asString(16), "single bit difference");
109 108
110 // 109 //
111 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("01", 16); 110 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("01", 16);
112 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855', 16); 111 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b855', 16);
113 result = value_1.xor(value_2); 112 result = value_1.xor(value_2);
114 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b854', 16); 113 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b935ca495991b7852b854', 16);
115 is(result.asString(16), expectedResult.asString(16), "01 xor value"); 114 is(result.asString(16), expectedResult.asString(16), "01 xor value");
116 115
117 // 116 //
118 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16); 117 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
119 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16); 118 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('f3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 16);
120 result = value_1.xor(value_2); 119 result = value_1.xor(value_2);
121 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('1000000000000000000000000000000000000000000000000000000000000000', 16); 120 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('1000000000000000000000000000000000000000000000000000000000000000', 16);
122 is(result.asString(16), expectedResult.asString(16), "first bit difference xor"); 121 is(result.asString(16), expectedResult.asString(16), "first bit difference xor");
123 122
124 // 123 //
125 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('84a2c58a', 16); 124 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('84a2c58a', 16);
126 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('38925faf', 16); 125 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value('38925faf', 16);
127 result = value_1.xor(value_2); 126 result = value_1.xor(value_2);
128 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('bc309a25', 16); 127 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('bc309a25', 16);
129 is(result.asString(16), expectedResult.asString(16), "84a2c58a XOR 38925faf = bc309a25"); 128 is(result.asString(16), expectedResult.asString(16), "84a2c58a XOR 38925faf = bc309a25");
130 129
131 // 130 //
132 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("01401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16); 131 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("01401ca87b8f144684a2c58ae9308c237789e4bf1f36dd117c150b7d6076dd1da6197fe4c5225a064db0e4222589d5ca50eb6bb6b7147a03f61528438a8767c6a6c4a6883fd6f067", 16);
133 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16); 132 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0112f5c97e74737b38925fafe22cea3e12b868d4ddea5b3341db8fc2e788cab74f0a7a3cc27087a89365945369938650a99217d566e13f80dc87f08273f7411b6b01ef1d399c772a", 16);
134 result = value_1.xor(value_2); 133 result = value_1.xor(value_2);
135 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('0052e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d', 16); 134 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value('0052e96105fb673dbc309a250b1c661d65318c6bc2dc86223dce84bf87fe17aae91305d80752ddaeded570714c1a539af9797c63d1f545832a92d8c1f97026ddcdc54995064a874d', 16);
136 is(result.asString(16), expectedResult.asString(16), "xor"); 135 is(result.asString(16), expectedResult.asString(16), "xor");
137 136
138 137
139 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", 16); 138 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", 16);
140 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("01ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f816429a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 139 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("01ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f816429a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
141 result = value_2.xor(value_1.shiftLeft(value_2.bitSize() - value_1.bitSize())); 140 result = value_2.xor(value_1.shiftLeft(value_2.bitSize() - value_1.bitSize()));
142 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f892e29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 141 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f892e29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
143 is(result.asString(16), expectedResult.asString(16), "xor"); 142 is(result.asString(16), expectedResult.asString(16), "xor");
144 is(result.bitSize(), 1120, "xor.bitSize"); 143 is(result.bitSize(), 1120, "xor.bitSize");
145 is(result.wordSize(), 35, "result wordSize"); 144 is(result.wordSize(), 35, "result wordSize");
146 is(expectedResult.bitSize(), 1120, "xor.bitSize"); 145 is(expectedResult.bitSize(), 1120, "xor.bitSize");
147 is(expectedResult.wordSize(), 35, "expectedResult wordSize"); 146 is(expectedResult.wordSize(), 35, "expectedResult wordSize");
148 is(result.compare(expectedResult), 0, "compare"); 147 is(result.compare(expectedResult), 0, "compare");
149 148
150 149
151 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", 16); 150 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425", 16);
152 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f892e29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 151 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("ebcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f892e29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
153 result = value_2.xor(value_1.shiftLeft(value_2.bitSize() - value_1.bitSize())); 152 result = value_2.xor(value_1.shiftLeft(value_2.bitSize() - value_1.bitSize()));
154 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("6bcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f8d0b29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16); 153 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("6bcb09fac51945162a0775f42df6151169826efdc55dea5d17c22adb92e6b1a6ae8311545ad7e0f46f09a5b960855e673db1e803a5b94562161213204ca1f24792e81f06a4f8d0b29a492f106cc6d0b0ff4617b736dab590590a8cff9f807a15282544404e6b35841703c9fb00a9cad1d6878d601efc25368bdc51d5ff14a81610f4fe62cb2f452aee520a16", 16);
155 is(result.asString(16), expectedResult.asString(16), "xor"); 154 is(result.asString(16), expectedResult.asString(16), "xor");
156 is(result.bitSize(), 1119, "xor.bitSize"); 155 is(result.bitSize(), 1119, "xor.bitSize");
157 is(expectedResult.bitSize(), 1119, "xor.bitSize"); 156 is(expectedResult.bitSize(), 1119, "xor.bitSize");
158 is(result.compare(expectedResult), 0, "compare"); 157 is(result.compare(expectedResult), 0, "compare");
159 //value_1 = 158 //value_1 =
160 //value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 16); 159 //value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 16);
161 160
162 161
163 value_1 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010 01010101 00000000", 16)).value(); 162 value_1 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010 01010101 00000000", 16)).value();
164 value_2 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010", 16)).value(); 163 value_2 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010", 16)).value();
165 result = new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._xor(value_1, value_2, 2)); 164 result = new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._xor(value_1, value_2, 2));
166 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("01010101 00000000", 16); 165 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("01010101 00000000", 16);
167 is(result.asString(16), expectedResult.asString(16), "xor with offset 2"); 166 is(result.asString(16), expectedResult.asString(16), "xor with offset 2");
168 167
169 value_1 = (new Clipperz.Crypto.ECC.BinaryField.Value(" 10101010 01010101 00000000", 16)).value(); 168 value_1 = (new Clipperz.Crypto.ECC.BinaryField.Value(" 10101010 01010101 00000000", 16)).value();
170 value_2 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010 10101010", 16)).value(); 169 value_2 = (new Clipperz.Crypto.ECC.BinaryField.Value("10101010 10101010", 16)).value();
171 result = new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._xor(value_1, value_2, 2)); 170 result = new Clipperz.Crypto.ECC.BinaryField.Value(Clipperz.Crypto.ECC.BinaryField.Value._xor(value_1, value_2, 2));
172 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("10101010 00000000 01010101 00000000", 16); 171 expectedResult = new Clipperz.Crypto.ECC.BinaryField.Value("10101010 00000000 01010101 00000000", 16);
173 is(result.asString(16), expectedResult.asString(16), "xor with offset 2 (2)"); 172 is(result.asString(16), expectedResult.asString(16), "xor with offset 2 (2)");
174 173
175 // 174 //
176 //isZero 175 //isZero
177 // 176 //
178 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('0', 16); 177 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('0', 16);
179 is(value_1.isZero(), true, "0.isZero() == true"); 178 is(value_1.isZero(), true, "0.isZero() == true");
180 179
181 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('1', 16); 180 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value('1', 16);
182 is(value_1.isZero(), false, "1.isZero() == false"); 181 is(value_1.isZero(), false, "1.isZero() == false");
183 182
184 // 183 //
185 //Comparison 184 //Comparison
186 // 185 //
187 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16); 186 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16);
188 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16); 187 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16);
189 is (value_1.compare(value_2), 0, "BinaryField.value(0) = BinaryField.value(0)"); 188 is (value_1.compare(value_2), 0, "BinaryField.value(0) = BinaryField.value(0)");
190 //is (value_1.compare(0), 0, "BinaryField.value(0) = 0"); 189 //is (value_1.compare(0), 0, "BinaryField.value(0) = 0");
191 190
192 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 191 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
193 is (value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) != BinaryField.value(0)"); 192 is (value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) != BinaryField.value(0)");
194 193
195 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 194 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
196 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16); 195 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("0", 16);
197 is(value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) > BinaryField.value(0)"); 196 is(value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) > BinaryField.value(0)");
198 is(value_2.compare(value_1), -1, "BinaryField.value(0) < BinaryField.value(xxxx)"); 197 is(value_2.compare(value_1), -1, "BinaryField.value(0) < BinaryField.value(xxxx)");
199 198
200 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16); 199 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1", 16);
201 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("05", 16); 200 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("05", 16);
202 is(value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) > BinaryField.value(05)"); 201 is(value_1.compare(value_2), 1, "BinaryField.value(xxxxxx) > BinaryField.value(05)");
203 is(value_2.compare(value_1), -1, "BinaryField.value(05) < BinaryField.value(xxxx)"); 202 is(value_2.compare(value_1), -1, "BinaryField.value(05) < BinaryField.value(xxxx)");
204 203
205 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("-10", 16); 204 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("-10", 16);
206 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("10", 16); 205 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("10", 16);
207 is(value_1.compare(value_2), -1, "BinaryField.value(-10) - BinaryField.value(10). No negative number are managed"); 206 is(value_1.compare(value_2), -1, "BinaryField.value(-10) - BinaryField.value(10). No negative number are managed");
208 207
209 // 208 //
210 //more comparison 209 //more comparison
211 // 210 //
212 211
213 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 212 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
214 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 213 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
215 result = value_1.compare(value_2); 214 result = value_1.compare(value_2);
216 is(result, 0, "equal compare"); 215 is(result, 0, "equal compare");
217 216
218 // 217 //
219 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442", 16); 218 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442", 16);
220 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442", 16); 219 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442", 16);
221 result = value_1.compare(value_2); 220 result = value_1.compare(value_2);
222 is(result, -1, "second term with one more bit at the leftmost - compare (1)"); 221 is(result, -1, "second term with one more bit at the leftmost - compare (1)");
223 222
224 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14", 16); 223 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14", 16);
225 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14", 16); 224 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14", 16);
226 result = value_1.compare(value_2); 225 result = value_1.compare(value_2);
227 is(result, -1, "second term with one more bit at the leftmost - compare (2)"); 226 is(result, -1, "second term with one more bit at the leftmost - compare (2)");
228 227
229 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8", 16); 228 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8", 16);
230 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8", 16); 229 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8", 16);
231 result = value_1.compare(value_2); 230 result = value_1.compare(value_2);
232 is(result, -1, "second term with one more bit at the leftmost - compare (3)"); 231 is(result, -1, "second term with one more bit at the leftmost - compare (3)");
233 232
234 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16); 233 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
235 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16); 234 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
236 result = value_1.compare(value_2); 235 result = value_1.compare(value_2);
237 is(result, -1, "second term with one more bit at the leftmost - compare (n)"); 236 is(result, -1, "second term with one more bit at the leftmost - compare (n)");
238 237
239 // 238 //
240 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442", 16); 239 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442", 16);
241 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442", 16); 240 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442", 16);
242 result = value_1.compare(value_2); 241 result = value_1.compare(value_2);
243 is(result, 1, "first term with one more bit at the leftmost - compare (1)"); 242 is(result, 1, "first term with one more bit at the leftmost - compare (1)");
244 243
245 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14", 16); 244 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14", 16);
246 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14", 16); 245 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14", 16);
247 result = value_1.compare(value_2); 246 result = value_1.compare(value_2);
248 is(result, 1, "first term with one more bit at the leftmost - compare (2)"); 247 is(result, 1, "first term with one more bit at the leftmost - compare (2)");
249 248
250 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16); 249 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
251 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16); 250 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", 16);
252 result = value_1.compare(value_2); 251 result = value_1.compare(value_2);
253 is(result, 1, "first term with one more bit at the leftmost - compare (n)"); 252 is(result, 1, "first term with one more bit at the leftmost - compare (n)");
254 253
255 // 254 //
256 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16); 255 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16);
257 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 256 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
258 result = value_1.compare(value_2); 257 result = value_1.compare(value_2);
259 is(result, 1, "first term with one more bit in the middle - compare"); 258 is(result, 1, "first term with one more bit in the middle - compare");
260 259
261 // 260 //
262 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16); 261 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427af41e4649b934ca495991b7852b855", 16);
263 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427aeffffffffffffffffffffffffffff", 16); 262 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427aeffffffffffffffffffffffffffff", 16);
264 result = value_1.compare(value_2); 263 result = value_1.compare(value_2);
265 is(result, 1, "first term with one more bit in the middle - compare"); 264 is(result, 1, "first term with one more bit in the middle - compare");
266 265
267 // 266 //
268 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16); 267 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 16);
269 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("05", 16); 268 value_2 = new Clipperz.Crypto.ECC.BinaryField.Value("05", 16);
270 result = value_1.compare(value_2); 269 result = value_1.compare(value_2);
271 is(result, 1, "equal compare"); 270 is(result, 1, "equal compare");
272 271
273 272
274 273
275 // 274 //
276 //isBitSet 275 //isBitSet
277 // 276 //
278 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16); 277 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("ff", 16);
279 result = value_1.isBitSet(1); 278 result = value_1.isBitSet(1);
280 expectedResult = true; 279 expectedResult = true;
281 is(result, expectedResult, "'ff'.isBitSet(1)"); 280 is(result, expectedResult, "'ff'.isBitSet(1)");
282 281
283 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f0", 16); 282 value_1 = new Clipperz.Crypto.ECC.BinaryField.Value("f0", 16);
284 result =value_1.isBitSet(1); 283 result =value_1.isBitSet(1);
285 expectedResult = false; 284 expectedResult = false;
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/PRNG.html b/frontend/gamma/tests/tests/Clipperz/Crypto/PRNG.html
index 438d96f..61aa1c2 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/PRNG.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/PRNG.html
@@ -1,114 +1,113 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script> jslog_config_enabled = true; </script> 28 <script> jslog_config_enabled = true; </script>
29 29
30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
31 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
32 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
33 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
34 33
35 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
41 40
42<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Statistics.js'></script>--> 41<!--<script type='text/javascript' src='../../../../js/Clipperz/Crypto/Statistics.js'></script>-->
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
46 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 45 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 46 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
48</head> 47</head>
49<body> 48<body>
50<pre id="test"> 49<pre id="test">
51<script type="text/javascript"> 50<script type="text/javascript">
52test_PRNG = function() { 51test_PRNG = function() {
53 varrand1, rand2; 52 varrand1, rand2;
54 var i,c; 53 var i,c;
55 54
56 c = 10; 55 c = 10;
57 for (i=0; i<c; i++) { 56 for (i=0; i<c; i++) {
58 // jslog.debug(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString()); 57 // jslog.debug(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString());
59 } 58 }
60 59
61 rand1 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(1); 60 rand1 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(1);
62 is(rand1.byteAtIndex(0) <= 255, true, "getRandomByte returns always a single byte"); 61 is(rand1.byteAtIndex(0) <= 255, true, "getRandomByte returns always a single byte");
63 62
64 rand2 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(1); 63 rand2 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(1);
65 is(rand1.equals(rand2), false, "getRandomByte should almost always return two different values when called into sequence"); 64 is(rand1.equals(rand2), false, "getRandomByte should almost always return two different values when called into sequence");
66 65
67 66
68 rand1 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32); 67 rand1 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
69 rand2 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32); 68 rand2 = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32);
70 is(rand1.equals(rand2), false, "getRandomByte should almost always return two different values when called into sequence"); 69 is(rand1.equals(rand2), false, "getRandomByte should almost always return two different values when called into sequence");
71 is(rand1.split(0,1).equals(rand2.split(0,1)), false, "getRandomByte should almost always return two different values when called into sequence"); 70 is(rand1.split(0,1).equals(rand2.split(0,1)), false, "getRandomByte should almost always return two different values when called into sequence");
72 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 1", "Value for random test"); 71 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 1", "Value for random test");
73 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 2", "Value for random test"); 72 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 2", "Value for random test");
74 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 3", "Value for random test"); 73 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 3", "Value for random test");
75 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 4", "Value for random test"); 74 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 4", "Value for random test");
76 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 5", "Value for random test"); 75 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 5", "Value for random test");
77 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 6", "Value for random test"); 76 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 6", "Value for random test");
78 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 7", "Value for random test"); 77 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 7", "Value for random test");
79 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 8", "Value for random test"); 78 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 8", "Value for random test");
80 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 9", "Value for random test"); 79 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 9", "Value for random test");
81 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 10", "Value for random test"); 80 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 10", "Value for random test");
82 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 11", "Value for random test"); 81 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 11", "Value for random test");
83 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 12", "Value for random test"); 82 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 12", "Value for random test");
84 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 13", "Value for random test"); 83 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 13", "Value for random test");
85 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 14", "Value for random test"); 84 //is(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(10000).toHexString(), "rand 14", "Value for random test");
86//jslog.debug(rand1.toHexString()); 85//jslog.debug(rand1.toHexString());
87//jslog.debug(rand2.toHexString()); 86//jslog.debug(rand2.toHexString());
88 87
89 SimpleTest.finish(); 88 SimpleTest.finish();
90} 89}
91 90
92try { 91try {
93 MochiKit.Signal.connect(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'readyToGenerateRandomBytes', test_PRNG); 92 MochiKit.Signal.connect(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'readyToGenerateRandomBytes', test_PRNG);
94 Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose(); 93 Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
95 SimpleTest.waitForExplicitFinish(); 94 SimpleTest.waitForExplicitFinish();
96} catch (err) { 95} catch (err) {
97 96
98 var s = "test suite failure!\n"; 97 var s = "test suite failure!\n";
99 var o = {}; 98 var o = {};
100 var k = null; 99 var k = null;
101 for (k in err) { 100 for (k in err) {
102 // ensure unique keys?! 101 // ensure unique keys?!
103 if (!o[k]) { 102 if (!o[k]) {
104 s += k + ": " + err[k] + "\n"; 103 s += k + ": " + err[k] + "\n";
105 o[k] = err[k]; 104 o[k] = err[k];
106 } 105 }
107 } 106 }
108 ok ( false, s ); 107 ok ( false, s );
109} 108}
110 109
111</script> 110</script>
112</pre> 111</pre>
113</body> 112</body>
114</html> 113</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html b/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html
index f29f894..4c7fd86 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html
@@ -1,87 +1,86 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
35 34
36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/RSA.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/RSA.js'></script>
39 38
40</head> 39</head>
41<body> 40<body>
42<pre id="test"> 41<pre id="test">
43<script type="text/javascript"> 42<script type="text/javascript">
44try { 43try {
45 varrsaPublicKey; 44 varrsaPublicKey;
46 varrandomValue; 45 varrandomValue;
47 varpublicEncryptedValue; 46 varpublicEncryptedValue;
48 var privateEncryptedValue; 47 var privateEncryptedValue;
49 48
50 varstartTime; 49 varstartTime;
51 varendTime; 50 varendTime;
52 51
53 52
54startTime=new Date(); 53startTime=new Date();
55 rsaPublicKey = Clipperz.Crypto.RSA.generatePublicKey(512); 54 rsaPublicKey = Clipperz.Crypto.RSA.generatePublicKey(512);
56 55
57endTime=new Date(); 56endTime=new Date();
58is(true, true, 'Time to generate the RSA public key (size 512 bit): '+(endTime.getTime()-startTime.getTime())/1000.0); 57is(true, true, 'Time to generate the RSA public key (size 512 bit): '+(endTime.getTime()-startTime.getTime())/1000.0);
59 58
60 randomValue = Clipperz.Crypto.Base.generateRandomSeed(); 59 randomValue = Clipperz.Crypto.Base.generateRandomSeed();
61 publicEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPublicKey(rsaPublicKey, randomValue); 60 publicEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPublicKey(rsaPublicKey, randomValue);
62 privateEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPrivateKey(rsaPublicKey, randomValue); 61 privateEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPrivateKey(rsaPublicKey, randomValue);
63 62
64 is(publicEncryptedValue == privateEncryptedValue, false); 63 is(publicEncryptedValue == privateEncryptedValue, false);
65 is(Clipperz.Crypto.RSA.decryptUsingPrivateKey(rsaPublicKey, publicEncryptedValue), randomValue); 64 is(Clipperz.Crypto.RSA.decryptUsingPrivateKey(rsaPublicKey, publicEncryptedValue), randomValue);
66 is(Clipperz.Crypto.RSA.decryptUsingPublicKey(rsaPublicKey, privateEncryptedValue), randomValue); 65 is(Clipperz.Crypto.RSA.decryptUsingPublicKey(rsaPublicKey, privateEncryptedValue), randomValue);
67 66
68 //------------------------------------------------------------------------- 67 //-------------------------------------------------------------------------
69} catch (err) { 68} catch (err) {
70 69
71 var s = "test suite failure!\n"; 70 var s = "test suite failure!\n";
72 var o = {}; 71 var o = {};
73 var k = null; 72 var k = null;
74 for (k in err) { 73 for (k in err) {
75 // ensure unique keys?! 74 // ensure unique keys?!
76 if (!o[k]) { 75 if (!o[k]) {
77 s += k + ": " + err[k] + "\n"; 76 s += k + ": " + err[k] + "\n";
78 o[k] = err[k]; 77 o[k] = err[k];
79 } 78 }
80 } 79 }
81 ok ( false, s ); 80 ok ( false, s );
82} 81}
83 82
84</script> 83</script>
85</pre> 84</pre>
86</body> 85</body>
87</html> 86</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/SHA.html b/frontend/gamma/tests/tests/Clipperz/Crypto/SHA.html
index a580491..a2f6c04 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/SHA.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/SHA.html
@@ -1,172 +1,171 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.Crypto.SHA - TEST</title> 28 <title>Clipperz.Crypto.SHA - TEST</title>
29 29
30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
33 33
34 <script type='text/javascript' src='../../../js/JSON/json2.js'></script> 34 <script type='text/javascript' src='../../../js/JSON/json2.js'></script>
35 35
36 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
42 42
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
44 44
45 45
46 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script> 46 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
47 47
48</head> 48</head>
49<body> 49<body>
50<pre id="test"> 50<pre id="test">
51<script type="text/javascript" src="SHA.test.js"></script> 51<script type="text/javascript" src="SHA.test.js"></script>
52</pre> 52</pre>
53</body> 53</body>
54</html> 54</html>
55 55
56 56
57 57
58<!-- html> 58<!-- html>
59<head> 59<head>
60 <script> 60 <script>
61 jslog_config_enabled = true; 61 jslog_config_enabled = true;
62 clipperz_profiling_enabled = true; 62 clipperz_profiling_enabled = true;
63 </script> 63 </script>
64 64
65 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 65 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
66 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
67 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 66 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
68 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 67 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
69 68
70 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 69 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
71 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 70 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
72 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 71 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
73 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 72 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
74 73
75 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 74 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
76</head> 75</head>
77<body> 76<body>
78<pre id="test"> 77<pre id="test">
79<script type="text/javascript"> 78<script type="text/javascript">
80 79
81try { 80try {
82 varbyteArray; 81 varbyteArray;
83 varhash; 82 varhash;
84 var longText; 83 var longText;
85 var startTime, endTime; 84 var startTime, endTime;
86 85
87 longText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec nunc sapien, condimentum vitae, varius vel, pharetra in, augue. Mauris quam magna, pretium sit amet, accumsan id, volutpat lobortis, nibh. Fusce sagittis. Aenean justo. Curabitur euismod pede. Morbi at ante. Proin nisl leo, ultrices sed, facilisis et, nonummy sit amet, lorem. Praesent mauris tellus, pulvinar sed, nonummy vitae, rhoncus non, nunc. Proin placerat malesuada nisl. Nunc id enim. Maecenas commodo enim ac nibh. Sed condimentum, urna sit amet euismod gravida, mi urna varius odio, luctus pretium lectus justo nec felis. Ut in augue et est malesuada rhoncus. Sed vel orci. Mauris suscipit. Praesent cursus velit non turpis. Donec tristique dolor ac est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla est sapien, vulputate eget, bibendum id, pharetra nec, mauris. Aliquam faucibus tincidunt dui. Proin iaculis. Maecenas sagittis. Integer et augue. Donec vitae urna in orci aliquet commodo. Vestibulum lorem sem, suscipit ac, placerat nec, mollis in, felis. Donec laoreet odio a mauris. Integer rutrum, sapien id varius molestie, mauris odio egestas orci, non bibendum sem felis in metus. Phasellus consectetuer lectus adipiscing mauris. Ut magna tellus, euismod ac, suscipit tincidunt, ullamcorper adipiscing, massa. Etiam orci. Phasellus a urna. Cras neque quam, laoreet at, tempus eget, euismod nec, nibh. Etiam hendrerit. Aenean vel lorem. Ut ligula lacus, congue eu, lobortis sit amet, venenatis in, magna. Nullam cursus felis quis est. Sed sem est, condimentum eu, vestibulum a, mattis vel, diam. Curabitur tincidunt pede quis pede. Sed neque diam, convallis vel, luctus at, porta id, nisl. Suspendisse potenti. Sed volutpat lobortis orci. Praesent mi. In interdum. Suspendisse suscipit ipsum eget dolor. Curabitur et tellus sed velit hendrerit varius. Cras sit amet est. Donec arcu nulla, vehicula et, pretium in, placerat id, felis. Integer mollis auctor lectus. Integer ultrices elementum sapien. Nam et erat. Nam pulvinar porta tortor. Nam at risus. Quisque nulla. Integer vestibulum, lacus id bibendum laoreet, ligula mi pharetra lorem, sit amet pharetra felis mauris quis justo. Aliquam ultricies. Duis a pede eget lorem dapibus rhoncus. Aenean eu elit non libero consectetuer viverra. Maecenas velit mi, eleifend vel, malesuada vel, condimentum quis, odio. Mauris tempus augue sed turpis. Pellentesque condimentum, lacus vitae pellentesque ultricies, risus tellus posuere nisi, et dictum turpis pede nec elit. Sed eu lectus eu justo sagittis euismod. Vestibulum lobortis, urna id mollis rhoncus, orci quam euismod ligula, at malesuada lacus magna vitae massa. Phasellus mattis fermentum velit. Nulla vulputate consequat enim. Maecenas quis neque. Curabitur sagittis facilisis neque. In elementum, eros non porttitor rhoncus, libero turpis sodales odio, vitae porta tellus purus et ante. Nullam molestie sollicitudin metus. Donec a elit. Morbi ut lacus. Donec at arcu. Quisque velit diam, interdum a, lacinia at, varius et, odio. Cras neque magna, ornare id, sollicitudin id, consequat a, est. Phasellus vestibulum est at leo. Nam facilisis, nulla dapibus condimentum pellentesque, est magna viverra ligula, at sollicitudin urna augue ut sapien. Fusce justo."; 86 longText = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec nunc sapien, condimentum vitae, varius vel, pharetra in, augue. Mauris quam magna, pretium sit amet, accumsan id, volutpat lobortis, nibh. Fusce sagittis. Aenean justo. Curabitur euismod pede. Morbi at ante. Proin nisl leo, ultrices sed, facilisis et, nonummy sit amet, lorem. Praesent mauris tellus, pulvinar sed, nonummy vitae, rhoncus non, nunc. Proin placerat malesuada nisl. Nunc id enim. Maecenas commodo enim ac nibh. Sed condimentum, urna sit amet euismod gravida, mi urna varius odio, luctus pretium lectus justo nec felis. Ut in augue et est malesuada rhoncus. Sed vel orci. Mauris suscipit. Praesent cursus velit non turpis. Donec tristique dolor ac est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla est sapien, vulputate eget, bibendum id, pharetra nec, mauris. Aliquam faucibus tincidunt dui. Proin iaculis. Maecenas sagittis. Integer et augue. Donec vitae urna in orci aliquet commodo. Vestibulum lorem sem, suscipit ac, placerat nec, mollis in, felis. Donec laoreet odio a mauris. Integer rutrum, sapien id varius molestie, mauris odio egestas orci, non bibendum sem felis in metus. Phasellus consectetuer lectus adipiscing mauris. Ut magna tellus, euismod ac, suscipit tincidunt, ullamcorper adipiscing, massa. Etiam orci. Phasellus a urna. Cras neque quam, laoreet at, tempus eget, euismod nec, nibh. Etiam hendrerit. Aenean vel lorem. Ut ligula lacus, congue eu, lobortis sit amet, venenatis in, magna. Nullam cursus felis quis est. Sed sem est, condimentum eu, vestibulum a, mattis vel, diam. Curabitur tincidunt pede quis pede. Sed neque diam, convallis vel, luctus at, porta id, nisl. Suspendisse potenti. Sed volutpat lobortis orci. Praesent mi. In interdum. Suspendisse suscipit ipsum eget dolor. Curabitur et tellus sed velit hendrerit varius. Cras sit amet est. Donec arcu nulla, vehicula et, pretium in, placerat id, felis. Integer mollis auctor lectus. Integer ultrices elementum sapien. Nam et erat. Nam pulvinar porta tortor. Nam at risus. Quisque nulla. Integer vestibulum, lacus id bibendum laoreet, ligula mi pharetra lorem, sit amet pharetra felis mauris quis justo. Aliquam ultricies. Duis a pede eget lorem dapibus rhoncus. Aenean eu elit non libero consectetuer viverra. Maecenas velit mi, eleifend vel, malesuada vel, condimentum quis, odio. Mauris tempus augue sed turpis. Pellentesque condimentum, lacus vitae pellentesque ultricies, risus tellus posuere nisi, et dictum turpis pede nec elit. Sed eu lectus eu justo sagittis euismod. Vestibulum lobortis, urna id mollis rhoncus, orci quam euismod ligula, at malesuada lacus magna vitae massa. Phasellus mattis fermentum velit. Nulla vulputate consequat enim. Maecenas quis neque. Curabitur sagittis facilisis neque. In elementum, eros non porttitor rhoncus, libero turpis sodales odio, vitae porta tellus purus et ante. Nullam molestie sollicitudin metus. Donec a elit. Morbi ut lacus. Donec at arcu. Quisque velit diam, interdum a, lacinia at, varius et, odio. Cras neque magna, ornare id, sollicitudin id, consequat a, est. Phasellus vestibulum est at leo. Nam facilisis, nulla dapibus condimentum pellentesque, est magna viverra ligula, at sollicitudin urna augue ut sapien. Fusce justo.";
88 87
89 //------------------------------------------------------------------------- 88 //-------------------------------------------------------------------------
90 // 89 //
91 //Test of SHA-256 algorithm 90 //Test of SHA-256 algorithm
92 // 91 //
93 //------------------------------------------------------------------------- 92 //-------------------------------------------------------------------------
94 93
95 byteArray = new Clipperz.ByteArray(); 94 byteArray = new Clipperz.ByteArray();
96 hash = Clipperz.Crypto.SHA.sha256(byteArray); 95 hash = Clipperz.Crypto.SHA.sha256(byteArray);
97 is(hash.toHexString(), "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "sha256('')"); 96 is(hash.toHexString(), "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "sha256('')");
98 97
99 byteArray = new Clipperz.ByteArray("0xbd"); 98 byteArray = new Clipperz.ByteArray("0xbd");
100 hash = Clipperz.Crypto.SHA.sha256(byteArray); 99 hash = Clipperz.Crypto.SHA.sha256(byteArray);
101 is(hash.toHexString(), "0x68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b", "sha256('0xbd')"); 100 is(hash.toHexString(), "0x68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b", "sha256('0xbd')");
102 101
103 byteArray = new Clipperz.ByteArray("0x5fd4"); 102 byteArray = new Clipperz.ByteArray("0x5fd4");
104 hash = Clipperz.Crypto.SHA.sha256(byteArray); 103 hash = Clipperz.Crypto.SHA.sha256(byteArray);
105 is(hash.toHexString(), "0x7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788", "sha256('0x5fd4')"); 104 is(hash.toHexString(), "0x7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788", "sha256('0x5fd4')");
106 105
107 byteArray = new Clipperz.ByteArray("0xc98c8e55"); 106 byteArray = new Clipperz.ByteArray("0xc98c8e55");
108 hash = Clipperz.Crypto.SHA.sha256(byteArray); 107 hash = Clipperz.Crypto.SHA.sha256(byteArray);
109 is(hash.toHexString(), "0x7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504", "sha256('0xc98c8e55')"); 108 is(hash.toHexString(), "0x7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504", "sha256('0xc98c8e55')");
110 109
111 byteArray = new Clipperz.ByteArray("0x0df1cd526b5a4edd"); 110 byteArray = new Clipperz.ByteArray("0x0df1cd526b5a4edd");
112 hash = Clipperz.Crypto.SHA.sha256(byteArray); 111 hash = Clipperz.Crypto.SHA.sha256(byteArray);
113 is(hash.toHexString(), "0x47f527210d6e8f940b5082fec01b7305908fa2b49ea3ae597c19a3986097153c", "sha256('0x0df1cd526b5a4edd')"); 112 is(hash.toHexString(), "0x47f527210d6e8f940b5082fec01b7305908fa2b49ea3ae597c19a3986097153c", "sha256('0x0df1cd526b5a4edd')");
114 113
115 byteArray = new Clipperz.ByteArray("0xfdf4700984ee11b70af1880d0e0fefd4"); 114 byteArray = new Clipperz.ByteArray("0xfdf4700984ee11b70af1880d0e0fefd4");
116 hash = Clipperz.Crypto.SHA.sha256(byteArray); 115 hash = Clipperz.Crypto.SHA.sha256(byteArray);
117 is(hash.toHexString(), 116 is(hash.toHexString(),
118 "0xb01ae16eed3b4a770f127b98469ba26fe3d8e9f59d8a2983214afe6cff0e6b6c", 117 "0xb01ae16eed3b4a770f127b98469ba26fe3d8e9f59d8a2983214afe6cff0e6b6c",
119 "sha256('0xfdf4700984ee11b70af1880d0e0fefd4')"); 118 "sha256('0xfdf4700984ee11b70af1880d0e0fefd4')");
120 119
121 byteArray = new Clipperz.ByteArray("0x8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb"); 120 byteArray = new Clipperz.ByteArray("0x8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb");
122 hash = Clipperz.Crypto.SHA.sha256(byteArray); 121 hash = Clipperz.Crypto.SHA.sha256(byteArray);
123 is(hash.toHexString(), 122 is(hash.toHexString(),
124 "0x56059e8cb3c2978b198208bf5ca1e1ea5659b737a506324b7cec75b5ebaf057d", 123 "0x56059e8cb3c2978b198208bf5ca1e1ea5659b737a506324b7cec75b5ebaf057d",
125 "sha256('0x8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb')"); 124 "sha256('0x8cf53d90077df9a043bf8d10b470b144784411c93a4d504556834dae3ea4a5bb')");
126 125
127 byteArray = new Clipperz.ByteArray("0xeebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a"); 126 byteArray = new Clipperz.ByteArray("0xeebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a");
128 hash = Clipperz.Crypto.SHA.sha256(byteArray); 127 hash = Clipperz.Crypto.SHA.sha256(byteArray);
129 is(hash.toHexString(), 128 is(hash.toHexString(),
130 "0xc117b9dce689c399ec99008788cd5d24d8396fab7d96315c4f3fe6d56da63bb3", 129 "0xc117b9dce689c399ec99008788cd5d24d8396fab7d96315c4f3fe6d56da63bb3",
131 "sha256('0xeebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a')"); 130 "sha256('0xeebcf5cd6b12c90db64ff71a0e08ccd956e170a50dad769480d6b1fb3eff4934cde90f9e9b930ee637a66285c10f4e8a')");
132 131
133 byteArray = new Clipperz.ByteArray("0x3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad"); 132 byteArray = new Clipperz.ByteArray("0x3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad");
134 hash = Clipperz.Crypto.SHA.sha256(byteArray); 133 hash = Clipperz.Crypto.SHA.sha256(byteArray);
135 is(hash.toHexString(), 134 is(hash.toHexString(),
136 "0x105a60865830ac3a371d3843324d4bb5fa8ec0e02ddaa389ad8da4f10215c454", 135 "0x105a60865830ac3a371d3843324d4bb5fa8ec0e02ddaa389ad8da4f10215c454",
137 "sha256('0x3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad')"); 136 "sha256('0x3592ecfd1eac618fd390e7a9c24b656532509367c21a0eac1212ac83c0b20cd896eb72b801c4d212c5452bbbf09317b50c5c9fb1997553d2bbc29bb42f5748ad')");
138 137
139 138
140 byteArray = new Clipperz.ByteArray(longText); 139 byteArray = new Clipperz.ByteArray(longText);
141startTime = new Date(); 140startTime = new Date();
142//console.profile("SHA256"); 141//console.profile("SHA256");
143 hash = Clipperz.Crypto.SHA.sha256(byteArray); 142 hash = Clipperz.Crypto.SHA.sha256(byteArray);
144//console.profileEnd("SHA256"); 143//console.profileEnd("SHA256");
145endTime = new Date(); 144endTime = new Date();
146 is(hash.toHexString(), 145 is(hash.toHexString(),
147 "0xf6fac13c06784e0fbc61a3d25c41c9984840a8b617a2beb57cf6fa3e5e4a8949", 146 "0xf6fac13c06784e0fbc61a3d25c41c9984840a8b617a2beb57cf6fa3e5e4a8949",
148 "sha256(longText)"); 147 "sha256(longText)");
149 is((endTime - startTime) < 500, true, "Long text hash performance (" + (endTime - startTime) + ")"); 148 is((endTime - startTime) < 500, true, "Long text hash performance (" + (endTime - startTime) + ")");
150 MochiKit.Logging.logDebug("elapsed time: " + (endTime - startTime)); 149 MochiKit.Logging.logDebug("elapsed time: " + (endTime - startTime));
151 150
152//############################################################################# 151//#############################################################################
153 152
154} catch (err) { 153} catch (err) {
155 154
156 var s = "test suite failure!\n"; 155 var s = "test suite failure!\n";
157 var o = {}; 156 var o = {};
158 var k = null; 157 var k = null;
159 for (k in err) { 158 for (k in err) {
160 // ensure unique keys?! 159 // ensure unique keys?!
161 if (!o[k]) { 160 if (!o[k]) {
162 s += k + ": " + err[k] + "\n"; 161 s += k + ": " + err[k] + "\n";
163 o[k] = err[k]; 162 o[k] = err[k];
164 } 163 }
165 } 164 }
166 ok ( false, s ); 165 ok ( false, s );
167} 166}
168 167
169</script> 168</script>
170</pre> 169</pre>
171</body> 170</body>
172</html --> 171</html -->
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html b/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
index d0ee153..ba842a9 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/SRP.html
@@ -1,158 +1,157 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
35 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
37 36
38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
44</head> 43</head>
45<body> 44<body>
46<pre id="test"> 45<pre id="test">
47<script type="text/javascript"> 46<script type="text/javascript">
48hashString = function(aValue) { 47hashString = function(aValue) {
49 return Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(aValue)).toHexString().substring(2) 48 return Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray(aValue)).toHexString().substring(2)
50} 49}
51try { 50try {
52 varusername; 51 varusername;
53 varpassphrase; 52 varpassphrase;
54 53
55 var C; 54 var C;
56 var P; 55 var P;
57 var encryptedText_1; 56 var encryptedText_1;
58 var encryptedText_2; 57 var encryptedText_2;
59 varsalt; 58 varsalt;
60 varx; 59 varx;
61 var v; 60 var v;
62 var v1; 61 var v1;
63 62
64 username = "giulio.cesare"; 63 username = "giulio.cesare";
65 passphrase = "trustno1"; 64 passphrase = "trustno1";
66 65
67 C = hashString(username); 66 C = hashString(username);
68 is (C, "bde3c7b5fdcd9d6ce72782ca1ae912fc4397d668fcb3a73a04e5d47852670c4a", "C"); 67 is (C, "bde3c7b5fdcd9d6ce72782ca1ae912fc4397d668fcb3a73a04e5d47852670c4a", "C");
69 68
70 P = hashString(passphrase + username); 69 P = hashString(passphrase + username);
71 is (P, "d79f5c5a04e91e1c85fb64cb6ee9481cb52c181047f69da02cd6c3ce6d058a76", "P"); 70 is (P, "d79f5c5a04e91e1c85fb64cb6ee9481cb52c181047f69da02cd6c3ce6d058a76", "P");
72 71
73 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988"; 72 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988";
74 73
75 x = hashString(salt + P); 74 x = hashString(salt + P);
76 is(x, "21fe88a158e420aade86e00b5eb12a4c19bf15482fa34c542c90b1afdbd5b5fd", "x"); 75 is(x, "21fe88a158e420aade86e00b5eb12a4c19bf15482fa34c542c90b1afdbd5b5fd", "x");
77 76
78 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); 77 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
79 is(v.asString(10), "33816467430011076413789931449607305355248467973000153409872503376381719918118", "v"); 78 is(v.asString(10), "33816467430011076413789931449607305355248467973000153409872503376381719918118", "v");
80 is(v.asString(16), "4ac37139dbf32ebabd2c43f91dd085066d3c457d059efd5902d32ed247fcb626", "v (base 16)"); 79 is(v.asString(16), "4ac37139dbf32ebabd2c43f91dd085066d3c457d059efd5902d32ed247fcb626", "v (base 16)");
81 80
82 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 81 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
83 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 82 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
84 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result"); 83 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result");
85 84
86 //------------------------------------------------------------------------- 85 //-------------------------------------------------------------------------
87 86
88 username = "giulio.cesare.debug"; 87 username = "giulio.cesare.debug";
89 passphrase = "trustno1"; 88 passphrase = "trustno1";
90 89
91 C = hashString(username); 90 C = hashString(username);
92 is (C, "fa1af609123b97a10d676158ed538d4657a89ac33a102b22bd9a66712039e208", "C"); 91 is (C, "fa1af609123b97a10d676158ed538d4657a89ac33a102b22bd9a66712039e208", "C");
93 92
94 P = hashString(passphrase + username); 93 P = hashString(passphrase + username);
95 is (P, "e1bfba03dd626b12f29458a6ad63fb2c01b4765548504e1e2f6b1503c82e4253", "P"); 94 is (P, "e1bfba03dd626b12f29458a6ad63fb2c01b4765548504e1e2f6b1503c82e4253", "P");
96 95
97 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988"; 96 salt = "cf1fa93393ade60318b8276f1f39420098419445005a7dc9117975fe1f8d9988";
98 97
99 x = hashString(salt + P); 98 x = hashString(salt + P);
100 is(x, "93d4af3cdcd2447a745d309826dff3161feed4b15f32db8e909ff032a2bc8fb8", "x"); 99 is(x, "93d4af3cdcd2447a745d309826dff3161feed4b15f32db8e909ff032a2bc8fb8", "x");
101 100
102 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n()); 101 v = Clipperz.Crypto.SRP.g().powerModule(new Clipperz.Crypto.BigInt(x, 16), Clipperz.Crypto.SRP.n());
103 is(v.asString(10), "115049747015252903452664067168789229427785288458366249918596663144588656606556", "v"); 102 is(v.asString(10), "115049747015252903452664067168789229427785288458366249918596663144588656606556", "v");
104 103
105 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 104 //encryptedText_1 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
106 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username); 105 //encryptedText_2 = Clipperz.Crypto.Base.encryptUsingSecretKey(passphrase, username);
107 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result"); 106 //is (encryptedText_1 != encryptedText_2, true, "Two round of encryption (with random padding bits) should NOT produce the same result");
108 107
109 //------------------------------------------------------------------------- 108 //-------------------------------------------------------------------------
110 109
111 var srpConnection; 110 var srpConnection;
112 var C, P, salt; 111 var C, P, salt;
113 112
114 C = "da8602c2f847306f4eb9acdaad925277d1fad1408f173f128a078aea15e60b1e"; 113 C = "da8602c2f847306f4eb9acdaad925277d1fad1408f173f128a078aea15e60b1e";
115 P = "77643559beca49dd21c1c31db10bb0a9009662cb504413dc3fa3b7303c7e02ba"; 114 P = "77643559beca49dd21c1c31db10bb0a9009662cb504413dc3fa3b7303c7e02ba";
116 salt ="000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1"; 115 salt ="000108cbbacda1f03ea9360301045434ec7d82ba150936df08a229cbb4832ce1";
117 116
118 srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256}); 117 srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256});
119 srpConnection._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); 118 srpConnection._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10);
120 srpConnection.set_s(new Clipperz.Crypto.BigInt(salt, 16)); 119 srpConnection.set_s(new Clipperz.Crypto.BigInt(salt, 16));
121 is (srpConnection.s().asString(16, 64), salt, "salt read/write is coherent"); 120 is (srpConnection.s().asString(16, 64), salt, "salt read/write is coherent");
122 srpConnection.set_B(new Clipperz.Crypto.BigInt("123541032067854367017620977654446651448957899464139861291542193929199957895435", 10)); 121 srpConnection.set_B(new Clipperz.Crypto.BigInt("123541032067854367017620977654446651448957899464139861291542193929199957895435", 10));
123 122
124 is(srpConnection.serverSideCredentialsWithSalt(salt).v, 123 is(srpConnection.serverSideCredentialsWithSalt(salt).v,
125 "c73169c8236d37bf9ef11a2349e3064b7dc6e883a58d64443ea9235677520030", 124 "c73169c8236d37bf9ef11a2349e3064b7dc6e883a58d64443ea9235677520030",
126 "server side credentials - v" 125 "server side credentials - v"
127 ) 126 )
128 is(srpConnection.S(), "84134227508133659832466942692590826994401065200828529664948840490489960952050", "Server side 'S'"); 127 is(srpConnection.S(), "84134227508133659832466942692590826994401065200828529664948840490489960952050", "Server side 'S'");
129//MochiKit.Logging.logDebug("=== serverSideCredentials: " + MochiKit.Base.serializeJSON(srpConnection.serverSideCredentialsWithSalt(salt))); 128//MochiKit.Logging.logDebug("=== serverSideCredentials: " + MochiKit.Base.serializeJSON(srpConnection.serverSideCredentialsWithSalt(salt)));
130 129
131 srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256}); 130 srpConnection = new Clipperz.Crypto.SRP.Connection({C:C, P:P, hash:Clipperz.Crypto.SHA.sha_d256});
132 try { 131 try {
133 srpConnection.set_B(new Clipperz.Crypto.BigInt("0", 10)); 132 srpConnection.set_B(new Clipperz.Crypto.BigInt("0", 10));
134 ok(false, "Setting B to 0 should raise an exception"); 133 ok(false, "Setting B to 0 should raise an exception");
135 } catch(e) { 134 } catch(e) {
136 ok(true, "Setting B to 0 should raise an exception"); 135 ok(true, "Setting B to 0 should raise an exception");
137 } 136 }
138 //------------------------------------------------------------------------- 137 //-------------------------------------------------------------------------
139 138
140} catch (err) { 139} catch (err) {
141 140
142 var s = "test suite failure!\n"; 141 var s = "test suite failure!\n";
143 var o = {}; 142 var o = {};
144 var k = null; 143 var k = null;
145 for (k in err) { 144 for (k in err) {
146 // ensure unique keys?! 145 // ensure unique keys?!
147 if (!o[k]) { 146 if (!o[k]) {
148 s += k + ": " + err[k] + "\n"; 147 s += k + ": " + err[k] + "\n";
149 o[k] = err[k]; 148 o[k] = err[k];
150 } 149 }
151 } 150 }
152 ok ( false, s ); 151 ok ( false, s );
153} 152}
154 153
155</script> 154</script>
156</pre> 155</pre>
157</body> 156</body>
158</html> 157</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/Usage.html b/frontend/gamma/tests/tests/Clipperz/Crypto/Usage.html
index 8920915..4e7ad3d 100644
--- a/frontend/gamma/tests/tests/Clipperz/Crypto/Usage.html
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/Usage.html
@@ -1,119 +1,118 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.Crypto.Usage - TEST</title> 28 <title>Clipperz.Crypto.Usage - TEST</title>
29 29
30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
31 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
32 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
33 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
34 33
35 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script> 34 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
36 35
37 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
42 41
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
46 45
47</head> 46</head>
48<body> 47<body>
49<pre id="test"> 48<pre id="test">
50<script type="text/javascript"> 49<script type="text/javascript">
51Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose(); 50Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose();
52 51
53MochiKit.Base.update(Clipperz, { 52MochiKit.Base.update(Clipperz, {
54 'PM': { 53 'PM': {
55 'Crypto': { 54 'Crypto': {
56 'passwordEntropy': function(aValue) { 55 'passwordEntropy': function(aValue) {
57 var result; 56 var result;
58 varbitPerChar; 57 varbitPerChar;
59 58
60 bitPerChar = 4; 59 bitPerChar = 4;
61 if (/[a-z]/.test(aValue)) { 60 if (/[a-z]/.test(aValue)) {
62 bitPerChar ++; 61 bitPerChar ++;
63 } 62 }
64 if (/[A-Z]/.test(aValue)) { 63 if (/[A-Z]/.test(aValue)) {
65 bitPerChar ++; 64 bitPerChar ++;
66 } 65 }
67 if (/[^a-zA-Z0-9]/.test(aValue)) { 66 if (/[^a-zA-Z0-9]/.test(aValue)) {
68 bitPerChar ++; 67 bitPerChar ++;
69 } 68 }
70 //MochiKit.Logging.logDebug("--- bitPerChar: " + bitPerChar); 69 //MochiKit.Logging.logDebug("--- bitPerChar: " + bitPerChar);
71 70
72 result = aValue.length * bitPerChar; 71 result = aValue.length * bitPerChar;
73 72
74 return result; 73 return result;
75 } 74 }
76 } 75 }
77 } 76 }
78}) 77})
79 78
80try { 79try {
81 var keyValue; 80 var keyValue;
82 var keyEntropy; 81 var keyEntropy;
83 varkey; 82 varkey;
84 var plainText; 83 var plainText;
85 var cypherText; 84 var cypherText;
86 var randomBytes; 85 var randomBytes;
87 var hashedValue; 86 var hashedValue;
88 87
89 key = Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray("This is my long and complex passphrase")); 88 key = Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray("This is my long and complex passphrase"));
90 keyEntropy = Clipperz.PM.Crypto.passwordEntropy(key); 89 keyEntropy = Clipperz.PM.Crypto.passwordEntropy(key);
91 90
92 cypherText = Clipperz.Crypto.AES.encrypt(key, new Clipperz.ByteArray("some text to encrypt")); 91 cypherText = Clipperz.Crypto.AES.encrypt(key, new Clipperz.ByteArray("some text to encrypt"));
93 plainText = Clipperz.Crypto.AES.decrypt(key, cypherText).asString(); 92 plainText = Clipperz.Crypto.AES.decrypt(key, cypherText).asString();
94 is(plainText, "some text to encrypt"); 93 is(plainText, "some text to encrypt");
95 94
96 randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(256/8); 95 randomBytes = Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(256/8);
97 hashedValue = Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray("text to hash")); 96 hashedValue = Clipperz.Crypto.SHA.sha256(new Clipperz.ByteArray("text to hash"));
98 97
99//############################################################################# 98//#############################################################################
100 99
101} catch (err) { 100} catch (err) {
102 101
103 var s = "test suite failure!\n"; 102 var s = "test suite failure!\n";
104 var o = {}; 103 var o = {};
105 var k = null; 104 var k = null;
106 for (k in err) { 105 for (k in err) {
107 // ensure unique keys?! 106 // ensure unique keys?!
108 if (!o[k]) { 107 if (!o[k]) {
109 s += k + ": " + err[k] + "\n"; 108 s += k + ": " + err[k] + "\n";
110 o[k] = err[k]; 109 o[k] = err[k];
111 } 110 }
112 } 111 }
113 ok ( false, s ); 112 ok ( false, s );
114} 113}
115 114
116</script> 115</script>
117</pre> 116</pre>
118</body> 117</body>
119</html> 118</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/Date.html b/frontend/gamma/tests/tests/Clipperz/PM/Date.html
index a606ca4..7b87185 100644
--- a/frontend/gamma/tests/tests/Clipperz/PM/Date.html
+++ b/frontend/gamma/tests/tests/Clipperz/PM/Date.html
@@ -1,56 +1,55 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.PM.Date - test</title> 28 <title>Clipperz.PM.Date - test</title>
29 29
30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
31 <!-- script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script -->
32 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
33 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
34 33
35 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script> 34 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
36 35
37 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
41 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script> 40 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
43 42
44 <script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script>
46 <script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script> 45 <script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script>
47 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script> 46 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
48 47
49</head> 48</head>
50<body> 49<body>
51<pre id="test"> 50<pre id="test">
52 <script type="text/javascript" src="Date.test.js"></script> 51 <script type="text/javascript" src="Date.test.js"></script>
53</pre> 52</pre>
54 53
55</body> 54</body>
56</html> 55</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/Proxy.html b/frontend/gamma/tests/tests/Clipperz/PM/Proxy.html
index 8dc533f..8177285 100644
--- a/frontend/gamma/tests/tests/Clipperz/PM/Proxy.html
+++ b/frontend/gamma/tests/tests/Clipperz/PM/Proxy.html
@@ -1,62 +1,61 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.PM.Proxy - TEST</title> 28 <title>Clipperz.PM.Proxy - TEST</title>
29 29
30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
31 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
32 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
33 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
34 33
35 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
41 40
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
46 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 45 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script> 46 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
48 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script> 47 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
49 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script> 48 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
50 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script> 49 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
51 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script> 50 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
52 51
53 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script> 52 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
54 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script> 53 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
55 54
56</head> 55</head>
57<body> 56<body>
58<pre id="test"> 57<pre id="test">
59 <script type="text/javascript" src="Proxy.test.js"></script> 58 <script type="text/javascript" src="Proxy.test.js"></script>
60</pre> 59</pre>
61</body> 60</body>
62</html> 61</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/Toll.html b/frontend/gamma/tests/tests/Clipperz/PM/Toll.html
index 9baf167..6c2e000 100644
--- a/frontend/gamma/tests/tests/Clipperz/PM/Toll.html
+++ b/frontend/gamma/tests/tests/Clipperz/PM/Toll.html
@@ -1,59 +1,58 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.PM.Toll - test</title> 28 <title>Clipperz.PM.Toll - test</title>
29 29
30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
31 <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
32 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
33 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
34 33
35 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
40 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
41 40
42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
46 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 45 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script> 46 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
48 47
49 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script> 48 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
50 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script> 49 <script type="text/javascript" src="../../../SimpleTest/SimpleTest.Async.js"></script>
51 50
52</head> 51</head>
53<body> 52<body>
54<pre id="test"> 53<pre id="test">
55 <script type="text/javascript" src="Toll.test.js"></script> 54 <script type="text/javascript" src="Toll.test.js"></script>
56</pre> 55</pre>
57 56
58</body> 57</body>
59</html> 58</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/UI/Web/Controllers/MainController.html b/frontend/gamma/tests/tests/Clipperz/PM/UI/Web/Controllers/MainController.html
index 04f0e70..1eea01b 100644
--- a/frontend/gamma/tests/tests/Clipperz/PM/UI/Web/Controllers/MainController.html
+++ b/frontend/gamma/tests/tests/Clipperz/PM/UI/Web/Controllers/MainController.html
@@ -1,61 +1,60 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Clipperz.PM.UI.Web.MainController - test</title> 28 <title>Clipperz.PM.UI.Web.MainController - test</title>
29 29
30 <script type="text/javascript" src="../../../../../../../js/MochiKit/MochiKit.js"></script> 30 <script type="text/javascript" src="../../../../../../../js/MochiKit/MochiKit.js"></script>
31 <script type="text/javascript" src="../../../../../../../js/JSLog/jslog.js"></script>
32 <script type="text/javascript" src="../../../../../../SimpleTest/SimpleTest.js"></script> 31 <script type="text/javascript" src="../../../../../../SimpleTest/SimpleTest.js"></script>
33 <link rel="stylesheet" type="text/css" href="../../../../../../SimpleTest/test.css"> 32 <link rel="stylesheet" type="text/css" href="../../../../../../SimpleTest/test.css">
34 33
35 <script type='text/javascript' src='../../../../../../../js/Clipperz/YUI/Utils.js'></script> 34 <script type='text/javascript' src='../../../../../../../js/Clipperz/YUI/Utils.js'></script>
36 <script type='text/javascript' src='../../../../../../../js/Clipperz/Base.js'></script> 35 <script type='text/javascript' src='../../../../../../../js/Clipperz/Base.js'></script>
37 <script type='text/javascript' src='../../../../../../../js/Clipperz/ByteArray.js'></script> 36 <script type='text/javascript' src='../../../../../../../js/Clipperz/ByteArray.js'></script>
38 <script type='text/javascript' src='../../../../../../../js/Clipperz/Logging.js'></script> 37 <script type='text/javascript' src='../../../../../../../js/Clipperz/Logging.js'></script>
39 <script type='text/javascript' src='../../../../../../../js/Clipperz/Async.js'></script> 38 <script type='text/javascript' src='../../../../../../../js/Clipperz/Async.js'></script>
40 <script type='text/javascript' src='../../../../../../../js/Clipperz/KeyValueObjectStore.js'></script> 39 <script type='text/javascript' src='../../../../../../../js/Clipperz/KeyValueObjectStore.js'></script>
41 40
42 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/Base.js'></script> 41 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/Base.js'></script>
43 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/BigInt.js'></script> 42 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/BigInt.js'></script>
44 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/AES.js'></script> 43 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/AES.js'></script>
45 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/SHA.js'></script> 44 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/SHA.js'></script>
46 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/PRNG.js'></script> 45 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/PRNG.js'></script>
47 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/SRP.js'></script> 46 <script type='text/javascript' src='../../../../../../../js/Clipperz/Crypto/SRP.js'></script>
48 47
49 <script type='text/javascript' src='../../../../../../../js/Clipperz/Signal.js'></script> 48 <script type='text/javascript' src='../../../../../../../js/Clipperz/Signal.js'></script>
50 49
51 <script type='text/javascript' src='../../../../../../../js/Clipperz/PM/UI/Web/Controllers/MainController.js'></script> 50 <script type='text/javascript' src='../../../../../../../js/Clipperz/PM/UI/Web/Controllers/MainController.js'></script>
52 <script type="text/javascript" src="../../../../../../SimpleTest/SimpleTest.Async.js"></script> 51 <script type="text/javascript" src="../../../../../../SimpleTest/SimpleTest.Async.js"></script>
53 52
54</head> 53</head>
55<body> 54<body>
56<pre id="test"> 55<pre id="test">
57 <script type="text/javascript" src="MainController.test.js"></script> 56 <script type="text/javascript" src="MainController.test.js"></script>
58</pre> 57</pre>
59 58
60</body> 59</body>
61</html> 60</html>
diff --git a/frontend/gamma/tests/tests/Clipperz/RoboFormExportProcessor.html b/frontend/gamma/tests/tests/Clipperz/RoboFormExportProcessor.html
index 87cde0f..b4500e3 100644
--- a/frontend/gamma/tests/tests/Clipperz/RoboFormExportProcessor.html
+++ b/frontend/gamma/tests/tests/Clipperz/RoboFormExportProcessor.html
@@ -1,207 +1,206 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script> 28 <script type="text/javascript" src="../../../js/MochiKit/MochiKit.js"></script>
29 <script type="text/javascript" src="../../../js/JSLog/jslog.js"></script>
30 <script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script> 29 <script type="text/javascript" src="../../SimpleTest/SimpleTest.js"></script>
31 <link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css"> 30 <link rel="stylesheet" type="text/css" href="../../SimpleTest/test.css">
32 31
33 <script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script> 32 <script type='text/javascript' src='../../../js/Clipperz/YUI/Utils.js'></script>
34 <script type='text/javascript' src='../../../js/Clipperz/Base.js'></script> 33 <script type='text/javascript' src='../../../js/Clipperz/Base.js'></script>
35 <script type='text/javascript' src='../../../js/Clipperz/Async.js'></script> 34 <script type='text/javascript' src='../../../js/Clipperz/Async.js'></script>
36 <script type='text/javascript' src='../../../js/Clipperz/KeePassExportProcessor.js'></script> 35 <script type='text/javascript' src='../../../js/Clipperz/KeePassExportProcessor.js'></script>
37 36
38 <script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script> 37 <script type="text/javascript" src="../../SimpleTest/SimpleTest.Async.js"></script>
39</head> 38</head>
40<body> 39<body>
41<pre id="test"> 40<pre id="test">
42<script type="text/javascript"> 41<script type="text/javascript">
43try { 42try {
44 var deferredResult; 43 var deferredResult;
45 varkeePassProcessor; 44 varkeePassProcessor;
46 45
47 keePassProcessor = new Clipperz.KeePassExportProcessor(); 46 keePassProcessor = new Clipperz.KeePassExportProcessor();
48 47
49 deferredResult = new MochiKit.Async.Deferred(); 48 deferredResult = new MochiKit.Async.Deferred();
50 49
51 deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\n" }); 50 deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\n" });
52 deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse')); 51 deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse'));
53 deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\"}]", "first test"); }); 52 deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\"}]", "first test"); });
54 deferredResult.addErrback(function(anError) { is("ERROR", anError) }); 53 deferredResult.addErrback(function(anError) { is("ERROR", anError) });
55 54
56 deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" }); 55 deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" });
57 deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse')); 56 deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse'));
58 deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "second test"); }); 57 deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "second test"); });
59 deferredResult.addErrback(function(anError) { is("ERROR", anError) }); 58 deferredResult.addErrback(function(anError) { is("ERROR", anError) });
60 59
61 deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\nwith some notes stored\non multiple lines\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" }); 60 deferredResult.addCallback(function(aResult) { return "[Gmail]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.gmail.com\nPassword: NHy08ZCMYsqUeLQCawR7\nNotes: Personal account\nwith some notes stored\non multiple lines\n\n[del.icio.us]\nGroup: General\nUserName: joe69\nURL: http://del.icio.us\nPassword: tS1cIEeqp5y0wkU\nNotes: social bookmarking site\n\n[Amazon]\nGroup: General\nUserName: jclipperz\nURL: http://www.amazon.com\nPassword: wvpkqNPIsqlI5g6XE9Tz\nNotes: The US online store\n\n[Paypal]\nGroup: General\nUserName: joeclipperz\nURL: http://www.paypal.com\nPassword: 24T4wIcvHnM28T3L\nNotes: Linked to my savings account\n\n[Technorati]\nGroup: General\nUserName: jclipperz\nURL: http://www.technorati.com\nPassword: UcVeNqF\nNotes: Blog ranking and searching\n\n[American Airlines]\nGroup: General\nUserName: joe.clipperz\nURL: http://www.aa.com\nPassword: AtrYbmi7lmSjR\nNotes: Adavantages card n. 795495\n" });
62 deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse')); 61 deferredResult.addCallback(MochiKit.Base.method(keePassProcessor, 'deferredParse'));
63 deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\\nwith some notes stored\\non multiple lines\\n\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "third test"); }); 62 deferredResult.addCallback(function(aResult) { is(MochiKit.Base.serializeJSON(aResult), "[{\"Title\":\"Gmail\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.gmail.com\", \"Password\":\"NHy08ZCMYsqUeLQCawR7\", \"Notes\":\"Personal account\\nwith some notes stored\\non multiple lines\\n\"}, {\"Title\":\"del.icio.us\", \"Group\":\"General\", \"UserName\":\"joe69\", \"URL\":\"http://del.icio.us\", \"Password\":\"tS1cIEeqp5y0wkU\", \"Notes\":\"social bookmarking site\"}, {\"Title\":\"Amazon\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.amazon.com\", \"Password\":\"wvpkqNPIsqlI5g6XE9Tz\", \"Notes\":\"The US online store\"}, {\"Title\":\"Paypal\", \"Group\":\"General\", \"UserName\":\"joeclipperz\", \"URL\":\"http://www.paypal.com\", \"Password\":\"24T4wIcvHnM28T3L\", \"Notes\":\"Linked to my savings account\"}, {\"Title\":\"Technorati\", \"Group\":\"General\", \"UserName\":\"jclipperz\", \"URL\":\"http://www.technorati.com\", \"Password\":\"UcVeNqF\", \"Notes\":\"Blog ranking and searching\"}, {\"Title\":\"American Airlines\", \"Group\":\"General\", \"UserName\":\"joe.clipperz\", \"URL\":\"http://www.aa.com\", \"Password\":\"AtrYbmi7lmSjR\", \"Notes\":\"Adavantages card n. 795495\"}]", "third test"); });
64 deferredResult.addErrback(function(anError) { is("ERROR", anError) }); 63 deferredResult.addErrback(function(anError) { is("ERROR", anError) });
65 64
66 65
67 66
68 deferredResult.addBoth(SimpleTest.finish); 67 deferredResult.addBoth(SimpleTest.finish);
69 deferredResult.callback(); 68 deferredResult.callback();
70 69
71/* 70/*
72 var set; 71 var set;
73 varobject1; 72 varobject1;
74 varobject2; 73 varobject2;
75 var object3; 74 var object3;
76 75
77 set = new Clipperz.Set(); 76 set = new Clipperz.Set();
78 77
79 object1 = new Object(); 78 object1 = new Object();
80 object2 = new Object(); 79 object2 = new Object();
81 object3 = new Object(); 80 object3 = new Object();
82 81
83 object1.label = "object 1"; 82 object1.label = "object 1";
84 object2.label = "object 2"; 83 object2.label = "object 2";
85 object3.label = "object 3"; 84 object3.label = "object 3";
86 85
87 is(set.size(), 0, "A new set should be empty"); 86 is(set.size(), 0, "A new set should be empty");
88 87
89 set.add(object1); 88 set.add(object1);
90 is(set.size(), 1); 89 is(set.size(), 1);
91 is(set.contains(object1), true); 90 is(set.contains(object1), true);
92 is(set.contains(object2), false); 91 is(set.contains(object2), false);
93 92
94 set.add(object1); 93 set.add(object1);
95 is(set.size(), 1, "Adding the same object twice does not change the set content"); 94 is(set.size(), 1, "Adding the same object twice does not change the set content");
96 is(set.contains(object1), true); 95 is(set.contains(object1), true);
97 is(set.contains(object2), false); 96 is(set.contains(object2), false);
98 97
99 set.add(object2); 98 set.add(object2);
100 is(set.size(), 2); 99 is(set.size(), 2);
101 is(set.contains(object1), true); 100 is(set.contains(object1), true);
102 is(set.contains(object2), true); 101 is(set.contains(object2), true);
103 is(set.contains(object3), false); 102 is(set.contains(object3), false);
104 103
105 set.remove(object1); 104 set.remove(object1);
106 is(set.size(), 1, "Size check after removing an object"); 105 is(set.size(), 1, "Size check after removing an object");
107 is(set.contains(object1), false); 106 is(set.contains(object1), false);
108 is(set.contains(object2), true); 107 is(set.contains(object2), true);
109 is(set.contains(object3), false); 108 is(set.contains(object3), false);
110 109
111 set.remove(object1); 110 set.remove(object1);
112 is(set.size(), 1, "Removing twice the same object does not change the set content"); 111 is(set.size(), 1, "Removing twice the same object does not change the set content");
113 is(set.contains(object1), false); 112 is(set.contains(object1), false);
114 is(set.contains(object2), true); 113 is(set.contains(object2), true);
115 is(set.contains(object3), false); 114 is(set.contains(object3), false);
116 115
117 set.empty(); 116 set.empty();
118 is(set.size(), 0); 117 is(set.size(), 0);
119 118
120 { 119 {
121 varitems; 120 varitems;
122 varpopulatedSet; 121 varpopulatedSet;
123 122
124 items = ["item1", "item2", "item3"]; 123 items = ["item1", "item2", "item3"];
125 124
126 populatedSet = new Clipperz.Set({'items': items}); 125 populatedSet = new Clipperz.Set({'items': items});
127 is(populatedSet.size(), 3); 126 is(populatedSet.size(), 3);
128 is(populatedSet.contains("item1"), true); 127 is(populatedSet.contains("item1"), true);
129 is(populatedSet.contains("item4"), false); 128 is(populatedSet.contains("item4"), false);
130 129
131 items.splice(0, items.length); 130 items.splice(0, items.length);
132 is(populatedSet.size(), 3); 131 is(populatedSet.size(), 3);
133 } 132 }
134 133
135 { 134 {
136 varitems; 135 varitems;
137 vardeletedItems; 136 vardeletedItems;
138 137
139 items = ["item1", "item2", "item3"]; 138 items = ["item1", "item2", "item3"];
140 139
141 set = new Clipperz.Set({'items': items}); 140 set = new Clipperz.Set({'items': items});
142 deletedItems = ["item1"]; 141 deletedItems = ["item1"];
143 set.remove(deletedItems); 142 set.remove(deletedItems);
144 is(set.size(), 2, "here I am"); 143 is(set.size(), 2, "here I am");
145 is(set.contains("item1"), false); 144 is(set.contains("item1"), false);
146 is(set.contains("item2"), true); 145 is(set.contains("item2"), true);
147 146
148 set = new Clipperz.Set({'items': items}); 147 set = new Clipperz.Set({'items': items});
149 deletedItems = ["item1", "item2"]; 148 deletedItems = ["item1", "item2"];
150 set.remove(deletedItems); 149 set.remove(deletedItems);
151 is(set.size(), 1); 150 is(set.size(), 1);
152 is(set.contains("item1"), false); 151 is(set.contains("item1"), false);
153 is(set.contains("item2"), false); 152 is(set.contains("item2"), false);
154 153
155 set = new Clipperz.Set({'items': items}); 154 set = new Clipperz.Set({'items': items});
156 deletedItems = ["item1", "item4"]; 155 deletedItems = ["item1", "item4"];
157 set.remove(deletedItems); 156 set.remove(deletedItems);
158 is(set.size(), 2); 157 is(set.size(), 2);
159 is(set.contains("item1"), false); 158 is(set.contains("item1"), false);
160 is(set.contains("item2"), true); 159 is(set.contains("item2"), true);
161 } 160 }
162 161
163 { 162 {
164 var items; 163 var items;
165 var poppedItem; 164 var poppedItem;
166 165
167 items = ["item1", "item2", "item3"]; 166 items = ["item1", "item2", "item3"];
168 set = new Clipperz.Set({'items': items}); 167 set = new Clipperz.Set({'items': items});
169 168
170 poppedItem = set.popAnItem(); 169 poppedItem = set.popAnItem();
171 ok(poppedItem != null, "test popAnItem - 1"); 170 ok(poppedItem != null, "test popAnItem - 1");
172 is(set.size(), 2, "test popAnItem - 2"); 171 is(set.size(), 2, "test popAnItem - 2");
173 172
174 poppedItem = set.popAnItem(); 173 poppedItem = set.popAnItem();
175 ok(poppedItem != null, "test popAnItem - 3"); 174 ok(poppedItem != null, "test popAnItem - 3");
176 is(set.size(), 1, "test popAnItem - 4"); 175 is(set.size(), 1, "test popAnItem - 4");
177 176
178 poppedItem = set.popAnItem(); 177 poppedItem = set.popAnItem();
179 ok(poppedItem != null, "test popAnItem - 5"); 178 ok(poppedItem != null, "test popAnItem - 5");
180 is(set.size(), 0, "test popAnItem - 6"); 179 is(set.size(), 0, "test popAnItem - 6");
181 180
182 poppedItem = set.popAnItem(); 181 poppedItem = set.popAnItem();
183 ok(poppedItem == null, "test popAnItem - 7"); 182 ok(poppedItem == null, "test popAnItem - 7");
184 } 183 }
185*/ 184*/
186 185
187 SimpleTest.waitForExplicitFinish(); 186 SimpleTest.waitForExplicitFinish();
188 187
189} catch (err) { 188} catch (err) {
190 189
191 var s = "test suite failure!\n"; 190 var s = "test suite failure!\n";
192 var o = {}; 191 var o = {};
193 var k = null; 192 var k = null;
194 for (k in err) { 193 for (k in err) {
195 // ensure unique keys?! 194 // ensure unique keys?!
196 if (!o[k]) { 195 if (!o[k]) {
197 s += k + ": " + err[k] + "\n"; 196 s += k + ": " + err[k] + "\n";
198 o[k] = err[k]; 197 o[k] = err[k];
199 } 198 }
200 } 199 }
201 ok ( false, s ); 200 ok ( false, s );
202} 201}
203 202
204</script> 203</script>
205</pre> 204</pre>
206</body> 205</body>
207</html> 206</html>
diff --git a/frontend/gamma/tests/tests/Components/CardDialogNew/index.html b/frontend/gamma/tests/tests/Components/CardDialogNew/index.html
index 2d502b4..64f9e4d 100644
--- a/frontend/gamma/tests/tests/Components/CardDialogNew/index.html
+++ b/frontend/gamma/tests/tests/Components/CardDialogNew/index.html
@@ -1,114 +1,112 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>Card Dialog NEW - test</title> 28 <title>Card Dialog NEW - test</title>
29 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 29 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
30 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script> 30 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
31 31
32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
35 <script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
40 40
41 <script type='text/javascript' src='../../../../js/Clipperz/Signal.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Signal.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/Style.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Style.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Visual.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Visual.js'></script>
44 <script type='text/javascript' src='../../../../js/Clipperz/Set.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/Set.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script> 45 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
46 46
47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
48 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 48 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
49 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 49 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
50 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 50 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
51 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 51 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
52 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script> 52 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
53 53
54 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script> 54 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
55 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script> 55 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
56 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script> 56 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
57 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script> 57 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
58 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script> 58 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
59 59
60 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script> 60 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
61 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script> 61 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
62 62
63 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script> 63 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script>
64 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script> 64 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
65 <script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script> 65 <script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script>
66 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script> 66 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
67 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.js'></script> 67 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.js'></script>
68 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script> 68 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
69 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script> 69 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
70 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script> 70 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
71 <!-- script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Field.js'></script --> 71 <!-- script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Field.js'></script -->
72 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.js'></script> 72 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.js'></script>
73 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script> 73 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
74 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script> 74 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
75 75
76 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/BaseComponent.js'></script> 76 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/BaseComponent.js'></script>
77 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Button.js'></script> 77 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Button.js'></script>
78 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ComponentSlot.js'></script> 78 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ComponentSlot.js'></script>
79 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js'></script> 79 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js'></script>
80 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ProgressBar.js'></script> 80 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ProgressBar.js'></script>
81 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js'></script> 81 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js'></script>
82 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js'></script> 82 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js'></script>
83 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Tooltip.js'></script> 83 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Tooltip.js'></script>
84 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js'></script> 84 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js'></script>
85 85
86 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js'></script> 86 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js'></script>
87 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js'></script> 87 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js'></script>
88 88
89 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js'></script> 89 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js'></script>
90 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js'></script> 90 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js'></script>
91 91
92 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js'></script> 92 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js'></script>
93 93
94 <script type='text/javascript' src='./User.data.js'></script> 94 <script type='text/javascript' src='./User.data.js'></script>
95 <script type='text/javascript' src='./cardDialogNew_test.js'></script> 95 <script type='text/javascript' src='./cardDialogNew_test.js'></script>
96<script> 96<script>
97 Clipperz_IEisBroken = false; 97 Clipperz_IEisBroken = false;
98</script> 98</script>
99 99
100<!--[if IE]><script> 100<!--[if IE]><script>
101Clipperz_IEisBroken = true; 101Clipperz_IEisBroken = true;
102</script><![endif]--> 102</script><![endif]-->
103 103
104 <link rel="stylesheet" type="text/css" href="../../../../css/clipperz/clipperz.css" /> 104 <link rel="stylesheet" type="text/css" href="../../../../css/web.css" />
105 <link rel="stylesheet" type="text/css" href="../../../../css/clipperz/compact.css" />
106 <link rel="stylesheet" type="text/css" href="../../../../css/clipperz/ytheme-clipperz.css" />
107 105
108</head> 106</head>
109<body> 107<body>
110 108
111<div id="tableWrapper"></div> 109<div id="tableWrapper"></div>
112 110
113</body> 111</body>
114</html> 112</html>
diff --git a/frontend/gamma/tests/tests/Components/Tooltips/index.html b/frontend/gamma/tests/tests/Components/Tooltips/index.html
index 02c6c34..3772227 100644
--- a/frontend/gamma/tests/tests/Components/Tooltips/index.html
+++ b/frontend/gamma/tests/tests/Components/Tooltips/index.html
@@ -1,140 +1,138 @@
1<!-- 1<!--
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz Community Edition.
6Clipperz Community Edition is an online password manager. 6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 7For further information about its features and functionalities please
8refer to http://www.clipperz.com. 8refer to http://www.clipperz.com.
9 9
10* Clipperz Community Edition is free software: you can redistribute 10* Clipperz Community Edition is free software: you can redistribute
11 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
12 License as published by the Free Software Foundation, either version 12 License as published by the Free Software Foundation, either version
13 3 of the License, or (at your option) any later version. 13 3 of the License, or (at your option) any later version.
14 14
15* Clipperz Community Edition is distributed in the hope that it will 15* Clipperz Community Edition is distributed in the hope that it will
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 16 be useful, but WITHOUT ANY WARRANTY; without even the implied
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 18 See the GNU Affero General Public License for more details.
19 19
20* 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
21 License along with Clipperz Community Edition. If not, see 21 License along with Clipperz Community Edition. If not, see
22 <http://www.gnu.org/licenses/>. 22 <http://www.gnu.org/licenses/>.
23 23
24--> 24-->
25 25
26<html> 26<html>
27<head> 27<head>
28 <title>TOOLTIPS - test</title> 28 <title>TOOLTIPS - test</title>
29 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> 29 <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
30 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script> 30 <script type='text/javascript' src='../../../../js/JSON/json2.js'></script>
31 31
32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> 32 <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script>
33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> 33 <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script>
34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> 34 <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
35 <script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script> 35 <script type='text/javascript' src='../../../../js/Clipperz/Date.js'></script>
36 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script> 36 <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
37 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> 37 <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script>
38 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> 38 <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script>
39 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script> 39 <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script>
40 40
41 <script type='text/javascript' src='../../../../js/Clipperz/Signal.js'></script> 41 <script type='text/javascript' src='../../../../js/Clipperz/Signal.js'></script>
42 <script type='text/javascript' src='../../../../js/Clipperz/Style.js'></script> 42 <script type='text/javascript' src='../../../../js/Clipperz/Style.js'></script>
43 <script type='text/javascript' src='../../../../js/Clipperz/Visual.js'></script> 43 <script type='text/javascript' src='../../../../js/Clipperz/Visual.js'></script>
44 <script type='text/javascript' src='../../../../js/Clipperz/Set.js'></script> 44 <script type='text/javascript' src='../../../../js/Clipperz/Set.js'></script>
45 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script> 45 <script type='text/javascript' src='../../../../js/Clipperz/KeyValueObjectStore.js'></script>
46 46
47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> 47 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
48 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> 48 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
49 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> 49 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script>
50 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> 50 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script>
51 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> 51 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script>
52 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script> 52 <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script>
53 53
54 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script> 54 <script type='text/javascript' src='../../../../js/Clipperz/PM/Toll.js'></script>
55 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script> 55 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script>
56 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script> 56 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.js'></script>
57 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script> 57 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Test.js'></script>
58 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script> 58 <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js'></script>
59 59
60 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script> 60 <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script>
61 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script> 61 <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script>
62 62
63 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script> 63 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings.js'></script>
64 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script> 64 <script type='text/javascript' src='../../../../js/Clipperz/PM/Strings/Strings_en-US.js'></script>
65 <script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script> 65 <script type='text/javascript' src='../../../../js/Clipperz/PM/Date.js'></script>
66 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script> 66 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/EncryptedRemoteObject.js'></script>
67 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.js'></script> 67 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.js'></script>
68 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script> 68 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.js'></script>
69 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script> 69 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Version.Field.js'></script>
70 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script> 70 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/DirectLogin.js'></script>
71 <!-- script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Field.js'></script --> 71 <!-- script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/Record.Field.js'></script -->
72 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.js'></script> 72 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.js'></script>
73 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script> 73 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.Legacy.js'></script>
74 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script> 74 <script type='text/javascript' src='../../../../js/Clipperz/PM/DataModel/User.Header.RecordIndex.js'></script>
75 75
76 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/BaseComponent.js'></script> 76 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/BaseComponent.js'></script>
77 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ComponentSlot.js'></script> 77 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ComponentSlot.js'></script>
78 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js'></script> 78 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/PasswordEntropyDisplay.js'></script>
79 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ProgressBar.js'></script> 79 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/ProgressBar.js'></script>
80 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js'></script> 80 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/SimpleMessagePanel.js'></script>
81 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js'></script> 81 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TabPanelComponent.js'></script>
82 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Tooltip.js'></script> 82 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/Tooltip.js'></script>
83 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js'></script> 83 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Components/TranslatorWidget.js'></script>
84 84
85 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js'></script> 85 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogComponent.js'></script>
86 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js'></script> 86 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Components/CardDialogRecordFieldComponent.js'></script>
87 87
88 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js'></script> 88 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js'></script>
89 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js'></script> 89 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js'></script>
90 90
91 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js'></script> 91 <script type='text/javascript' src='../../../../js/Clipperz/PM/UI/Web/Controllers/CardDialogController.js'></script>
92 92
93 <script type='text/javascript' src='./tooltips_test.js'></script> 93 <script type='text/javascript' src='./tooltips_test.js'></script>
94<script> 94<script>
95 Clipperz_IEisBroken = false; 95 Clipperz_IEisBroken = false;
96</script> 96</script>
97 97
98<!--[if IE]><script> 98<!--[if IE]><script>
99Clipperz_IEisBroken = true; 99Clipperz_IEisBroken = true;
100</script><![endif]--> 100</script><![endif]-->
101 101
102 <link rel="stylesheet" type="text/css" href="../../../../css/clipperz/clipperz.css" /> 102 <link rel="stylesheet" type="text/css" href="../../../../css/web.css" />
103 <link rel="stylesheet" type="text/css" href="../../../../css/clipperz/compact.css" />
104 <link rel="stylesheet" type="text/css" href="../../../../css/clipperz/ytheme-clipperz.css" />
105 103
106<style> 104<style>
107 105
108div.leftColumn { 106div.leftColumn {
109 float:left; 107 float:left;
110} 108}
111 109
112div.rightColumn { 110div.rightColumn {
113 float:left; 111 float:left;
114} 112}
115 113
116div.boxWrapper { 114div.boxWrapper {
117 padding: 70px 200px; 115 padding: 70px 200px;
118} 116}
119 117
120div.box { 118div.box {
121 width: 100px; 119 width: 100px;
122 height: 30px; 120 height: 30px;
123 border: 1px solid red; 121 border: 1px solid red;
124} 122}
125</style> 123</style>
126 124
127</head> 125</head>
128<body> 126<body>
129 127
130<div class="leftColumn"> 128<div class="leftColumn">
131 <div class="boxWrapper"><div id="ABOVE" class="box">above</div></div> 129 <div class="boxWrapper"><div id="ABOVE" class="box">above</div></div>
132 <div class="boxWrapper"><div id="BELOW" class="box">below</div></div> 130 <div class="boxWrapper"><div id="BELOW" class="box">below</div></div>
133</div> 131</div>
134<div class="rightColumn"> 132<div class="rightColumn">
135 <div class="boxWrapper"><div id="LEFT" class="box">left</div></div> 133 <div class="boxWrapper"><div id="LEFT" class="box">left</div></div>
136 <div class="boxWrapper"><div id="RIGHT" class="box">right</div></div> 134 <div class="boxWrapper"><div id="RIGHT" class="box">right</div></div>
137</div> 135</div>
138 136
139</body> 137</body>
140</html> 138</html>