old_sql 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. data/README.md +24 -13
  2. data/app/controllers/old_sql/report_controller.rb +3 -17
  3. data/app/views/layouts/old_sql/chart.html.erb +11 -0
  4. data/app/views/old_sql/report/chart.html.erb +8 -25
  5. data/lib/generators/old_sql/templates/user_design_template.csv +2 -3
  6. data/lib/generators/old_sql/templates/user_old_sql_demo_chart_design.yml +18 -9
  7. data/lib/old_sql/report_design/chart.rb +2 -2
  8. data/lib/old_sql/report_design/chart_item.rb +4 -4
  9. data/lib/old_sql/report_design/chart_parser.rb +2 -2
  10. data/public/javascripts/old_sql/chart.js +33 -0
  11. metadata +5 -265
  12. data/public/javascripts/old_sql/MochiKit-1.4.2/Changes +0 -362
  13. data/public/javascripts/old_sql/MochiKit-1.4.2/LICENSE.txt +0 -69
  14. data/public/javascripts/old_sql/MochiKit-1.4.2/MANIFEST +0 -179
  15. data/public/javascripts/old_sql/MochiKit-1.4.2/META.json +0 -17
  16. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Async.html +0 -814
  17. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Base.html +0 -1703
  18. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Color.html +0 -755
  19. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/DOM.html +0 -1197
  20. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/DateTime.html +0 -168
  21. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/DragAndDrop.html +0 -187
  22. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Format.html +0 -300
  23. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Iter.html +0 -524
  24. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Logging.html +0 -420
  25. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/LoggingPane.html +0 -142
  26. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Position.html +0 -38
  27. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Selector.html +0 -240
  28. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Signal.html +0 -508
  29. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Sortable.html +0 -244
  30. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Style.html +0 -385
  31. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/VersionHistory.html +0 -384
  32. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/Visual.html +0 -1161
  33. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/html/MochiKit/index.html +0 -447
  34. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/js/toc.js +0 -113
  35. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Async.rst +0 -767
  36. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Base.rst +0 -1445
  37. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Color.rst +0 -651
  38. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/DOM.rst +0 -1143
  39. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/DateTime.rst +0 -145
  40. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/DragAndDrop.rst +0 -197
  41. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Format.rst +0 -258
  42. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Iter.rst +0 -454
  43. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Logging.rst +0 -348
  44. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/LoggingPane.rst +0 -128
  45. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Position.rst +0 -26
  46. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Selector.rst +0 -203
  47. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Signal.rst +0 -498
  48. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Sortable.rst +0 -186
  49. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Style.rst +0 -353
  50. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/VersionHistory.rst +0 -362
  51. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/Visual.rst +0 -895
  52. data/public/javascripts/old_sql/MochiKit-1.4.2/doc/rst/MochiKit/index.rst +0 -83
  53. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/ajax_tables.css +0 -69
  54. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/ajax_tables.js +0 -401
  55. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/domains.json +0 -10
  56. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/domains.xml +0 -40
  57. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/ajax_tables/index.html +0 -96
  58. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/color_wheel/color_wheel.css +0 -4
  59. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/color_wheel/color_wheel.js +0 -95
  60. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/color_wheel/index.html +0 -31
  61. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/dnd_sortable.css +0 -23
  62. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/dropmarker.png +0 -0
  63. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/icon.png +0 -0
  64. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/index.html +0 -54
  65. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable2_test.html +0 -150
  66. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable3_test.html +0 -42
  67. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable4_test.html +0 -90
  68. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable5_test.html +0 -29
  69. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable_test.html +0 -38
  70. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/dnd_sortable/sortable_tree_test.html +0 -189
  71. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/draggable/draggable.css +0 -28
  72. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/draggable/draggable.js +0 -73
  73. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/draggable/index.html +0 -38
  74. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_bigslide.html +0 -36
  75. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_blind.html +0 -65
  76. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_blindslide.html +0 -31
  77. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_combi.css +0 -18
  78. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_fadeappear.html +0 -61
  79. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_grow_shrink.html +0 -38
  80. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_onload.html +0 -67
  81. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_queue.html +0 -67
  82. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_queue_limit.html +0 -30
  83. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_scroll.html +0 -483
  84. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/effects_slide.html +0 -62
  85. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/full.html +0 -71
  86. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/icon.png +0 -0
  87. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/effects/index.html +0 -150
  88. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/interpreter/index.html +0 -88
  89. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/interpreter/interpreter.css +0 -54
  90. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/interpreter/interpreter.js +0 -373
  91. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/key_events/index.html +0 -78
  92. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/key_events/key_events.css +0 -5
  93. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/key_events/key_events.js +0 -85
  94. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/logging_pane/index.html +0 -46
  95. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/logging_pane/logging_pane.css +0 -78
  96. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/logging_pane/logging_pane.js +0 -11
  97. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mochiregexp/index.html +0 -74
  98. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mochiregexp/mochiregexp.css +0 -73
  99. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mochiregexp/mochiregexp.js +0 -125
  100. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mouse_events/index.html +0 -88
  101. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mouse_events/mouse_events.css +0 -17
  102. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/mouse_events/mouse_events.js +0 -59
  103. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/rounded_corners/index.html +0 -28
  104. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/rounded_corners/rounded_corners.css +0 -3
  105. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/rounded_corners/rounded_corners.js +0 -19
  106. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_boxes.html +0 -45
  107. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_full.html +0 -119
  108. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_ghost.html +0 -40
  109. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_hoverclass.html +0 -43
  110. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_scroll.html +0 -91
  111. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/dnd_snap.html +0 -54
  112. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/index.html +0 -93
  113. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/simple_dnd/simple_dnd.css +0 -64
  114. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/sortable_tables/index.html +0 -71
  115. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/sortable_tables/sortable_tables.css +0 -66
  116. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/sortable_tables/sortable_tables.js +0 -203
  117. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/SyntaxHighlighter.css +0 -177
  118. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/Tests.html +0 -339
  119. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushCSharp.js +0 -30
  120. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushDelphi.js +0 -31
  121. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushJScript.js +0 -22
  122. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushPhp.js +0 -23
  123. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushPython.js +0 -71
  124. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushSql.js +0 -40
  125. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushVb.js +0 -29
  126. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shBrushXml.js +0 -61
  127. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/lib/SyntaxHighlighter/shCore.js +0 -622
  128. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/view-source.css +0 -1
  129. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/view-source.html +0 -19
  130. data/public/javascripts/old_sql/MochiKit-1.4.2/examples/view-source/view-source.js +0 -70
  131. data/public/javascripts/old_sql/MochiKit-1.4.2/include/_img/bg_docheader.gif +0 -0
  132. data/public/javascripts/old_sql/MochiKit-1.4.2/include/_img/g_bullet.gif +0 -0
  133. data/public/javascripts/old_sql/MochiKit-1.4.2/include/_img/g_logo_doc.gif +0 -0
  134. data/public/javascripts/old_sql/MochiKit-1.4.2/include/css/documentation.css +0 -130
  135. data/public/javascripts/old_sql/MochiKit-1.4.2/include/css/general.css +0 -48
  136. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Async.js +0 -682
  137. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Base.js +0 -1489
  138. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Color.js +0 -863
  139. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/DOM.js +0 -1256
  140. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/DateTime.js +0 -222
  141. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/DragAndDrop.js +0 -793
  142. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Format.js +0 -304
  143. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Iter.js +0 -844
  144. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Logging.js +0 -315
  145. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/LoggingPane.js +0 -353
  146. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/MochiKit.js +0 -188
  147. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/MockDOM.js +0 -115
  148. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Position.js +0 -236
  149. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Selector.js +0 -415
  150. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Signal.js +0 -897
  151. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Sortable.js +0 -589
  152. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Style.js +0 -594
  153. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Test.js +0 -162
  154. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/Visual.js +0 -2026
  155. data/public/javascripts/old_sql/MochiKit-1.4.2/lib/MochiKit/__package__.js +0 -18
  156. data/public/javascripts/old_sql/MochiKit-1.4.2/packed/MochiKit/MochiKit.js +0 -7829
  157. data/public/javascripts/old_sql/MochiKit-1.4.2/packed/MochiKit/__package__.js +0 -6
  158. data/public/javascripts/old_sql/MochiKit-1.4.2/packed/MochiKit/customize.html +0 -251
  159. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/FakeJSAN.js +0 -40
  160. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/SimpleTest/SimpleTest.js +0 -381
  161. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/SimpleTest/TestRunner.js +0 -159
  162. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/SimpleTest/test.css +0 -28
  163. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/cli.js +0 -6
  164. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/index.html +0 -25
  165. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/standalone.js +0 -16
  166. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Base.js +0 -577
  167. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Color.js +0 -137
  168. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_DateTime.js +0 -52
  169. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_DragAndDrop.js +0 -30
  170. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Format.js +0 -89
  171. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Iter.js +0 -186
  172. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Logging.js +0 -88
  173. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Async.html +0 -408
  174. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Async.json +0 -1
  175. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Base.html +0 -34
  176. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Color.html +0 -84
  177. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DOM-Safari.html +0 -48
  178. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DOM.html +0 -363
  179. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DateTime.html +0 -39
  180. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-DragAndDrop.html +0 -54
  181. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Format.html +0 -39
  182. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Iter.html +0 -38
  183. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-JSAN.html +0 -32
  184. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Logging.html +0 -40
  185. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-MochiKit.html +0 -18
  186. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Selector.html +0 -295
  187. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Signal.html +0 -43
  188. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Style.html +0 -223
  189. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_MochiKit-Visual.html +0 -197
  190. data/public/javascripts/old_sql/MochiKit-1.4.2/tests/test_Signal.js +0 -481
  191. data/public/javascripts/old_sql/plotkit-0.9.1/COPYING +0 -28
  192. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/Base.js +0 -406
  193. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/Canvas.js +0 -683
  194. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/EasyPlot.js +0 -161
  195. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/Layout.js +0 -756
  196. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/PlotKit.js +0 -151
  197. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/PlotKit_Packed.js +0 -2177
  198. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/SVG.js +0 -705
  199. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/SweetCanvas.js +0 -348
  200. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/SweetSVG.js +0 -247
  201. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/dummy.svg +0 -9
  202. data/public/javascripts/old_sql/plotkit-0.9.1/PlotKit/excanvas.js +0 -723
  203. data/public/javascripts/old_sql/plotkit-0.9.1/README +0 -1
  204. data/public/javascripts/old_sql/plotkit-0.9.1/doc/MochiKitAdditions.html +0 -2
  205. data/public/javascripts/old_sql/plotkit-0.9.1/doc/MochiKitAdditions.txt +0 -2
  206. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Base.html +0 -302
  207. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Base.txt +0 -139
  208. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Canvas.html +0 -172
  209. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Canvas.txt +0 -81
  210. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.EasyPlot.html +0 -155
  211. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.EasyPlot.txt +0 -50
  212. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Layout.html +0 -428
  213. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Layout.txt +0 -330
  214. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.QuickStart.html +0 -368
  215. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.QuickStart.txt +0 -256
  216. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Renderer.html +0 -436
  217. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.Renderer.txt +0 -299
  218. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SVG.html +0 -159
  219. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SVG.txt +0 -64
  220. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetCanvas.html +0 -131
  221. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetCanvas.txt +0 -34
  222. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetSVG.html +0 -131
  223. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.SweetSVG.txt +0 -34
  224. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.html +0 -334
  225. data/public/javascripts/old_sql/plotkit-0.9.1/doc/PlotKit.txt +0 -151
  226. data/public/javascripts/old_sql/plotkit-0.9.1/doc/SVGCanvasCompat.html +0 -304
  227. data/public/javascripts/old_sql/plotkit-0.9.1/doc/SVGCanvasCompat.txt +0 -144
  228. data/public/javascripts/old_sql/plotkit-0.9.1/doc/barsample.png +0 -0
  229. data/public/javascripts/old_sql/plotkit-0.9.1/doc/black.png +0 -0
  230. data/public/javascripts/old_sql/plotkit-0.9.1/doc/blue.png +0 -0
  231. data/public/javascripts/old_sql/plotkit-0.9.1/doc/cyan.png +0 -0
  232. data/public/javascripts/old_sql/plotkit-0.9.1/doc/doc.css +0 -62
  233. data/public/javascripts/old_sql/plotkit-0.9.1/doc/generate.py +0 -37
  234. data/public/javascripts/old_sql/plotkit-0.9.1/doc/green.png +0 -0
  235. data/public/javascripts/old_sql/plotkit-0.9.1/doc/orange.png +0 -0
  236. data/public/javascripts/old_sql/plotkit-0.9.1/doc/piesample.png +0 -0
  237. data/public/javascripts/old_sql/plotkit-0.9.1/doc/purple.png +0 -0
  238. data/public/javascripts/old_sql/plotkit-0.9.1/doc/red.png +0 -0
  239. data/public/javascripts/old_sql/plotkit-0.9.1/scripts/custom_rhino.jar +0 -0
  240. data/public/javascripts/old_sql/plotkit-0.9.1/scripts/pack.py +0 -58
  241. data/public/javascripts/old_sql/plotkit-0.9.1/tests/axis.html +0 -31
  242. data/public/javascripts/old_sql/plotkit-0.9.1/tests/basic.html +0 -25
  243. data/public/javascripts/old_sql/plotkit-0.9.1/tests/basic.js +0 -143
  244. data/public/javascripts/old_sql/plotkit-0.9.1/tests/debug.html +0 -56
  245. data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo-svg.html +0 -58
  246. data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo-svg.js +0 -133
  247. data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo.html +0 -57
  248. data/public/javascripts/old_sql/plotkit-0.9.1/tests/demo.js +0 -136
  249. data/public/javascripts/old_sql/plotkit-0.9.1/tests/dynamic.html +0 -161
  250. data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/firefox.png +0 -0
  251. data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/konqueror.png +0 -0
  252. data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/mozilla.ico +0 -0
  253. data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/msie.gif +0 -0
  254. data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/opera.ico +0 -0
  255. data/public/javascripts/old_sql/plotkit-0.9.1/tests/img/safari.gif +0 -0
  256. data/public/javascripts/old_sql/plotkit-0.9.1/tests/labels-img.html +0 -38
  257. data/public/javascripts/old_sql/plotkit-0.9.1/tests/labels.html +0 -43
  258. data/public/javascripts/old_sql/plotkit-0.9.1/tests/prototype_compat.html +0 -28
  259. data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-easy.html +0 -29
  260. data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-horiz.html +0 -53
  261. data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-neg.html +0 -29
  262. data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart-svg.html +0 -61
  263. data/public/javascripts/old_sql/plotkit-0.9.1/tests/quickstart.html +0 -57
  264. data/public/javascripts/old_sql/plotkit-0.9.1/tests/sample.txt +0 -6
  265. data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg-sweet.html +0 -29
  266. data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg-sweet.js +0 -141
  267. data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg.html +0 -26
  268. data/public/javascripts/old_sql/plotkit-0.9.1/tests/svg.js +0 -147
  269. data/public/javascripts/old_sql/plotkit-0.9.1/tests/sweet.html +0 -24
  270. data/public/javascripts/old_sql/plotkit-0.9.1/tests/sweet.js +0 -89
  271. data/public/javascripts/old_sql/plotkit-0.9.1/tests/tests.css +0 -66
  272. data/public/javascripts/old_sql/plotkit-0.9.1/tests/testsvg.html +0 -20
  273. data/public/javascripts/old_sql/plotkit-0.9.1/tests/testsvg.js +0 -31
