daftos 0.1.0 → 0.2.0

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