ace-rails-ap 0.0.2 → 0.0.3

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