@@ -1,1445 +0,0 @@
1
- .. title:: MochiKit.Base - functional programming and useful comparisons
2
-
3
- Name
4
- ====
5
-
6
- MochiKit.Base - functional programming and useful comparisons
7
-
8
-
9
- Synopsis
10
- ========
11
-
12
- ::
13
-
14
- myObjectRepr = function () {
15
- // gives a nice, stable string representation for objects,
16
- // ignoring any methods
17
- var keyValuePairs = [];
18
- for (var k in this) {
19
- var v = this[k];
20
- if (typeof(v) != 'function') {
21
- keyValuePairs.push([k, v]);
22
- }
23
- };
24
- keyValuePairs.sort(compare);
25
- return "{" + map(
26
- function (pair) {
27
- return map(repr, pair).join(":");
28
- },
29
- keyValuePairs
30
- ).join(", ") + "}";
31
- };
32
-
33
- // repr() will look for objects that have a repr method
34
- myObjectArray = [
35
- {"a": 3, "b": 2, "repr": myObjectRepr},
36
- {"a": 1, "b": 2, "repr": myObjectRepr}
37
- ];
38
-
39
- // sort it by the "a" property, check to see if it matches
40
- myObjectArray.sort(keyComparator("a"));
41
- expectedRepr = '[{"a": 1, "b": 2}, {"a": 3, "b": 2}]';
42
- assert( repr(myObjectArray) == expectedRepr );
43
-
44
- // get just the "a" values out into an array
45
- sortedAValues = map(itemgetter("a"), myObjectArray);
46
- assert( compare(sortedAValues, [1, 3]) == 0 );
47
-
48
- // serialize an array as JSON, unserialize it, expect something equivalent
49
- myArray = [1, 2, "3", null, undefined];
50
- assert( objEqual(evalJSON(serializeJSON(myArray)), myArray) );
51
-
52
-
53
- Description
54
- ===========
55
-
56
- :mochiref:`MochiKit.Base` is the foundation for the MochiKit suite.
57
- It provides:
58
-
59
- - An extensible comparison facility
60
- (:mochiref:`compare`, :mochiref:`registerComparator`)
61
- - An extensible programmer representation facility
62
- (:mochiref:`repr`, :mochiref:`registerRepr`)
63
- - An extensible JSON [1]_ serialization and evaluation facility
64
- (:mochiref:`serializeJSON`, :mochiref:`evalJSON`,
65
- :mochiref:`registerJSON`)
66
- - A simple adaptation facility (:mochiref:`AdapterRegistry`)
67
- - Convenience functions for manipulating objects and Arrays
68
- (:mochiref:`update`, :mochiref:`setdefault`, :mochiref:`extend`, etc.)
69
- - Array-based functional programming
70
- (:mochiref:`map`, :mochiref:`filter`, etc.)
71
- - Bound and partially applied functions
72
- (:mochiref:`bind`, :mochiref:`method`, :mochiref:`partial`)
73
-
74
- Python users will feel at home with :mochiref:`MochiKit.Base`, as the
75
- facilities are quite similar to those available as part of Python and
76
- the Python standard library.
77
-
78
-
79
- Dependencies
80
- ============
81
-
82
- None.
83
-
84
-
85
- Overview
86
- ========
87
-
88
- Comparison
89
- ----------
90
-
91
- The comparators (operators for comparison) in JavaScript are deeply
92
- broken, and it is not possible to teach them new tricks.
93
-
94
- MochiKit exposes an extensible comparison facility as a simple
95
- :mochiref:`compare(a, b)` function, which should be used in lieu of
96
- JavaScript's operators whenever comparing objects other than numbers
97
- or strings (though you can certainly use :mochiref:`compare` for
98
- those, too!).
99
-
100
- The :mochiref:`compare` function has the same signature and return
101
- value as a sort function for ``Array.prototype.sort``, and is often
102
- used in that context.
103
-
104
- Defining new comparators for the :mochiref:`compare` function to use
105
- is done by adding an entry to its :mochiref:`AdapterRegistry` with the
106
- :mochiref:`registerComparator` function.
107
-
108
-
109
- Programmer Representation
110
- -------------------------
111
-
112
- JavaScript's default representation mechanism, ``toString``, is
113
- notorious for having terrible default behavior. It's also very unwise
114
- to change that default, as other JavaScript code you may be using may
115
- depend on it.
116
-
117
- It's also useful to separate the concept of a "string representation"
118
- and a "string representation for programmers", much like Python does
119
- with its str and repr protocols.
120
-
121
- :mochiref:`repr` provides this programmer representation for
122
- JavaScript, in a way that doesn't require object prototype hacking:
123
- using an :mochiref:`AdapterRegistry`.
124
-
125
- Objects that implement the repr protocol can either implement a
126
- ``.repr()`` or ``.__repr__()`` method, or they can simply have an
127
- adapter setup to generate programmer representations. By default, the
128
- registry provides nice representations for ``null``, ``undefined``,
129
- ``Array``, and objects or functions with a ``NAME`` attribute that use
130
- the default ``toString``. For objects that ``repr`` doesn't already
131
- understand, it simply defaults to ``toString``, so it will integrate
132
- seamlessly with code that implements the idiomatic JavaScript
133
- ``toString`` method!
134
-
135
- To define a programmer representation for your own objects, simply add
136
- a ``.repr()`` or ``.__repr__()`` method that returns a string. For
137
- objects that you didn't create (e.g., from a script you didn't write,
138
- or a built-in object), it is instead recommended that you create an
139
- adapter with :mochiref:`registerRepr`.
140
-
141
-
142
- JSON Serialization
143
- ------------------
144
-
145
- JSON [1]_, JavaScript Object Notation, is a widely used serialization
146
- format in the context of web development. It's extremely simple,
147
- lightweight, and fast. In its essence, JSON is a restricted subset of
148
- JavaScript syntax suitable for sending over the wire that can be
149
- unserialized with a simple eval. It's often used as an alternative to
150
- XML in "AJAX" contexts because it is compact, fast, and much simpler
151
- to use for most purposes.
152
-
153
- To create a JSON serialization of any object, simply call
154
- :mochiref:`serializeJSON()` with that object. To unserialize a JSON
155
- string, simply call :mochiref:`evalJSON()` with the serialization.
156
-
157
- In order of precedence, :mochiref:`serializeJSON` coerces the given
158
- argument into a JSON serialization:
159
-
160
- 1. Primitive types are returned as their JSON representation:
161
- ``string``, ``number``, ``boolean``, ``null``.
162
- 2. If the object has a ``__json__`` or ``json`` method, then it is
163
- called with no arguments. If the result of this method is not the
164
- object itself, then the new object goes through rule processing
165
- again (e.g. it may return a string, which is then serialized in
166
- JSON format).
167
- 3. If the object is ``Array``-like (has a ``length`` property that is
168
- a number, and is not a function), then it is serialized as a JSON
169
- array. Each element will be processed according to these rules in
170
- order. Elements that can not be serialized (e.g. functions) will
171
- be replaced with ``undefined``.
172
- 4. The ``jsonRegistry`` :mochiref:`AdapterRegistry` is consulted for
173
- an adapter for this object. JSON adapters take one argument (the
174
- object), and are expected to behave like a ``__json__`` or
175
- ``json`` method (return another object to be serialized, or
176
- itself).
177
- 5. If the object is ``undefined``, a ``TypeError`` is thrown. If you
178
- wish to serialize ``undefined`` as ``null`` or some other value, you
179
- should create an adapter to do so.
180
- 6. If no adapter is available, the object is enumerated and
181
- serialized as a JSON object (name:value pairs). All names are
182
- expected to be strings. Each value is serialized according to
183
- these rules, and if it can not be serialized (e.g. methods), then
184
- that name:value pair will be skipped.
185
-
186
-
187
- Adapter Registries
188
- ------------------
189
-
190
- MochiKit makes extensive use of adapter registries, which enable you
191
- to implement object-specific behaviors for objects that you do not
192
- necessarily want to modify, such as built-in objects. This is
193
- especially useful because JavaScript does not provide a method for
194
- hiding user-defined properties from ``for propName in obj``
195
- enumeration.
196
-
197
- :mochiref:`AdapterRegistry` is simply an encapsulation for an ordered
198
- list of "check" and "wrap" function pairs. Each
199
- :mochiref:`AdapterRegistry` instance should perform one function, but
200
- may have multiple ways to achieve that function based upon the
201
- arguments. One way to think of it is as a poor man's generic function,
202
- or multiple dispatch (on arbitrary functions, not just type!).
203
-
204
- Check functions take one or more arguments, and return ``true`` if the
205
- argument list is suitable for the wrap function. Check functions
206
- should perform "cheap" checks of an object's type or contents, before
207
- the "expensive" wrap function is called.
208
-
209
- Wrap functions take the same arguments as check functions and do some
210
- operation, such as creating a programmer representation or comparing
211
- both arguments.
212
-
213
-
214
- Convenience Functions
215
- ---------------------
216
-
217
- Much of :mochiref:`MochiKit.Base` is there to simply remove the grunt
218
- work of doing generic JavaScript programming.
219
-
220
- Need to take every property from one object and set them on another?
221
- No problem, just call :mochiref:`update(dest, src)`! What if you just
222
- wanted to update keys that weren't already set? Look no further than
223
- :mochiref:`setdefault(dest, src[, ...])`.
224
-
225
- Want to return a mutable object, but don't want to suffer the
226
- consequences if the user mutates it? Just :mochiref:`clone(it)` and
227
- you'll get a copy-on-write clone. Cheaper than a copy!
228
-
229
- Need to extend an ``Array`` with another array? Or even an
230
- ``Array``-like object such as a ``NodeList`` or the special
231
- ``arguments`` object? Even if you need to skip the first few elements
232
- of the source ``Array``-like object, it's no problem with
233
- :mochiref:`extend(dstArray, srcArrayLike[, skip])`!
234
-
235
- Wouldn't it be convenient to have all of the JavaScript operators were
236
- available as functions somewhere? That's what the
237
- :mochiref:`operators` table is for, and it even comes with additional
238
- operators based on the :mochiref:`compare` function.
239
-
240
- Need to walk some tree of objects and manipulate or find something in
241
- it? A DOM element tree perhaps? Use :mochiref:`nodeWalk(node,
242
- visitor)`!
243
-
244
- There's plenty more, so check out the `API Reference`_ below.
245
-
246
-
247
- Functional Programming
248
- ----------------------
249
-
250
- Functional programming constructs such as :mochiref:`map` and
251
- :mochiref:`filter` can save you a lot of time, because JavaScript
252
- iteration is error-prone and arduous. Writing less code is the best
253
- way to prevent bugs, and functional programming can help you do that.
254
-
255
- :mochiref:`MochiKit.Base` ships with a few simple Array-based
256
- functional programming constructs, namely :mochiref:`map` and
257
- :mochiref:`filter`, and their "extended" brethren, :mochiref:`xmap`
258
- and :mochiref:`xfilter`.
259
-
260
- :mochiref:`map(func, arrayLike[, ...])` takes a function and an
261
- ``Array``-like object, and creates a new ``Array``. The new ``Array``
262
- is the result of ``func(element)`` for every element of ``arrayLike``,
263
- much like the ``Array.prototype.map`` extension in Mozilla. However,
264
- :mochiref:`MochiKit.Base` takes that a step further and gives you the
265
- full blown Python version of :mochiref:`map`, which will take several
266
- ``Array``-like objects, and calls the function with one argument per
267
- given ``Array``-like, e.g.::
268
-
269
- var arrayOne = [1, 2, 3, 4, 5];
270
- var arrayTwo = [1, 5, 2, 4, 3];
271
- var arrayThree = [5, 2, 1, 3, 4];
272
- var biggestElements = map(objMax, arrayOne, arrayTwo, arrayThree);
273
- assert( objEqual(biggestElements, [5, 5, 3, 4, 5]) );
274
-
275
- :mochiref:`filter(func, arrayLike[, self])` takes a function and an
276
- ``Array``-like object, and returns a new ``Array``. This is basically
277
- identical to the ``Array.prototype.filter`` extension in
278
- Mozilla. self, if given, will be used as ``this`` in the context of
279
- func when called.
280
-
281
- :mochiref:`xmap` and :mochiref:`xfilter` are just special forms of
282
- :mochiref:`map` and :mochiref:`filter` that accept a function as the
283
- first argument, and use the extra arguments as the ``Array``-like. Not
284
- terribly interesting, but a definite time-saver in some cases.
285
-
286
- If you appreciate the functional programming facilities here, you
287
- should definitely check out :mochiref:`MochiKit.Iter`, which provides
288
- full blown iterators, :mochiref:`MochiKit.Iter.range`,
289
- :mochiref:`MochiKit.Iter.reduce`, and a near-complete port of Python's
290
- itertools [2]_ module, with some extra stuff thrown in for good
291
- measure!
292
-
293
-
294
- Bound and Partial Functions
295
- ---------------------------
296
-
297
- JavaScript's method-calling special form and lack of bound functions
298
- (functions that know what ``this`` should be) are one of the first
299
- stumbling blocks that programmers new to JavaScript face. The
300
- :mochiref:`bind(func, self)` method fixes that right up by returning a
301
- new function that calls func with the right ``this``.
302
-
303
- In order to take real advantage of all this fancy functional
304
- programming stuff, you're probably going to want partial
305
- application. This allows you to create a new function from an existing
306
- function that remembers some of the arguments. For example, if you
307
- wanted to compare a given object to a slew of other objects, you could
308
- do something like this::
309
-
310
- compareWithOne = partial(compare, 1);
311
- results = map(compareWithOne, [0, 1, 2, 3]);
312
- assert( objEqual(results, [-1, 0, 1, 1]) );
313
-
314
- One of the better uses of partial functions is in
315
- :mochiref:`MochiKit.DOM`, which is certainly a must-see for those of
316
- you creating lots of DOM elements with JavaScript!
317
-
318
-
319
- API Reference
320
- =============
321
-
322
- Errors
323
- ------
324
-
325
- :mochidef:`NotFound`:
326
-
327
- A singleton error raised when no suitable adapter is found
328
-
329
- *Availability*:
330
- Available in MochiKit 1.3.1+
331
-
332
-
333
- Constructors
334
- ------------
335
-
336
- :mochidef:`AdapterRegistry`:
337
-
338
- A registry to facilitate adaptation.
339
-
340
- All ``check``/``wrap`` function pairs in a given registry should
341
- take the same number of arguments.
342
-
343
- *Availability*:
344
- Available in MochiKit 1.3.1+
345
-
346
-
347
- :mochidef:`AdapterRegistry.prototype.register(name, check, wrap[, override])`:
348
-
349
- ``name``:
350
- a unique identifier used to identify this adapter so that it
351
- may be unregistered.
352
-
353
- ``check``:
354
- function that should return ``true`` if the given arguments
355
- are appropriate for the ``wrap`` function.
356
-
357
- ``wrap``:
358
- function that takes the same parameters as ``check`` and does
359
- the adaptation. Every ``wrap``/``check`` function pair in the
360
- registry should have the same number of arguments.
361
-
362
- ``override``:
363
- if ``true``, the ``check`` function will be
364
- given highest priority. Otherwise, the lowest.
365
-
366
- *Availability*:
367
- Available in MochiKit 1.3.1+
368
-
369
-
370
- :mochidef:`AdapterRegistry.prototype.match(obj[, ...])`:
371
-
372
- Find an adapter for the given arguments by calling every ``check``
373
- function until one returns ``true``.
374
-
375
- If no suitable adapter is found, throws :mochiref:`NotFound`.
376
-
377
- *Availability*:
378
- Available in MochiKit 1.3.1+
379
-
380
-
381
- :mochidef:`AdapterRegistry.prototype.unregister(name)`:
382
-
383
- Remove a named adapter from the registry
384
-
385
- *Availability*:
386
- Available in MochiKit 1.3.1+
387
-
388
-
389
- :mochidef:`NamedError`:
390
-
391
- Convenience constructor for creating new errors
392
- (e.g. :mochiref:`NotFound`)
393
-
394
- *Availability*:
395
- Available in MochiKit 1.3.1+
396
-
397
-
398
- Functions
399
- ---------
400
-
401
- :mochidef:`arrayEqual(self, arr)`:
402
-
403
- Compare the arrays ``self`` and ``arr`` for equality using
404
- ``compare`` on each element. Uses a fast-path for length
405
- differences.
406
-
407
- *Availability*:
408
- Available in MochiKit 1.3.1+
409
-
410
-
411
- :mochidef:`average(lst[, ...])`:
412
-
413
- This function is an alias of :mochiref:`mean()`.
414
-
415
- *Availability*:
416
- Available in MochiKit 1.3.1+
417
-
418
-
419
- :mochidef:`bind(func, self[, arg, ...])`:
420
-
421
- Return a copy of ``func`` bound to ``self``. This means whenever
422
- and however the returned function is called, ``this`` will always
423
- reference the given ``self``. ``func`` may be either a function
424
- object, or a string. If it is a string, then ``self[func]`` will
425
- be used, making these two statements equivalent::
426
-
427
- bind("method", self);
428
- bind(self.method, self);
429
-
430
- Calling :mochiref:`bind(func, self)` on an already bound function
431
- will return a new function that is bound to the new ``self``! If
432
- ``self`` is ``undefined``, then the previous ``self`` is used. If
433
- ``self`` is ``null``, then the ``this`` object is used (which may
434
- or may not be the global object). To force binding to the global
435
- object, you should pass it explicitly.
436
-
437
- Additional arguments, if given, will be partially applied to the
438
- function. These three expressions are equivalent and return
439
- equally efficient functions (:mochiref:`bind` and
440
- :mochiref:`partial` share the same code path):
441
-
442
- - :mochiref:`bind(oldfunc, self, arg1, arg2)`
443
- - :mochiref:`bind(partial(oldfunc, arg1, arg2), self)`
444
- - :mochiref:`partial(bind(oldfunc, self), arg1, arg2)`
445
-
446
- *Availability*:
447
- Available in MochiKit 1.3.1+
448
-
449
-
450
- :mochidef:`bindLate(func, self[, arg, ...])`:
451
-
452
- Alternate version of :mochiref:`bind` that uses late lookup of
453
- the ``func`` parameter in ``self``. I.e, the ``self[func]``
454
- function lookup will occur on each call to the returned function,
455
- not when ``bindLate`` is called. Note that this difference is
456
- only applicable when ``func`` is a string, otherwise ``bindLate``
457
- and ``bind`` are identical.
458
-
459
- *Availability*:
460
- Available in MochiKit 1.4+
461
-
462
-
463
- :mochidef:`bindMethods(self)`:
464
-
465
- Replace all functions ``meth`` on ``self`` with
466
- :mochiref:`bind(meth, self)`. This emulates Python's bound
467
- instance methods, where there is no need to worry about preserving
468
- ``this`` when the method is used as a callback.
469
-
470
- *Availability*:
471
- Available in MochiKit 1.3.1+
472
-
473
-
474
- :mochidef:`camelize(str)`:
475
-
476
- Converts hyphenated strings to camelCase::
477
-
478
- assert( camelize("border-left") == "borderLeft" );
479
-
480
- *Availability*:
481
- Available in MochiKit 1.4+
482
-
483
-
484
- :mochidef:`clone(obj)`:
485
-
486
- Return a new object using ``obj`` as its prototype. Use this if
487
- you want to return a mutable object (e.g. instance state), but
488
- don't want the user to mutate it. If they do, it won't have any
489
- effect on the original ``obj``.
490
-
491
- Note that this is a shallow clone, so mutable properties will have
492
- to be cloned separately if you want to "protect" them.
493
-
494
- *Availability*:
495
- Available in MochiKit 1.3.1+
496
-
497
-
498
- :mochidef:`compare(a, b)`:
499
-
500
- Compare two objects in a sensible manner. Currently this is:
501
-
502
- 1. ``undefined`` and ``null`` compare equal to each other
503
- 2. ``undefined`` and ``null`` are less than anything else
504
- 3. If JavaScript says ``a == b``, then we trust it
505
- 4. comparators registered with registerComparator are used to
506
- find a good comparator. Built-in comparators are currently
507
- available for ``Array``-like and ``Date``-like objects.
508
- 5. Otherwise hope that the built-in comparison operators do
509
- something useful, which should work for numbers and strings.
510
- 6. If neither ``a < b`` or ``a > b``, then throw a ``TypeError``
511
-
512
- Returns what one would expect from a comparison function:
513
-
514
- +-----------+---------------+
515
- | Value | Condition |
516
- +-----------+---------------+
517
- | ``0`` | ``a == b`` |
518
- +-----------+---------------+
519
- | ``1`` | ``a > b`` |
520
- +-----------+---------------+
521
- | ``-1`` | ``a < b`` |
522
- +-----------+---------------+
523
-
524
- *Availability*:
525
- Available in MochiKit 1.3.1+
526
-
527
-
528
- :mochidef:`compose(f1, f2, ..., fN)`:
529
-
530
- Return a new function as the combination of the given function
531
- arguments, equivalent to ``f1(f2(arguments))``.
532
-
533
- *Availability*:
534
- Available in MochiKit 1.4+
535
-
536
-
537
- :mochidef:`concat(lst[, ...])`:
538
-
539
- Concatenates all given ``Array``-like arguments and returns
540
- a new ``Array``::
541
-
542
- var lst = concat(["1","3","5"], ["2","4","6"]);
543
- assert( lst.toString() == "1,3,5,2,4,6" );
544
-
545
- *Availability*:
546
- Available in MochiKit 1.3.1+
547
-
548
-
549
- :mochidef:`counter(n=1)`:
550
-
551
- Returns a function that will return a number one greater than
552
- the previous returned value, starting at ``n``. For example::
553
-
554
- nextId = counter()
555
- assert( nextId() == 1 )
556
- assert( nextId() == 2 )
557
-
558
- For an iterator with this behavior, see
559
- :mochiref:`MochiKit.Iter.count`.
560
-
561
- *Availability*:
562
- Available in MochiKit 1.3.1+
563
-
564
-
565
- :mochidef:`extend(self, obj, skip=0)`:
566
-
567
- Mutate the array ``self`` by extending it with an ``Array``-like
568
- ``obj``, starting from index ``skip``. If ``null`` is given as the
569
- initial array, a new one will be created.
570
-
571
- This mutates *and returns* ``self``, be warned.
572
-
573
- *Availability*:
574
- Available in MochiKit 1.3.1+
575
-
576
-
577
- :mochidef:`evalJSON(aJSONString)`:
578
-
579
- Unserialize a JSON [1]_ represenation of an object.
580
-
581
- Note that this uses the ``eval`` function of the interpreter, and
582
- therefore trusts the contents of ``aJSONString`` to be safe. This
583
- is acceptable when the JSON and JavaScript application originate
584
- from the same server, but in other scenarios it may not be the
585
- appropriate security model. Currently, a validating JSON parser is
586
- beyond the scope of MochiKit, but there is one available from
587
- json.org [1]_.
588
-
589
- *Availability*:
590
- Available in MochiKit 1.3.1+
591
-
592
-
593
- :mochidef:`filter(fn, lst)`:
594
-
595
- Returns a new ``Array`` composed of all elements from ``lst``
596
- where ``fn(lst[i])`` returns a true value.
597
-
598
- If ``fn`` is ``null``, ``operator.truth`` will be used.
599
-
600
- *Availability*:
601
- Available in MochiKit 1.3.1+
602
-
603
-
604
- :mochidef:`findValue(lst, value, start=0, end=lst.length)`:
605
-
606
- Finds the index of ``value`` in the ``Array``-like object ``lst``
607
- using :mochiref:`compare`. The search starts at the index
608
- ``start``, and ends at the index ``end - 1``. If ``value`` is not
609
- found in ``lst``, it will return ``-1``.
610
-
611
- For example::
612
-
613
- assert( findValue([1, 2, 3, 2, 1], 2) == 1 )
614
- assert( findValue([1, 2, 3, 2, 1], 2, 2) == 3 )
615
-
616
- *Availability*:
617
- Available in MochiKit 1.3.1+
618
-
619
-
620
- :mochidef:`findIdentical(lst, value, start=0, end=lst.length)`:
621
-
622
- Finds the index of ``value`` in the ``Array``-like object ``lst``
623
- using the ``===`` operator. The search starts at the index
624
- ``start``, and ends at the index ``end - 1``. If ``value`` is not
625
- found in ``lst``, it will return ``-1``.
626
-
627
- You should use this function instead of :mochiref:`findValue` if
628
- ``lst`` may be comprised of objects for which no comparator is
629
- defined and all you care about is finding an identical object
630
- (e.g. the same instance), or if ``lst`` is comprised of just
631
- numbers or strings and performance is important.
632
-
633
- For example::
634
-
635
- assert( findIdentical([1, 2, 3, 2, 1], 2) == 1 )
636
- assert( findIdentical([1, 2, 3, 2, 1], 2, 2) == 3 )
637
-
638
- *Availability*:
639
- Available in MochiKit 1.3.1+
640
-
641
-
642
- :mochidef:`flattenArguments(arg[, ...])`:
643
-
644
- Given a bunch of arguments, return a single ``Array`` containing
645
- all of those arguments. Any ``Array``-like argument will be extended
646
- in-place, e.g.::
647
-
648
- compare(flattenArguments(1, [2, 3, [4, 5]]), [1, 2, 3, 4, 5]) == 0
649
-
650
- *Availability*:
651
- Available in MochiKit 1.3.1+
652
-
653
-
654
- :mochidef:`flattenArray(lst)`:
655
-
656
- Return a new ``Array`` consisting of every item in lst with ``Array``
657
- items expanded in-place recursively. This differs from
658
- :mochiref:`flattenArguments` in that it only takes one argument and
659
- it only flattens items that are ``instanceof Array``.
660
-
661
- compare(flattenArray([1, [2, 3, [4, 5]]]), [1, 2, 3, 4, 5]) == 0
662
-
663
- *Availability*:
664
- Available in MochiKit 1.4+
665
-
666
-
667
- :mochidef:`forwardCall(name)`:
668
-
669
- Returns a function that forwards a method call to
670
- ``this.name(...)``
671
-
672
- *Availability*:
673
- Available in MochiKit 1.3.1+
674
-
675
-
676
- :mochidef:`isArrayLike(obj[, ...])`:
677
-
678
- Returns ``true`` if all given arguments are ``Array``-like (have a
679
- ``.length`` property and ``typeof(obj) == 'object'``)
680
-
681
- *Availability*:
682
- Available in MochiKit 1.3.1+
683
-
684
-
685
- :mochidef:`isDateLike(obj[, ...])`:
686
-
687
- Returns ``true`` if all given arguments are ``Date``-like (have a
688
- ``.getTime()`` method)
689
-
690
- *Availability*:
691
- Available in MochiKit 1.3.1+
692
-
693
-
694
- :mochidef:`isEmpty(obj[, ...])`:
695
-
696
- Returns ``true`` if all the given ``Array``-like or string
697
- arguments are empty ``(obj.length == 0)``
698
-
699
- *Availability*:
700
- Available in MochiKit 1.3.1+
701
-
702
-
703
- :mochidef:`isNotEmpty(obj[, ...])`:
704
-
705
- Returns ``true`` if all the given ``Array``-like or string
706
- arguments are not empty ``(obj.length > 0)``
707
-
708
- *Availability*:
709
- Available in MochiKit 1.3.1+
710
-
711
-
712
- :mochidef:`isNull(obj[, ...])`:
713
-
714
- Returns ``true`` if all arguments are ``null``.
715
-
716
- *Availability*:
717
- Available in MochiKit 1.3.1+
718
-
719
-
720
- :mochidef:`isUndefinedOrNull(obj[, ...])`:
721
-
722
- Returns ``true`` if all arguments are undefined or ``null``
723
-
724
- *Availability*:
725
- Available in MochiKit 1.3.1+
726
-
727
-
728
- :mochidef:`itemgetter(name)`:
729
-
730
- Returns a ``function(obj)`` that returns ``obj[name]``
731
-
732
- *Availability*:
733
- Available in MochiKit 1.3.1+
734
-
735
-
736
- :mochidef:`items(obj)`:
737
-
738
- Return an ``Array`` of ``[propertyName, propertyValue]`` pairs for
739
- the given ``obj`` (in the order determined by ``for propName in
740
- obj``).
741
-
742
- *Availability*:
743
- Available in MochiKit 1.3.1+
744
-
745
-
746
- :mochidef:`keyComparator(key[, ...])`:
747
-
748
- A comparator factory that compares ``a[key]`` with ``b[key]``.
749
- e.g.::
750
-
751
- var lst = ["a", "bbb", "cc"];
752
- lst.sort(keyComparator("length"));
753
- assert( lst.toString() == "a,cc,bbb" );
754
-
755
- *Availability*:
756
- Available in MochiKit 1.3.1+
757
-
758
-
759
- :mochidef:`keys(obj)`:
760
-
761
- Return an ``Array`` of the property names of an object (in the
762
- order determined by ``for propName in obj``).
763
-
764
- *Availability*:
765
- Available in MochiKit 1.3.1+
766
-
767
-
768
- :mochidef:`listMax(lst)`:
769
-
770
- Return the largest element of an ``Array``-like object, as
771
- determined by :mochiref:`compare`. This is a special form of
772
- :mochiref:`listMinMax`, specifically
773
- :mochiref:`partial(listMinMax, 1)`.
774
-
775
- *Availability*:
776
- Available in MochiKit 1.3.1+
777
-
778
-
779
- :mochidef:`listMin(lst)`:
780
-
781
- Return the smallest element of an ``Array``-like object, as
782
- determined by :mochiref:`compare`. This is a special form of
783
- :mochiref:`listMinMax`, specifically
784
- :mochiref:`partial(listMinMax, -1)`.
785
-
786
- *Availability*:
787
- Available in MochiKit 1.3.1+
788
-
789
-
790
- :mochidef:`listMinMax(which, lst)`:
791
-
792
- If ``which == -1`` then it will return the smallest element of the
793
- ``Array``-like ``lst``. This is also available as
794
- :mochiref:`listMin(lst)`.
795
-
796
- If ``which == 1`` then it will return the largest element of the
797
- ``Array``-like ``lst``. This is also available as
798
- :mochiref:`listMax(list)`.
799
-
800
- *Availability*:
801
- Available in MochiKit 1.3.1+
802
-
803
-
804
- :mochidef:`map(fn, lst[, ...])`:
805
-
806
- Return a new array composed of the results of ``fn(x)`` for every
807
- ``x`` in ``lst``.
808
-
809
- If ``fn`` is ``null``, and only one sequence argument is given the
810
- identity function is used.
811
-
812
- :mochiref:`map(null, lst)` -> ``lst.slice()``;
813
-
814
- If ``fn`` is not ``null`` and more than one sequence argument is
815
- given, then one element from each sequence is used to build the
816
- argument list for ``fn``.
817
-
818
- :mochiref:`map(fn, p, q, ...)`
819
- -> ``[fn(p[0], q[0], ..), fn(p[1], q[1], ...), ...]``
820
-
821
- If ``fn`` is ``null``, and more than one sequence is given as
822
- arguments, then the ``Array`` function is used.
823
-
824
- :mochiref:`map(null, p, q, ...)`
825
- -> :mochiref:`MochiKit.Iter.zip(p, q, ...)`
826
- -> ``[[p0, q0, ...], [p1, q1, ...], ...];``
827
-
828
- Since this is a common idiom, :mochiref:`zip(p, q, ...)`
829
- is actually a shortcut for this.
830
-
831
- *Availability*:
832
- Available in MochiKit 1.3.1+
833
-
834
- :mochidef:`mean(lst[, ...])`:
835
-
836
- Returns the arithmetic mean (average) of the argument list, or an array.
837
- This function applies :mochiref:`flattenArguments()` to the argument list.
838
-
839
- *Availability*:
840
- Available in MochiKit 1.4+
841
-
842
-
843
- :mochidef:`median(lst[, ...])`:
844
-
845
- Returns the median of the argument list, or an array. This function
846
- applies :mochiref:`flattenArguments()` to the argument list.
847
-
848
- *Availability*:
849
- Available in MochiKit 1.4+
850
-
851
-
852
- :mochidef:`merge(obj[, ...])`:
853
-
854
- Create a new instance of ``Object`` that contains every property
855
- from all given objects. If a property is defined on more than one
856
- of the objects, the last property is used.
857
-
858
- This is a special form of :mochiref:`update(self, obj[, ...])`,
859
- specifically, it is defined as :mochiref:`partial(update, null)`.
860
-
861
- *Availability*:
862
- Available in MochiKit 1.3.1+
863
-
864
-
865
- :mochidef:`method(self, func, ...)`:
866
-
867
- Alternate form of :mochiref:`bind` that takes the object before
868
- the function. These two calls are equivalent::
869
-
870
- bind("method", myobject)
871
- method(myobject, "method")
872
-
873
- *Availability*:
874
- Available in MochiKit 1.3.1+
875
-
876
-
877
- :mochidef:`methodcaller(name[, args...])`:
878
-
879
- Return a new function that calls a method on its argument,
880
- for example::
881
-
882
- lst = map(methodcaller("toLowerCase"), ["THIS", "is", "LoWeRCaSe"]);
883
- assert( lst.join(" ") == "this is lowercase" );
884
-
885
- *Availability*:
886
- Available in MochiKit 1.4+
887
-
888
-
889
- :mochidef:`nameFunctions(namespace)`:
890
-
891
- Given a ``namespace`` (object or function) with a ``NAME``
892
- property, find all methods in it and give them nice ``NAME``
893
- properties too (for use with :mochiref:`repr`). e.g.::
894
-
895
- namespace = {
896
- NAME: "Awesome",
897
- Dude: function () {}
898
- }
899
- nameFunctions(namespace);
900
- assert( namespace.Dude.NAME == 'Awesome.Dude' );
901
-
902
- *Availability*:
903
- Available in MochiKit 1.3.1+
904
-
905
-
906
- :mochidef:`noop()`:
907
-
908
- A function that performs no operation. Use this where you would
909
- otherwise use ``(function () {})`` in order to avoid Internet
910
- Explorer cyclic garbage leakage.
911
-
912
- *Availability*:
913
- Available in MochiKit 1.4
914
-
915
-
916
- :mochidef:`objEqual(a, b)`:
917
-
918
- Return ``true`` if ``compare(a, b) == 0``
919
-
920
- *Availability*:
921
- Available in MochiKit 1.3.1+
922
-
923
-
924
- :mochidef:`nodeWalk(node, visitor)`:
925
-
926
- Non-recursive generic node walking function (e.g. for a DOM).
927
-
928
- The walk order for nodeWalk is breadth first, meaning that all
929
- siblings will be visited before any children.
930
-
931
- ``node``:
932
- The initial node to be searched.
933
-
934
- ``visitor``:
935
- The visitor function, will be called as ``visitor(node)``, and
936
- should return an ``Array``-like of nodes to be searched next
937
- (e.g. ``node.childNodes``). Leaf nodes may return ``null`` or
938
- ``undefined``.
939
-
940
- *Availability*:
941
- Available in MochiKit 1.3.1+
942
-
943
-
944
- :mochidef:`objMax(obj[, ...])`:
945
-
946
- Return the maximum object according to :mochiref:`compare` out of
947
- the given arguments. This is similar to :mochiref:`listMax`,
948
- except is uses the arguments instead of a given ``Array``-like.
949
-
950
- *Availability*:
951
- Available in MochiKit 1.3.1+
952
-
953
-
954
- :mochidef:`objMin(obj[, ...])`:
955
-
956
- Return the minimum object according to :mochiref:`compare` out of
957
- the given arguments. This is similar to :mochiref:`listMin`,
958
- except it uses the arguments instead of a given ``Array``-like.
959
-
960
- *Availability*:
961
- Available in MochiKit 1.3.1+
962
-
963
-
964
- :mochidef:`operator`:
965
-
966
- A table of JavaScript's operators for usage with :mochiref:`map`,
967
- :mochiref:`filter`, etc.
968
-
969
-
970
- Unary Logic Operators:
971
-
972
- +--------------------+--------------------------+-------------------+
973
- | Operator | Implementation | Description |
974
- +====================+==========================+===================+
975
- | ``truth(a)`` | ``!!a`` | Logical truth |
976
- +--------------------+--------------------------+-------------------+
977
- | ``lognot(a)`` | ``!a`` | Logical not |
978
- +--------------------+--------------------------+-------------------+
979
- | ``identity(a)`` | ``a`` | Logical identity |
980
- +--------------------+--------------------------+-------------------+
981
-
982
-
983
-
984
- Unary Math Operators:
985
-
986
- +--------------------+--------------------------+---------------+
987
- | Operator | Implementation | Description |
988
- +====================+==========================+===============+
989
- | ``not(a)`` | ``~a`` | Bitwise not |
990
- +--------------------+--------------------------+---------------+
991
- | ``neg(a)`` | ``-a`` | Negation |
992
- +--------------------+--------------------------+---------------+
993
-
994
-
995
-
996
- Binary Operators:
997
-
998
- +-------------------+-------------------+-------------------------------+
999
- | Operator | Implementation | Description |
1000
- +===================+===================+===============================+
1001
- | ``add(a, b)`` | ``a + b`` | Addition |
1002
- +-------------------+-------------------+-------------------------------+
1003
- | ``sub(a, b)`` | ``a - b`` | Subtraction |
1004
- +-------------------+-------------------+-------------------------------+
1005
- | ``div(a, b)`` | ``a / b`` | Division |
1006
- +-------------------+-------------------+-------------------------------+
1007
- | ``mod(a, b)`` | ``a % b`` | Modulus |
1008
- +-------------------+-------------------+-------------------------------+
1009
- | ``mul(a, b)`` | ``a * b`` | Multiplication |
1010
- +-------------------+-------------------+-------------------------------+
1011
- | ``and(a, b)`` | ``a & b`` | Bitwise and |
1012
- +-------------------+-------------------+-------------------------------+
1013
- | ``or(a, b)`` | ``a | b`` | Bitwise or |
1014
- +-------------------+-------------------+-------------------------------+
1015
- | ``xor(a, b)`` | ``a ^ b`` | Bitwise exclusive or |
1016
- +-------------------+-------------------+-------------------------------+
1017
- | ``lshift(a, b)`` | ``a << b`` | Bitwise left shift |
1018
- +-------------------+-------------------+-------------------------------+
1019
- | ``rshift(a, b)`` | ``a >> b`` | Bitwise signed right shift |
1020
- +-------------------+-------------------+-------------------------------+
1021
- | ``zrshift(a, b)`` | ``a >>> b`` | Bitwise unsigned right shift |
1022
- +-------------------+-------------------+-------------------------------+
1023
-
1024
-
1025
-
1026
- Built-in Comparators:
1027
-
1028
- +---------------+-------------------+---------------------------+
1029
- | Operator | Implementation | Description |
1030
- +===============+===================+===========================+
1031
- | ``eq(a, b)`` | ``a == b`` | Equals |
1032
- +---------------+-------------------+---------------------------+
1033
- | ``ne(a, b)`` | ``a != b`` | Not equals |
1034
- +---------------+-------------------+---------------------------+
1035
- | ``gt(a, b)`` | ``a > b`` | Greater than |
1036
- +---------------+-------------------+---------------------------+
1037
- | ``ge(a, b)`` | ``a >= b`` | Greater than or equal to |
1038
- +---------------+-------------------+---------------------------+
1039
- | ``lt(a, b)`` | ``a < b`` | Less than |
1040
- +---------------+-------------------+---------------------------+
1041
- | ``le(a, b)`` | ``a <= b`` | Less than or equal to |
1042
- +---------------+-------------------+---------------------------+
1043
-
1044
-
1045
-
1046
- Strict Built-in Comparators:
1047
-
1048
- +---------------+-------------------+---------------------------+
1049
- | Operator | Implementation | Description |
1050
- +===============+===================+===========================+
1051
- | ``seq(a, b)`` | ``a === b`` | Strict equals |
1052
- +---------------+-------------------+---------------------------+
1053
- | ``sne(a, b)`` | ``a !== b`` | Strict not equals |
1054
- +---------------+-------------------+---------------------------+
1055
-
1056
-
1057
-
1058
- Extended Comparators (uses :mochiref:`compare`):
1059
-
1060
- +---------------+---------------------------+---------------------------+
1061
- | Operator | Implementation | Description |
1062
- +===============+===========================+===========================+
1063
- | ``ceq(a, b)`` | ``compare(a, b) == 0`` | Equals |
1064
- +---------------+---------------------------+---------------------------+
1065
- | ``cne(a, b)`` | ``compare(a, b) != 0`` | Not equals |
1066
- +---------------+---------------------------+---------------------------+
1067
- | ``cgt(a, b)`` | ``compare(a, b) == 1`` | Greater than |
1068
- +---------------+---------------------------+---------------------------+
1069
- | ``cge(a, b)`` | ``compare(a, b) != -1`` | Greater than or equal to |
1070
- +---------------+---------------------------+---------------------------+
1071
- | ``clt(a, b)`` | ``compare(a, b) == -1`` | Less than |
1072
- +---------------+---------------------------+---------------------------+
1073
- | ``cle(a, b)`` | ``compare(a, b) != 1`` | Less than or equal to |
1074
- +---------------+---------------------------+---------------------------+
1075
-
1076
-
1077
-
1078
- Binary Logical Operators:
1079
-
1080
- +-----------------------+-------------------+---------------------------+
1081
- | Operator | Implementation | Description |
1082
- +=======================+===================+===========================+
1083
- | ``logand(a, b)`` | ``a && b`` | Logical and |
1084
- +-----------------------+-------------------+---------------------------+
1085
- | ``logor(a, b)`` | ``a || b`` | Logical or |
1086
- +-----------------------+-------------------+---------------------------+
1087
- | ``contains(a, b)`` | ``b in a`` | Has property (note order) |
1088
- +-----------------------+-------------------+---------------------------+
1089
-
1090
- *Availability*:
1091
- Available in MochiKit 1.3.1+
1092
-
1093
-
1094
- :mochidef:`parseQueryString(encodedString[, useArrays=false])`:
1095
-
1096
- Parse a name=value pair URL query string into an object with a
1097
- property for each pair. e.g.::
1098
-
1099
- var args = parseQueryString("foo=value%20one&bar=two");
1100
- assert( args.foo == "value one" && args.bar == "two" );
1101
-
1102
- If you expect that the query string will reuse the same name, then
1103
- give ``true`` as a second argument, which will use arrays to store
1104
- the values. e.g.::
1105
-
1106
- var args = parseQueryString("foo=one&foo=two", true);
1107
- assert( args.foo[0] == "one" && args.foo[1] == "two" );
1108
-
1109
- *Availability*:
1110
- Available in MochiKit 1.3.1+
1111
-
1112
-
1113
- :mochidef:`partial(func, arg[, ...])`:
1114
-
1115
- Return a partially applied function, e.g.::
1116
-
1117
- addNumbers = function (a, b) {
1118
- return a + b;
1119
- }
1120
-
1121
- addOne = partial(addNumbers, 1);
1122
-
1123
- assert(addOne(2) == 3);
1124
-
1125
- :mochiref:`partial` is a special form of :mochiref:`bind` that
1126
- does not alter the bound ``self`` (if any). It is equivalent to
1127
- calling::
1128
-
1129
- bind(func, undefined, arg[, ...]);
1130
-
1131
- See the documentation for :mochiref:`bind` for more details about
1132
- this facility.
1133
-
1134
- This could be used to implement, but is NOT currying.
1135
-
1136
- *Availability*:
1137
- Available in MochiKit 1.3.1+
1138
-
1139
-
1140
- :mochidef:`queryString(names, values)`:
1141
-
1142
- Creates a URL query string from a pair of ``Array``-like objects
1143
- representing ``names`` and ``values``. Each name=value pair will
1144
- be URL encoded by :mochiref:`urlEncode`. name=value pairs with a
1145
- value of ``undefined`` or ``null`` will be skipped. e.g.::
1146
-
1147
- var keys = ["foo", "bar"];
1148
- var values = ["value one", "two"];
1149
- assert( queryString(keys, values) == "foo=value%20one&bar=two" );
1150
-
1151
- Alternate form 1:
1152
- :mochiref:`queryString(domElement)`
1153
-
1154
- If :mochiref:`MochiKit.DOM` is loaded, one argument is given, and
1155
- that argument is either a string or has a ``nodeType`` property
1156
- greater than zero, then ``names`` and ``values`` will be the
1157
- result of :mochiref:`MochiKit.DOM.formContents(domElement)`.
1158
-
1159
- Alternate form 2:
1160
- :mochiref:`queryString({name: value, ...})`
1161
-
1162
- Note that when using the alternate form, the order of the
1163
- name=value pairs in the resultant query string is dependent on how
1164
- the particular JavaScript implementation handles ``for (..in..)``
1165
- property enumeration.
1166
-
1167
- When using the second alternate form, name=value pairs with
1168
- ``typeof(value) == "function"`` are ignored. This is a workaround
1169
- for the case where a poorly designed library has modified
1170
- ``Object.prototype`` and inserted "convenience functions".
1171
-
1172
- Values that are Array-like will be expanded as if they were multiply
1173
- defined HTML elements. For example::
1174
-
1175
- assert( queryString({a: [1,2]}) === "a=1&a=2" );
1176
-
1177
- Alternate form 2 (MochiKit 1.4+):
1178
- :mochiref:`queryString([names, values])`
1179
-
1180
- This form behaves identically to :mochiref:`queryString(names, values)`,
1181
- except it takes both arguments as a single Array. This mirrors the
1182
- return value of :mochiref:`MochiKit.DOM.formContents`.
1183
-
1184
- *Availability*:
1185
- Available in MochiKit 1.3.1+
1186
-
1187
-
1188
- :mochidef:`registerComparator(name, check, comparator[, override])`:
1189
-
1190
- Register a comparator for use with :mochiref:`compare`.
1191
-
1192
- ``name``:
1193
- unique identifier describing the comparator.
1194
-
1195
- ``check``:
1196
- ``function(a, b)`` that returns ``true`` if ``a`` and ``b``
1197
- can be compared with ``comparator``.
1198
-
1199
- ``comparator``:
1200
- ``function(a, b)`` that returns:
1201
-
1202
- +-------+-----------+
1203
- | Value | Condition |
1204
- +-------+-----------+
1205
- | 0 | a == b |
1206
- +-------+-----------+
1207
- | 1 | a > b |
1208
- +-------+-----------+
1209
- | -1 | a < b |
1210
- +-------+-----------+
1211
-
1212
- ``comparator`` is guaranteed to only be called if ``check(a,
1213
- b)`` returns a ``true`` value.
1214
-
1215
- ``override``:
1216
- if ``true``, then this will be made the highest precedence
1217
- comparator. Otherwise, the lowest.
1218
-
1219
- *Availability*:
1220
- Available in MochiKit 1.3.1+
1221
-
1222
-
1223
- :mochidef:`registerJSON(name, check, simplifier[, override])`:
1224
-
1225
- Register a simplifier function for use with
1226
- :mochiref:`serializeJSON`.
1227
-
1228
- ``name``:
1229
- unique identifier describing the serialization.
1230
-
1231
- ``check``:
1232
- ``function(obj)`` that returns ``true`` if ``obj`` can
1233
- can be simplified for serialization by ``simplifier``.
1234
-
1235
- ``simplifier``:
1236
- ``function(obj)`` that returns a simpler object that can be
1237
- further serialized by :mochiref:`serializeJSON`. For example,
1238
- you could simplify ``Date``-like objects to ISO 8601 timestamp
1239
- strings with the following simplifier::
1240
-
1241
- var simplifyDateAsISO = function (obj) {
1242
- return toISOTimestamp(obj, true);
1243
- };
1244
- registerJSON("DateLike", isDateLike, simplifyDateAsISO);
1245
-
1246
- ``simplifier`` is guaranteed to only be called if
1247
- ``check(obj)`` returns a ``true`` value.
1248
-
1249
- ``override``:
1250
- if ``true``, then this will be made the highest precedence
1251
- serialization. Otherwise, the lowest.
1252
-
1253
- *Availability*:
1254
- Available in MochiKit 1.3.1+
1255
-
1256
-
1257
- :mochidef:`registerRepr(name, check, wrap[, override])`:
1258
-
1259
- Register a programmer representation function. :mochiref:`repr`
1260
- functions should take one argument and return a string
1261
- representation of it suitable for developers, primarily used when
1262
- debugging.
1263
-
1264
- If ``override`` is given, it is used as the highest priority repr,
1265
- otherwise it will be used as the lowest.
1266
-
1267
- *Availability*:
1268
- Available in MochiKit 1.3.1+
1269
-
1270
-
1271
- :mochidef:`repr(obj)`:
1272
-
1273
- Return a programmer representation for ``obj``. See the
1274
- `Programmer Representation`_ overview for more information about
1275
- this function.
1276
-
1277
- *Availability*:
1278
- Available in MochiKit 1.3.1+
1279
-
1280
-
1281
- :mochidef:`reverseKeyComparator(key)`:
1282
-
1283
- A comparator factory that compares ``a[key]`` with ``b[key]`` in
1284
- reverse. e.g.::
1285
-
1286
- var lst = ["a", "bbb", "cc"];
1287
- lst.sort(reverseKeyComparator("length"));
1288
- assert(lst.toString() == "bbb,cc,a");
1289
-
1290
- *Availability*:
1291
- Available in MochiKit 1.3.1+
1292
-
1293
-
1294
- :mochidef:`serializeJSON(anObject)`:
1295
-
1296
- Serialize ``anObject`` in the JSON [1]_ format, see `JSON
1297
- Serialization`_ for the coercion rules. For unserializable objects
1298
- (functions that do not have an adapter, ``__json__`` method, or
1299
- ``json`` method), this will return ``undefined``.
1300
-
1301
- For those familiar with Python, JSON is similar in scope to
1302
- pickle, but it can not handle recursive object graphs.
1303
-
1304
- *Availability*:
1305
- Available in MochiKit 1.3.1+
1306
-
1307
-
1308
- :mochidef:`setdefault(self, obj[, ...])`:
1309
-
1310
- Mutate ``self`` by adding all properties from other object(s) that
1311
- it does not already have set.
1312
-
1313
- If ``self`` is ``null``, a new ``Object`` instance will be created
1314
- and returned.
1315
-
1316
- This mutates *and returns* ``self``, be warned.
1317
-
1318
- *Availability*:
1319
- Available in MochiKit 1.3.1+
1320
-
1321
-
1322
- :mochidef:`typeMatcher(typ[, ...])`:
1323
-
1324
- Given a set of types (as string arguments), returns a
1325
- ``function(obj[, ...])`` that will return ``true`` if the types of
1326
- the given arguments are all members of that set.
1327
-
1328
- *Availability*:
1329
- Available in MochiKit 1.3.1+
1330
-
1331
-
1332
- :mochidef:`update(self, obj[, ...])`:
1333
-
1334
- Mutate ``self`` by replacing its key:value pairs with those from
1335
- other object(s). Key:value pairs from later objects will overwrite
1336
- those from earlier objects.
1337
-
1338
- If ``self`` is ``null``, a new ``Object`` instance will be created
1339
- and returned.
1340
-
1341
- This mutates *and returns* ``self``, be warned.
1342
-
1343
- A version of this function that creates a new object is available
1344
- as :mochiref:`merge(a, b[, ...])`
1345
-
1346
- *Availability*:
1347
- Available in MochiKit 1.3.1+
1348
-
1349
-
1350
- :mochidef:`updatetree(self, obj[, ...])`:
1351
-
1352
- Mutate ``self`` by replacing its key:value pairs with those from
1353
- other object(s). If a given key has an object value in both
1354
- ``self`` and ``obj``, then this function will be called
1355
- recursively, updating instead of replacing that object.
1356
-
1357
- If ``self`` is ``null``, a new ``Object`` instance will be created
1358
- and returned.
1359
-
1360
- This mutates *and returns* ``self``, be warned.
1361
-
1362
- *Availability*:
1363
- Available in MochiKit 1.3.1+
1364
-
1365
-
1366
- :mochidef:`urlEncode(unencoded)`:
1367
-
1368
- Converts ``unencoded`` into a URL-encoded string. In this
1369
- implementation, spaces are converted to %20 instead of "+". e.g.::
1370
-
1371
- assert( URLencode("1+2=2") == "1%2B2%3D2");
1372
-
1373
- *Availability*:
1374
- Available in MochiKit 1.3.1+
1375
-
1376
-
1377
- :mochidef:`values(obj)`:
1378
-
1379
- Return an ``Array`` of the property values of an object (in the
1380
- order determined by ``for propName in obj``).
1381
-
1382
- *Availability*:
1383
- Available in MochiKit 1.4+
1384
-
1385
-
1386
- :mochidef:`xfilter(fn, obj[, ...])`:
1387
-
1388
- Returns a new ``Array`` composed of the arguments where
1389
- ``fn(obj)`` returns a true value.
1390
-
1391
- If ``fn`` is ``null``, ``operator.truth`` will be used.
1392
-
1393
- *Availability*:
1394
- Available in MochiKit 1.3.1+
1395
-
1396
-
1397
- :mochidef:`xmap(fn, obj[, ...)`:
1398
-
1399
- Return a new ``Array`` composed of ``fn(obj)`` for every ``obj``
1400
- given as an argument.
1401
-
1402
- If ``fn`` is ``null``, ``operator.identity`` is used.
1403
-
1404
- *Availability*:
1405
- Available in MochiKit 1.3.1+
1406
-
1407
- :mochidef:`zip(p, q, ...)`:
1408
-
1409
- Returns an array where the n-th element is an array of the n-th
1410
- elements from each of the arrays p, q, ...
1411
-
1412
- This is equivalent to calling :mochiref:`map(fn, p, q, ...)` with
1413
- ``null`` as the first argument.
1414
-
1415
- :mochiref:`zip(p, q, ...)`
1416
- -> :mochiref:`map(null, p, q, ...)`
1417
- -> ``[[p0, q0, ...], [p1, q1, ...], ...];``
1418
-
1419
- *Availability*:
1420
- Available in MochiKit 1.3.1+
1421
-
1422
-
1423
- See Also
1424
- ========
1425
-
1426
- .. [1] JSON, JavaScript Object Notation: http://json.org/
1427
- .. [2] Python's itertools
1428
- module: http://docs.python.org/lib/module-itertools.html
1429
-
1430
- Authors
1431
- =======
1432
-
1433
- - Bob Ippolito <bob@redivi.com>
1434
-
1435
-
1436
- Copyright
1437
- =========
1438
-
1439
- Copyright 2005 Bob Ippolito <bob@redivi.com>. This program is
1440
- dual-licensed free software; you can redistribute it and/or modify it
1441
- under the terms of the `MIT License`_ or the `Academic Free License
1442
- v2.1`_.
1443
-
1444
- .. _`MIT License`: http://www.opensource.org/licenses/mit-license.php
1445
- .. _`Academic Free License v2.1`: http://www.opensource.org/licenses/afl-2.1.php