aced_rails 0.0.1

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 (255) hide show
  1. data/.gitignore +17 -0
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +49 -0
  6. data/Rakefile +2 -0
  7. data/aced_rails.gemspec +19 -0
  8. data/lib/aced_rails.rb +7 -0
  9. data/lib/aced_rails/engine.rb +4 -0
  10. data/lib/aced_rails/version.rb +3 -0
  11. data/vendor/assets/javascripts/ace/ace-compat-noconflict.js +1 -0
  12. data/vendor/assets/javascripts/ace/ace-compat-uncompressed-noconflict.js +480 -0
  13. data/vendor/assets/javascripts/ace/ace-compat-uncompressed.js +480 -0
  14. data/vendor/assets/javascripts/ace/ace-compat.js +1 -0
  15. data/vendor/assets/javascripts/ace/ace-noconflict.js +10 -0
  16. data/vendor/assets/javascripts/ace/ace-uncompressed-noconflict.js +14649 -0
  17. data/vendor/assets/javascripts/ace/ace-uncompressed.js +14649 -0
  18. data/vendor/assets/javascripts/ace/ace.js +10 -0
  19. data/vendor/assets/javascripts/ace/keybinding-emacs-noconflict.js +1 -0
  20. data/vendor/assets/javascripts/ace/keybinding-emacs-uncompressed-noconflict.js +405 -0
  21. data/vendor/assets/javascripts/ace/keybinding-emacs-uncompressed.js +405 -0
  22. data/vendor/assets/javascripts/ace/keybinding-emacs.js +1 -0
  23. data/vendor/assets/javascripts/ace/keybinding-vim-noconflict.js +1 -0
  24. data/vendor/assets/javascripts/ace/keybinding-vim-uncompressed-noconflict.js +393 -0
  25. data/vendor/assets/javascripts/ace/keybinding-vim-uncompressed.js +393 -0
  26. data/vendor/assets/javascripts/ace/keybinding-vim.js +1 -0
  27. data/vendor/assets/javascripts/ace/mode-c_cpp-noconflict.js +1 -0
  28. data/vendor/assets/javascripts/ace/mode-c_cpp-uncompressed-noconflict.js +918 -0
  29. data/vendor/assets/javascripts/ace/mode-c_cpp-uncompressed.js +918 -0
  30. data/vendor/assets/javascripts/ace/mode-c_cpp.js +1 -0
  31. data/vendor/assets/javascripts/ace/mode-clojure-noconflict.js +1 -0
  32. data/vendor/assets/javascripts/ace/mode-clojure-uncompressed-noconflict.js +422 -0
  33. data/vendor/assets/javascripts/ace/mode-clojure-uncompressed.js +422 -0
  34. data/vendor/assets/javascripts/ace/mode-clojure.js +1 -0
  35. data/vendor/assets/javascripts/ace/mode-coffee-noconflict.js +1 -0
  36. data/vendor/assets/javascripts/ace/mode-coffee-uncompressed-noconflict.js +605 -0
  37. data/vendor/assets/javascripts/ace/mode-coffee-uncompressed.js +605 -0
  38. data/vendor/assets/javascripts/ace/mode-coffee.js +1 -0
  39. data/vendor/assets/javascripts/ace/mode-coldfusion-noconflict.js +1 -0
  40. data/vendor/assets/javascripts/ace/mode-coldfusion-uncompressed-noconflict.js +2361 -0
  41. data/vendor/assets/javascripts/ace/mode-coldfusion-uncompressed.js +2361 -0
  42. data/vendor/assets/javascripts/ace/mode-coldfusion.js +1 -0
  43. data/vendor/assets/javascripts/ace/mode-csharp-noconflict.js +1 -0
  44. data/vendor/assets/javascripts/ace/mode-csharp-uncompressed-noconflict.js +768 -0
  45. data/vendor/assets/javascripts/ace/mode-csharp-uncompressed.js +768 -0
  46. data/vendor/assets/javascripts/ace/mode-csharp.js +1 -0
  47. data/vendor/assets/javascripts/ace/mode-css-noconflict.js +1 -0
  48. data/vendor/assets/javascripts/ace/mode-css-uncompressed-noconflict.js +664 -0
  49. data/vendor/assets/javascripts/ace/mode-css-uncompressed.js +664 -0
  50. data/vendor/assets/javascripts/ace/mode-css.js +1 -0
  51. data/vendor/assets/javascripts/ace/mode-groovy-noconflict.js +1 -0
  52. data/vendor/assets/javascripts/ace/mode-groovy-uncompressed-noconflict.js +1280 -0
  53. data/vendor/assets/javascripts/ace/mode-groovy-uncompressed.js +1280 -0
  54. data/vendor/assets/javascripts/ace/mode-groovy.js +1 -0
  55. data/vendor/assets/javascripts/ace/mode-haxe-noconflict.js +1 -0
  56. data/vendor/assets/javascripts/ace/mode-haxe-uncompressed-noconflict.js +768 -0
  57. data/vendor/assets/javascripts/ace/mode-haxe-uncompressed.js +768 -0
  58. data/vendor/assets/javascripts/ace/mode-haxe.js +1 -0
  59. data/vendor/assets/javascripts/ace/mode-html-noconflict.js +1 -0
  60. data/vendor/assets/javascripts/ace/mode-html-uncompressed-noconflict.js +2377 -0
  61. data/vendor/assets/javascripts/ace/mode-html-uncompressed.js +2377 -0
  62. data/vendor/assets/javascripts/ace/mode-html.js +1 -0
  63. data/vendor/assets/javascripts/ace/mode-java-noconflict.js +1 -0
  64. data/vendor/assets/javascripts/ace/mode-java-uncompressed-noconflict.js +1282 -0
  65. data/vendor/assets/javascripts/ace/mode-java-uncompressed.js +1282 -0
  66. data/vendor/assets/javascripts/ace/mode-java.js +1 -0
  67. data/vendor/assets/javascripts/ace/mode-javascript-noconflict.js +1 -0
  68. data/vendor/assets/javascripts/ace/mode-javascript-uncompressed-noconflict.js +1113 -0
  69. data/vendor/assets/javascripts/ace/mode-javascript-uncompressed.js +1113 -0
  70. data/vendor/assets/javascripts/ace/mode-javascript.js +1 -0
  71. data/vendor/assets/javascripts/ace/mode-json-noconflict.js +1 -0
  72. data/vendor/assets/javascripts/ace/mode-json-uncompressed-noconflict.js +696 -0
  73. data/vendor/assets/javascripts/ace/mode-json-uncompressed.js +696 -0
  74. data/vendor/assets/javascripts/ace/mode-json.js +1 -0
  75. data/vendor/assets/javascripts/ace/mode-latex-noconflict.js +1 -0
  76. data/vendor/assets/javascripts/ace/mode-latex-uncompressed-noconflict.js +95 -0
  77. data/vendor/assets/javascripts/ace/mode-latex-uncompressed.js +95 -0
  78. data/vendor/assets/javascripts/ace/mode-latex.js +1 -0
  79. data/vendor/assets/javascripts/ace/mode-lua-noconflict.js +1 -0
  80. data/vendor/assets/javascripts/ace/mode-lua-uncompressed-noconflict.js +523 -0
  81. data/vendor/assets/javascripts/ace/mode-lua-uncompressed.js +523 -0
  82. data/vendor/assets/javascripts/ace/mode-lua.js +1 -0
  83. data/vendor/assets/javascripts/ace/mode-markdown-noconflict.js +1 -0
  84. data/vendor/assets/javascripts/ace/mode-markdown-uncompressed-noconflict.js +2819 -0
  85. data/vendor/assets/javascripts/ace/mode-markdown-uncompressed.js +2819 -0
  86. data/vendor/assets/javascripts/ace/mode-markdown.js +1 -0
  87. data/vendor/assets/javascripts/ace/mode-ocaml-noconflict.js +1 -0
  88. data/vendor/assets/javascripts/ace/mode-ocaml-uncompressed-noconflict.js +539 -0
  89. data/vendor/assets/javascripts/ace/mode-ocaml-uncompressed.js +539 -0
  90. data/vendor/assets/javascripts/ace/mode-ocaml.js +1 -0
  91. data/vendor/assets/javascripts/ace/mode-perl-noconflict.js +1 -0
  92. data/vendor/assets/javascripts/ace/mode-perl-uncompressed-noconflict.js +573 -0
  93. data/vendor/assets/javascripts/ace/mode-perl-uncompressed.js +573 -0
  94. data/vendor/assets/javascripts/ace/mode-perl.js +1 -0
  95. data/vendor/assets/javascripts/ace/mode-pgsql-noconflict.js +1 -0
  96. data/vendor/assets/javascripts/ace/mode-pgsql-uncompressed-noconflict.js +1107 -0
  97. data/vendor/assets/javascripts/ace/mode-pgsql-uncompressed.js +1107 -0
  98. data/vendor/assets/javascripts/ace/mode-pgsql.js +1 -0
  99. data/vendor/assets/javascripts/ace/mode-php-noconflict.js +1 -0
  100. data/vendor/assets/javascripts/ace/mode-php-uncompressed-noconflict.js +1884 -0
  101. data/vendor/assets/javascripts/ace/mode-php-uncompressed.js +1884 -0
  102. data/vendor/assets/javascripts/ace/mode-php.js +1 -0
  103. data/vendor/assets/javascripts/ace/mode-powershell-noconflict.js +1 -0
  104. data/vendor/assets/javascripts/ace/mode-powershell-uncompressed-noconflict.js +706 -0
  105. data/vendor/assets/javascripts/ace/mode-powershell-uncompressed.js +706 -0
  106. data/vendor/assets/javascripts/ace/mode-powershell.js +1 -0
  107. data/vendor/assets/javascripts/ace/mode-python-noconflict.js +1 -0
  108. data/vendor/assets/javascripts/ace/mode-python-uncompressed-noconflict.js +506 -0
  109. data/vendor/assets/javascripts/ace/mode-python-uncompressed.js +506 -0
  110. data/vendor/assets/javascripts/ace/mode-python.js +1 -0
  111. data/vendor/assets/javascripts/ace/mode-ruby-noconflict.js +1 -0
  112. data/vendor/assets/javascripts/ace/mode-ruby-uncompressed-noconflict.js +391 -0
  113. data/vendor/assets/javascripts/ace/mode-ruby-uncompressed.js +391 -0
  114. data/vendor/assets/javascripts/ace/mode-ruby.js +1 -0
  115. data/vendor/assets/javascripts/ace/mode-scad-noconflict.js +1 -0
  116. data/vendor/assets/javascripts/ace/mode-scad-uncompressed-noconflict.js +906 -0
  117. data/vendor/assets/javascripts/ace/mode-scad-uncompressed.js +906 -0
  118. data/vendor/assets/javascripts/ace/mode-scad.js +1 -0
  119. data/vendor/assets/javascripts/ace/mode-scala-noconflict.js +1 -0
  120. data/vendor/assets/javascripts/ace/mode-scala-uncompressed-noconflict.js +1282 -0
  121. data/vendor/assets/javascripts/ace/mode-scala-uncompressed.js +1282 -0
  122. data/vendor/assets/javascripts/ace/mode-scala.js +1 -0
  123. data/vendor/assets/javascripts/ace/mode-scss-noconflict.js +1 -0
  124. data/vendor/assets/javascripts/ace/mode-scss-uncompressed-noconflict.js +678 -0
  125. data/vendor/assets/javascripts/ace/mode-scss-uncompressed.js +678 -0
  126. data/vendor/assets/javascripts/ace/mode-scss.js +1 -0
  127. data/vendor/assets/javascripts/ace/mode-sh-noconflict.js +1 -0
  128. data/vendor/assets/javascripts/ace/mode-sh-uncompressed-noconflict.js +268 -0
  129. data/vendor/assets/javascripts/ace/mode-sh-uncompressed.js +268 -0
  130. data/vendor/assets/javascripts/ace/mode-sh.js +1 -0
  131. data/vendor/assets/javascripts/ace/mode-sql-noconflict.js +1 -0
  132. data/vendor/assets/javascripts/ace/mode-sql-uncompressed-noconflict.js +159 -0
  133. data/vendor/assets/javascripts/ace/mode-sql-uncompressed.js +159 -0
  134. data/vendor/assets/javascripts/ace/mode-sql.js +1 -0
  135. data/vendor/assets/javascripts/ace/mode-svg-noconflict.js +1 -0
  136. data/vendor/assets/javascripts/ace/mode-svg-uncompressed-noconflict.js +2016 -0
  137. data/vendor/assets/javascripts/ace/mode-svg-uncompressed.js +2016 -0
  138. data/vendor/assets/javascripts/ace/mode-svg.js +1 -0
  139. data/vendor/assets/javascripts/ace/mode-text-noconflict.js +0 -0
  140. data/vendor/assets/javascripts/ace/mode-text-uncompressed-noconflict.js +0 -0
  141. data/vendor/assets/javascripts/ace/mode-text-uncompressed.js +0 -0
  142. data/vendor/assets/javascripts/ace/mode-text.js +0 -0
  143. data/vendor/assets/javascripts/ace/mode-textile-noconflict.js +1 -0
  144. data/vendor/assets/javascripts/ace/mode-textile-uncompressed-noconflict.js +254 -0
  145. data/vendor/assets/javascripts/ace/mode-textile-uncompressed.js +254 -0
  146. data/vendor/assets/javascripts/ace/mode-textile.js +1 -0
  147. data/vendor/assets/javascripts/ace/mode-xml-noconflict.js +1 -0
  148. data/vendor/assets/javascripts/ace/mode-xml-uncompressed-noconflict.js +1001 -0
  149. data/vendor/assets/javascripts/ace/mode-xml-uncompressed.js +1001 -0
  150. data/vendor/assets/javascripts/ace/mode-xml.js +1 -0
  151. data/vendor/assets/javascripts/ace/theme-chrome-noconflict.js +1 -0
  152. data/vendor/assets/javascripts/ace/theme-chrome-uncompressed-noconflict.js +212 -0
  153. data/vendor/assets/javascripts/ace/theme-chrome-uncompressed.js +212 -0
  154. data/vendor/assets/javascripts/ace/theme-chrome.js +1 -0
  155. data/vendor/assets/javascripts/ace/theme-clouds-noconflict.js +1 -0
  156. data/vendor/assets/javascripts/ace/theme-clouds-uncompressed-noconflict.js +155 -0
  157. data/vendor/assets/javascripts/ace/theme-clouds-uncompressed.js +155 -0
  158. data/vendor/assets/javascripts/ace/theme-clouds.js +1 -0
  159. data/vendor/assets/javascripts/ace/theme-clouds_midnight-noconflict.js +1 -0
  160. data/vendor/assets/javascripts/ace/theme-clouds_midnight-uncompressed-noconflict.js +156 -0
  161. data/vendor/assets/javascripts/ace/theme-clouds_midnight-uncompressed.js +156 -0
  162. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +1 -0
  163. data/vendor/assets/javascripts/ace/theme-cobalt-noconflict.js +1 -0
  164. data/vendor/assets/javascripts/ace/theme-cobalt-uncompressed-noconflict.js +170 -0
  165. data/vendor/assets/javascripts/ace/theme-cobalt-uncompressed.js +170 -0
  166. data/vendor/assets/javascripts/ace/theme-cobalt.js +1 -0
  167. data/vendor/assets/javascripts/ace/theme-crimson_editor-noconflict.js +1 -0
  168. data/vendor/assets/javascripts/ace/theme-crimson_editor-uncompressed-noconflict.js +198 -0
  169. data/vendor/assets/javascripts/ace/theme-crimson_editor-uncompressed.js +198 -0
  170. data/vendor/assets/javascripts/ace/theme-crimson_editor.js +1 -0
  171. data/vendor/assets/javascripts/ace/theme-dawn-noconflict.js +1 -0
  172. data/vendor/assets/javascripts/ace/theme-dawn-uncompressed-noconflict.js +174 -0
  173. data/vendor/assets/javascripts/ace/theme-dawn-uncompressed.js +174 -0
  174. data/vendor/assets/javascripts/ace/theme-dawn.js +1 -0
  175. data/vendor/assets/javascripts/ace/theme-dreamweaver-noconflict.js +1 -0
  176. data/vendor/assets/javascripts/ace/theme-dreamweaver-uncompressed-noconflict.js +227 -0
  177. data/vendor/assets/javascripts/ace/theme-dreamweaver-uncompressed.js +227 -0
  178. data/vendor/assets/javascripts/ace/theme-dreamweaver.js +1 -0
  179. data/vendor/assets/javascripts/ace/theme-eclipse-noconflict.js +1 -0
  180. data/vendor/assets/javascripts/ace/theme-eclipse-uncompressed-noconflict.js +147 -0
  181. data/vendor/assets/javascripts/ace/theme-eclipse-uncompressed.js +147 -0
  182. data/vendor/assets/javascripts/ace/theme-eclipse.js +1 -0
  183. data/vendor/assets/javascripts/ace/theme-idle_fingers-noconflict.js +1 -0
  184. data/vendor/assets/javascripts/ace/theme-idle_fingers-uncompressed-noconflict.js +162 -0
  185. data/vendor/assets/javascripts/ace/theme-idle_fingers-uncompressed.js +162 -0
  186. data/vendor/assets/javascripts/ace/theme-idle_fingers.js +1 -0
  187. data/vendor/assets/javascripts/ace/theme-kr_theme-noconflict.js +1 -0
  188. data/vendor/assets/javascripts/ace/theme-kr_theme-uncompressed-noconflict.js +165 -0
  189. data/vendor/assets/javascripts/ace/theme-kr_theme-uncompressed.js +165 -0
  190. data/vendor/assets/javascripts/ace/theme-kr_theme.js +1 -0
  191. data/vendor/assets/javascripts/ace/theme-merbivore-noconflict.js +1 -0
  192. data/vendor/assets/javascripts/ace/theme-merbivore-uncompressed-noconflict.js +165 -0
  193. data/vendor/assets/javascripts/ace/theme-merbivore-uncompressed.js +165 -0
  194. data/vendor/assets/javascripts/ace/theme-merbivore.js +1 -0
  195. data/vendor/assets/javascripts/ace/theme-merbivore_soft-noconflict.js +1 -0
  196. data/vendor/assets/javascripts/ace/theme-merbivore_soft-uncompressed-noconflict.js +171 -0
  197. data/vendor/assets/javascripts/ace/theme-merbivore_soft-uncompressed.js +171 -0
  198. data/vendor/assets/javascripts/ace/theme-merbivore_soft.js +1 -0
  199. data/vendor/assets/javascripts/ace/theme-mono_industrial-noconflict.js +1 -0
  200. data/vendor/assets/javascripts/ace/theme-mono_industrial-uncompressed-noconflict.js +169 -0
  201. data/vendor/assets/javascripts/ace/theme-mono_industrial-uncompressed.js +169 -0
  202. data/vendor/assets/javascripts/ace/theme-mono_industrial.js +1 -0
  203. data/vendor/assets/javascripts/ace/theme-monokai-noconflict.js +1 -0
  204. data/vendor/assets/javascripts/ace/theme-monokai-uncompressed-noconflict.js +171 -0
  205. data/vendor/assets/javascripts/ace/theme-monokai-uncompressed.js +171 -0
  206. data/vendor/assets/javascripts/ace/theme-monokai.js +1 -0
  207. data/vendor/assets/javascripts/ace/theme-pastel_on_dark-noconflict.js +1 -0
  208. data/vendor/assets/javascripts/ace/theme-pastel_on_dark-uncompressed-noconflict.js +179 -0
  209. data/vendor/assets/javascripts/ace/theme-pastel_on_dark-uncompressed.js +179 -0
  210. data/vendor/assets/javascripts/ace/theme-pastel_on_dark.js +1 -0
  211. data/vendor/assets/javascripts/ace/theme-solarized_dark-noconflict.js +1 -0
  212. data/vendor/assets/javascripts/ace/theme-solarized_dark-uncompressed-noconflict.js +160 -0
  213. data/vendor/assets/javascripts/ace/theme-solarized_dark-uncompressed.js +160 -0
  214. data/vendor/assets/javascripts/ace/theme-solarized_dark.js +1 -0
  215. data/vendor/assets/javascripts/ace/theme-solarized_light-noconflict.js +1 -0
  216. data/vendor/assets/javascripts/ace/theme-solarized_light-uncompressed-noconflict.js +159 -0
  217. data/vendor/assets/javascripts/ace/theme-solarized_light-uncompressed.js +159 -0
  218. data/vendor/assets/javascripts/ace/theme-solarized_light.js +1 -0
  219. data/vendor/assets/javascripts/ace/theme-textmate-noconflict.js +0 -0
  220. data/vendor/assets/javascripts/ace/theme-textmate-uncompressed-noconflict.js +0 -0
  221. data/vendor/assets/javascripts/ace/theme-textmate-uncompressed.js +0 -0
  222. data/vendor/assets/javascripts/ace/theme-textmate.js +0 -0
  223. data/vendor/assets/javascripts/ace/theme-tomorrow-noconflict.js +1 -0
  224. data/vendor/assets/javascripts/ace/theme-tomorrow-uncompressed-noconflict.js +189 -0
  225. data/vendor/assets/javascripts/ace/theme-tomorrow-uncompressed.js +189 -0
  226. data/vendor/assets/javascripts/ace/theme-tomorrow.js +1 -0
  227. data/vendor/assets/javascripts/ace/theme-tomorrow_night-noconflict.js +1 -0
  228. data/vendor/assets/javascripts/ace/theme-tomorrow_night-uncompressed-noconflict.js +189 -0
  229. data/vendor/assets/javascripts/ace/theme-tomorrow_night-uncompressed.js +189 -0
  230. data/vendor/assets/javascripts/ace/theme-tomorrow_night.js +1 -0
  231. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue-noconflict.js +1 -0
  232. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue-uncompressed-noconflict.js +189 -0
  233. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue-uncompressed.js +189 -0
  234. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue.js +1 -0
  235. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright-noconflict.js +1 -0
  236. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright-uncompressed-noconflict.js +189 -0
  237. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright-uncompressed.js +189 -0
  238. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright.js +1 -0
  239. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties-noconflict.js +1 -0
  240. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties-uncompressed-noconflict.js +185 -0
  241. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties-uncompressed.js +185 -0
  242. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties.js +1 -0
  243. data/vendor/assets/javascripts/ace/theme-twilight-noconflict.js +1 -0
  244. data/vendor/assets/javascripts/ace/theme-twilight-uncompressed-noconflict.js +183 -0
  245. data/vendor/assets/javascripts/ace/theme-twilight-uncompressed.js +183 -0
  246. data/vendor/assets/javascripts/ace/theme-twilight.js +1 -0
  247. data/vendor/assets/javascripts/ace/theme-vibrant_ink-noconflict.js +1 -0
  248. data/vendor/assets/javascripts/ace/theme-vibrant_ink-uncompressed-noconflict.js +166 -0
  249. data/vendor/assets/javascripts/ace/theme-vibrant_ink-uncompressed.js +166 -0
  250. data/vendor/assets/javascripts/ace/theme-vibrant_ink.js +1 -0
  251. data/vendor/assets/javascripts/ace/worker-coffee.js +7456 -0
  252. data/vendor/assets/javascripts/ace/worker-css.js +11693 -0
  253. data/vendor/assets/javascripts/ace/worker-javascript.js +10305 -0
  254. data/vendor/assets/javascripts/ace/worker-json.js +3062 -0
  255. metadata +310 -0
@@ -0,0 +1,3062 @@
1
+ "no use strict";
2
+
3
+ var console = {
4
+ log: function(msg) {
5
+ postMessage({type: "log", data: msg});
6
+ }
7
+ };
8
+ var window = {
9
+ console: console
10
+ };
11
+
12
+ var normalizeModule = function(parentId, moduleName) {
13
+ // normalize plugin requires
14
+ if (moduleName.indexOf("!") !== -1) {
15
+ var chunks = moduleName.split("!");
16
+ return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
17
+ }
18
+ // normalize relative requires
19
+ if (moduleName.charAt(0) == ".") {
20
+ var base = parentId.split("/").slice(0, -1).join("/");
21
+ var moduleName = base + "/" + moduleName;
22
+
23
+ while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
24
+ var previous = moduleName;
25
+ var moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
26
+ }
27
+ }
28
+
29
+ return moduleName;
30
+ };
31
+
32
+ var require = function(parentId, id) {
33
+ var id = normalizeModule(parentId, id);
34
+
35
+ var module = require.modules[id];
36
+ if (module) {
37
+ if (!module.initialized) {
38
+ module.exports = module.factory().exports;
39
+ module.initialized = true;
40
+ }
41
+ return module.exports;
42
+ }
43
+
44
+ var chunks = id.split("/");
45
+ chunks[0] = require.tlns[chunks[0]] || chunks[0];
46
+ var path = chunks.join("/") + ".js";
47
+
48
+ require.id = id;
49
+ importScripts(path);
50
+ return require(parentId, id);
51
+ };
52
+
53
+ require.modules = {};
54
+ require.tlns = {};
55
+
56
+ var define = function(id, deps, factory) {
57
+ if (arguments.length == 2) {
58
+ factory = deps;
59
+ } else if (arguments.length == 1) {
60
+ factory = id;
61
+ id = require.id;
62
+ }
63
+
64
+ if (id.indexOf("text!") === 0)
65
+ return;
66
+
67
+ var req = function(deps, factory) {
68
+ return require(id, deps, factory);
69
+ };
70
+
71
+ require.modules[id] = {
72
+ factory: function() {
73
+ var module = {
74
+ exports: {}
75
+ };
76
+ var returnExports = factory(req, module.exports, module);
77
+ if (returnExports)
78
+ module.exports = returnExports;
79
+ return module;
80
+ }
81
+ };
82
+ };
83
+
84
+ function initBaseUrls(topLevelNamespaces) {
85
+ require.tlns = topLevelNamespaces;
86
+ }
87
+
88
+ function initSender() {
89
+
90
+ var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
91
+ var oop = require(null, "ace/lib/oop");
92
+
93
+ var Sender = function() {};
94
+
95
+ (function() {
96
+
97
+ oop.implement(this, EventEmitter);
98
+
99
+ this.callback = function(data, callbackId) {
100
+ postMessage({
101
+ type: "call",
102
+ id: callbackId,
103
+ data: data
104
+ });
105
+ };
106
+
107
+ this.emit = function(name, data) {
108
+ postMessage({
109
+ type: "event",
110
+ name: name,
111
+ data: data
112
+ });
113
+ };
114
+
115
+ }).call(Sender.prototype);
116
+
117
+ return new Sender();
118
+ }
119
+
120
+ var main;
121
+ var sender;
122
+
123
+ onmessage = function(e) {
124
+ var msg = e.data;
125
+ if (msg.command) {
126
+ main[msg.command].apply(main, msg.args);
127
+ }
128
+ else if (msg.init) {
129
+ initBaseUrls(msg.tlns);
130
+ require(null, "ace/lib/fixoldbrowsers");
131
+ sender = initSender();
132
+ var clazz = require(null, msg.module)[msg.classname];
133
+ main = new clazz(sender);
134
+ }
135
+ else if (msg.event && sender) {
136
+ sender._emit(msg.event, msg.data);
137
+ }
138
+ };
139
+ // vim:set ts=4 sts=4 sw=4 st:
140
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
141
+ // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
142
+ // -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified
143
+ // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
144
+ // -- Irakli Gozalishvili Copyright (C) 2010 MIT License
145
+
146
+ /*!
147
+ Copyright (c) 2009, 280 North Inc. http://280north.com/
148
+ MIT License. http://github.com/280north/narwhal/blob/master/README.md
149
+ */
150
+
151
+ define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
152
+ "use strict";
153
+
154
+ require("./regexp");
155
+ require("./es5-shim");
156
+
157
+ });/**
158
+ * Based on code from:
159
+ *
160
+ * XRegExp 1.5.0
161
+ * (c) 2007-2010 Steven Levithan
162
+ * MIT License
163
+ * <http://xregexp.com>
164
+ * Provides an augmented, extensible, cross-browser implementation of regular expressions,
165
+ * including support for additional syntax, flags, and methods
166
+ */
167
+
168
+ define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
169
+ "use strict";
170
+
171
+ //---------------------------------
172
+ // Private variables
173
+ //---------------------------------
174
+
175
+ var real = {
176
+ exec: RegExp.prototype.exec,
177
+ test: RegExp.prototype.test,
178
+ match: String.prototype.match,
179
+ replace: String.prototype.replace,
180
+ split: String.prototype.split
181
+ },
182
+ compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
183
+ compliantLastIndexIncrement = function () {
184
+ var x = /^/g;
185
+ real.test.call(x, "");
186
+ return !x.lastIndex;
187
+ }();
188
+
189
+ //---------------------------------
190
+ // Overriden native methods
191
+ //---------------------------------
192
+
193
+ // Adds named capture support (with backreferences returned as `result.name`), and fixes two
194
+ // cross-browser issues per ES3:
195
+ // - Captured values for nonparticipating capturing groups should be returned as `undefined`,
196
+ // rather than the empty string.
197
+ // - `lastIndex` should not be incremented after zero-length matches.
198
+ RegExp.prototype.exec = function (str) {
199
+ var match = real.exec.apply(this, arguments),
200
+ name, r2;
201
+ if ( typeof(str) == 'string' && match) {
202
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
203
+ // nonparticipating capturing groups
204
+ if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
205
+ r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
206
+ // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
207
+ // matching due to characters outside the match
208
+ real.replace.call(str.slice(match.index), r2, function () {
209
+ for (var i = 1; i < arguments.length - 2; i++) {
210
+ if (arguments[i] === undefined)
211
+ match[i] = undefined;
212
+ }
213
+ });
214
+ }
215
+ // Attach named capture properties
216
+ if (this._xregexp && this._xregexp.captureNames) {
217
+ for (var i = 1; i < match.length; i++) {
218
+ name = this._xregexp.captureNames[i - 1];
219
+ if (name)
220
+ match[name] = match[i];
221
+ }
222
+ }
223
+ // Fix browsers that increment `lastIndex` after zero-length matches
224
+ if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
225
+ this.lastIndex--;
226
+ }
227
+ return match;
228
+ };
229
+
230
+ // Don't override `test` if it won't change anything
231
+ if (!compliantLastIndexIncrement) {
232
+ // Fix browser bug in native method
233
+ RegExp.prototype.test = function (str) {
234
+ // Use the native `exec` to skip some processing overhead, even though the overriden
235
+ // `exec` would take care of the `lastIndex` fix
236
+ var match = real.exec.call(this, str);
237
+ // Fix browsers that increment `lastIndex` after zero-length matches
238
+ if (match && this.global && !match[0].length && (this.lastIndex > match.index))
239
+ this.lastIndex--;
240
+ return !!match;
241
+ };
242
+ }
243
+
244
+ //---------------------------------
245
+ // Private helper functions
246
+ //---------------------------------
247
+
248
+ function getNativeFlags (regex) {
249
+ return (regex.global ? "g" : "") +
250
+ (regex.ignoreCase ? "i" : "") +
251
+ (regex.multiline ? "m" : "") +
252
+ (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
253
+ (regex.sticky ? "y" : "");
254
+ };
255
+
256
+ function indexOf (array, item, from) {
257
+ if (Array.prototype.indexOf) // Use the native array method if available
258
+ return array.indexOf(item, from);
259
+ for (var i = from || 0; i < array.length; i++) {
260
+ if (array[i] === item)
261
+ return i;
262
+ }
263
+ return -1;
264
+ };
265
+
266
+ });
267
+ // vim: ts=4 sts=4 sw=4 expandtab
268
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
269
+ // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
270
+ // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
271
+ // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
272
+ // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
273
+ // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
274
+ // -- kossnocorp Sasha Koss XXX TODO License or CLA
275
+ // -- bryanforbes Bryan Forbes XXX TODO License or CLA
276
+ // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
277
+ // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
278
+ // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
279
+ // -- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain)
280
+ // -- iwyg XXX TODO License or CLA
281
+ // -- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License
282
+ // -- xavierm02 Montillet Xavier XXX TODO License or CLA
283
+ // -- Raynos Raynos XXX TODO License or CLA
284
+ // -- samsonjs Sami Samhuri Copyright (C) 2010 MIT License
285
+ // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
286
+ // -- lexer Alexey Zakharov XXX TODO License or CLA
287
+
288
+ /*!
289
+ Copyright (c) 2009, 280 North Inc. http://280north.com/
290
+ MIT License. http://github.com/280north/narwhal/blob/master/README.md
291
+ */
292
+
293
+ define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
294
+
295
+ /**
296
+ * Brings an environment as close to ECMAScript 5 compliance
297
+ * as is possible with the facilities of erstwhile engines.
298
+ *
299
+ * Annotated ES5: http://es5.github.com/ (specific links below)
300
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
301
+ *
302
+ * @module
303
+ */
304
+
305
+ /*whatsupdoc*/
306
+
307
+ //
308
+ // Function
309
+ // ========
310
+ //
311
+
312
+ // ES-5 15.3.4.5
313
+ // http://es5.github.com/#x15.3.4.5
314
+
315
+ if (!Function.prototype.bind) {
316
+ Function.prototype.bind = function bind(that) { // .length is 1
317
+ // 1. Let Target be the this value.
318
+ var target = this;
319
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
320
+ if (typeof target != "function")
321
+ throw new TypeError(); // TODO message
322
+ // 3. Let A be a new (possibly empty) internal list of all of the
323
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
324
+ // XXX slicedArgs will stand in for "A" if used
325
+ var args = slice.call(arguments, 1); // for normal call
326
+ // 4. Let F be a new native ECMAScript object.
327
+ // 11. Set the [[Prototype]] internal property of F to the standard
328
+ // built-in Function prototype object as specified in 15.3.3.1.
329
+ // 12. Set the [[Call]] internal property of F as described in
330
+ // 15.3.4.5.1.
331
+ // 13. Set the [[Construct]] internal property of F as described in
332
+ // 15.3.4.5.2.
333
+ // 14. Set the [[HasInstance]] internal property of F as described in
334
+ // 15.3.4.5.3.
335
+ var bound = function () {
336
+
337
+ if (this instanceof bound) {
338
+ // 15.3.4.5.2 [[Construct]]
339
+ // When the [[Construct]] internal method of a function object,
340
+ // F that was created using the bind function is called with a
341
+ // list of arguments ExtraArgs, the following steps are taken:
342
+ // 1. Let target be the value of F's [[TargetFunction]]
343
+ // internal property.
344
+ // 2. If target has no [[Construct]] internal method, a
345
+ // TypeError exception is thrown.
346
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
347
+ // property.
348
+ // 4. Let args be a new list containing the same values as the
349
+ // list boundArgs in the same order followed by the same
350
+ // values as the list ExtraArgs in the same order.
351
+ // 5. Return the result of calling the [[Construct]] internal
352
+ // method of target providing args as the arguments.
353
+
354
+ var F = function(){};
355
+ F.prototype = target.prototype;
356
+ var self = new F;
357
+
358
+ var result = target.apply(
359
+ self,
360
+ args.concat(slice.call(arguments))
361
+ );
362
+ if (result !== null && Object(result) === result)
363
+ return result;
364
+ return self;
365
+
366
+ } else {
367
+ // 15.3.4.5.1 [[Call]]
368
+ // When the [[Call]] internal method of a function object, F,
369
+ // which was created using the bind function is called with a
370
+ // this value and a list of arguments ExtraArgs, the following
371
+ // steps are taken:
372
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
373
+ // property.
374
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
375
+ // property.
376
+ // 3. Let target be the value of F's [[TargetFunction]] internal
377
+ // property.
378
+ // 4. Let args be a new list containing the same values as the
379
+ // list boundArgs in the same order followed by the same
380
+ // values as the list ExtraArgs in the same order.
381
+ // 5. Return the result of calling the [[Call]] internal method
382
+ // of target providing boundThis as the this value and
383
+ // providing args as the arguments.
384
+
385
+ // equiv: target.call(this, ...boundArgs, ...args)
386
+ return target.apply(
387
+ that,
388
+ args.concat(slice.call(arguments))
389
+ );
390
+
391
+ }
392
+
393
+ };
394
+ // XXX bound.length is never writable, so don't even try
395
+ //
396
+ // 15. If the [[Class]] internal property of Target is "Function", then
397
+ // a. Let L be the length property of Target minus the length of A.
398
+ // b. Set the length own property of F to either 0 or L, whichever is
399
+ // larger.
400
+ // 16. Else set the length own property of F to 0.
401
+ // 17. Set the attributes of the length own property of F to the values
402
+ // specified in 15.3.5.1.
403
+
404
+ // TODO
405
+ // 18. Set the [[Extensible]] internal property of F to true.
406
+
407
+ // TODO
408
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
409
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
410
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
411
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
412
+ // false.
413
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
414
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
415
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
416
+ // and false.
417
+
418
+ // TODO
419
+ // NOTE Function objects created using Function.prototype.bind do not
420
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
421
+ // [[Scope]] internal properties.
422
+ // XXX can't delete prototype in pure-js.
423
+
424
+ // 22. Return F.
425
+ return bound;
426
+ };
427
+ }
428
+
429
+ // Shortcut to an often accessed properties, in order to avoid multiple
430
+ // dereference that costs universally.
431
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
432
+ // us it in defining shortcuts.
433
+ var call = Function.prototype.call;
434
+ var prototypeOfArray = Array.prototype;
435
+ var prototypeOfObject = Object.prototype;
436
+ var slice = prototypeOfArray.slice;
437
+ var toString = call.bind(prototypeOfObject.toString);
438
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
439
+
440
+ // If JS engine supports accessors creating shortcuts.
441
+ var defineGetter;
442
+ var defineSetter;
443
+ var lookupGetter;
444
+ var lookupSetter;
445
+ var supportsAccessors;
446
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
447
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
448
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
449
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
450
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
451
+ }
452
+
453
+ //
454
+ // Array
455
+ // =====
456
+ //
457
+
458
+ // ES5 15.4.3.2
459
+ // http://es5.github.com/#x15.4.3.2
460
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
461
+ if (!Array.isArray) {
462
+ Array.isArray = function isArray(obj) {
463
+ return toString(obj) == "[object Array]";
464
+ };
465
+ }
466
+
467
+ // The IsCallable() check in the Array functions
468
+ // has been replaced with a strict check on the
469
+ // internal class of the object to trap cases where
470
+ // the provided function was actually a regular
471
+ // expression literal, which in V8 and
472
+ // JavaScriptCore is a typeof "function". Only in
473
+ // V8 are regular expression literals permitted as
474
+ // reduce parameters, so it is desirable in the
475
+ // general case for the shim to match the more
476
+ // strict and common behavior of rejecting regular
477
+ // expressions.
478
+
479
+ // ES5 15.4.4.18
480
+ // http://es5.github.com/#x15.4.4.18
481
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
482
+ if (!Array.prototype.forEach) {
483
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
484
+ var self = toObject(this),
485
+ thisp = arguments[1],
486
+ i = 0,
487
+ length = self.length >>> 0;
488
+
489
+ // If no callback function or if callback is not a callable function
490
+ if (toString(fun) != "[object Function]") {
491
+ throw new TypeError(); // TODO message
492
+ }
493
+
494
+ while (i < length) {
495
+ if (i in self) {
496
+ // Invoke the callback function with call, passing arguments:
497
+ // context, property value, property key, thisArg object context
498
+ fun.call(thisp, self[i], i, self);
499
+ }
500
+ i++;
501
+ }
502
+ };
503
+ }
504
+
505
+ // ES5 15.4.4.19
506
+ // http://es5.github.com/#x15.4.4.19
507
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
508
+ if (!Array.prototype.map) {
509
+ Array.prototype.map = function map(fun /*, thisp*/) {
510
+ var self = toObject(this),
511
+ length = self.length >>> 0,
512
+ result = Array(length),
513
+ thisp = arguments[1];
514
+
515
+ // If no callback function or if callback is not a callable function
516
+ if (toString(fun) != "[object Function]") {
517
+ throw new TypeError(); // TODO message
518
+ }
519
+
520
+ for (var i = 0; i < length; i++) {
521
+ if (i in self)
522
+ result[i] = fun.call(thisp, self[i], i, self);
523
+ }
524
+ return result;
525
+ };
526
+ }
527
+
528
+ // ES5 15.4.4.20
529
+ // http://es5.github.com/#x15.4.4.20
530
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
531
+ if (!Array.prototype.filter) {
532
+ Array.prototype.filter = function filter(fun /*, thisp */) {
533
+ var self = toObject(this),
534
+ length = self.length >>> 0,
535
+ result = [],
536
+ thisp = arguments[1];
537
+
538
+ // If no callback function or if callback is not a callable function
539
+ if (toString(fun) != "[object Function]") {
540
+ throw new TypeError(); // TODO message
541
+ }
542
+
543
+ for (var i = 0; i < length; i++) {
544
+ if (i in self && fun.call(thisp, self[i], i, self))
545
+ result.push(self[i]);
546
+ }
547
+ return result;
548
+ };
549
+ }
550
+
551
+ // ES5 15.4.4.16
552
+ // http://es5.github.com/#x15.4.4.16
553
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
554
+ if (!Array.prototype.every) {
555
+ Array.prototype.every = function every(fun /*, thisp */) {
556
+ var self = toObject(this),
557
+ length = self.length >>> 0,
558
+ thisp = arguments[1];
559
+
560
+ // If no callback function or if callback is not a callable function
561
+ if (toString(fun) != "[object Function]") {
562
+ throw new TypeError(); // TODO message
563
+ }
564
+
565
+ for (var i = 0; i < length; i++) {
566
+ if (i in self && !fun.call(thisp, self[i], i, self))
567
+ return false;
568
+ }
569
+ return true;
570
+ };
571
+ }
572
+
573
+ // ES5 15.4.4.17
574
+ // http://es5.github.com/#x15.4.4.17
575
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
576
+ if (!Array.prototype.some) {
577
+ Array.prototype.some = function some(fun /*, thisp */) {
578
+ var self = toObject(this),
579
+ length = self.length >>> 0,
580
+ thisp = arguments[1];
581
+
582
+ // If no callback function or if callback is not a callable function
583
+ if (toString(fun) != "[object Function]") {
584
+ throw new TypeError(); // TODO message
585
+ }
586
+
587
+ for (var i = 0; i < length; i++) {
588
+ if (i in self && fun.call(thisp, self[i], i, self))
589
+ return true;
590
+ }
591
+ return false;
592
+ };
593
+ }
594
+
595
+ // ES5 15.4.4.21
596
+ // http://es5.github.com/#x15.4.4.21
597
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
598
+ if (!Array.prototype.reduce) {
599
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
600
+ var self = toObject(this),
601
+ length = self.length >>> 0;
602
+
603
+ // If no callback function or if callback is not a callable function
604
+ if (toString(fun) != "[object Function]") {
605
+ throw new TypeError(); // TODO message
606
+ }
607
+
608
+ // no value to return if no initial value and an empty array
609
+ if (!length && arguments.length == 1)
610
+ throw new TypeError(); // TODO message
611
+
612
+ var i = 0;
613
+ var result;
614
+ if (arguments.length >= 2) {
615
+ result = arguments[1];
616
+ } else {
617
+ do {
618
+ if (i in self) {
619
+ result = self[i++];
620
+ break;
621
+ }
622
+
623
+ // if array contains no values, no initial value to return
624
+ if (++i >= length)
625
+ throw new TypeError(); // TODO message
626
+ } while (true);
627
+ }
628
+
629
+ for (; i < length; i++) {
630
+ if (i in self)
631
+ result = fun.call(void 0, result, self[i], i, self);
632
+ }
633
+
634
+ return result;
635
+ };
636
+ }
637
+
638
+ // ES5 15.4.4.22
639
+ // http://es5.github.com/#x15.4.4.22
640
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
641
+ if (!Array.prototype.reduceRight) {
642
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
643
+ var self = toObject(this),
644
+ length = self.length >>> 0;
645
+
646
+ // If no callback function or if callback is not a callable function
647
+ if (toString(fun) != "[object Function]") {
648
+ throw new TypeError(); // TODO message
649
+ }
650
+
651
+ // no value to return if no initial value, empty array
652
+ if (!length && arguments.length == 1)
653
+ throw new TypeError(); // TODO message
654
+
655
+ var result, i = length - 1;
656
+ if (arguments.length >= 2) {
657
+ result = arguments[1];
658
+ } else {
659
+ do {
660
+ if (i in self) {
661
+ result = self[i--];
662
+ break;
663
+ }
664
+
665
+ // if array contains no values, no initial value to return
666
+ if (--i < 0)
667
+ throw new TypeError(); // TODO message
668
+ } while (true);
669
+ }
670
+
671
+ do {
672
+ if (i in this)
673
+ result = fun.call(void 0, result, self[i], i, self);
674
+ } while (i--);
675
+
676
+ return result;
677
+ };
678
+ }
679
+
680
+ // ES5 15.4.4.14
681
+ // http://es5.github.com/#x15.4.4.14
682
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
683
+ if (!Array.prototype.indexOf) {
684
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
685
+ var self = toObject(this),
686
+ length = self.length >>> 0;
687
+
688
+ if (!length)
689
+ return -1;
690
+
691
+ var i = 0;
692
+ if (arguments.length > 1)
693
+ i = toInteger(arguments[1]);
694
+
695
+ // handle negative indices
696
+ i = i >= 0 ? i : Math.max(0, length + i);
697
+ for (; i < length; i++) {
698
+ if (i in self && self[i] === sought) {
699
+ return i;
700
+ }
701
+ }
702
+ return -1;
703
+ };
704
+ }
705
+
706
+ // ES5 15.4.4.15
707
+ // http://es5.github.com/#x15.4.4.15
708
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
709
+ if (!Array.prototype.lastIndexOf) {
710
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
711
+ var self = toObject(this),
712
+ length = self.length >>> 0;
713
+
714
+ if (!length)
715
+ return -1;
716
+ var i = length - 1;
717
+ if (arguments.length > 1)
718
+ i = Math.min(i, toInteger(arguments[1]));
719
+ // handle negative indices
720
+ i = i >= 0 ? i : length - Math.abs(i);
721
+ for (; i >= 0; i--) {
722
+ if (i in self && sought === self[i])
723
+ return i;
724
+ }
725
+ return -1;
726
+ };
727
+ }
728
+
729
+ //
730
+ // Object
731
+ // ======
732
+ //
733
+
734
+ // ES5 15.2.3.2
735
+ // http://es5.github.com/#x15.2.3.2
736
+ if (!Object.getPrototypeOf) {
737
+ // https://github.com/kriskowal/es5-shim/issues#issue/2
738
+ // http://ejohn.org/blog/objectgetprototypeof/
739
+ // recommended by fschaefer on github
740
+ Object.getPrototypeOf = function getPrototypeOf(object) {
741
+ return object.__proto__ || (
742
+ object.constructor ?
743
+ object.constructor.prototype :
744
+ prototypeOfObject
745
+ );
746
+ };
747
+ }
748
+
749
+ // ES5 15.2.3.3
750
+ // http://es5.github.com/#x15.2.3.3
751
+ if (!Object.getOwnPropertyDescriptor) {
752
+ var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
753
+ "non-object: ";
754
+ Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
755
+ if ((typeof object != "object" && typeof object != "function") || object === null)
756
+ throw new TypeError(ERR_NON_OBJECT + object);
757
+ // If object does not owns property return undefined immediately.
758
+ if (!owns(object, property))
759
+ return;
760
+
761
+ var descriptor, getter, setter;
762
+
763
+ // If object has a property then it's for sure both `enumerable` and
764
+ // `configurable`.
765
+ descriptor = { enumerable: true, configurable: true };
766
+
767
+ // If JS engine supports accessor properties then property may be a
768
+ // getter or setter.
769
+ if (supportsAccessors) {
770
+ // Unfortunately `__lookupGetter__` will return a getter even
771
+ // if object has own non getter property along with a same named
772
+ // inherited getter. To avoid misbehavior we temporary remove
773
+ // `__proto__` so that `__lookupGetter__` will return getter only
774
+ // if it's owned by an object.
775
+ var prototype = object.__proto__;
776
+ object.__proto__ = prototypeOfObject;
777
+
778
+ var getter = lookupGetter(object, property);
779
+ var setter = lookupSetter(object, property);
780
+
781
+ // Once we have getter and setter we can put values back.
782
+ object.__proto__ = prototype;
783
+
784
+ if (getter || setter) {
785
+ if (getter) descriptor.get = getter;
786
+ if (setter) descriptor.set = setter;
787
+
788
+ // If it was accessor property we're done and return here
789
+ // in order to avoid adding `value` to the descriptor.
790
+ return descriptor;
791
+ }
792
+ }
793
+
794
+ // If we got this far we know that object has an own property that is
795
+ // not an accessor so we set it as a value and return descriptor.
796
+ descriptor.value = object[property];
797
+ return descriptor;
798
+ };
799
+ }
800
+
801
+ // ES5 15.2.3.4
802
+ // http://es5.github.com/#x15.2.3.4
803
+ if (!Object.getOwnPropertyNames) {
804
+ Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
805
+ return Object.keys(object);
806
+ };
807
+ }
808
+
809
+ // ES5 15.2.3.5
810
+ // http://es5.github.com/#x15.2.3.5
811
+ if (!Object.create) {
812
+ Object.create = function create(prototype, properties) {
813
+ var object;
814
+ if (prototype === null) {
815
+ object = { "__proto__": null };
816
+ } else {
817
+ if (typeof prototype != "object")
818
+ throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
819
+ var Type = function () {};
820
+ Type.prototype = prototype;
821
+ object = new Type();
822
+ // IE has no built-in implementation of `Object.getPrototypeOf`
823
+ // neither `__proto__`, but this manually setting `__proto__` will
824
+ // guarantee that `Object.getPrototypeOf` will work as expected with
825
+ // objects created using `Object.create`
826
+ object.__proto__ = prototype;
827
+ }
828
+ if (properties !== void 0)
829
+ Object.defineProperties(object, properties);
830
+ return object;
831
+ };
832
+ }
833
+
834
+ // ES5 15.2.3.6
835
+ // http://es5.github.com/#x15.2.3.6
836
+
837
+ // Patch for WebKit and IE8 standard mode
838
+ // Designed by hax <hax.github.com>
839
+ // related issue: https://github.com/kriskowal/es5-shim/issues#issue/5
840
+ // IE8 Reference:
841
+ // http://msdn.microsoft.com/en-us/library/dd282900.aspx
842
+ // http://msdn.microsoft.com/en-us/library/dd229916.aspx
843
+ // WebKit Bugs:
844
+ // https://bugs.webkit.org/show_bug.cgi?id=36423
845
+
846
+ function doesDefinePropertyWork(object) {
847
+ try {
848
+ Object.defineProperty(object, "sentinel", {});
849
+ return "sentinel" in object;
850
+ } catch (exception) {
851
+ // returns falsy
852
+ }
853
+ }
854
+
855
+ // check whether defineProperty works if it's given. Otherwise,
856
+ // shim partially.
857
+ if (Object.defineProperty) {
858
+ var definePropertyWorksOnObject = doesDefinePropertyWork({});
859
+ var definePropertyWorksOnDom = typeof document == "undefined" ||
860
+ doesDefinePropertyWork(document.createElement("div"));
861
+ if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
862
+ var definePropertyFallback = Object.defineProperty;
863
+ }
864
+ }
865
+
866
+ if (!Object.defineProperty || definePropertyFallback) {
867
+ var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
868
+ var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
869
+ var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
870
+ "on this javascript engine";
871
+
872
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
873
+ if ((typeof object != "object" && typeof object != "function") || object === null)
874
+ throw new TypeError(ERR_NON_OBJECT_TARGET + object);
875
+ if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
876
+ throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
877
+
878
+ // make a valiant attempt to use the real defineProperty
879
+ // for I8's DOM elements.
880
+ if (definePropertyFallback) {
881
+ try {
882
+ return definePropertyFallback.call(Object, object, property, descriptor);
883
+ } catch (exception) {
884
+ // try the shim if the real one doesn't work
885
+ }
886
+ }
887
+
888
+ // If it's a data property.
889
+ if (owns(descriptor, "value")) {
890
+ // fail silently if "writable", "enumerable", or "configurable"
891
+ // are requested but not supported
892
+ /*
893
+ // alternate approach:
894
+ if ( // can't implement these features; allow false but not true
895
+ !(owns(descriptor, "writable") ? descriptor.writable : true) ||
896
+ !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) ||
897
+ !(owns(descriptor, "configurable") ? descriptor.configurable : true)
898
+ )
899
+ throw new RangeError(
900
+ "This implementation of Object.defineProperty does not " +
901
+ "support configurable, enumerable, or writable."
902
+ );
903
+ */
904
+
905
+ if (supportsAccessors && (lookupGetter(object, property) ||
906
+ lookupSetter(object, property)))
907
+ {
908
+ // As accessors are supported only on engines implementing
909
+ // `__proto__` we can safely override `__proto__` while defining
910
+ // a property to make sure that we don't hit an inherited
911
+ // accessor.
912
+ var prototype = object.__proto__;
913
+ object.__proto__ = prototypeOfObject;
914
+ // Deleting a property anyway since getter / setter may be
915
+ // defined on object itself.
916
+ delete object[property];
917
+ object[property] = descriptor.value;
918
+ // Setting original `__proto__` back now.
919
+ object.__proto__ = prototype;
920
+ } else {
921
+ object[property] = descriptor.value;
922
+ }
923
+ } else {
924
+ if (!supportsAccessors)
925
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
926
+ // If we got that far then getters and setters can be defined !!
927
+ if (owns(descriptor, "get"))
928
+ defineGetter(object, property, descriptor.get);
929
+ if (owns(descriptor, "set"))
930
+ defineSetter(object, property, descriptor.set);
931
+ }
932
+
933
+ return object;
934
+ };
935
+ }
936
+
937
+ // ES5 15.2.3.7
938
+ // http://es5.github.com/#x15.2.3.7
939
+ if (!Object.defineProperties) {
940
+ Object.defineProperties = function defineProperties(object, properties) {
941
+ for (var property in properties) {
942
+ if (owns(properties, property))
943
+ Object.defineProperty(object, property, properties[property]);
944
+ }
945
+ return object;
946
+ };
947
+ }
948
+
949
+ // ES5 15.2.3.8
950
+ // http://es5.github.com/#x15.2.3.8
951
+ if (!Object.seal) {
952
+ Object.seal = function seal(object) {
953
+ // this is misleading and breaks feature-detection, but
954
+ // allows "securable" code to "gracefully" degrade to working
955
+ // but insecure code.
956
+ return object;
957
+ };
958
+ }
959
+
960
+ // ES5 15.2.3.9
961
+ // http://es5.github.com/#x15.2.3.9
962
+ if (!Object.freeze) {
963
+ Object.freeze = function freeze(object) {
964
+ // this is misleading and breaks feature-detection, but
965
+ // allows "securable" code to "gracefully" degrade to working
966
+ // but insecure code.
967
+ return object;
968
+ };
969
+ }
970
+
971
+ // detect a Rhino bug and patch it
972
+ try {
973
+ Object.freeze(function () {});
974
+ } catch (exception) {
975
+ Object.freeze = (function freeze(freezeObject) {
976
+ return function freeze(object) {
977
+ if (typeof object == "function") {
978
+ return object;
979
+ } else {
980
+ return freezeObject(object);
981
+ }
982
+ };
983
+ })(Object.freeze);
984
+ }
985
+
986
+ // ES5 15.2.3.10
987
+ // http://es5.github.com/#x15.2.3.10
988
+ if (!Object.preventExtensions) {
989
+ Object.preventExtensions = function preventExtensions(object) {
990
+ // this is misleading and breaks feature-detection, but
991
+ // allows "securable" code to "gracefully" degrade to working
992
+ // but insecure code.
993
+ return object;
994
+ };
995
+ }
996
+
997
+ // ES5 15.2.3.11
998
+ // http://es5.github.com/#x15.2.3.11
999
+ if (!Object.isSealed) {
1000
+ Object.isSealed = function isSealed(object) {
1001
+ return false;
1002
+ };
1003
+ }
1004
+
1005
+ // ES5 15.2.3.12
1006
+ // http://es5.github.com/#x15.2.3.12
1007
+ if (!Object.isFrozen) {
1008
+ Object.isFrozen = function isFrozen(object) {
1009
+ return false;
1010
+ };
1011
+ }
1012
+
1013
+ // ES5 15.2.3.13
1014
+ // http://es5.github.com/#x15.2.3.13
1015
+ if (!Object.isExtensible) {
1016
+ Object.isExtensible = function isExtensible(object) {
1017
+ // 1. If Type(O) is not Object throw a TypeError exception.
1018
+ if (Object(object) === object) {
1019
+ throw new TypeError(); // TODO message
1020
+ }
1021
+ // 2. Return the Boolean value of the [[Extensible]] internal property of O.
1022
+ var name = '';
1023
+ while (owns(object, name)) {
1024
+ name += '?';
1025
+ }
1026
+ object[name] = true;
1027
+ var returnValue = owns(object, name);
1028
+ delete object[name];
1029
+ return returnValue;
1030
+ };
1031
+ }
1032
+
1033
+ // ES5 15.2.3.14
1034
+ // http://es5.github.com/#x15.2.3.14
1035
+ if (!Object.keys) {
1036
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
1037
+ var hasDontEnumBug = true,
1038
+ dontEnums = [
1039
+ "toString",
1040
+ "toLocaleString",
1041
+ "valueOf",
1042
+ "hasOwnProperty",
1043
+ "isPrototypeOf",
1044
+ "propertyIsEnumerable",
1045
+ "constructor"
1046
+ ],
1047
+ dontEnumsLength = dontEnums.length;
1048
+
1049
+ for (var key in {"toString": null})
1050
+ hasDontEnumBug = false;
1051
+
1052
+ Object.keys = function keys(object) {
1053
+
1054
+ if ((typeof object != "object" && typeof object != "function") || object === null)
1055
+ throw new TypeError("Object.keys called on a non-object");
1056
+
1057
+ var keys = [];
1058
+ for (var name in object) {
1059
+ if (owns(object, name)) {
1060
+ keys.push(name);
1061
+ }
1062
+ }
1063
+
1064
+ if (hasDontEnumBug) {
1065
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
1066
+ var dontEnum = dontEnums[i];
1067
+ if (owns(object, dontEnum)) {
1068
+ keys.push(dontEnum);
1069
+ }
1070
+ }
1071
+ }
1072
+
1073
+ return keys;
1074
+ };
1075
+
1076
+ }
1077
+
1078
+ //
1079
+ // Date
1080
+ // ====
1081
+ //
1082
+
1083
+ // ES5 15.9.5.43
1084
+ // http://es5.github.com/#x15.9.5.43
1085
+ // This function returns a String value represent the instance in time
1086
+ // represented by this Date object. The format of the String is the Date Time
1087
+ // string format defined in 15.9.1.15. All fields are present in the String.
1088
+ // The time zone is always UTC, denoted by the suffix Z. If the time value of
1089
+ // this object is not a finite Number a RangeError exception is thrown.
1090
+ if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) {
1091
+ Date.prototype.toISOString = function toISOString() {
1092
+ var result, length, value, year;
1093
+ if (!isFinite(this))
1094
+ throw new RangeError;
1095
+
1096
+ // the date time string format is specified in 15.9.1.15.
1097
+ result = [this.getUTCMonth() + 1, this.getUTCDate(),
1098
+ this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
1099
+ year = this.getUTCFullYear();
1100
+ year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6);
1101
+
1102
+ length = result.length;
1103
+ while (length--) {
1104
+ value = result[length];
1105
+ // pad months, days, hours, minutes, and seconds to have two digits.
1106
+ if (value < 10)
1107
+ result[length] = "0" + value;
1108
+ }
1109
+ // pad milliseconds to have three digits.
1110
+ return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." +
1111
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
1112
+ }
1113
+ }
1114
+
1115
+ // ES5 15.9.4.4
1116
+ // http://es5.github.com/#x15.9.4.4
1117
+ if (!Date.now) {
1118
+ Date.now = function now() {
1119
+ return new Date().getTime();
1120
+ };
1121
+ }
1122
+
1123
+ // ES5 15.9.5.44
1124
+ // http://es5.github.com/#x15.9.5.44
1125
+ // This function provides a String representation of a Date object for use by
1126
+ // JSON.stringify (15.12.3).
1127
+ if (!Date.prototype.toJSON) {
1128
+ Date.prototype.toJSON = function toJSON(key) {
1129
+ // When the toJSON method is called with argument key, the following
1130
+ // steps are taken:
1131
+
1132
+ // 1. Let O be the result of calling ToObject, giving it the this
1133
+ // value as its argument.
1134
+ // 2. Let tv be ToPrimitive(O, hint Number).
1135
+ // 3. If tv is a Number and is not finite, return null.
1136
+ // XXX
1137
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
1138
+ // O with argument "toISOString".
1139
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
1140
+ if (typeof this.toISOString != "function")
1141
+ throw new TypeError(); // TODO message
1142
+ // 6. Return the result of calling the [[Call]] internal method of
1143
+ // toISO with O as the this value and an empty argument list.
1144
+ return this.toISOString();
1145
+
1146
+ // NOTE 1 The argument is ignored.
1147
+
1148
+ // NOTE 2 The toJSON function is intentionally generic; it does not
1149
+ // require that its this value be a Date object. Therefore, it can be
1150
+ // transferred to other kinds of objects for use as a method. However,
1151
+ // it does require that any such object have a toISOString method. An
1152
+ // object is free to use the argument key to filter its
1153
+ // stringification.
1154
+ };
1155
+ }
1156
+
1157
+ // ES5 15.9.4.2
1158
+ // http://es5.github.com/#x15.9.4.2
1159
+ // based on work shared by Daniel Friesen (dantman)
1160
+ // http://gist.github.com/303249
1161
+ if (Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
1162
+ // XXX global assignment won't work in embeddings that use
1163
+ // an alternate object for the context.
1164
+ Date = (function(NativeDate) {
1165
+
1166
+ // Date.length === 7
1167
+ var Date = function Date(Y, M, D, h, m, s, ms) {
1168
+ var length = arguments.length;
1169
+ if (this instanceof NativeDate) {
1170
+ var date = length == 1 && String(Y) === Y ? // isString(Y)
1171
+ // We explicitly pass it through parse:
1172
+ new NativeDate(Date.parse(Y)) :
1173
+ // We have to manually make calls depending on argument
1174
+ // length here
1175
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
1176
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
1177
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
1178
+ length >= 4 ? new NativeDate(Y, M, D, h) :
1179
+ length >= 3 ? new NativeDate(Y, M, D) :
1180
+ length >= 2 ? new NativeDate(Y, M) :
1181
+ length >= 1 ? new NativeDate(Y) :
1182
+ new NativeDate();
1183
+ // Prevent mixups with unfixed Date object
1184
+ date.constructor = Date;
1185
+ return date;
1186
+ }
1187
+ return NativeDate.apply(this, arguments);
1188
+ };
1189
+
1190
+ // 15.9.1.15 Date Time String Format.
1191
+ var isoDateExpression = new RegExp("^" +
1192
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year
1193
+ "(?:-(\\d{2})" + // optional month capture
1194
+ "(?:-(\\d{2})" + // optional day capture
1195
+ "(?:" + // capture hours:minutes:seconds.milliseconds
1196
+ "T(\\d{2})" + // hours capture
1197
+ ":(\\d{2})" + // minutes capture
1198
+ "(?:" + // optional :seconds.milliseconds
1199
+ ":(\\d{2})" + // seconds capture
1200
+ "(?:\\.(\\d{3}))?" + // milliseconds capture
1201
+ ")?" +
1202
+ "(?:" + // capture UTC offset component
1203
+ "Z|" + // UTC capture
1204
+ "(?:" + // offset specifier +/-hours:minutes
1205
+ "([-+])" + // sign capture
1206
+ "(\\d{2})" + // hours offset capture
1207
+ ":(\\d{2})" + // minutes offset capture
1208
+ ")" +
1209
+ ")?)?)?)?" +
1210
+ "$");
1211
+
1212
+ // Copy any custom methods a 3rd party library may have added
1213
+ for (var key in NativeDate)
1214
+ Date[key] = NativeDate[key];
1215
+
1216
+ // Copy "native" methods explicitly; they may be non-enumerable
1217
+ Date.now = NativeDate.now;
1218
+ Date.UTC = NativeDate.UTC;
1219
+ Date.prototype = NativeDate.prototype;
1220
+ Date.prototype.constructor = Date;
1221
+
1222
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
1223
+ Date.parse = function parse(string) {
1224
+ var match = isoDateExpression.exec(string);
1225
+ if (match) {
1226
+ match.shift(); // kill match[0], the full match
1227
+ // parse months, days, hours, minutes, seconds, and milliseconds
1228
+ for (var i = 1; i < 7; i++) {
1229
+ // provide default values if necessary
1230
+ match[i] = +(match[i] || (i < 3 ? 1 : 0));
1231
+ // match[1] is the month. Months are 0-11 in JavaScript
1232
+ // `Date` objects, but 1-12 in ISO notation, so we
1233
+ // decrement.
1234
+ if (i == 1)
1235
+ match[i]--;
1236
+ }
1237
+
1238
+ // parse the UTC offset component
1239
+ var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop();
1240
+
1241
+ // compute the explicit time zone offset if specified
1242
+ var offset = 0;
1243
+ if (sign) {
1244
+ // detect invalid offsets and return early
1245
+ if (hourOffset > 23 || minuteOffset > 59)
1246
+ return NaN;
1247
+
1248
+ // express the provided time zone offset in minutes. The offset is
1249
+ // negative for time zones west of UTC; positive otherwise.
1250
+ offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1);
1251
+ }
1252
+
1253
+ // Date.UTC for years between 0 and 99 converts year to 1900 + year
1254
+ // The Gregorian calendar has a 400-year cycle, so
1255
+ // to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...),
1256
+ // where 12622780800000 - number of milliseconds in Gregorian calendar 400 years
1257
+ var year = +match[0];
1258
+ if (0 <= year && year <= 99) {
1259
+ match[0] = year + 400;
1260
+ return NativeDate.UTC.apply(this, match) + offset - 12622780800000;
1261
+ }
1262
+
1263
+ // compute a new UTC date value, accounting for the optional offset
1264
+ return NativeDate.UTC.apply(this, match) + offset;
1265
+ }
1266
+ return NativeDate.parse.apply(this, arguments);
1267
+ };
1268
+
1269
+ return Date;
1270
+ })(Date);
1271
+ }
1272
+
1273
+ //
1274
+ // String
1275
+ // ======
1276
+ //
1277
+
1278
+ // ES5 15.5.4.20
1279
+ // http://es5.github.com/#x15.5.4.20
1280
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1281
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1282
+ "\u2029\uFEFF";
1283
+ if (!String.prototype.trim || ws.trim()) {
1284
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1285
+ // http://perfectionkills.com/whitespace-deviations/
1286
+ ws = "[" + ws + "]";
1287
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1288
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1289
+ String.prototype.trim = function trim() {
1290
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
1291
+ };
1292
+ }
1293
+
1294
+ //
1295
+ // Util
1296
+ // ======
1297
+ //
1298
+
1299
+ // ES5 9.4
1300
+ // http://es5.github.com/#x9.4
1301
+ // http://jsperf.com/to-integer
1302
+ var toInteger = function (n) {
1303
+ n = +n;
1304
+ if (n !== n) // isNaN
1305
+ n = 0;
1306
+ else if (n !== 0 && n !== (1/0) && n !== -(1/0))
1307
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
1308
+ return n;
1309
+ };
1310
+
1311
+ var prepareString = "a"[0] != "a",
1312
+ // ES5 9.9
1313
+ // http://es5.github.com/#x9.9
1314
+ toObject = function (o) {
1315
+ if (o == null) { // this matches both null and undefined
1316
+ throw new TypeError(); // TODO message
1317
+ }
1318
+ // If the implementation doesn't support by-index access of
1319
+ // string characters (ex. IE < 7), split the string
1320
+ if (prepareString && typeof o == "string" && o) {
1321
+ return o.split("");
1322
+ }
1323
+ return Object(o);
1324
+ };
1325
+ });/* vim:ts=4:sts=4:sw=4:
1326
+ * ***** BEGIN LICENSE BLOCK *****
1327
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1328
+ *
1329
+ * The contents of this file are subject to the Mozilla Public License Version
1330
+ * 1.1 (the "License"); you may not use this file except in compliance with
1331
+ * the License. You may obtain a copy of the License at
1332
+ * http://www.mozilla.org/MPL/
1333
+ *
1334
+ * Software distributed under the License is distributed on an "AS IS" basis,
1335
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1336
+ * for the specific language governing rights and limitations under the
1337
+ * License.
1338
+ *
1339
+ * The Original Code is Ajax.org Code Editor (ACE).
1340
+ *
1341
+ * The Initial Developer of the Original Code is
1342
+ * Ajax.org B.V.
1343
+ * Portions created by the Initial Developer are Copyright (C) 2010
1344
+ * the Initial Developer. All Rights Reserved.
1345
+ *
1346
+ * Contributor(s):
1347
+ * Fabian Jakobs <fabian AT ajax DOT org>
1348
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
1349
+ * Mike de Boer <mike AT ajax DOT org>
1350
+ *
1351
+ * Alternatively, the contents of this file may be used under the terms of
1352
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
1353
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1354
+ * in which case the provisions of the GPL or the LGPL are applicable instead
1355
+ * of those above. If you wish to allow use of your version of this file only
1356
+ * under the terms of either the GPL or the LGPL, and not to allow others to
1357
+ * use your version of this file under the terms of the MPL, indicate your
1358
+ * decision by deleting the provisions above and replace them with the notice
1359
+ * and other provisions required by the GPL or the LGPL. If you do not delete
1360
+ * the provisions above, a recipient may use your version of this file under
1361
+ * the terms of any one of the MPL, the GPL or the LGPL.
1362
+ *
1363
+ * ***** END LICENSE BLOCK ***** */
1364
+
1365
+ define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
1366
+ "use strict";
1367
+
1368
+ var EventEmitter = {};
1369
+
1370
+ EventEmitter._emit =
1371
+ EventEmitter._dispatchEvent = function(eventName, e) {
1372
+ this._eventRegistry = this._eventRegistry || {};
1373
+ this._defaultHandlers = this._defaultHandlers || {};
1374
+
1375
+ var listeners = this._eventRegistry[eventName] || [];
1376
+ var defaultHandler = this._defaultHandlers[eventName];
1377
+ if (!listeners.length && !defaultHandler)
1378
+ return;
1379
+
1380
+ e = e || {};
1381
+ e.type = eventName;
1382
+
1383
+ if (!e.stopPropagation) {
1384
+ e.stopPropagation = function() {
1385
+ this.propagationStopped = true;
1386
+ };
1387
+ }
1388
+
1389
+ if (!e.preventDefault) {
1390
+ e.preventDefault = function() {
1391
+ this.defaultPrevented = true;
1392
+ };
1393
+ }
1394
+
1395
+ for (var i=0; i<listeners.length; i++) {
1396
+ listeners[i](e);
1397
+ if (e.propagationStopped)
1398
+ break;
1399
+ }
1400
+
1401
+ if (defaultHandler && !e.defaultPrevented)
1402
+ defaultHandler(e);
1403
+ };
1404
+
1405
+ EventEmitter.setDefaultHandler = function(eventName, callback) {
1406
+ this._defaultHandlers = this._defaultHandlers || {};
1407
+
1408
+ if (this._defaultHandlers[eventName])
1409
+ throw new Error("The default handler for '" + eventName + "' is already set");
1410
+
1411
+ this._defaultHandlers[eventName] = callback;
1412
+ };
1413
+
1414
+ EventEmitter.on =
1415
+ EventEmitter.addEventListener = function(eventName, callback) {
1416
+ this._eventRegistry = this._eventRegistry || {};
1417
+
1418
+ var listeners = this._eventRegistry[eventName];
1419
+ if (!listeners)
1420
+ var listeners = this._eventRegistry[eventName] = [];
1421
+
1422
+ if (listeners.indexOf(callback) == -1)
1423
+ listeners.push(callback);
1424
+ };
1425
+
1426
+ EventEmitter.removeListener =
1427
+ EventEmitter.removeEventListener = function(eventName, callback) {
1428
+ this._eventRegistry = this._eventRegistry || {};
1429
+
1430
+ var listeners = this._eventRegistry[eventName];
1431
+ if (!listeners)
1432
+ return;
1433
+
1434
+ var index = listeners.indexOf(callback);
1435
+ if (index !== -1)
1436
+ listeners.splice(index, 1);
1437
+ };
1438
+
1439
+ EventEmitter.removeAllListeners = function(eventName) {
1440
+ if (this._eventRegistry) this._eventRegistry[eventName] = [];
1441
+ };
1442
+
1443
+ exports.EventEmitter = EventEmitter;
1444
+
1445
+ });/* ***** BEGIN LICENSE BLOCK *****
1446
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1447
+ *
1448
+ * The contents of this file are subject to the Mozilla Public License Version
1449
+ * 1.1 (the "License"); you may not use this file except in compliance with
1450
+ * the License. You may obtain a copy of the License at
1451
+ * http://www.mozilla.org/MPL/
1452
+ *
1453
+ * Software distributed under the License is distributed on an "AS IS" basis,
1454
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1455
+ * for the specific language governing rights and limitations under the
1456
+ * License.
1457
+ *
1458
+ * The Original Code is Ajax.org Code Editor (ACE).
1459
+ *
1460
+ * The Initial Developer of the Original Code is
1461
+ * Ajax.org B.V.
1462
+ * Portions created by the Initial Developer are Copyright (C) 2010
1463
+ * the Initial Developer. All Rights Reserved.
1464
+ *
1465
+ * Contributor(s):
1466
+ * Fabian Jakobs <fabian AT ajax DOT org>
1467
+ *
1468
+ * Alternatively, the contents of this file may be used under the terms of
1469
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
1470
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1471
+ * in which case the provisions of the GPL or the LGPL are applicable instead
1472
+ * of those above. If you wish to allow use of your version of this file only
1473
+ * under the terms of either the GPL or the LGPL, and not to allow others to
1474
+ * use your version of this file under the terms of the MPL, indicate your
1475
+ * decision by deleting the provisions above and replace them with the notice
1476
+ * and other provisions required by the GPL or the LGPL. If you do not delete
1477
+ * the provisions above, a recipient may use your version of this file under
1478
+ * the terms of any one of the MPL, the GPL or the LGPL.
1479
+ *
1480
+ * ***** END LICENSE BLOCK ***** */
1481
+
1482
+ define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
1483
+ "use strict";
1484
+
1485
+ exports.inherits = (function() {
1486
+ var tempCtor = function() {};
1487
+ return function(ctor, superCtor) {
1488
+ tempCtor.prototype = superCtor.prototype;
1489
+ ctor.super_ = superCtor.prototype;
1490
+ ctor.prototype = new tempCtor();
1491
+ ctor.prototype.constructor = ctor;
1492
+ };
1493
+ }());
1494
+
1495
+ exports.mixin = function(obj, mixin) {
1496
+ for (var key in mixin) {
1497
+ obj[key] = mixin[key];
1498
+ }
1499
+ };
1500
+
1501
+ exports.implement = function(proto, mixin) {
1502
+ exports.mixin(proto, mixin);
1503
+ };
1504
+
1505
+ });
1506
+ /* ***** BEGIN LICENSE BLOCK *****
1507
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1508
+ *
1509
+ * The contents of this file are subject to the Mozilla Public License Version
1510
+ * 1.1 (the "License"); you may not use this file except in compliance with
1511
+ * the License. You may obtain a copy of the License at
1512
+ * http://www.mozilla.org/MPL/
1513
+ *
1514
+ * Software distributed under the License is distributed on an "AS IS" basis,
1515
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1516
+ * for the specific language governing rights and limitations under the
1517
+ * License.
1518
+ *
1519
+ * The Original Code is Ajax.org Code Editor (ACE).
1520
+ *
1521
+ * The Initial Developer of the Original Code is
1522
+ * Ajax.org B.V.
1523
+ * Portions created by the Initial Developer are Copyright (C) 2010
1524
+ * the Initial Developer. All Rights Reserved.
1525
+ *
1526
+ * Contributor(s):
1527
+ * Fabian Jakobs <fabian AT ajax DOT org>
1528
+ *
1529
+ * Alternatively, the contents of this file may be used under the terms of
1530
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
1531
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1532
+ * in which case the provisions of the GPL or the LGPL are applicable instead
1533
+ * of those above. If you wish to allow use of your version of this file only
1534
+ * under the terms of either the GPL or the LGPL, and not to allow others to
1535
+ * use your version of this file under the terms of the MPL, indicate your
1536
+ * decision by deleting the provisions above and replace them with the notice
1537
+ * and other provisions required by the GPL or the LGPL. If you do not delete
1538
+ * the provisions above, a recipient may use your version of this file under
1539
+ * the terms of any one of the MPL, the GPL or the LGPL.
1540
+ *
1541
+ * ***** END LICENSE BLOCK ***** */
1542
+
1543
+ define('ace/mode/json_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/json/json_parse'], function(require, exports, module) {
1544
+ "use strict";
1545
+
1546
+ var oop = require("../lib/oop");
1547
+ var Mirror = require("../worker/mirror").Mirror;
1548
+ var parse = require("./json/json_parse");
1549
+
1550
+ var JsonWorker = exports.JsonWorker = function(sender) {
1551
+ Mirror.call(this, sender);
1552
+ this.setTimeout(200);
1553
+ };
1554
+
1555
+ oop.inherits(JsonWorker, Mirror);
1556
+
1557
+ (function() {
1558
+
1559
+ this.onUpdate = function() {
1560
+ var value = this.doc.getValue();
1561
+
1562
+ try {
1563
+ var result = parse(value);
1564
+ } catch (e) {
1565
+ var pos = this.charToDocumentPosition(e.at-1);
1566
+ this.sender.emit("error", {
1567
+ row: pos.row,
1568
+ column: pos.column,
1569
+ text: e.message,
1570
+ type: "error"
1571
+ });
1572
+ return;
1573
+ }
1574
+ this.sender.emit("ok");
1575
+ };
1576
+
1577
+ this.charToDocumentPosition = function(charPos) {
1578
+ var i = 0;
1579
+ var len = this.doc.getLength();
1580
+ var nl = this.doc.getNewLineCharacter().length;
1581
+
1582
+ if (!len) {
1583
+ return { row: 0, column: 0};
1584
+ }
1585
+
1586
+ var lineStart = 0;
1587
+ while (i < len) {
1588
+ var line = this.doc.getLine(i);
1589
+ var lineLength = line.length + nl;
1590
+ if (lineStart + lineLength > charPos)
1591
+ return {
1592
+ row: i,
1593
+ column: charPos - lineStart
1594
+ };
1595
+
1596
+ lineStart += lineLength;
1597
+ i += 1;
1598
+ }
1599
+
1600
+ return {
1601
+ row: i-1,
1602
+ column: line.length
1603
+ };
1604
+ };
1605
+
1606
+ }).call(JsonWorker.prototype);
1607
+
1608
+ });define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) {
1609
+ "use strict";
1610
+
1611
+ var Document = require("../document").Document;
1612
+ var lang = require("../lib/lang");
1613
+
1614
+ var Mirror = exports.Mirror = function(sender) {
1615
+ this.sender = sender;
1616
+ var doc = this.doc = new Document("");
1617
+
1618
+ var deferredUpdate = this.deferredUpdate = lang.deferredCall(this.onUpdate.bind(this));
1619
+
1620
+ var _self = this;
1621
+ sender.on("change", function(e) {
1622
+ doc.applyDeltas([e.data]);
1623
+ deferredUpdate.schedule(_self.$timeout);
1624
+ });
1625
+ };
1626
+
1627
+ (function() {
1628
+
1629
+ this.$timeout = 500;
1630
+
1631
+ this.setTimeout = function(timeout) {
1632
+ this.$timeout = timeout;
1633
+ };
1634
+
1635
+ this.setValue = function(value) {
1636
+ this.doc.setValue(value);
1637
+ this.deferredUpdate.schedule(this.$timeout);
1638
+ };
1639
+
1640
+ this.getValue = function(callbackId) {
1641
+ this.sender.callback(this.doc.getValue(), callbackId);
1642
+ };
1643
+
1644
+ this.onUpdate = function() {
1645
+ // abstract method
1646
+ };
1647
+
1648
+ }).call(Mirror.prototype);
1649
+
1650
+ });/* ***** BEGIN LICENSE BLOCK *****
1651
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1652
+ *
1653
+ * The contents of this file are subject to the Mozilla Public License Version
1654
+ * 1.1 (the "License"); you may not use this file except in compliance with
1655
+ * the License. You may obtain a copy of the License at
1656
+ * http://www.mozilla.org/MPL/
1657
+ *
1658
+ * Software distributed under the License is distributed on an "AS IS" basis,
1659
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1660
+ * for the specific language governing rights and limitations under the
1661
+ * License.
1662
+ *
1663
+ * The Original Code is Ajax.org Code Editor (ACE).
1664
+ *
1665
+ * The Initial Developer of the Original Code is
1666
+ * Ajax.org B.V.
1667
+ * Portions created by the Initial Developer are Copyright (C) 2010
1668
+ * the Initial Developer. All Rights Reserved.
1669
+ *
1670
+ * Contributor(s):
1671
+ * Fabian Jakobs <fabian AT ajax DOT org>
1672
+ *
1673
+ * Alternatively, the contents of this file may be used under the terms of
1674
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
1675
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1676
+ * in which case the provisions of the GPL or the LGPL are applicable instead
1677
+ * of those above. If you wish to allow use of your version of this file only
1678
+ * under the terms of either the GPL or the LGPL, and not to allow others to
1679
+ * use your version of this file under the terms of the MPL, indicate your
1680
+ * decision by deleting the provisions above and replace them with the notice
1681
+ * and other provisions required by the GPL or the LGPL. If you do not delete
1682
+ * the provisions above, a recipient may use your version of this file under
1683
+ * the terms of any one of the MPL, the GPL or the LGPL.
1684
+ *
1685
+ * ***** END LICENSE BLOCK ***** */
1686
+
1687
+ define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
1688
+ "use strict";
1689
+
1690
+ var oop = require("./lib/oop");
1691
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
1692
+ var Range = require("./range").Range;
1693
+ var Anchor = require("./anchor").Anchor;
1694
+
1695
+ var Document = function(text) {
1696
+ this.$lines = [];
1697
+
1698
+ if (Array.isArray(text)) {
1699
+ this.insertLines(0, text);
1700
+ }
1701
+ // There has to be one line at least in the document. If you pass an empty
1702
+ // string to the insert function, nothing will happen. Workaround.
1703
+ else if (text.length == 0) {
1704
+ this.$lines = [""];
1705
+ } else {
1706
+ this.insert({row: 0, column:0}, text);
1707
+ }
1708
+ };
1709
+
1710
+ (function() {
1711
+
1712
+ oop.implement(this, EventEmitter);
1713
+
1714
+ this.setValue = function(text) {
1715
+ var len = this.getLength();
1716
+ this.remove(new Range(0, 0, len, this.getLine(len-1).length));
1717
+ this.insert({row: 0, column:0}, text);
1718
+ };
1719
+
1720
+ this.getValue = function() {
1721
+ return this.getAllLines().join(this.getNewLineCharacter());
1722
+ };
1723
+
1724
+ this.createAnchor = function(row, column) {
1725
+ return new Anchor(this, row, column);
1726
+ };
1727
+
1728
+ // check for IE split bug
1729
+ if ("aaa".split(/a/).length == 0)
1730
+ this.$split = function(text) {
1731
+ return text.replace(/\r\n|\r/g, "\n").split("\n");
1732
+ }
1733
+ else
1734
+ this.$split = function(text) {
1735
+ return text.split(/\r\n|\r|\n/);
1736
+ };
1737
+
1738
+
1739
+ this.$detectNewLine = function(text) {
1740
+ var match = text.match(/^.*?(\r\n|\r|\n)/m);
1741
+ if (match) {
1742
+ this.$autoNewLine = match[1];
1743
+ } else {
1744
+ this.$autoNewLine = "\n";
1745
+ }
1746
+ };
1747
+
1748
+ this.getNewLineCharacter = function() {
1749
+ switch (this.$newLineMode) {
1750
+ case "windows":
1751
+ return "\r\n";
1752
+
1753
+ case "unix":
1754
+ return "\n";
1755
+
1756
+ case "auto":
1757
+ return this.$autoNewLine;
1758
+ }
1759
+ };
1760
+
1761
+ this.$autoNewLine = "\n";
1762
+ this.$newLineMode = "auto";
1763
+ this.setNewLineMode = function(newLineMode) {
1764
+ if (this.$newLineMode === newLineMode)
1765
+ return;
1766
+
1767
+ this.$newLineMode = newLineMode;
1768
+ };
1769
+
1770
+ this.getNewLineMode = function() {
1771
+ return this.$newLineMode;
1772
+ };
1773
+
1774
+ this.isNewLine = function(text) {
1775
+ return (text == "\r\n" || text == "\r" || text == "\n");
1776
+ };
1777
+
1778
+ /**
1779
+ * Get a verbatim copy of the given line as it is in the document
1780
+ */
1781
+ this.getLine = function(row) {
1782
+ return this.$lines[row] || "";
1783
+ };
1784
+
1785
+ this.getLines = function(firstRow, lastRow) {
1786
+ return this.$lines.slice(firstRow, lastRow + 1);
1787
+ };
1788
+
1789
+ /**
1790
+ * Returns all lines in the document as string array. Warning: The caller
1791
+ * should not modify this array!
1792
+ */
1793
+ this.getAllLines = function() {
1794
+ return this.getLines(0, this.getLength());
1795
+ };
1796
+
1797
+ this.getLength = function() {
1798
+ return this.$lines.length;
1799
+ };
1800
+
1801
+ this.getTextRange = function(range) {
1802
+ if (range.start.row == range.end.row) {
1803
+ return this.$lines[range.start.row].substring(range.start.column,
1804
+ range.end.column);
1805
+ }
1806
+ else {
1807
+ var lines = [];
1808
+ lines.push(this.$lines[range.start.row].substring(range.start.column));
1809
+ lines.push.apply(lines, this.getLines(range.start.row+1, range.end.row-1));
1810
+ lines.push(this.$lines[range.end.row].substring(0, range.end.column));
1811
+ return lines.join(this.getNewLineCharacter());
1812
+ }
1813
+ };
1814
+
1815
+ this.$clipPosition = function(position) {
1816
+ var length = this.getLength();
1817
+ if (position.row >= length) {
1818
+ position.row = Math.max(0, length - 1);
1819
+ position.column = this.getLine(length-1).length;
1820
+ }
1821
+ return position;
1822
+ };
1823
+
1824
+ this.insert = function(position, text) {
1825
+ if (!text || text.length === 0)
1826
+ return position;
1827
+
1828
+ position = this.$clipPosition(position);
1829
+
1830
+ if (this.getLength() <= 1)
1831
+ this.$detectNewLine(text);
1832
+
1833
+ var lines = this.$split(text);
1834
+ var firstLine = lines.splice(0, 1)[0];
1835
+ var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
1836
+
1837
+ position = this.insertInLine(position, firstLine);
1838
+ if (lastLine !== null) {
1839
+ position = this.insertNewLine(position); // terminate first line
1840
+ position = this.insertLines(position.row, lines);
1841
+ position = this.insertInLine(position, lastLine || "");
1842
+ }
1843
+ return position;
1844
+ };
1845
+
1846
+ this.insertLines = function(row, lines) {
1847
+ if (lines.length == 0)
1848
+ return {row: row, column: 0};
1849
+
1850
+ var args = [row, 0];
1851
+ args.push.apply(args, lines);
1852
+ this.$lines.splice.apply(this.$lines, args);
1853
+
1854
+ var range = new Range(row, 0, row + lines.length, 0);
1855
+ var delta = {
1856
+ action: "insertLines",
1857
+ range: range,
1858
+ lines: lines
1859
+ };
1860
+ this._emit("change", { data: delta });
1861
+ return range.end;
1862
+ };
1863
+
1864
+ this.insertNewLine = function(position) {
1865
+ position = this.$clipPosition(position);
1866
+ var line = this.$lines[position.row] || "";
1867
+
1868
+ this.$lines[position.row] = line.substring(0, position.column);
1869
+ this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
1870
+
1871
+ var end = {
1872
+ row : position.row + 1,
1873
+ column : 0
1874
+ };
1875
+
1876
+ var delta = {
1877
+ action: "insertText",
1878
+ range: Range.fromPoints(position, end),
1879
+ text: this.getNewLineCharacter()
1880
+ };
1881
+ this._emit("change", { data: delta });
1882
+
1883
+ return end;
1884
+ };
1885
+
1886
+ this.insertInLine = function(position, text) {
1887
+ if (text.length == 0)
1888
+ return position;
1889
+
1890
+ var line = this.$lines[position.row] || "";
1891
+
1892
+ this.$lines[position.row] = line.substring(0, position.column) + text
1893
+ + line.substring(position.column);
1894
+
1895
+ var end = {
1896
+ row : position.row,
1897
+ column : position.column + text.length
1898
+ };
1899
+
1900
+ var delta = {
1901
+ action: "insertText",
1902
+ range: Range.fromPoints(position, end),
1903
+ text: text
1904
+ };
1905
+ this._emit("change", { data: delta });
1906
+
1907
+ return end;
1908
+ };
1909
+
1910
+ this.remove = function(range) {
1911
+ // clip to document
1912
+ range.start = this.$clipPosition(range.start);
1913
+ range.end = this.$clipPosition(range.end);
1914
+
1915
+ if (range.isEmpty())
1916
+ return range.start;
1917
+
1918
+ var firstRow = range.start.row;
1919
+ var lastRow = range.end.row;
1920
+
1921
+ if (range.isMultiLine()) {
1922
+ var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
1923
+ var lastFullRow = lastRow - 1;
1924
+
1925
+ if (range.end.column > 0)
1926
+ this.removeInLine(lastRow, 0, range.end.column);
1927
+
1928
+ if (lastFullRow >= firstFullRow)
1929
+ this.removeLines(firstFullRow, lastFullRow);
1930
+
1931
+ if (firstFullRow != firstRow) {
1932
+ this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
1933
+ this.removeNewLine(range.start.row);
1934
+ }
1935
+ }
1936
+ else {
1937
+ this.removeInLine(firstRow, range.start.column, range.end.column);
1938
+ }
1939
+ return range.start;
1940
+ };
1941
+
1942
+ this.removeInLine = function(row, startColumn, endColumn) {
1943
+ if (startColumn == endColumn)
1944
+ return;
1945
+
1946
+ var range = new Range(row, startColumn, row, endColumn);
1947
+ var line = this.getLine(row);
1948
+ var removed = line.substring(startColumn, endColumn);
1949
+ var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
1950
+ this.$lines.splice(row, 1, newLine);
1951
+
1952
+ var delta = {
1953
+ action: "removeText",
1954
+ range: range,
1955
+ text: removed
1956
+ };
1957
+ this._emit("change", { data: delta });
1958
+ return range.start;
1959
+ };
1960
+
1961
+ /**
1962
+ * Removes a range of full lines
1963
+ *
1964
+ * @param firstRow {Integer} The first row to be removed
1965
+ * @param lastRow {Integer} The last row to be removed
1966
+ * @return {String[]} The removed lines
1967
+ */
1968
+ this.removeLines = function(firstRow, lastRow) {
1969
+ var range = new Range(firstRow, 0, lastRow + 1, 0);
1970
+ var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
1971
+
1972
+ var delta = {
1973
+ action: "removeLines",
1974
+ range: range,
1975
+ nl: this.getNewLineCharacter(),
1976
+ lines: removed
1977
+ };
1978
+ this._emit("change", { data: delta });
1979
+ return removed;
1980
+ };
1981
+
1982
+ this.removeNewLine = function(row) {
1983
+ var firstLine = this.getLine(row);
1984
+ var secondLine = this.getLine(row+1);
1985
+
1986
+ var range = new Range(row, firstLine.length, row+1, 0);
1987
+ var line = firstLine + secondLine;
1988
+
1989
+ this.$lines.splice(row, 2, line);
1990
+
1991
+ var delta = {
1992
+ action: "removeText",
1993
+ range: range,
1994
+ text: this.getNewLineCharacter()
1995
+ };
1996
+ this._emit("change", { data: delta });
1997
+ };
1998
+
1999
+ this.replace = function(range, text) {
2000
+ if (text.length == 0 && range.isEmpty())
2001
+ return range.start;
2002
+
2003
+ // Shortcut: If the text we want to insert is the same as it is already
2004
+ // in the document, we don't have to replace anything.
2005
+ if (text == this.getTextRange(range))
2006
+ return range.end;
2007
+
2008
+ this.remove(range);
2009
+ if (text) {
2010
+ var end = this.insert(range.start, text);
2011
+ }
2012
+ else {
2013
+ end = range.start;
2014
+ }
2015
+
2016
+ return end;
2017
+ };
2018
+
2019
+ this.applyDeltas = function(deltas) {
2020
+ for (var i=0; i<deltas.length; i++) {
2021
+ var delta = deltas[i];
2022
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
2023
+
2024
+ if (delta.action == "insertLines")
2025
+ this.insertLines(range.start.row, delta.lines);
2026
+ else if (delta.action == "insertText")
2027
+ this.insert(range.start, delta.text);
2028
+ else if (delta.action == "removeLines")
2029
+ this.removeLines(range.start.row, range.end.row - 1);
2030
+ else if (delta.action == "removeText")
2031
+ this.remove(range);
2032
+ }
2033
+ };
2034
+
2035
+ this.revertDeltas = function(deltas) {
2036
+ for (var i=deltas.length-1; i>=0; i--) {
2037
+ var delta = deltas[i];
2038
+
2039
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
2040
+
2041
+ if (delta.action == "insertLines")
2042
+ this.removeLines(range.start.row, range.end.row - 1);
2043
+ else if (delta.action == "insertText")
2044
+ this.remove(range);
2045
+ else if (delta.action == "removeLines")
2046
+ this.insertLines(range.start.row, delta.lines);
2047
+ else if (delta.action == "removeText")
2048
+ this.insert(range.start, delta.text);
2049
+ }
2050
+ };
2051
+
2052
+ }).call(Document.prototype);
2053
+
2054
+ exports.Document = Document;
2055
+ });
2056
+ /* ***** BEGIN LICENSE BLOCK *****
2057
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2058
+ *
2059
+ * The contents of this file are subject to the Mozilla Public License Version
2060
+ * 1.1 (the "License"); you may not use this file except in compliance with
2061
+ * the License. You may obtain a copy of the License at
2062
+ * http://www.mozilla.org/MPL/
2063
+ *
2064
+ * Software distributed under the License is distributed on an "AS IS" basis,
2065
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2066
+ * for the specific language governing rights and limitations under the
2067
+ * License.
2068
+ *
2069
+ * The Original Code is Ajax.org Code Editor (ACE).
2070
+ *
2071
+ * The Initial Developer of the Original Code is
2072
+ * Ajax.org B.V.
2073
+ * Portions created by the Initial Developer are Copyright (C) 2010
2074
+ * the Initial Developer. All Rights Reserved.
2075
+ *
2076
+ * Contributor(s):
2077
+ * Fabian Jakobs <fabian AT ajax DOT org>
2078
+ *
2079
+ * Alternatively, the contents of this file may be used under the terms of
2080
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
2081
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2082
+ * in which case the provisions of the GPL or the LGPL are applicable instead
2083
+ * of those above. If you wish to allow use of your version of this file only
2084
+ * under the terms of either the GPL or the LGPL, and not to allow others to
2085
+ * use your version of this file under the terms of the MPL, indicate your
2086
+ * decision by deleting the provisions above and replace them with the notice
2087
+ * and other provisions required by the GPL or the LGPL. If you do not delete
2088
+ * the provisions above, a recipient may use your version of this file under
2089
+ * the terms of any one of the MPL, the GPL or the LGPL.
2090
+ *
2091
+ * ***** END LICENSE BLOCK ***** */
2092
+
2093
+ define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
2094
+ "use strict";
2095
+
2096
+ var Range = function(startRow, startColumn, endRow, endColumn) {
2097
+ this.start = {
2098
+ row: startRow,
2099
+ column: startColumn
2100
+ };
2101
+
2102
+ this.end = {
2103
+ row: endRow,
2104
+ column: endColumn
2105
+ };
2106
+ };
2107
+
2108
+ (function() {
2109
+ this.isEequal = function(range) {
2110
+ return this.start.row == range.start.row &&
2111
+ this.end.row == range.end.row &&
2112
+ this.start.column == range.start.column &&
2113
+ this.end.column == range.end.column
2114
+ };
2115
+
2116
+ this.toString = function() {
2117
+ return ("Range: [" + this.start.row + "/" + this.start.column +
2118
+ "] -> [" + this.end.row + "/" + this.end.column + "]");
2119
+ };
2120
+
2121
+ this.contains = function(row, column) {
2122
+ return this.compare(row, column) == 0;
2123
+ };
2124
+
2125
+ /**
2126
+ * Compares this range (A) with another range (B), where B is the passed in
2127
+ * range.
2128
+ *
2129
+ * Return values:
2130
+ * -2: (B) is infront of (A) and doesn't intersect with (A)
2131
+ * -1: (B) begins before (A) but ends inside of (A)
2132
+ * 0: (B) is completly inside of (A) OR (A) is complety inside of (B)
2133
+ * +1: (B) begins inside of (A) but ends outside of (A)
2134
+ * +2: (B) is after (A) and doesn't intersect with (A)
2135
+ *
2136
+ * 42: FTW state: (B) ends in (A) but starts outside of (A)
2137
+ */
2138
+ this.compareRange = function(range) {
2139
+ var cmp,
2140
+ end = range.end,
2141
+ start = range.start;
2142
+
2143
+ cmp = this.compare(end.row, end.column);
2144
+ if (cmp == 1) {
2145
+ cmp = this.compare(start.row, start.column);
2146
+ if (cmp == 1) {
2147
+ return 2;
2148
+ } else if (cmp == 0) {
2149
+ return 1;
2150
+ } else {
2151
+ return 0;
2152
+ }
2153
+ } else if (cmp == -1) {
2154
+ return -2;
2155
+ } else {
2156
+ cmp = this.compare(start.row, start.column);
2157
+ if (cmp == -1) {
2158
+ return -1;
2159
+ } else if (cmp == 1) {
2160
+ return 42;
2161
+ } else {
2162
+ return 0;
2163
+ }
2164
+ }
2165
+ }
2166
+
2167
+ this.comparePoint = function(p) {
2168
+ return this.compare(p.row, p.column);
2169
+ }
2170
+
2171
+ this.containsRange = function(range) {
2172
+ return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
2173
+ }
2174
+
2175
+ this.isEnd = function(row, column) {
2176
+ return this.end.row == row && this.end.column == column;
2177
+ }
2178
+
2179
+ this.isStart = function(row, column) {
2180
+ return this.start.row == row && this.start.column == column;
2181
+ }
2182
+
2183
+ this.setStart = function(row, column) {
2184
+ if (typeof row == "object") {
2185
+ this.start.column = row.column;
2186
+ this.start.row = row.row;
2187
+ } else {
2188
+ this.start.row = row;
2189
+ this.start.column = column;
2190
+ }
2191
+ }
2192
+
2193
+ this.setEnd = function(row, column) {
2194
+ if (typeof row == "object") {
2195
+ this.end.column = row.column;
2196
+ this.end.row = row.row;
2197
+ } else {
2198
+ this.end.row = row;
2199
+ this.end.column = column;
2200
+ }
2201
+ }
2202
+
2203
+ this.inside = function(row, column) {
2204
+ if (this.compare(row, column) == 0) {
2205
+ if (this.isEnd(row, column) || this.isStart(row, column)) {
2206
+ return false;
2207
+ } else {
2208
+ return true;
2209
+ }
2210
+ }
2211
+ return false;
2212
+ }
2213
+
2214
+ this.insideStart = function(row, column) {
2215
+ if (this.compare(row, column) == 0) {
2216
+ if (this.isEnd(row, column)) {
2217
+ return false;
2218
+ } else {
2219
+ return true;
2220
+ }
2221
+ }
2222
+ return false;
2223
+ }
2224
+
2225
+ this.insideEnd = function(row, column) {
2226
+ if (this.compare(row, column) == 0) {
2227
+ if (this.isStart(row, column)) {
2228
+ return false;
2229
+ } else {
2230
+ return true;
2231
+ }
2232
+ }
2233
+ return false;
2234
+ }
2235
+
2236
+ this.compare = function(row, column) {
2237
+ if (!this.isMultiLine()) {
2238
+ if (row === this.start.row) {
2239
+ return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
2240
+ };
2241
+ }
2242
+
2243
+ if (row < this.start.row)
2244
+ return -1;
2245
+
2246
+ if (row > this.end.row)
2247
+ return 1;
2248
+
2249
+ if (this.start.row === row)
2250
+ return column >= this.start.column ? 0 : -1;
2251
+
2252
+ if (this.end.row === row)
2253
+ return column <= this.end.column ? 0 : 1;
2254
+
2255
+ return 0;
2256
+ };
2257
+
2258
+ /**
2259
+ * Like .compare(), but if isStart is true, return -1;
2260
+ */
2261
+ this.compareStart = function(row, column) {
2262
+ if (this.start.row == row && this.start.column == column) {
2263
+ return -1;
2264
+ } else {
2265
+ return this.compare(row, column);
2266
+ }
2267
+ }
2268
+
2269
+ /**
2270
+ * Like .compare(), but if isEnd is true, return 1;
2271
+ */
2272
+ this.compareEnd = function(row, column) {
2273
+ if (this.end.row == row && this.end.column == column) {
2274
+ return 1;
2275
+ } else {
2276
+ return this.compare(row, column);
2277
+ }
2278
+ }
2279
+
2280
+ this.compareInside = function(row, column) {
2281
+ if (this.end.row == row && this.end.column == column) {
2282
+ return 1;
2283
+ } else if (this.start.row == row && this.start.column == column) {
2284
+ return -1;
2285
+ } else {
2286
+ return this.compare(row, column);
2287
+ }
2288
+ }
2289
+
2290
+ this.clipRows = function(firstRow, lastRow) {
2291
+ if (this.end.row > lastRow) {
2292
+ var end = {
2293
+ row: lastRow+1,
2294
+ column: 0
2295
+ };
2296
+ }
2297
+
2298
+ if (this.start.row > lastRow) {
2299
+ var start = {
2300
+ row: lastRow+1,
2301
+ column: 0
2302
+ };
2303
+ }
2304
+
2305
+ if (this.start.row < firstRow) {
2306
+ var start = {
2307
+ row: firstRow,
2308
+ column: 0
2309
+ };
2310
+ }
2311
+
2312
+ if (this.end.row < firstRow) {
2313
+ var end = {
2314
+ row: firstRow,
2315
+ column: 0
2316
+ };
2317
+ }
2318
+ return Range.fromPoints(start || this.start, end || this.end);
2319
+ };
2320
+
2321
+ this.extend = function(row, column) {
2322
+ var cmp = this.compare(row, column);
2323
+
2324
+ if (cmp == 0)
2325
+ return this;
2326
+ else if (cmp == -1)
2327
+ var start = {row: row, column: column};
2328
+ else
2329
+ var end = {row: row, column: column};
2330
+
2331
+ return Range.fromPoints(start || this.start, end || this.end);
2332
+ };
2333
+
2334
+ this.isEmpty = function() {
2335
+ return (this.start.row == this.end.row && this.start.column == this.end.column);
2336
+ };
2337
+
2338
+ this.isMultiLine = function() {
2339
+ return (this.start.row !== this.end.row);
2340
+ };
2341
+
2342
+ this.clone = function() {
2343
+ return Range.fromPoints(this.start, this.end);
2344
+ };
2345
+
2346
+ this.collapseRows = function() {
2347
+ if (this.end.column == 0)
2348
+ return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
2349
+ else
2350
+ return new Range(this.start.row, 0, this.end.row, 0)
2351
+ };
2352
+
2353
+ this.toScreenRange = function(session) {
2354
+ var screenPosStart =
2355
+ session.documentToScreenPosition(this.start);
2356
+ var screenPosEnd =
2357
+ session.documentToScreenPosition(this.end);
2358
+
2359
+ return new Range(
2360
+ screenPosStart.row, screenPosStart.column,
2361
+ screenPosEnd.row, screenPosEnd.column
2362
+ );
2363
+ };
2364
+
2365
+ }).call(Range.prototype);
2366
+
2367
+
2368
+ Range.fromPoints = function(start, end) {
2369
+ return new Range(start.row, start.column, end.row, end.column);
2370
+ };
2371
+
2372
+ exports.Range = Range;
2373
+ });
2374
+ /* ***** BEGIN LICENSE BLOCK *****
2375
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2376
+ *
2377
+ * The contents of this file are subject to the Mozilla Public License Version
2378
+ * 1.1 (the "License"); you may not use this file except in compliance with
2379
+ * the License. You may obtain a copy of the License at
2380
+ * http://www.mozilla.org/MPL/
2381
+ *
2382
+ * Software distributed under the License is distributed on an "AS IS" basis,
2383
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2384
+ * for the specific language governing rights and limitations under the
2385
+ * License.
2386
+ *
2387
+ * The Original Code is Ajax.org Code Editor (ACE).
2388
+ *
2389
+ * The Initial Developer of the Original Code is
2390
+ * Ajax.org B.V.
2391
+ * Portions created by the Initial Developer are Copyright (C) 2010
2392
+ * the Initial Developer. All Rights Reserved.
2393
+ *
2394
+ * Contributor(s):
2395
+ * Fabian Jakobs <fabian AT ajax DOT org>
2396
+ *
2397
+ * Alternatively, the contents of this file may be used under the terms of
2398
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
2399
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2400
+ * in which case the provisions of the GPL or the LGPL are applicable instead
2401
+ * of those above. If you wish to allow use of your version of this file only
2402
+ * under the terms of either the GPL or the LGPL, and not to allow others to
2403
+ * use your version of this file under the terms of the MPL, indicate your
2404
+ * decision by deleting the provisions above and replace them with the notice
2405
+ * and other provisions required by the GPL or the LGPL. If you do not delete
2406
+ * the provisions above, a recipient may use your version of this file under
2407
+ * the terms of any one of the MPL, the GPL or the LGPL.
2408
+ *
2409
+ * ***** END LICENSE BLOCK ***** */
2410
+
2411
+ define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
2412
+ "use strict";
2413
+
2414
+ var oop = require("./lib/oop");
2415
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
2416
+
2417
+ /**
2418
+ * An Anchor is a floating pointer in the document. Whenever text is inserted or
2419
+ * deleted before the cursor, the position of the cursor is updated
2420
+ */
2421
+ var Anchor = exports.Anchor = function(doc, row, column) {
2422
+ this.document = doc;
2423
+
2424
+ if (typeof column == "undefined")
2425
+ this.setPosition(row.row, row.column);
2426
+ else
2427
+ this.setPosition(row, column);
2428
+
2429
+ this.$onChange = this.onChange.bind(this);
2430
+ doc.on("change", this.$onChange);
2431
+ };
2432
+
2433
+ (function() {
2434
+
2435
+ oop.implement(this, EventEmitter);
2436
+
2437
+ this.getPosition = function() {
2438
+ return this.$clipPositionToDocument(this.row, this.column);
2439
+ };
2440
+
2441
+ this.getDocument = function() {
2442
+ return this.document;
2443
+ };
2444
+
2445
+ this.onChange = function(e) {
2446
+ var delta = e.data;
2447
+ var range = delta.range;
2448
+
2449
+ if (range.start.row == range.end.row && range.start.row != this.row)
2450
+ return;
2451
+
2452
+ if (range.start.row > this.row)
2453
+ return;
2454
+
2455
+ if (range.start.row == this.row && range.start.column > this.column)
2456
+ return;
2457
+
2458
+ var row = this.row;
2459
+ var column = this.column;
2460
+
2461
+ if (delta.action === "insertText") {
2462
+ if (range.start.row === row && range.start.column <= column) {
2463
+ if (range.start.row === range.end.row) {
2464
+ column += range.end.column - range.start.column;
2465
+ }
2466
+ else {
2467
+ column -= range.start.column;
2468
+ row += range.end.row - range.start.row;
2469
+ }
2470
+ }
2471
+ else if (range.start.row !== range.end.row && range.start.row < row) {
2472
+ row += range.end.row - range.start.row;
2473
+ }
2474
+ } else if (delta.action === "insertLines") {
2475
+ if (range.start.row <= row) {
2476
+ row += range.end.row - range.start.row;
2477
+ }
2478
+ }
2479
+ else if (delta.action == "removeText") {
2480
+ if (range.start.row == row && range.start.column < column) {
2481
+ if (range.end.column >= column)
2482
+ column = range.start.column;
2483
+ else
2484
+ column = Math.max(0, column - (range.end.column - range.start.column));
2485
+
2486
+ } else if (range.start.row !== range.end.row && range.start.row < row) {
2487
+ if (range.end.row == row) {
2488
+ column = Math.max(0, column - range.end.column) + range.start.column;
2489
+ }
2490
+ row -= (range.end.row - range.start.row);
2491
+ }
2492
+ else if (range.end.row == row) {
2493
+ row -= range.end.row - range.start.row;
2494
+ column = Math.max(0, column - range.end.column) + range.start.column;
2495
+ }
2496
+ } else if (delta.action == "removeLines") {
2497
+ if (range.start.row <= row) {
2498
+ if (range.end.row <= row)
2499
+ row -= range.end.row - range.start.row;
2500
+ else {
2501
+ row = range.start.row;
2502
+ column = 0;
2503
+ }
2504
+ }
2505
+ }
2506
+
2507
+ this.setPosition(row, column, true);
2508
+ };
2509
+
2510
+ this.setPosition = function(row, column, noClip) {
2511
+ var pos;
2512
+ if (noClip) {
2513
+ pos = {
2514
+ row: row,
2515
+ column: column
2516
+ };
2517
+ }
2518
+ else {
2519
+ pos = this.$clipPositionToDocument(row, column);
2520
+ }
2521
+
2522
+ if (this.row == pos.row && this.column == pos.column)
2523
+ return;
2524
+
2525
+ var old = {
2526
+ row: this.row,
2527
+ column: this.column
2528
+ };
2529
+
2530
+ this.row = pos.row;
2531
+ this.column = pos.column;
2532
+ this._emit("change", {
2533
+ old: old,
2534
+ value: pos
2535
+ });
2536
+ };
2537
+
2538
+ this.detach = function() {
2539
+ this.document.removeEventListener("change", this.$onChange);
2540
+ };
2541
+
2542
+ this.$clipPositionToDocument = function(row, column) {
2543
+ var pos = {};
2544
+
2545
+ if (row >= this.document.getLength()) {
2546
+ pos.row = Math.max(0, this.document.getLength() - 1);
2547
+ pos.column = this.document.getLine(pos.row).length;
2548
+ }
2549
+ else if (row < 0) {
2550
+ pos.row = 0;
2551
+ pos.column = 0;
2552
+ }
2553
+ else {
2554
+ pos.row = row;
2555
+ pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
2556
+ }
2557
+
2558
+ if (column < 0)
2559
+ pos.column = 0;
2560
+
2561
+ return pos;
2562
+ };
2563
+
2564
+ }).call(Anchor.prototype);
2565
+
2566
+ });
2567
+ /* ***** BEGIN LICENSE BLOCK *****
2568
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2569
+ *
2570
+ * The contents of this file are subject to the Mozilla Public License Version
2571
+ * 1.1 (the "License"); you may not use this file except in compliance with
2572
+ * the License. You may obtain a copy of the License at
2573
+ * http://www.mozilla.org/MPL/
2574
+ *
2575
+ * Software distributed under the License is distributed on an "AS IS" basis,
2576
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2577
+ * for the specific language governing rights and limitations under the
2578
+ * License.
2579
+ *
2580
+ * The Original Code is Ajax.org Code Editor (ACE).
2581
+ *
2582
+ * The Initial Developer of the Original Code is
2583
+ * Ajax.org B.V.
2584
+ * Portions created by the Initial Developer are Copyright (C) 2010
2585
+ * the Initial Developer. All Rights Reserved.
2586
+ *
2587
+ * Contributor(s):
2588
+ * Fabian Jakobs <fabian AT ajax DOT org>
2589
+ *
2590
+ * Alternatively, the contents of this file may be used under the terms of
2591
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
2592
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2593
+ * in which case the provisions of the GPL or the LGPL are applicable instead
2594
+ * of those above. If you wish to allow use of your version of this file only
2595
+ * under the terms of either the GPL or the LGPL, and not to allow others to
2596
+ * use your version of this file under the terms of the MPL, indicate your
2597
+ * decision by deleting the provisions above and replace them with the notice
2598
+ * and other provisions required by the GPL or the LGPL. If you do not delete
2599
+ * the provisions above, a recipient may use your version of this file under
2600
+ * the terms of any one of the MPL, the GPL or the LGPL.
2601
+ *
2602
+ * ***** END LICENSE BLOCK ***** */
2603
+
2604
+ define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
2605
+ "use strict";
2606
+
2607
+ exports.stringReverse = function(string) {
2608
+ return string.split("").reverse().join("");
2609
+ };
2610
+
2611
+ exports.stringRepeat = function (string, count) {
2612
+ return new Array(count + 1).join(string);
2613
+ };
2614
+
2615
+ var trimBeginRegexp = /^\s\s*/;
2616
+ var trimEndRegexp = /\s\s*$/;
2617
+
2618
+ exports.stringTrimLeft = function (string) {
2619
+ return string.replace(trimBeginRegexp, '');
2620
+ };
2621
+
2622
+ exports.stringTrimRight = function (string) {
2623
+ return string.replace(trimEndRegexp, '');
2624
+ };
2625
+
2626
+ exports.copyObject = function(obj) {
2627
+ var copy = {};
2628
+ for (var key in obj) {
2629
+ copy[key] = obj[key];
2630
+ }
2631
+ return copy;
2632
+ };
2633
+
2634
+ exports.copyArray = function(array){
2635
+ var copy = [];
2636
+ for (var i=0, l=array.length; i<l; i++) {
2637
+ if (array[i] && typeof array[i] == "object")
2638
+ copy[i] = this.copyObject( array[i] );
2639
+ else
2640
+ copy[i] = array[i];
2641
+ }
2642
+ return copy;
2643
+ };
2644
+
2645
+ exports.deepCopy = function (obj) {
2646
+ if (typeof obj != "object") {
2647
+ return obj;
2648
+ }
2649
+
2650
+ var copy = obj.constructor();
2651
+ for (var key in obj) {
2652
+ if (typeof obj[key] == "object") {
2653
+ copy[key] = this.deepCopy(obj[key]);
2654
+ } else {
2655
+ copy[key] = obj[key];
2656
+ }
2657
+ }
2658
+ return copy;
2659
+ };
2660
+
2661
+ exports.arrayToMap = function(arr) {
2662
+ var map = {};
2663
+ for (var i=0; i<arr.length; i++) {
2664
+ map[arr[i]] = 1;
2665
+ }
2666
+ return map;
2667
+
2668
+ };
2669
+
2670
+ /**
2671
+ * splice out of 'array' anything that === 'value'
2672
+ */
2673
+ exports.arrayRemove = function(array, value) {
2674
+ for (var i = 0; i <= array.length; i++) {
2675
+ if (value === array[i]) {
2676
+ array.splice(i, 1);
2677
+ }
2678
+ }
2679
+ };
2680
+
2681
+ exports.escapeRegExp = function(str) {
2682
+ return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
2683
+ };
2684
+
2685
+ exports.deferredCall = function(fcn) {
2686
+
2687
+ var timer = null;
2688
+ var callback = function() {
2689
+ timer = null;
2690
+ fcn();
2691
+ };
2692
+
2693
+ var deferred = function(timeout) {
2694
+ deferred.cancel();
2695
+ timer = setTimeout(callback, timeout || 0);
2696
+ return deferred;
2697
+ };
2698
+
2699
+ deferred.schedule = deferred;
2700
+
2701
+ deferred.call = function() {
2702
+ this.cancel();
2703
+ fcn();
2704
+ return deferred;
2705
+ };
2706
+
2707
+ deferred.cancel = function() {
2708
+ clearTimeout(timer);
2709
+ timer = null;
2710
+ return deferred;
2711
+ };
2712
+
2713
+ return deferred;
2714
+ };
2715
+
2716
+ });
2717
+ /*
2718
+ http://www.JSON.org/json_parse.js
2719
+ 2008-09-18
2720
+
2721
+ Public Domain.
2722
+
2723
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
2724
+
2725
+ This file creates a json_parse function.
2726
+
2727
+ json_parse(text, reviver)
2728
+ This method parses a JSON text to produce an object or array.
2729
+ It can throw a SyntaxError exception.
2730
+
2731
+ The optional reviver parameter is a function that can filter and
2732
+ transform the results. It receives each of the keys and values,
2733
+ and its return value is used instead of the original value.
2734
+ If it returns what it received, then the structure is not modified.
2735
+ If it returns undefined then the member is deleted.
2736
+
2737
+ Example:
2738
+
2739
+ // Parse the text. Values that look like ISO date strings will
2740
+ // be converted to Date objects.
2741
+
2742
+ myData = json_parse(text, function (key, value) {
2743
+ var a;
2744
+ if (typeof value === 'string') {
2745
+ a =
2746
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
2747
+ if (a) {
2748
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
2749
+ +a[5], +a[6]));
2750
+ }
2751
+ }
2752
+ return value;
2753
+ });
2754
+
2755
+ This is a reference implementation. You are free to copy, modify, or
2756
+ redistribute.
2757
+
2758
+ This code should be minified before deployment.
2759
+ See http://javascript.crockford.com/jsmin.html
2760
+
2761
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
2762
+ NOT CONTROL.
2763
+ */
2764
+
2765
+ /*members "", "\"", "\/", "\\", at, b, call, charAt, f, fromCharCode,
2766
+ hasOwnProperty, message, n, name, push, r, t, text
2767
+ */
2768
+
2769
+ define('ace/mode/json/json_parse', ['require', 'exports', 'module' ], function(require, exports, module) {
2770
+ "use strict";
2771
+
2772
+ // This is a function that can parse a JSON text, producing a JavaScript
2773
+ // data structure. It is a simple, recursive descent parser. It does not use
2774
+ // eval or regular expressions, so it can be used as a model for implementing
2775
+ // a JSON parser in other languages.
2776
+
2777
+ // We are defining the function inside of another function to avoid creating
2778
+ // global variables.
2779
+
2780
+ var at, // The index of the current character
2781
+ ch, // The current character
2782
+ escapee = {
2783
+ '"': '"',
2784
+ '\\': '\\',
2785
+ '/': '/',
2786
+ b: '\b',
2787
+ f: '\f',
2788
+ n: '\n',
2789
+ r: '\r',
2790
+ t: '\t'
2791
+ },
2792
+ text,
2793
+
2794
+ error = function (m) {
2795
+
2796
+ // Call error when something is wrong.
2797
+
2798
+ throw {
2799
+ name: 'SyntaxError',
2800
+ message: m,
2801
+ at: at,
2802
+ text: text
2803
+ };
2804
+ },
2805
+
2806
+ next = function (c) {
2807
+
2808
+ // If a c parameter is provided, verify that it matches the current character.
2809
+
2810
+ if (c && c !== ch) {
2811
+ error("Expected '" + c + "' instead of '" + ch + "'");
2812
+ }
2813
+
2814
+ // Get the next character. When there are no more characters,
2815
+ // return the empty string.
2816
+
2817
+ ch = text.charAt(at);
2818
+ at += 1;
2819
+ return ch;
2820
+ },
2821
+
2822
+ number = function () {
2823
+
2824
+ // Parse a number value.
2825
+
2826
+ var number,
2827
+ string = '';
2828
+
2829
+ if (ch === '-') {
2830
+ string = '-';
2831
+ next('-');
2832
+ }
2833
+ while (ch >= '0' && ch <= '9') {
2834
+ string += ch;
2835
+ next();
2836
+ }
2837
+ if (ch === '.') {
2838
+ string += '.';
2839
+ while (next() && ch >= '0' && ch <= '9') {
2840
+ string += ch;
2841
+ }
2842
+ }
2843
+ if (ch === 'e' || ch === 'E') {
2844
+ string += ch;
2845
+ next();
2846
+ if (ch === '-' || ch === '+') {
2847
+ string += ch;
2848
+ next();
2849
+ }
2850
+ while (ch >= '0' && ch <= '9') {
2851
+ string += ch;
2852
+ next();
2853
+ }
2854
+ }
2855
+ number = +string;
2856
+ if (isNaN(number)) {
2857
+ error("Bad number");
2858
+ } else {
2859
+ return number;
2860
+ }
2861
+ },
2862
+
2863
+ string = function () {
2864
+
2865
+ // Parse a string value.
2866
+
2867
+ var hex,
2868
+ i,
2869
+ string = '',
2870
+ uffff;
2871
+
2872
+ // When parsing for string values, we must look for " and \ characters.
2873
+
2874
+ if (ch === '"') {
2875
+ while (next()) {
2876
+ if (ch === '"') {
2877
+ next();
2878
+ return string;
2879
+ } else if (ch === '\\') {
2880
+ next();
2881
+ if (ch === 'u') {
2882
+ uffff = 0;
2883
+ for (i = 0; i < 4; i += 1) {
2884
+ hex = parseInt(next(), 16);
2885
+ if (!isFinite(hex)) {
2886
+ break;
2887
+ }
2888
+ uffff = uffff * 16 + hex;
2889
+ }
2890
+ string += String.fromCharCode(uffff);
2891
+ } else if (typeof escapee[ch] === 'string') {
2892
+ string += escapee[ch];
2893
+ } else {
2894
+ break;
2895
+ }
2896
+ } else {
2897
+ string += ch;
2898
+ }
2899
+ }
2900
+ }
2901
+ error("Bad string");
2902
+ },
2903
+
2904
+ white = function () {
2905
+
2906
+ // Skip whitespace.
2907
+
2908
+ while (ch && ch <= ' ') {
2909
+ next();
2910
+ }
2911
+ },
2912
+
2913
+ word = function () {
2914
+
2915
+ // true, false, or null.
2916
+
2917
+ switch (ch) {
2918
+ case 't':
2919
+ next('t');
2920
+ next('r');
2921
+ next('u');
2922
+ next('e');
2923
+ return true;
2924
+ case 'f':
2925
+ next('f');
2926
+ next('a');
2927
+ next('l');
2928
+ next('s');
2929
+ next('e');
2930
+ return false;
2931
+ case 'n':
2932
+ next('n');
2933
+ next('u');
2934
+ next('l');
2935
+ next('l');
2936
+ return null;
2937
+ }
2938
+ error("Unexpected '" + ch + "'");
2939
+ },
2940
+
2941
+ value, // Place holder for the value function.
2942
+
2943
+ array = function () {
2944
+
2945
+ // Parse an array value.
2946
+
2947
+ var array = [];
2948
+
2949
+ if (ch === '[') {
2950
+ next('[');
2951
+ white();
2952
+ if (ch === ']') {
2953
+ next(']');
2954
+ return array; // empty array
2955
+ }
2956
+ while (ch) {
2957
+ array.push(value());
2958
+ white();
2959
+ if (ch === ']') {
2960
+ next(']');
2961
+ return array;
2962
+ }
2963
+ next(',');
2964
+ white();
2965
+ }
2966
+ }
2967
+ error("Bad array");
2968
+ },
2969
+
2970
+ object = function () {
2971
+
2972
+ // Parse an object value.
2973
+
2974
+ var key,
2975
+ object = {};
2976
+
2977
+ if (ch === '{') {
2978
+ next('{');
2979
+ white();
2980
+ if (ch === '}') {
2981
+ next('}');
2982
+ return object; // empty object
2983
+ }
2984
+ while (ch) {
2985
+ key = string();
2986
+ white();
2987
+ next(':');
2988
+ if (Object.hasOwnProperty.call(object, key)) {
2989
+ error('Duplicate key "' + key + '"');
2990
+ }
2991
+ object[key] = value();
2992
+ white();
2993
+ if (ch === '}') {
2994
+ next('}');
2995
+ return object;
2996
+ }
2997
+ next(',');
2998
+ white();
2999
+ }
3000
+ }
3001
+ error("Bad object");
3002
+ };
3003
+
3004
+ value = function () {
3005
+
3006
+ // Parse a JSON value. It could be an object, an array, a string, a number,
3007
+ // or a word.
3008
+
3009
+ white();
3010
+ switch (ch) {
3011
+ case '{':
3012
+ return object();
3013
+ case '[':
3014
+ return array();
3015
+ case '"':
3016
+ return string();
3017
+ case '-':
3018
+ return number();
3019
+ default:
3020
+ return ch >= '0' && ch <= '9' ? number() : word();
3021
+ }
3022
+ };
3023
+
3024
+ // Return the json_parse function. It will have access to all of the above
3025
+ // functions and variables.
3026
+
3027
+ return function (source, reviver) {
3028
+ var result;
3029
+
3030
+ text = source;
3031
+ at = 0;
3032
+ ch = ' ';
3033
+ result = value();
3034
+ white();
3035
+ if (ch) {
3036
+ error("Syntax error");
3037
+ }
3038
+
3039
+ // If there is a reviver function, we recursively walk the new structure,
3040
+ // passing each name/value pair to the reviver function for possible
3041
+ // transformation, starting with a temporary root object that holds the result
3042
+ // in an empty key. If there is not a reviver function, we simply return the
3043
+ // result.
3044
+
3045
+ return typeof reviver === 'function' ? function walk(holder, key) {
3046
+ var k, v, value = holder[key];
3047
+ if (value && typeof value === 'object') {
3048
+ for (k in value) {
3049
+ if (Object.hasOwnProperty.call(value, k)) {
3050
+ v = walk(value, k);
3051
+ if (v !== undefined) {
3052
+ value[k] = v;
3053
+ } else {
3054
+ delete value[k];
3055
+ }
3056
+ }
3057
+ }
3058
+ }
3059
+ return reviver.call(holder, key, value);
3060
+ }({'': result}, '') : result;
3061
+ };
3062
+ });