datagram 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/.env.sample +7 -0
  2. data/.gitignore +20 -0
  3. data/.rbenv-version +1 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +22 -0
  6. data/Procfile +1 -0
  7. data/README.md +29 -0
  8. data/Rakefile +1 -0
  9. data/config.ru +5 -0
  10. data/datagram.gemspec +23 -0
  11. data/db/migrate/1_create_queries.rb +9 -0
  12. data/db/migrate/2_add_name_to_queries.rb +5 -0
  13. data/lib/datagram/version.rb +3 -0
  14. data/lib/datagram.rb +135 -0
  15. data/lib/views/application.coffee +222 -0
  16. data/lib/views/index.haml +47 -0
  17. data/lib/views/layout.haml +17 -0
  18. data/lib/views/style.sass +179 -0
  19. data/public/ace/ace.js +15209 -0
  20. data/public/ace/ext-elastic_tabstops_lite.js +301 -0
  21. data/public/ace/ext-emmet.js +253 -0
  22. data/public/ace/ext-searchbox.js +441 -0
  23. data/public/ace/ext-spellcheck.js +67 -0
  24. data/public/ace/ext-static_highlight.js +96 -0
  25. data/public/ace/ext-textarea.js +492 -0
  26. data/public/ace/ext-whitespace.js +204 -0
  27. data/public/ace/keybinding-emacs.js +962 -0
  28. data/public/ace/keybinding-vim.js +1704 -0
  29. data/public/ace/mode-abap.js +260 -0
  30. data/public/ace/mode-asciidoc.js +372 -0
  31. data/public/ace/mode-c9search.js +182 -0
  32. data/public/ace/mode-c_cpp.js +737 -0
  33. data/public/ace/mode-clojure.js +299 -0
  34. data/public/ace/mode-coffee.js +426 -0
  35. data/public/ace/mode-coldfusion.js +1753 -0
  36. data/public/ace/mode-csharp.js +612 -0
  37. data/public/ace/mode-css.js +773 -0
  38. data/public/ace/mode-curly.js +1950 -0
  39. data/public/ace/mode-dart.js +945 -0
  40. data/public/ace/mode-diff.js +166 -0
  41. data/public/ace/mode-django.js +1969 -0
  42. data/public/ace/mode-dot.js +320 -0
  43. data/public/ace/mode-ftl.js +907 -0
  44. data/public/ace/mode-glsl.js +810 -0
  45. data/public/ace/mode-golang.js +632 -0
  46. data/public/ace/mode-groovy.js +1037 -0
  47. data/public/ace/mode-haml.js +487 -0
  48. data/public/ace/mode-haxe.js +609 -0
  49. data/public/ace/mode-html.js +1881 -0
  50. data/public/ace/mode-jade.js +1951 -0
  51. data/public/ace/mode-java.js +996 -0
  52. data/public/ace/mode-javascript.js +876 -0
  53. data/public/ace/mode-json.js +578 -0
  54. data/public/ace/mode-jsp.js +1351 -0
  55. data/public/ace/mode-jsx.js +635 -0
  56. data/public/ace/mode-latex.js +189 -0
  57. data/public/ace/mode-less.js +807 -0
  58. data/public/ace/mode-liquid.js +862 -0
  59. data/public/ace/mode-lisp.js +138 -0
  60. data/public/ace/mode-livescript.js +288 -0
  61. data/public/ace/mode-logiql.js +664 -0
  62. data/public/ace/mode-lsl.js +828 -0
  63. data/public/ace/mode-lua.js +455 -0
  64. data/public/ace/mode-luapage.js +2340 -0
  65. data/public/ace/mode-lucene.js +64 -0
  66. data/public/ace/mode-makefile.js +313 -0
  67. data/public/ace/mode-markdown.js +2280 -0
  68. data/public/ace/mode-mushcode.js +704 -0
  69. data/public/ace/mode-mushcode_high_rules.js +569 -0
  70. data/public/ace/mode-objectivec.js +659 -0
  71. data/public/ace/mode-ocaml.js +443 -0
  72. data/public/ace/mode-pascal.js +233 -0
  73. data/public/ace/mode-perl.js +316 -0
  74. data/public/ace/mode-pgsql.js +908 -0
  75. data/public/ace/mode-php.js +2291 -0
  76. data/public/ace/mode-powershell.js +618 -0
  77. data/public/ace/mode-python.js +264 -0
  78. data/public/ace/mode-r.js +404 -0
  79. data/public/ace/mode-rdoc.js +184 -0
  80. data/public/ace/mode-rhtml.js +2168 -0
  81. data/public/ace/mode-ruby.js +431 -0
  82. data/public/ace/mode-sass.js +442 -0
  83. data/public/ace/mode-scad.js +670 -0
  84. data/public/ace/mode-scala.js +1025 -0
  85. data/public/ace/mode-scheme.js +144 -0
  86. data/public/ace/mode-scss.js +832 -0
  87. data/public/ace/mode-sh.js +204 -0
  88. data/public/ace/mode-sql.js +118 -0
  89. data/public/ace/mode-stylus.js +483 -0
  90. data/public/ace/mode-svg.js +1442 -0
  91. data/public/ace/mode-tcl.js +319 -0
  92. data/public/ace/mode-tex.js +166 -0
  93. data/public/ace/mode-text.js +0 -0
  94. data/public/ace/mode-textile.js +170 -0
  95. data/public/ace/mode-tmsnippet.js +200 -0
  96. data/public/ace/mode-toml.js +180 -0
  97. data/public/ace/mode-typescript.js +961 -0
  98. data/public/ace/mode-vbscript.js +281 -0
  99. data/public/ace/mode-velocity.js +962 -0
  100. data/public/ace/mode-xml.js +789 -0
  101. data/public/ace/mode-xquery.js +2750 -0
  102. data/public/ace/mode-yaml.js +289 -0
  103. data/public/ace/theme-ambiance.js +202 -0
  104. data/public/ace/theme-chaos.js +182 -0
  105. data/public/ace/theme-chrome.js +161 -0
  106. data/public/ace/theme-clouds.js +135 -0
  107. data/public/ace/theme-clouds_midnight.js +136 -0
  108. data/public/ace/theme-cobalt.js +150 -0
  109. data/public/ace/theme-crimson_editor.js +154 -0
  110. data/public/ace/theme-dawn.js +146 -0
  111. data/public/ace/theme-dreamweaver.js +173 -0
  112. data/public/ace/theme-eclipse.js +122 -0
  113. data/public/ace/theme-github.js +136 -0
  114. data/public/ace/theme-idle_fingers.js +136 -0
  115. data/public/ace/theme-kr.js +143 -0
  116. data/public/ace/theme-merbivore.js +135 -0
  117. data/public/ace/theme-merbivore_soft.js +136 -0
  118. data/public/ace/theme-mono_industrial.js +148 -0
  119. data/public/ace/theme-monokai.js +140 -0
  120. data/public/ace/theme-pastel_on_dark.js +148 -0
  121. data/public/ace/theme-solarized_dark.js +128 -0
  122. data/public/ace/theme-solarized_light.js +131 -0
  123. data/public/ace/theme-terminal.js +154 -0
  124. data/public/ace/theme-textmate.js +0 -0
  125. data/public/ace/theme-tomorrow.js +147 -0
  126. data/public/ace/theme-tomorrow_night.js +147 -0
  127. data/public/ace/theme-tomorrow_night_blue.js +145 -0
  128. data/public/ace/theme-tomorrow_night_bright.js +147 -0
  129. data/public/ace/theme-tomorrow_night_eighties.js +144 -0
  130. data/public/ace/theme-twilight.js +147 -0
  131. data/public/ace/theme-vibrant_ink.js +131 -0
  132. data/public/ace/theme-xcode.js +125 -0
  133. data/public/ace/worker-coffee.js +7091 -0
  134. data/public/ace/worker-css.js +8289 -0
  135. data/public/ace/worker-javascript.js +6496 -0
  136. data/public/ace/worker-json.js +2305 -0
  137. data/public/ace/worker-lua.js +3313 -0
  138. data/public/ace/worker-php.js +6743 -0
  139. data/public/ace/worker-xquery.js +21897 -0
  140. data/public/font/FontAwesome.otf +0 -0
  141. data/public/font/fontawesome-webfont.eot +0 -0
  142. data/public/font/fontawesome-webfont.svg +284 -0
  143. data/public/font/fontawesome-webfont.ttf +0 -0
  144. data/public/font/fontawesome-webfont.woff +0 -0
  145. data/public/font-awesome.css +540 -0
  146. data/public/jquery.js +9597 -0
  147. data/script/migrate.sh +2 -0
  148. metadata +242 -0
@@ -0,0 +1,2305 @@
1
+ "no use strict";
2
+ ;(function(window) {
3
+ if (typeof window.window != "undefined" && window.document) {
4
+ return;
5
+ }
6
+
7
+ window.console = {
8
+ log: function() {
9
+ var msgs = Array.prototype.slice.call(arguments, 0);
10
+ postMessage({type: "log", data: msgs});
11
+ },
12
+ error: function() {
13
+ var msgs = Array.prototype.slice.call(arguments, 0);
14
+ postMessage({type: "log", data: msgs});
15
+ }
16
+ };
17
+ window.window = window;
18
+ window.ace = window;
19
+
20
+ window.normalizeModule = function(parentId, moduleName) {
21
+ // normalize plugin requires
22
+ if (moduleName.indexOf("!") !== -1) {
23
+ var chunks = moduleName.split("!");
24
+ return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
25
+ }
26
+ // normalize relative requires
27
+ if (moduleName.charAt(0) == ".") {
28
+ var base = parentId.split("/").slice(0, -1).join("/");
29
+ moduleName = base + "/" + moduleName;
30
+
31
+ while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
32
+ var previous = moduleName;
33
+ moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
34
+ }
35
+ }
36
+
37
+ return moduleName;
38
+ };
39
+
40
+ window.require = function(parentId, id) {
41
+ if (!id.charAt)
42
+ throw new Error("worker.js require() accepts only (parentId, id) as arguments");
43
+
44
+ id = normalizeModule(parentId, id);
45
+
46
+ var module = require.modules[id];
47
+ if (module) {
48
+ if (!module.initialized) {
49
+ module.initialized = true;
50
+ module.exports = module.factory().exports;
51
+ }
52
+ return module.exports;
53
+ }
54
+
55
+ var chunks = id.split("/");
56
+ chunks[0] = require.tlns[chunks[0]] || chunks[0];
57
+ var path = chunks.join("/") + ".js";
58
+
59
+ require.id = id;
60
+ importScripts(path);
61
+ return require(parentId, id);
62
+ };
63
+
64
+ require.modules = {};
65
+ require.tlns = {};
66
+
67
+ window.define = function(id, deps, factory) {
68
+ if (arguments.length == 2) {
69
+ factory = deps;
70
+ if (typeof id != "string") {
71
+ deps = id;
72
+ id = require.id;
73
+ }
74
+ } else if (arguments.length == 1) {
75
+ factory = id;
76
+ id = require.id;
77
+ }
78
+
79
+ if (id.indexOf("text!") === 0)
80
+ return;
81
+
82
+ var req = function(deps, factory) {
83
+ return require(id, deps, factory);
84
+ };
85
+
86
+ require.modules[id] = {
87
+ factory: function() {
88
+ var module = {
89
+ exports: {}
90
+ };
91
+ var returnExports = factory(req, module.exports, module);
92
+ if (returnExports)
93
+ module.exports = returnExports;
94
+ return module;
95
+ }
96
+ };
97
+ };
98
+
99
+ window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
100
+ require.tlns = topLevelNamespaces;
101
+ }
102
+
103
+ window.initSender = function initSender() {
104
+
105
+ var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
106
+ var oop = require(null, "ace/lib/oop");
107
+
108
+ var Sender = function() {};
109
+
110
+ (function() {
111
+
112
+ oop.implement(this, EventEmitter);
113
+
114
+ this.callback = function(data, callbackId) {
115
+ postMessage({
116
+ type: "call",
117
+ id: callbackId,
118
+ data: data
119
+ });
120
+ };
121
+
122
+ this.emit = function(name, data) {
123
+ postMessage({
124
+ type: "event",
125
+ name: name,
126
+ data: data
127
+ });
128
+ };
129
+
130
+ }).call(Sender.prototype);
131
+
132
+ return new Sender();
133
+ }
134
+
135
+ window.main = null;
136
+ window.sender = null;
137
+
138
+ window.onmessage = function(e) {
139
+ var msg = e.data;
140
+ if (msg.command) {
141
+ if (main[msg.command])
142
+ main[msg.command].apply(main, msg.args);
143
+ else
144
+ throw new Error("Unknown command:" + msg.command);
145
+ }
146
+ else if (msg.init) {
147
+ initBaseUrls(msg.tlns);
148
+ require(null, "ace/lib/fixoldbrowsers");
149
+ sender = initSender();
150
+ var clazz = require(null, msg.module)[msg.classname];
151
+ main = new clazz(sender);
152
+ }
153
+ else if (msg.event && sender) {
154
+ sender._emit(msg.event, msg.data);
155
+ }
156
+ };
157
+ })(this);// vim:set ts=4 sts=4 sw=4 st:
158
+
159
+ define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
160
+
161
+
162
+ require("./regexp");
163
+ require("./es5-shim");
164
+
165
+ });
166
+
167
+ define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
168
+
169
+ var real = {
170
+ exec: RegExp.prototype.exec,
171
+ test: RegExp.prototype.test,
172
+ match: String.prototype.match,
173
+ replace: String.prototype.replace,
174
+ split: String.prototype.split
175
+ },
176
+ compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
177
+ compliantLastIndexIncrement = function () {
178
+ var x = /^/g;
179
+ real.test.call(x, "");
180
+ return !x.lastIndex;
181
+ }();
182
+
183
+ if (compliantLastIndexIncrement && compliantExecNpcg)
184
+ return;
185
+ RegExp.prototype.exec = function (str) {
186
+ var match = real.exec.apply(this, arguments),
187
+ name, r2;
188
+ if ( typeof(str) == 'string' && match) {
189
+ if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
190
+ r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
191
+ real.replace.call(str.slice(match.index), r2, function () {
192
+ for (var i = 1; i < arguments.length - 2; i++) {
193
+ if (arguments[i] === undefined)
194
+ match[i] = undefined;
195
+ }
196
+ });
197
+ }
198
+ if (this._xregexp && this._xregexp.captureNames) {
199
+ for (var i = 1; i < match.length; i++) {
200
+ name = this._xregexp.captureNames[i - 1];
201
+ if (name)
202
+ match[name] = match[i];
203
+ }
204
+ }
205
+ if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
206
+ this.lastIndex--;
207
+ }
208
+ return match;
209
+ };
210
+ if (!compliantLastIndexIncrement) {
211
+ RegExp.prototype.test = function (str) {
212
+ var match = real.exec.call(this, str);
213
+ if (match && this.global && !match[0].length && (this.lastIndex > match.index))
214
+ this.lastIndex--;
215
+ return !!match;
216
+ };
217
+ }
218
+
219
+ function getNativeFlags (regex) {
220
+ return (regex.global ? "g" : "") +
221
+ (regex.ignoreCase ? "i" : "") +
222
+ (regex.multiline ? "m" : "") +
223
+ (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
224
+ (regex.sticky ? "y" : "");
225
+ }
226
+
227
+ function indexOf (array, item, from) {
228
+ if (Array.prototype.indexOf) // Use the native array method if available
229
+ return array.indexOf(item, from);
230
+ for (var i = from || 0; i < array.length; i++) {
231
+ if (array[i] === item)
232
+ return i;
233
+ }
234
+ return -1;
235
+ }
236
+
237
+ });
238
+
239
+ define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
240
+
241
+ function Empty() {}
242
+
243
+ if (!Function.prototype.bind) {
244
+ Function.prototype.bind = function bind(that) { // .length is 1
245
+ var target = this;
246
+ if (typeof target != "function") {
247
+ throw new TypeError("Function.prototype.bind called on incompatible " + target);
248
+ }
249
+ var args = slice.call(arguments, 1); // for normal call
250
+ var bound = function () {
251
+
252
+ if (this instanceof bound) {
253
+
254
+ var result = target.apply(
255
+ this,
256
+ args.concat(slice.call(arguments))
257
+ );
258
+ if (Object(result) === result) {
259
+ return result;
260
+ }
261
+ return this;
262
+
263
+ } else {
264
+ return target.apply(
265
+ that,
266
+ args.concat(slice.call(arguments))
267
+ );
268
+
269
+ }
270
+
271
+ };
272
+ if(target.prototype) {
273
+ Empty.prototype = target.prototype;
274
+ bound.prototype = new Empty();
275
+ Empty.prototype = null;
276
+ }
277
+ return bound;
278
+ };
279
+ }
280
+ var call = Function.prototype.call;
281
+ var prototypeOfArray = Array.prototype;
282
+ var prototypeOfObject = Object.prototype;
283
+ var slice = prototypeOfArray.slice;
284
+ var _toString = call.bind(prototypeOfObject.toString);
285
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
286
+ var defineGetter;
287
+ var defineSetter;
288
+ var lookupGetter;
289
+ var lookupSetter;
290
+ var supportsAccessors;
291
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
292
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
293
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
294
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
295
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
296
+ }
297
+ if ([1,2].splice(0).length != 2) {
298
+ if(function() { // test IE < 9 to splice bug - see issue #138
299
+ function makeArray(l) {
300
+ var a = new Array(l+2);
301
+ a[0] = a[1] = 0;
302
+ return a;
303
+ }
304
+ var array = [], lengthBefore;
305
+
306
+ array.splice.apply(array, makeArray(20));
307
+ array.splice.apply(array, makeArray(26));
308
+
309
+ lengthBefore = array.length; //46
310
+ array.splice(5, 0, "XXX"); // add one element
311
+
312
+ lengthBefore + 1 == array.length
313
+
314
+ if (lengthBefore + 1 == array.length) {
315
+ return true;// has right splice implementation without bugs
316
+ }
317
+ }()) {//IE 6/7
318
+ var array_splice = Array.prototype.splice;
319
+ Array.prototype.splice = function(start, deleteCount) {
320
+ if (!arguments.length) {
321
+ return [];
322
+ } else {
323
+ return array_splice.apply(this, [
324
+ start === void 0 ? 0 : start,
325
+ deleteCount === void 0 ? (this.length - start) : deleteCount
326
+ ].concat(slice.call(arguments, 2)))
327
+ }
328
+ };
329
+ } else {//IE8
330
+ Array.prototype.splice = function(pos, removeCount){
331
+ var length = this.length;
332
+ if (pos > 0) {
333
+ if (pos > length)
334
+ pos = length;
335
+ } else if (pos == void 0) {
336
+ pos = 0;
337
+ } else if (pos < 0) {
338
+ pos = Math.max(length + pos, 0);
339
+ }
340
+
341
+ if (!(pos+removeCount < length))
342
+ removeCount = length - pos;
343
+
344
+ var removed = this.slice(pos, pos+removeCount);
345
+ var insert = slice.call(arguments, 2);
346
+ var add = insert.length;
347
+ if (pos === length) {
348
+ if (add) {
349
+ this.push.apply(this, insert);
350
+ }
351
+ } else {
352
+ var remove = Math.min(removeCount, length - pos);
353
+ var tailOldPos = pos + remove;
354
+ var tailNewPos = tailOldPos + add - remove;
355
+ var tailCount = length - tailOldPos;
356
+ var lengthAfterRemove = length - remove;
357
+
358
+ if (tailNewPos < tailOldPos) { // case A
359
+ for (var i = 0; i < tailCount; ++i) {
360
+ this[tailNewPos+i] = this[tailOldPos+i];
361
+ }
362
+ } else if (tailNewPos > tailOldPos) { // case B
363
+ for (i = tailCount; i--; ) {
364
+ this[tailNewPos+i] = this[tailOldPos+i];
365
+ }
366
+ } // else, add == remove (nothing to do)
367
+
368
+ if (add && pos === lengthAfterRemove) {
369
+ this.length = lengthAfterRemove; // truncate array
370
+ this.push.apply(this, insert);
371
+ } else {
372
+ this.length = lengthAfterRemove + add; // reserves space
373
+ for (i = 0; i < add; ++i) {
374
+ this[pos+i] = insert[i];
375
+ }
376
+ }
377
+ }
378
+ return removed;
379
+ };
380
+ }
381
+ }
382
+ if (!Array.isArray) {
383
+ Array.isArray = function isArray(obj) {
384
+ return _toString(obj) == "[object Array]";
385
+ };
386
+ }
387
+ var boxedString = Object("a"),
388
+ splitString = boxedString[0] != "a" || !(0 in boxedString);
389
+
390
+ if (!Array.prototype.forEach) {
391
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
392
+ var object = toObject(this),
393
+ self = splitString && _toString(this) == "[object String]" ?
394
+ this.split("") :
395
+ object,
396
+ thisp = arguments[1],
397
+ i = -1,
398
+ length = self.length >>> 0;
399
+ if (_toString(fun) != "[object Function]") {
400
+ throw new TypeError(); // TODO message
401
+ }
402
+
403
+ while (++i < length) {
404
+ if (i in self) {
405
+ fun.call(thisp, self[i], i, object);
406
+ }
407
+ }
408
+ };
409
+ }
410
+ if (!Array.prototype.map) {
411
+ Array.prototype.map = function map(fun /*, thisp*/) {
412
+ var object = toObject(this),
413
+ self = splitString && _toString(this) == "[object String]" ?
414
+ this.split("") :
415
+ object,
416
+ length = self.length >>> 0,
417
+ result = Array(length),
418
+ thisp = arguments[1];
419
+ if (_toString(fun) != "[object Function]") {
420
+ throw new TypeError(fun + " is not a function");
421
+ }
422
+
423
+ for (var i = 0; i < length; i++) {
424
+ if (i in self)
425
+ result[i] = fun.call(thisp, self[i], i, object);
426
+ }
427
+ return result;
428
+ };
429
+ }
430
+ if (!Array.prototype.filter) {
431
+ Array.prototype.filter = function filter(fun /*, thisp */) {
432
+ var object = toObject(this),
433
+ self = splitString && _toString(this) == "[object String]" ?
434
+ this.split("") :
435
+ object,
436
+ length = self.length >>> 0,
437
+ result = [],
438
+ value,
439
+ thisp = arguments[1];
440
+ if (_toString(fun) != "[object Function]") {
441
+ throw new TypeError(fun + " is not a function");
442
+ }
443
+
444
+ for (var i = 0; i < length; i++) {
445
+ if (i in self) {
446
+ value = self[i];
447
+ if (fun.call(thisp, value, i, object)) {
448
+ result.push(value);
449
+ }
450
+ }
451
+ }
452
+ return result;
453
+ };
454
+ }
455
+ if (!Array.prototype.every) {
456
+ Array.prototype.every = function every(fun /*, thisp */) {
457
+ var object = toObject(this),
458
+ self = splitString && _toString(this) == "[object String]" ?
459
+ this.split("") :
460
+ object,
461
+ length = self.length >>> 0,
462
+ thisp = arguments[1];
463
+ if (_toString(fun) != "[object Function]") {
464
+ throw new TypeError(fun + " is not a function");
465
+ }
466
+
467
+ for (var i = 0; i < length; i++) {
468
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
469
+ return false;
470
+ }
471
+ }
472
+ return true;
473
+ };
474
+ }
475
+ if (!Array.prototype.some) {
476
+ Array.prototype.some = function some(fun /*, thisp */) {
477
+ var object = toObject(this),
478
+ self = splitString && _toString(this) == "[object String]" ?
479
+ this.split("") :
480
+ object,
481
+ length = self.length >>> 0,
482
+ thisp = arguments[1];
483
+ if (_toString(fun) != "[object Function]") {
484
+ throw new TypeError(fun + " is not a function");
485
+ }
486
+
487
+ for (var i = 0; i < length; i++) {
488
+ if (i in self && fun.call(thisp, self[i], i, object)) {
489
+ return true;
490
+ }
491
+ }
492
+ return false;
493
+ };
494
+ }
495
+ if (!Array.prototype.reduce) {
496
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
497
+ var object = toObject(this),
498
+ self = splitString && _toString(this) == "[object String]" ?
499
+ this.split("") :
500
+ object,
501
+ length = self.length >>> 0;
502
+ if (_toString(fun) != "[object Function]") {
503
+ throw new TypeError(fun + " is not a function");
504
+ }
505
+ if (!length && arguments.length == 1) {
506
+ throw new TypeError("reduce of empty array with no initial value");
507
+ }
508
+
509
+ var i = 0;
510
+ var result;
511
+ if (arguments.length >= 2) {
512
+ result = arguments[1];
513
+ } else {
514
+ do {
515
+ if (i in self) {
516
+ result = self[i++];
517
+ break;
518
+ }
519
+ if (++i >= length) {
520
+ throw new TypeError("reduce of empty array with no initial value");
521
+ }
522
+ } while (true);
523
+ }
524
+
525
+ for (; i < length; i++) {
526
+ if (i in self) {
527
+ result = fun.call(void 0, result, self[i], i, object);
528
+ }
529
+ }
530
+
531
+ return result;
532
+ };
533
+ }
534
+ if (!Array.prototype.reduceRight) {
535
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
536
+ var object = toObject(this),
537
+ self = splitString && _toString(this) == "[object String]" ?
538
+ this.split("") :
539
+ object,
540
+ length = self.length >>> 0;
541
+ if (_toString(fun) != "[object Function]") {
542
+ throw new TypeError(fun + " is not a function");
543
+ }
544
+ if (!length && arguments.length == 1) {
545
+ throw new TypeError("reduceRight of empty array with no initial value");
546
+ }
547
+
548
+ var result, i = length - 1;
549
+ if (arguments.length >= 2) {
550
+ result = arguments[1];
551
+ } else {
552
+ do {
553
+ if (i in self) {
554
+ result = self[i--];
555
+ break;
556
+ }
557
+ if (--i < 0) {
558
+ throw new TypeError("reduceRight of empty array with no initial value");
559
+ }
560
+ } while (true);
561
+ }
562
+
563
+ do {
564
+ if (i in this) {
565
+ result = fun.call(void 0, result, self[i], i, object);
566
+ }
567
+ } while (i--);
568
+
569
+ return result;
570
+ };
571
+ }
572
+ if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
573
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
574
+ var self = splitString && _toString(this) == "[object String]" ?
575
+ this.split("") :
576
+ toObject(this),
577
+ length = self.length >>> 0;
578
+
579
+ if (!length) {
580
+ return -1;
581
+ }
582
+
583
+ var i = 0;
584
+ if (arguments.length > 1) {
585
+ i = toInteger(arguments[1]);
586
+ }
587
+ i = i >= 0 ? i : Math.max(0, length + i);
588
+ for (; i < length; i++) {
589
+ if (i in self && self[i] === sought) {
590
+ return i;
591
+ }
592
+ }
593
+ return -1;
594
+ };
595
+ }
596
+ if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
597
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
598
+ var self = splitString && _toString(this) == "[object String]" ?
599
+ this.split("") :
600
+ toObject(this),
601
+ length = self.length >>> 0;
602
+
603
+ if (!length) {
604
+ return -1;
605
+ }
606
+ var i = length - 1;
607
+ if (arguments.length > 1) {
608
+ i = Math.min(i, toInteger(arguments[1]));
609
+ }
610
+ i = i >= 0 ? i : length - Math.abs(i);
611
+ for (; i >= 0; i--) {
612
+ if (i in self && sought === self[i]) {
613
+ return i;
614
+ }
615
+ }
616
+ return -1;
617
+ };
618
+ }
619
+ if (!Object.getPrototypeOf) {
620
+ Object.getPrototypeOf = function getPrototypeOf(object) {
621
+ return object.__proto__ || (
622
+ object.constructor ?
623
+ object.constructor.prototype :
624
+ prototypeOfObject
625
+ );
626
+ };
627
+ }
628
+ if (!Object.getOwnPropertyDescriptor) {
629
+ var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
630
+ "non-object: ";
631
+ Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
632
+ if ((typeof object != "object" && typeof object != "function") || object === null)
633
+ throw new TypeError(ERR_NON_OBJECT + object);
634
+ if (!owns(object, property))
635
+ return;
636
+
637
+ var descriptor, getter, setter;
638
+ descriptor = { enumerable: true, configurable: true };
639
+ if (supportsAccessors) {
640
+ var prototype = object.__proto__;
641
+ object.__proto__ = prototypeOfObject;
642
+
643
+ var getter = lookupGetter(object, property);
644
+ var setter = lookupSetter(object, property);
645
+ object.__proto__ = prototype;
646
+
647
+ if (getter || setter) {
648
+ if (getter) descriptor.get = getter;
649
+ if (setter) descriptor.set = setter;
650
+ return descriptor;
651
+ }
652
+ }
653
+ descriptor.value = object[property];
654
+ return descriptor;
655
+ };
656
+ }
657
+ if (!Object.getOwnPropertyNames) {
658
+ Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
659
+ return Object.keys(object);
660
+ };
661
+ }
662
+ if (!Object.create) {
663
+ var createEmpty;
664
+ if (Object.prototype.__proto__ === null) {
665
+ createEmpty = function () {
666
+ return { "__proto__": null };
667
+ };
668
+ } else {
669
+ createEmpty = function () {
670
+ var empty = {};
671
+ for (var i in empty)
672
+ empty[i] = null;
673
+ empty.constructor =
674
+ empty.hasOwnProperty =
675
+ empty.propertyIsEnumerable =
676
+ empty.isPrototypeOf =
677
+ empty.toLocaleString =
678
+ empty.toString =
679
+ empty.valueOf =
680
+ empty.__proto__ = null;
681
+ return empty;
682
+ }
683
+ }
684
+
685
+ Object.create = function create(prototype, properties) {
686
+ var object;
687
+ if (prototype === null) {
688
+ object = createEmpty();
689
+ } else {
690
+ if (typeof prototype != "object")
691
+ throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
692
+ var Type = function () {};
693
+ Type.prototype = prototype;
694
+ object = new Type();
695
+ object.__proto__ = prototype;
696
+ }
697
+ if (properties !== void 0)
698
+ Object.defineProperties(object, properties);
699
+ return object;
700
+ };
701
+ }
702
+
703
+ function doesDefinePropertyWork(object) {
704
+ try {
705
+ Object.defineProperty(object, "sentinel", {});
706
+ return "sentinel" in object;
707
+ } catch (exception) {
708
+ }
709
+ }
710
+ if (Object.defineProperty) {
711
+ var definePropertyWorksOnObject = doesDefinePropertyWork({});
712
+ var definePropertyWorksOnDom = typeof document == "undefined" ||
713
+ doesDefinePropertyWork(document.createElement("div"));
714
+ if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
715
+ var definePropertyFallback = Object.defineProperty;
716
+ }
717
+ }
718
+
719
+ if (!Object.defineProperty || definePropertyFallback) {
720
+ var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
721
+ var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
722
+ var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
723
+ "on this javascript engine";
724
+
725
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
726
+ if ((typeof object != "object" && typeof object != "function") || object === null)
727
+ throw new TypeError(ERR_NON_OBJECT_TARGET + object);
728
+ if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
729
+ throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
730
+ if (definePropertyFallback) {
731
+ try {
732
+ return definePropertyFallback.call(Object, object, property, descriptor);
733
+ } catch (exception) {
734
+ }
735
+ }
736
+ if (owns(descriptor, "value")) {
737
+
738
+ if (supportsAccessors && (lookupGetter(object, property) ||
739
+ lookupSetter(object, property)))
740
+ {
741
+ var prototype = object.__proto__;
742
+ object.__proto__ = prototypeOfObject;
743
+ delete object[property];
744
+ object[property] = descriptor.value;
745
+ object.__proto__ = prototype;
746
+ } else {
747
+ object[property] = descriptor.value;
748
+ }
749
+ } else {
750
+ if (!supportsAccessors)
751
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
752
+ if (owns(descriptor, "get"))
753
+ defineGetter(object, property, descriptor.get);
754
+ if (owns(descriptor, "set"))
755
+ defineSetter(object, property, descriptor.set);
756
+ }
757
+
758
+ return object;
759
+ };
760
+ }
761
+ if (!Object.defineProperties) {
762
+ Object.defineProperties = function defineProperties(object, properties) {
763
+ for (var property in properties) {
764
+ if (owns(properties, property))
765
+ Object.defineProperty(object, property, properties[property]);
766
+ }
767
+ return object;
768
+ };
769
+ }
770
+ if (!Object.seal) {
771
+ Object.seal = function seal(object) {
772
+ return object;
773
+ };
774
+ }
775
+ if (!Object.freeze) {
776
+ Object.freeze = function freeze(object) {
777
+ return object;
778
+ };
779
+ }
780
+ try {
781
+ Object.freeze(function () {});
782
+ } catch (exception) {
783
+ Object.freeze = (function freeze(freezeObject) {
784
+ return function freeze(object) {
785
+ if (typeof object == "function") {
786
+ return object;
787
+ } else {
788
+ return freezeObject(object);
789
+ }
790
+ };
791
+ })(Object.freeze);
792
+ }
793
+ if (!Object.preventExtensions) {
794
+ Object.preventExtensions = function preventExtensions(object) {
795
+ return object;
796
+ };
797
+ }
798
+ if (!Object.isSealed) {
799
+ Object.isSealed = function isSealed(object) {
800
+ return false;
801
+ };
802
+ }
803
+ if (!Object.isFrozen) {
804
+ Object.isFrozen = function isFrozen(object) {
805
+ return false;
806
+ };
807
+ }
808
+ if (!Object.isExtensible) {
809
+ Object.isExtensible = function isExtensible(object) {
810
+ if (Object(object) === object) {
811
+ throw new TypeError(); // TODO message
812
+ }
813
+ var name = '';
814
+ while (owns(object, name)) {
815
+ name += '?';
816
+ }
817
+ object[name] = true;
818
+ var returnValue = owns(object, name);
819
+ delete object[name];
820
+ return returnValue;
821
+ };
822
+ }
823
+ if (!Object.keys) {
824
+ var hasDontEnumBug = true,
825
+ dontEnums = [
826
+ "toString",
827
+ "toLocaleString",
828
+ "valueOf",
829
+ "hasOwnProperty",
830
+ "isPrototypeOf",
831
+ "propertyIsEnumerable",
832
+ "constructor"
833
+ ],
834
+ dontEnumsLength = dontEnums.length;
835
+
836
+ for (var key in {"toString": null}) {
837
+ hasDontEnumBug = false;
838
+ }
839
+
840
+ Object.keys = function keys(object) {
841
+
842
+ if (
843
+ (typeof object != "object" && typeof object != "function") ||
844
+ object === null
845
+ ) {
846
+ throw new TypeError("Object.keys called on a non-object");
847
+ }
848
+
849
+ var keys = [];
850
+ for (var name in object) {
851
+ if (owns(object, name)) {
852
+ keys.push(name);
853
+ }
854
+ }
855
+
856
+ if (hasDontEnumBug) {
857
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
858
+ var dontEnum = dontEnums[i];
859
+ if (owns(object, dontEnum)) {
860
+ keys.push(dontEnum);
861
+ }
862
+ }
863
+ }
864
+ return keys;
865
+ };
866
+
867
+ }
868
+ if (!Date.now) {
869
+ Date.now = function now() {
870
+ return new Date().getTime();
871
+ };
872
+ }
873
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
874
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
875
+ "\u2029\uFEFF";
876
+ if (!String.prototype.trim || ws.trim()) {
877
+ ws = "[" + ws + "]";
878
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
879
+ trimEndRegexp = new RegExp(ws + ws + "*$");
880
+ String.prototype.trim = function trim() {
881
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
882
+ };
883
+ }
884
+
885
+ function toInteger(n) {
886
+ n = +n;
887
+ if (n !== n) { // isNaN
888
+ n = 0;
889
+ } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
890
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
891
+ }
892
+ return n;
893
+ }
894
+
895
+ function isPrimitive(input) {
896
+ var type = typeof input;
897
+ return (
898
+ input === null ||
899
+ type === "undefined" ||
900
+ type === "boolean" ||
901
+ type === "number" ||
902
+ type === "string"
903
+ );
904
+ }
905
+
906
+ function toPrimitive(input) {
907
+ var val, valueOf, toString;
908
+ if (isPrimitive(input)) {
909
+ return input;
910
+ }
911
+ valueOf = input.valueOf;
912
+ if (typeof valueOf === "function") {
913
+ val = valueOf.call(input);
914
+ if (isPrimitive(val)) {
915
+ return val;
916
+ }
917
+ }
918
+ toString = input.toString;
919
+ if (typeof toString === "function") {
920
+ val = toString.call(input);
921
+ if (isPrimitive(val)) {
922
+ return val;
923
+ }
924
+ }
925
+ throw new TypeError();
926
+ }
927
+ var toObject = function (o) {
928
+ if (o == null) { // this matches both null and undefined
929
+ throw new TypeError("can't convert "+o+" to object");
930
+ }
931
+ return Object(o);
932
+ };
933
+
934
+ });
935
+
936
+ define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
937
+
938
+
939
+ var EventEmitter = {};
940
+ var stopPropagation = function() { this.propagationStopped = true; };
941
+ var preventDefault = function() { this.defaultPrevented = true; };
942
+
943
+ EventEmitter._emit =
944
+ EventEmitter._dispatchEvent = function(eventName, e) {
945
+ this._eventRegistry || (this._eventRegistry = {});
946
+ this._defaultHandlers || (this._defaultHandlers = {});
947
+
948
+ var listeners = this._eventRegistry[eventName] || [];
949
+ var defaultHandler = this._defaultHandlers[eventName];
950
+ if (!listeners.length && !defaultHandler)
951
+ return;
952
+
953
+ if (typeof e != "object" || !e)
954
+ e = {};
955
+
956
+ if (!e.type)
957
+ e.type = eventName;
958
+ if (!e.stopPropagation)
959
+ e.stopPropagation = stopPropagation;
960
+ if (!e.preventDefault)
961
+ e.preventDefault = preventDefault;
962
+
963
+ for (var i=0; i<listeners.length; i++) {
964
+ listeners[i](e, this);
965
+ if (e.propagationStopped)
966
+ break;
967
+ }
968
+
969
+ if (defaultHandler && !e.defaultPrevented)
970
+ return defaultHandler(e, this);
971
+ };
972
+
973
+
974
+ EventEmitter._signal = function(eventName, e) {
975
+ var listeners = (this._eventRegistry || {})[eventName];
976
+ if (!listeners)
977
+ return;
978
+
979
+ for (var i=0; i<listeners.length; i++)
980
+ listeners[i](e, this);
981
+ };
982
+
983
+ EventEmitter.once = function(eventName, callback) {
984
+ var _self = this;
985
+ callback && this.addEventListener(eventName, function newCallback() {
986
+ _self.removeEventListener(eventName, newCallback);
987
+ callback.apply(null, arguments);
988
+ });
989
+ };
990
+
991
+
992
+ EventEmitter.setDefaultHandler = function(eventName, callback) {
993
+ this._defaultHandlers = this._defaultHandlers || {};
994
+
995
+ if (this._defaultHandlers[eventName])
996
+ throw new Error("The default handler for '" + eventName + "' is already set");
997
+
998
+ this._defaultHandlers[eventName] = callback;
999
+ };
1000
+
1001
+ EventEmitter.on =
1002
+ EventEmitter.addEventListener = function(eventName, callback, capturing) {
1003
+ this._eventRegistry = this._eventRegistry || {};
1004
+
1005
+ var listeners = this._eventRegistry[eventName];
1006
+ if (!listeners)
1007
+ listeners = this._eventRegistry[eventName] = [];
1008
+
1009
+ if (listeners.indexOf(callback) == -1)
1010
+ listeners[capturing ? "unshift" : "push"](callback);
1011
+ return callback;
1012
+ };
1013
+
1014
+ EventEmitter.off =
1015
+ EventEmitter.removeListener =
1016
+ EventEmitter.removeEventListener = function(eventName, callback) {
1017
+ this._eventRegistry = this._eventRegistry || {};
1018
+
1019
+ var listeners = this._eventRegistry[eventName];
1020
+ if (!listeners)
1021
+ return;
1022
+
1023
+ var index = listeners.indexOf(callback);
1024
+ if (index !== -1)
1025
+ listeners.splice(index, 1);
1026
+ };
1027
+
1028
+ EventEmitter.removeAllListeners = function(eventName) {
1029
+ if (this._eventRegistry) this._eventRegistry[eventName] = [];
1030
+ };
1031
+
1032
+ exports.EventEmitter = EventEmitter;
1033
+
1034
+ });
1035
+
1036
+ define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
1037
+
1038
+
1039
+ exports.inherits = (function() {
1040
+ var tempCtor = function() {};
1041
+ return function(ctor, superCtor) {
1042
+ tempCtor.prototype = superCtor.prototype;
1043
+ ctor.super_ = superCtor.prototype;
1044
+ ctor.prototype = new tempCtor();
1045
+ ctor.prototype.constructor = ctor;
1046
+ };
1047
+ }());
1048
+
1049
+ exports.mixin = function(obj, mixin) {
1050
+ for (var key in mixin) {
1051
+ obj[key] = mixin[key];
1052
+ }
1053
+ return obj;
1054
+ };
1055
+
1056
+ exports.implement = function(proto, mixin) {
1057
+ exports.mixin(proto, mixin);
1058
+ };
1059
+
1060
+ });
1061
+
1062
+ define('ace/mode/json_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/json/json_parse'], function(require, exports, module) {
1063
+
1064
+
1065
+ var oop = require("../lib/oop");
1066
+ var Mirror = require("../worker/mirror").Mirror;
1067
+ var parse = require("./json/json_parse");
1068
+
1069
+ var JsonWorker = exports.JsonWorker = function(sender) {
1070
+ Mirror.call(this, sender);
1071
+ this.setTimeout(200);
1072
+ };
1073
+
1074
+ oop.inherits(JsonWorker, Mirror);
1075
+
1076
+ (function() {
1077
+
1078
+ this.onUpdate = function() {
1079
+ var value = this.doc.getValue();
1080
+
1081
+ try {
1082
+ var result = parse(value);
1083
+ } catch (e) {
1084
+ var pos = this.doc.indexToPosition(e.at-1);
1085
+ this.sender.emit("error", {
1086
+ row: pos.row,
1087
+ column: pos.column,
1088
+ text: e.message,
1089
+ type: "error"
1090
+ });
1091
+ return;
1092
+ }
1093
+ this.sender.emit("ok");
1094
+ };
1095
+
1096
+ }).call(JsonWorker.prototype);
1097
+
1098
+ });
1099
+ define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) {
1100
+
1101
+
1102
+ var Document = require("../document").Document;
1103
+ var lang = require("../lib/lang");
1104
+
1105
+ var Mirror = exports.Mirror = function(sender) {
1106
+ this.sender = sender;
1107
+ var doc = this.doc = new Document("");
1108
+
1109
+ var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1110
+
1111
+ var _self = this;
1112
+ sender.on("change", function(e) {
1113
+ doc.applyDeltas([e.data]);
1114
+ deferredUpdate.schedule(_self.$timeout);
1115
+ });
1116
+ };
1117
+
1118
+ (function() {
1119
+
1120
+ this.$timeout = 500;
1121
+
1122
+ this.setTimeout = function(timeout) {
1123
+ this.$timeout = timeout;
1124
+ };
1125
+
1126
+ this.setValue = function(value) {
1127
+ this.doc.setValue(value);
1128
+ this.deferredUpdate.schedule(this.$timeout);
1129
+ };
1130
+
1131
+ this.getValue = function(callbackId) {
1132
+ this.sender.callback(this.doc.getValue(), callbackId);
1133
+ };
1134
+
1135
+ this.onUpdate = function() {
1136
+ };
1137
+
1138
+ }).call(Mirror.prototype);
1139
+
1140
+ });
1141
+
1142
+ define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
1143
+
1144
+
1145
+ var oop = require("./lib/oop");
1146
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
1147
+ var Range = require("./range").Range;
1148
+ var Anchor = require("./anchor").Anchor;
1149
+
1150
+ var Document = function(text) {
1151
+ this.$lines = [];
1152
+ if (text.length == 0) {
1153
+ this.$lines = [""];
1154
+ } else if (Array.isArray(text)) {
1155
+ this.insertLines(0, text);
1156
+ } else {
1157
+ this.insert({row: 0, column:0}, text);
1158
+ }
1159
+ };
1160
+
1161
+ (function() {
1162
+
1163
+ oop.implement(this, EventEmitter);
1164
+ this.setValue = function(text) {
1165
+ var len = this.getLength();
1166
+ this.remove(new Range(0, 0, len, this.getLine(len-1).length));
1167
+ this.insert({row: 0, column:0}, text);
1168
+ };
1169
+ this.getValue = function() {
1170
+ return this.getAllLines().join(this.getNewLineCharacter());
1171
+ };
1172
+ this.createAnchor = function(row, column) {
1173
+ return new Anchor(this, row, column);
1174
+ };
1175
+ if ("aaa".split(/a/).length == 0)
1176
+ this.$split = function(text) {
1177
+ return text.replace(/\r\n|\r/g, "\n").split("\n");
1178
+ }
1179
+ else
1180
+ this.$split = function(text) {
1181
+ return text.split(/\r\n|\r|\n/);
1182
+ };
1183
+
1184
+
1185
+
1186
+ this.$detectNewLine = function(text) {
1187
+ var match = text.match(/^.*?(\r\n|\r|\n)/m);
1188
+ if (match) {
1189
+ this.$autoNewLine = match[1];
1190
+ } else {
1191
+ this.$autoNewLine = "\n";
1192
+ }
1193
+ };
1194
+ this.getNewLineCharacter = function() {
1195
+ switch (this.$newLineMode) {
1196
+ case "windows":
1197
+ return "\r\n";
1198
+
1199
+ case "unix":
1200
+ return "\n";
1201
+
1202
+ default:
1203
+ return this.$autoNewLine;
1204
+ }
1205
+ };
1206
+
1207
+ this.$autoNewLine = "\n";
1208
+ this.$newLineMode = "auto";
1209
+ this.setNewLineMode = function(newLineMode) {
1210
+ if (this.$newLineMode === newLineMode)
1211
+ return;
1212
+
1213
+ this.$newLineMode = newLineMode;
1214
+ };
1215
+ this.getNewLineMode = function() {
1216
+ return this.$newLineMode;
1217
+ };
1218
+ this.isNewLine = function(text) {
1219
+ return (text == "\r\n" || text == "\r" || text == "\n");
1220
+ };
1221
+ this.getLine = function(row) {
1222
+ return this.$lines[row] || "";
1223
+ };
1224
+ this.getLines = function(firstRow, lastRow) {
1225
+ return this.$lines.slice(firstRow, lastRow + 1);
1226
+ };
1227
+ this.getAllLines = function() {
1228
+ return this.getLines(0, this.getLength());
1229
+ };
1230
+ this.getLength = function() {
1231
+ return this.$lines.length;
1232
+ };
1233
+ this.getTextRange = function(range) {
1234
+ if (range.start.row == range.end.row) {
1235
+ return this.$lines[range.start.row].substring(range.start.column,
1236
+ range.end.column);
1237
+ }
1238
+ else {
1239
+ var lines = this.getLines(range.start.row+1, range.end.row-1);
1240
+ lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
1241
+ lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
1242
+ return lines.join(this.getNewLineCharacter());
1243
+ }
1244
+ };
1245
+
1246
+ this.$clipPosition = function(position) {
1247
+ var length = this.getLength();
1248
+ if (position.row >= length) {
1249
+ position.row = Math.max(0, length - 1);
1250
+ position.column = this.getLine(length-1).length;
1251
+ } else if (position.row < 0)
1252
+ position.row = 0;
1253
+ return position;
1254
+ };
1255
+ this.insert = function(position, text) {
1256
+ if (!text || text.length === 0)
1257
+ return position;
1258
+
1259
+ position = this.$clipPosition(position);
1260
+ if (this.getLength() <= 1)
1261
+ this.$detectNewLine(text);
1262
+
1263
+ var lines = this.$split(text);
1264
+ var firstLine = lines.splice(0, 1)[0];
1265
+ var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
1266
+
1267
+ position = this.insertInLine(position, firstLine);
1268
+ if (lastLine !== null) {
1269
+ position = this.insertNewLine(position); // terminate first line
1270
+ position = this.insertLines(position.row, lines);
1271
+ position = this.insertInLine(position, lastLine || "");
1272
+ }
1273
+ return position;
1274
+ };
1275
+ this.insertLines = function(row, lines) {
1276
+ if (lines.length == 0)
1277
+ return {row: row, column: 0};
1278
+ if (lines.length > 0xFFFF) {
1279
+ var end = this.insertLines(row, lines.slice(0xFFFF));
1280
+ lines = lines.slice(0, 0xFFFF);
1281
+ }
1282
+
1283
+ var args = [row, 0];
1284
+ args.push.apply(args, lines);
1285
+ this.$lines.splice.apply(this.$lines, args);
1286
+
1287
+ var range = new Range(row, 0, row + lines.length, 0);
1288
+ var delta = {
1289
+ action: "insertLines",
1290
+ range: range,
1291
+ lines: lines
1292
+ };
1293
+ this._emit("change", { data: delta });
1294
+ return end || range.end;
1295
+ };
1296
+ this.insertNewLine = function(position) {
1297
+ position = this.$clipPosition(position);
1298
+ var line = this.$lines[position.row] || "";
1299
+
1300
+ this.$lines[position.row] = line.substring(0, position.column);
1301
+ this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
1302
+
1303
+ var end = {
1304
+ row : position.row + 1,
1305
+ column : 0
1306
+ };
1307
+
1308
+ var delta = {
1309
+ action: "insertText",
1310
+ range: Range.fromPoints(position, end),
1311
+ text: this.getNewLineCharacter()
1312
+ };
1313
+ this._emit("change", { data: delta });
1314
+
1315
+ return end;
1316
+ };
1317
+ this.insertInLine = function(position, text) {
1318
+ if (text.length == 0)
1319
+ return position;
1320
+
1321
+ var line = this.$lines[position.row] || "";
1322
+
1323
+ this.$lines[position.row] = line.substring(0, position.column) + text
1324
+ + line.substring(position.column);
1325
+
1326
+ var end = {
1327
+ row : position.row,
1328
+ column : position.column + text.length
1329
+ };
1330
+
1331
+ var delta = {
1332
+ action: "insertText",
1333
+ range: Range.fromPoints(position, end),
1334
+ text: text
1335
+ };
1336
+ this._emit("change", { data: delta });
1337
+
1338
+ return end;
1339
+ };
1340
+ this.remove = function(range) {
1341
+ range.start = this.$clipPosition(range.start);
1342
+ range.end = this.$clipPosition(range.end);
1343
+
1344
+ if (range.isEmpty())
1345
+ return range.start;
1346
+
1347
+ var firstRow = range.start.row;
1348
+ var lastRow = range.end.row;
1349
+
1350
+ if (range.isMultiLine()) {
1351
+ var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
1352
+ var lastFullRow = lastRow - 1;
1353
+
1354
+ if (range.end.column > 0)
1355
+ this.removeInLine(lastRow, 0, range.end.column);
1356
+
1357
+ if (lastFullRow >= firstFullRow)
1358
+ this.removeLines(firstFullRow, lastFullRow);
1359
+
1360
+ if (firstFullRow != firstRow) {
1361
+ this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
1362
+ this.removeNewLine(range.start.row);
1363
+ }
1364
+ }
1365
+ else {
1366
+ this.removeInLine(firstRow, range.start.column, range.end.column);
1367
+ }
1368
+ return range.start;
1369
+ };
1370
+ this.removeInLine = function(row, startColumn, endColumn) {
1371
+ if (startColumn == endColumn)
1372
+ return;
1373
+
1374
+ var range = new Range(row, startColumn, row, endColumn);
1375
+ var line = this.getLine(row);
1376
+ var removed = line.substring(startColumn, endColumn);
1377
+ var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
1378
+ this.$lines.splice(row, 1, newLine);
1379
+
1380
+ var delta = {
1381
+ action: "removeText",
1382
+ range: range,
1383
+ text: removed
1384
+ };
1385
+ this._emit("change", { data: delta });
1386
+ return range.start;
1387
+ };
1388
+ this.removeLines = function(firstRow, lastRow) {
1389
+ var range = new Range(firstRow, 0, lastRow + 1, 0);
1390
+ var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
1391
+
1392
+ var delta = {
1393
+ action: "removeLines",
1394
+ range: range,
1395
+ nl: this.getNewLineCharacter(),
1396
+ lines: removed
1397
+ };
1398
+ this._emit("change", { data: delta });
1399
+ return removed;
1400
+ };
1401
+ this.removeNewLine = function(row) {
1402
+ var firstLine = this.getLine(row);
1403
+ var secondLine = this.getLine(row+1);
1404
+
1405
+ var range = new Range(row, firstLine.length, row+1, 0);
1406
+ var line = firstLine + secondLine;
1407
+
1408
+ this.$lines.splice(row, 2, line);
1409
+
1410
+ var delta = {
1411
+ action: "removeText",
1412
+ range: range,
1413
+ text: this.getNewLineCharacter()
1414
+ };
1415
+ this._emit("change", { data: delta });
1416
+ };
1417
+ this.replace = function(range, text) {
1418
+ if (text.length == 0 && range.isEmpty())
1419
+ return range.start;
1420
+ if (text == this.getTextRange(range))
1421
+ return range.end;
1422
+
1423
+ this.remove(range);
1424
+ if (text) {
1425
+ var end = this.insert(range.start, text);
1426
+ }
1427
+ else {
1428
+ end = range.start;
1429
+ }
1430
+
1431
+ return end;
1432
+ };
1433
+ this.applyDeltas = function(deltas) {
1434
+ for (var i=0; i<deltas.length; i++) {
1435
+ var delta = deltas[i];
1436
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
1437
+
1438
+ if (delta.action == "insertLines")
1439
+ this.insertLines(range.start.row, delta.lines);
1440
+ else if (delta.action == "insertText")
1441
+ this.insert(range.start, delta.text);
1442
+ else if (delta.action == "removeLines")
1443
+ this.removeLines(range.start.row, range.end.row - 1);
1444
+ else if (delta.action == "removeText")
1445
+ this.remove(range);
1446
+ }
1447
+ };
1448
+ this.revertDeltas = function(deltas) {
1449
+ for (var i=deltas.length-1; i>=0; i--) {
1450
+ var delta = deltas[i];
1451
+
1452
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
1453
+
1454
+ if (delta.action == "insertLines")
1455
+ this.removeLines(range.start.row, range.end.row - 1);
1456
+ else if (delta.action == "insertText")
1457
+ this.remove(range);
1458
+ else if (delta.action == "removeLines")
1459
+ this.insertLines(range.start.row, delta.lines);
1460
+ else if (delta.action == "removeText")
1461
+ this.insert(range.start, delta.text);
1462
+ }
1463
+ };
1464
+ this.indexToPosition = function(index, startRow) {
1465
+ var lines = this.$lines || this.getAllLines();
1466
+ var newlineLength = this.getNewLineCharacter().length;
1467
+ for (var i = startRow || 0, l = lines.length; i < l; i++) {
1468
+ index -= lines[i].length + newlineLength;
1469
+ if (index < 0)
1470
+ return {row: i, column: index + lines[i].length + newlineLength};
1471
+ }
1472
+ return {row: l-1, column: lines[l-1].length};
1473
+ };
1474
+ this.positionToIndex = function(pos, startRow) {
1475
+ var lines = this.$lines || this.getAllLines();
1476
+ var newlineLength = this.getNewLineCharacter().length;
1477
+ var index = 0;
1478
+ var row = Math.min(pos.row, lines.length);
1479
+ for (var i = startRow || 0; i < row; ++i)
1480
+ index += lines[i].length;
1481
+
1482
+ return index + newlineLength * i + pos.column;
1483
+ };
1484
+
1485
+ }).call(Document.prototype);
1486
+
1487
+ exports.Document = Document;
1488
+ });
1489
+
1490
+ define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
1491
+
1492
+ var comparePoints = function(p1, p2) {
1493
+ return p1.row - p2.row || p1.column - p2.column;
1494
+ };
1495
+ var Range = function(startRow, startColumn, endRow, endColumn) {
1496
+ this.start = {
1497
+ row: startRow,
1498
+ column: startColumn
1499
+ };
1500
+
1501
+ this.end = {
1502
+ row: endRow,
1503
+ column: endColumn
1504
+ };
1505
+ };
1506
+
1507
+ (function() {
1508
+ this.isEqual = function(range) {
1509
+ return this.start.row === range.start.row &&
1510
+ this.end.row === range.end.row &&
1511
+ this.start.column === range.start.column &&
1512
+ this.end.column === range.end.column;
1513
+ };
1514
+ this.toString = function() {
1515
+ return ("Range: [" + this.start.row + "/" + this.start.column +
1516
+ "] -> [" + this.end.row + "/" + this.end.column + "]");
1517
+ };
1518
+
1519
+ this.contains = function(row, column) {
1520
+ return this.compare(row, column) == 0;
1521
+ };
1522
+ this.compareRange = function(range) {
1523
+ var cmp,
1524
+ end = range.end,
1525
+ start = range.start;
1526
+
1527
+ cmp = this.compare(end.row, end.column);
1528
+ if (cmp == 1) {
1529
+ cmp = this.compare(start.row, start.column);
1530
+ if (cmp == 1) {
1531
+ return 2;
1532
+ } else if (cmp == 0) {
1533
+ return 1;
1534
+ } else {
1535
+ return 0;
1536
+ }
1537
+ } else if (cmp == -1) {
1538
+ return -2;
1539
+ } else {
1540
+ cmp = this.compare(start.row, start.column);
1541
+ if (cmp == -1) {
1542
+ return -1;
1543
+ } else if (cmp == 1) {
1544
+ return 42;
1545
+ } else {
1546
+ return 0;
1547
+ }
1548
+ }
1549
+ };
1550
+ this.comparePoint = function(p) {
1551
+ return this.compare(p.row, p.column);
1552
+ };
1553
+ this.containsRange = function(range) {
1554
+ return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
1555
+ };
1556
+ this.intersects = function(range) {
1557
+ var cmp = this.compareRange(range);
1558
+ return (cmp == -1 || cmp == 0 || cmp == 1);
1559
+ };
1560
+ this.isEnd = function(row, column) {
1561
+ return this.end.row == row && this.end.column == column;
1562
+ };
1563
+ this.isStart = function(row, column) {
1564
+ return this.start.row == row && this.start.column == column;
1565
+ };
1566
+ this.setStart = function(row, column) {
1567
+ if (typeof row == "object") {
1568
+ this.start.column = row.column;
1569
+ this.start.row = row.row;
1570
+ } else {
1571
+ this.start.row = row;
1572
+ this.start.column = column;
1573
+ }
1574
+ };
1575
+ this.setEnd = function(row, column) {
1576
+ if (typeof row == "object") {
1577
+ this.end.column = row.column;
1578
+ this.end.row = row.row;
1579
+ } else {
1580
+ this.end.row = row;
1581
+ this.end.column = column;
1582
+ }
1583
+ };
1584
+ this.inside = function(row, column) {
1585
+ if (this.compare(row, column) == 0) {
1586
+ if (this.isEnd(row, column) || this.isStart(row, column)) {
1587
+ return false;
1588
+ } else {
1589
+ return true;
1590
+ }
1591
+ }
1592
+ return false;
1593
+ };
1594
+ this.insideStart = function(row, column) {
1595
+ if (this.compare(row, column) == 0) {
1596
+ if (this.isEnd(row, column)) {
1597
+ return false;
1598
+ } else {
1599
+ return true;
1600
+ }
1601
+ }
1602
+ return false;
1603
+ };
1604
+ this.insideEnd = function(row, column) {
1605
+ if (this.compare(row, column) == 0) {
1606
+ if (this.isStart(row, column)) {
1607
+ return false;
1608
+ } else {
1609
+ return true;
1610
+ }
1611
+ }
1612
+ return false;
1613
+ };
1614
+ this.compare = function(row, column) {
1615
+ if (!this.isMultiLine()) {
1616
+ if (row === this.start.row) {
1617
+ return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
1618
+ };
1619
+ }
1620
+
1621
+ if (row < this.start.row)
1622
+ return -1;
1623
+
1624
+ if (row > this.end.row)
1625
+ return 1;
1626
+
1627
+ if (this.start.row === row)
1628
+ return column >= this.start.column ? 0 : -1;
1629
+
1630
+ if (this.end.row === row)
1631
+ return column <= this.end.column ? 0 : 1;
1632
+
1633
+ return 0;
1634
+ };
1635
+ this.compareStart = function(row, column) {
1636
+ if (this.start.row == row && this.start.column == column) {
1637
+ return -1;
1638
+ } else {
1639
+ return this.compare(row, column);
1640
+ }
1641
+ };
1642
+ this.compareEnd = function(row, column) {
1643
+ if (this.end.row == row && this.end.column == column) {
1644
+ return 1;
1645
+ } else {
1646
+ return this.compare(row, column);
1647
+ }
1648
+ };
1649
+ this.compareInside = function(row, column) {
1650
+ if (this.end.row == row && this.end.column == column) {
1651
+ return 1;
1652
+ } else if (this.start.row == row && this.start.column == column) {
1653
+ return -1;
1654
+ } else {
1655
+ return this.compare(row, column);
1656
+ }
1657
+ };
1658
+ this.clipRows = function(firstRow, lastRow) {
1659
+ if (this.end.row > lastRow)
1660
+ var end = {row: lastRow + 1, column: 0};
1661
+ else if (this.end.row < firstRow)
1662
+ var end = {row: firstRow, column: 0};
1663
+
1664
+ if (this.start.row > lastRow)
1665
+ var start = {row: lastRow + 1, column: 0};
1666
+ else if (this.start.row < firstRow)
1667
+ var start = {row: firstRow, column: 0};
1668
+
1669
+ return Range.fromPoints(start || this.start, end || this.end);
1670
+ };
1671
+ this.extend = function(row, column) {
1672
+ var cmp = this.compare(row, column);
1673
+
1674
+ if (cmp == 0)
1675
+ return this;
1676
+ else if (cmp == -1)
1677
+ var start = {row: row, column: column};
1678
+ else
1679
+ var end = {row: row, column: column};
1680
+
1681
+ return Range.fromPoints(start || this.start, end || this.end);
1682
+ };
1683
+
1684
+ this.isEmpty = function() {
1685
+ return (this.start.row === this.end.row && this.start.column === this.end.column);
1686
+ };
1687
+ this.isMultiLine = function() {
1688
+ return (this.start.row !== this.end.row);
1689
+ };
1690
+ this.clone = function() {
1691
+ return Range.fromPoints(this.start, this.end);
1692
+ };
1693
+ this.collapseRows = function() {
1694
+ if (this.end.column == 0)
1695
+ return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
1696
+ else
1697
+ return new Range(this.start.row, 0, this.end.row, 0)
1698
+ };
1699
+ this.toScreenRange = function(session) {
1700
+ var screenPosStart = session.documentToScreenPosition(this.start);
1701
+ var screenPosEnd = session.documentToScreenPosition(this.end);
1702
+
1703
+ return new Range(
1704
+ screenPosStart.row, screenPosStart.column,
1705
+ screenPosEnd.row, screenPosEnd.column
1706
+ );
1707
+ };
1708
+ this.moveBy = function(row, column) {
1709
+ this.start.row += row;
1710
+ this.start.column += column;
1711
+ this.end.row += row;
1712
+ this.end.column += column;
1713
+ };
1714
+
1715
+ }).call(Range.prototype);
1716
+ Range.fromPoints = function(start, end) {
1717
+ return new Range(start.row, start.column, end.row, end.column);
1718
+ };
1719
+ Range.comparePoints = comparePoints;
1720
+
1721
+ Range.comparePoints = function(p1, p2) {
1722
+ return p1.row - p2.row || p1.column - p2.column;
1723
+ };
1724
+
1725
+
1726
+ exports.Range = Range;
1727
+ });
1728
+
1729
+ define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
1730
+
1731
+
1732
+ var oop = require("./lib/oop");
1733
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
1734
+
1735
+ var Anchor = exports.Anchor = function(doc, row, column) {
1736
+ this.document = doc;
1737
+
1738
+ if (typeof column == "undefined")
1739
+ this.setPosition(row.row, row.column);
1740
+ else
1741
+ this.setPosition(row, column);
1742
+
1743
+ this.$onChange = this.onChange.bind(this);
1744
+ doc.on("change", this.$onChange);
1745
+ };
1746
+
1747
+ (function() {
1748
+
1749
+ oop.implement(this, EventEmitter);
1750
+
1751
+ this.getPosition = function() {
1752
+ return this.$clipPositionToDocument(this.row, this.column);
1753
+ };
1754
+
1755
+ this.getDocument = function() {
1756
+ return this.document;
1757
+ };
1758
+
1759
+ this.onChange = function(e) {
1760
+ var delta = e.data;
1761
+ var range = delta.range;
1762
+
1763
+ if (range.start.row == range.end.row && range.start.row != this.row)
1764
+ return;
1765
+
1766
+ if (range.start.row > this.row)
1767
+ return;
1768
+
1769
+ if (range.start.row == this.row && range.start.column > this.column)
1770
+ return;
1771
+
1772
+ var row = this.row;
1773
+ var column = this.column;
1774
+ var start = range.start;
1775
+ var end = range.end;
1776
+
1777
+ if (delta.action === "insertText") {
1778
+ if (start.row === row && start.column <= column) {
1779
+ if (start.row === end.row) {
1780
+ column += end.column - start.column;
1781
+ } else {
1782
+ column -= start.column;
1783
+ row += end.row - start.row;
1784
+ }
1785
+ } else if (start.row !== end.row && start.row < row) {
1786
+ row += end.row - start.row;
1787
+ }
1788
+ } else if (delta.action === "insertLines") {
1789
+ if (start.row <= row) {
1790
+ row += end.row - start.row;
1791
+ }
1792
+ } else if (delta.action === "removeText") {
1793
+ if (start.row === row && start.column < column) {
1794
+ if (end.column >= column)
1795
+ column = start.column;
1796
+ else
1797
+ column = Math.max(0, column - (end.column - start.column));
1798
+
1799
+ } else if (start.row !== end.row && start.row < row) {
1800
+ if (end.row === row)
1801
+ column = Math.max(0, column - end.column) + start.column;
1802
+ row -= (end.row - start.row);
1803
+ } else if (end.row === row) {
1804
+ row -= end.row - start.row;
1805
+ column = Math.max(0, column - end.column) + start.column;
1806
+ }
1807
+ } else if (delta.action == "removeLines") {
1808
+ if (start.row <= row) {
1809
+ if (end.row <= row)
1810
+ row -= end.row - start.row;
1811
+ else {
1812
+ row = start.row;
1813
+ column = 0;
1814
+ }
1815
+ }
1816
+ }
1817
+
1818
+ this.setPosition(row, column, true);
1819
+ };
1820
+
1821
+ this.setPosition = function(row, column, noClip) {
1822
+ var pos;
1823
+ if (noClip) {
1824
+ pos = {
1825
+ row: row,
1826
+ column: column
1827
+ };
1828
+ } else {
1829
+ pos = this.$clipPositionToDocument(row, column);
1830
+ }
1831
+
1832
+ if (this.row == pos.row && this.column == pos.column)
1833
+ return;
1834
+
1835
+ var old = {
1836
+ row: this.row,
1837
+ column: this.column
1838
+ };
1839
+
1840
+ this.row = pos.row;
1841
+ this.column = pos.column;
1842
+ this._emit("change", {
1843
+ old: old,
1844
+ value: pos
1845
+ });
1846
+ };
1847
+
1848
+ this.detach = function() {
1849
+ this.document.removeEventListener("change", this.$onChange);
1850
+ };
1851
+ this.$clipPositionToDocument = function(row, column) {
1852
+ var pos = {};
1853
+
1854
+ if (row >= this.document.getLength()) {
1855
+ pos.row = Math.max(0, this.document.getLength() - 1);
1856
+ pos.column = this.document.getLine(pos.row).length;
1857
+ }
1858
+ else if (row < 0) {
1859
+ pos.row = 0;
1860
+ pos.column = 0;
1861
+ }
1862
+ else {
1863
+ pos.row = row;
1864
+ pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
1865
+ }
1866
+
1867
+ if (column < 0)
1868
+ pos.column = 0;
1869
+
1870
+ return pos;
1871
+ };
1872
+
1873
+ }).call(Anchor.prototype);
1874
+
1875
+ });
1876
+
1877
+ define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
1878
+
1879
+
1880
+ exports.stringReverse = function(string) {
1881
+ return string.split("").reverse().join("");
1882
+ };
1883
+
1884
+ exports.stringRepeat = function (string, count) {
1885
+ var result = '';
1886
+ while (count > 0) {
1887
+ if (count & 1)
1888
+ result += string;
1889
+
1890
+ if (count >>= 1)
1891
+ string += string;
1892
+ }
1893
+ return result;
1894
+ };
1895
+
1896
+ var trimBeginRegexp = /^\s\s*/;
1897
+ var trimEndRegexp = /\s\s*$/;
1898
+
1899
+ exports.stringTrimLeft = function (string) {
1900
+ return string.replace(trimBeginRegexp, '');
1901
+ };
1902
+
1903
+ exports.stringTrimRight = function (string) {
1904
+ return string.replace(trimEndRegexp, '');
1905
+ };
1906
+
1907
+ exports.copyObject = function(obj) {
1908
+ var copy = {};
1909
+ for (var key in obj) {
1910
+ copy[key] = obj[key];
1911
+ }
1912
+ return copy;
1913
+ };
1914
+
1915
+ exports.copyArray = function(array){
1916
+ var copy = [];
1917
+ for (var i=0, l=array.length; i<l; i++) {
1918
+ if (array[i] && typeof array[i] == "object")
1919
+ copy[i] = this.copyObject( array[i] );
1920
+ else
1921
+ copy[i] = array[i];
1922
+ }
1923
+ return copy;
1924
+ };
1925
+
1926
+ exports.deepCopy = function (obj) {
1927
+ if (typeof obj != "object") {
1928
+ return obj;
1929
+ }
1930
+
1931
+ var copy = obj.constructor();
1932
+ for (var key in obj) {
1933
+ if (typeof obj[key] == "object") {
1934
+ copy[key] = this.deepCopy(obj[key]);
1935
+ } else {
1936
+ copy[key] = obj[key];
1937
+ }
1938
+ }
1939
+ return copy;
1940
+ };
1941
+
1942
+ exports.arrayToMap = function(arr) {
1943
+ var map = {};
1944
+ for (var i=0; i<arr.length; i++) {
1945
+ map[arr[i]] = 1;
1946
+ }
1947
+ return map;
1948
+
1949
+ };
1950
+
1951
+ exports.createMap = function(props) {
1952
+ var map = Object.create(null);
1953
+ for (var i in props) {
1954
+ map[i] = props[i];
1955
+ }
1956
+ return map;
1957
+ };
1958
+ exports.arrayRemove = function(array, value) {
1959
+ for (var i = 0; i <= array.length; i++) {
1960
+ if (value === array[i]) {
1961
+ array.splice(i, 1);
1962
+ }
1963
+ }
1964
+ };
1965
+
1966
+ exports.escapeRegExp = function(str) {
1967
+ return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
1968
+ };
1969
+
1970
+ exports.escapeHTML = function(str) {
1971
+ return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
1972
+ };
1973
+
1974
+ exports.getMatchOffsets = function(string, regExp) {
1975
+ var matches = [];
1976
+
1977
+ string.replace(regExp, function(str) {
1978
+ matches.push({
1979
+ offset: arguments[arguments.length-2],
1980
+ length: str.length
1981
+ });
1982
+ });
1983
+
1984
+ return matches;
1985
+ };
1986
+ exports.deferredCall = function(fcn) {
1987
+
1988
+ var timer = null;
1989
+ var callback = function() {
1990
+ timer = null;
1991
+ fcn();
1992
+ };
1993
+
1994
+ var deferred = function(timeout) {
1995
+ deferred.cancel();
1996
+ timer = setTimeout(callback, timeout || 0);
1997
+ return deferred;
1998
+ };
1999
+
2000
+ deferred.schedule = deferred;
2001
+
2002
+ deferred.call = function() {
2003
+ this.cancel();
2004
+ fcn();
2005
+ return deferred;
2006
+ };
2007
+
2008
+ deferred.cancel = function() {
2009
+ clearTimeout(timer);
2010
+ timer = null;
2011
+ return deferred;
2012
+ };
2013
+
2014
+ return deferred;
2015
+ };
2016
+
2017
+
2018
+ exports.delayedCall = function(fcn, defaultTimeout) {
2019
+ var timer = null;
2020
+ var callback = function() {
2021
+ timer = null;
2022
+ fcn();
2023
+ };
2024
+
2025
+ var _self = function(timeout) {
2026
+ timer && clearTimeout(timer);
2027
+ timer = setTimeout(callback, timeout || defaultTimeout);
2028
+ };
2029
+
2030
+ _self.delay = _self;
2031
+ _self.schedule = function(timeout) {
2032
+ if (timer == null)
2033
+ timer = setTimeout(callback, timeout || 0);
2034
+ };
2035
+
2036
+ _self.call = function() {
2037
+ this.cancel();
2038
+ fcn();
2039
+ };
2040
+
2041
+ _self.cancel = function() {
2042
+ timer && clearTimeout(timer);
2043
+ timer = null;
2044
+ };
2045
+
2046
+ _self.isPending = function() {
2047
+ return timer;
2048
+ };
2049
+
2050
+ return _self;
2051
+ };
2052
+ });
2053
+
2054
+ define('ace/mode/json/json_parse', ['require', 'exports', 'module' ], function(require, exports, module) {
2055
+
2056
+ var at, // The index of the current character
2057
+ ch, // The current character
2058
+ escapee = {
2059
+ '"': '"',
2060
+ '\\': '\\',
2061
+ '/': '/',
2062
+ b: '\b',
2063
+ f: '\f',
2064
+ n: '\n',
2065
+ r: '\r',
2066
+ t: '\t'
2067
+ },
2068
+ text,
2069
+
2070
+ error = function (m) {
2071
+
2072
+ throw {
2073
+ name: 'SyntaxError',
2074
+ message: m,
2075
+ at: at,
2076
+ text: text
2077
+ };
2078
+ },
2079
+
2080
+ next = function (c) {
2081
+
2082
+ if (c && c !== ch) {
2083
+ error("Expected '" + c + "' instead of '" + ch + "'");
2084
+ }
2085
+
2086
+ ch = text.charAt(at);
2087
+ at += 1;
2088
+ return ch;
2089
+ },
2090
+
2091
+ number = function () {
2092
+
2093
+ var number,
2094
+ string = '';
2095
+
2096
+ if (ch === '-') {
2097
+ string = '-';
2098
+ next('-');
2099
+ }
2100
+ while (ch >= '0' && ch <= '9') {
2101
+ string += ch;
2102
+ next();
2103
+ }
2104
+ if (ch === '.') {
2105
+ string += '.';
2106
+ while (next() && ch >= '0' && ch <= '9') {
2107
+ string += ch;
2108
+ }
2109
+ }
2110
+ if (ch === 'e' || ch === 'E') {
2111
+ string += ch;
2112
+ next();
2113
+ if (ch === '-' || ch === '+') {
2114
+ string += ch;
2115
+ next();
2116
+ }
2117
+ while (ch >= '0' && ch <= '9') {
2118
+ string += ch;
2119
+ next();
2120
+ }
2121
+ }
2122
+ number = +string;
2123
+ if (isNaN(number)) {
2124
+ error("Bad number");
2125
+ } else {
2126
+ return number;
2127
+ }
2128
+ },
2129
+
2130
+ string = function () {
2131
+
2132
+ var hex,
2133
+ i,
2134
+ string = '',
2135
+ uffff;
2136
+
2137
+ if (ch === '"') {
2138
+ while (next()) {
2139
+ if (ch === '"') {
2140
+ next();
2141
+ return string;
2142
+ } else if (ch === '\\') {
2143
+ next();
2144
+ if (ch === 'u') {
2145
+ uffff = 0;
2146
+ for (i = 0; i < 4; i += 1) {
2147
+ hex = parseInt(next(), 16);
2148
+ if (!isFinite(hex)) {
2149
+ break;
2150
+ }
2151
+ uffff = uffff * 16 + hex;
2152
+ }
2153
+ string += String.fromCharCode(uffff);
2154
+ } else if (typeof escapee[ch] === 'string') {
2155
+ string += escapee[ch];
2156
+ } else {
2157
+ break;
2158
+ }
2159
+ } else {
2160
+ string += ch;
2161
+ }
2162
+ }
2163
+ }
2164
+ error("Bad string");
2165
+ },
2166
+
2167
+ white = function () {
2168
+
2169
+ while (ch && ch <= ' ') {
2170
+ next();
2171
+ }
2172
+ },
2173
+
2174
+ word = function () {
2175
+
2176
+ switch (ch) {
2177
+ case 't':
2178
+ next('t');
2179
+ next('r');
2180
+ next('u');
2181
+ next('e');
2182
+ return true;
2183
+ case 'f':
2184
+ next('f');
2185
+ next('a');
2186
+ next('l');
2187
+ next('s');
2188
+ next('e');
2189
+ return false;
2190
+ case 'n':
2191
+ next('n');
2192
+ next('u');
2193
+ next('l');
2194
+ next('l');
2195
+ return null;
2196
+ }
2197
+ error("Unexpected '" + ch + "'");
2198
+ },
2199
+
2200
+ value, // Place holder for the value function.
2201
+
2202
+ array = function () {
2203
+
2204
+ var array = [];
2205
+
2206
+ if (ch === '[') {
2207
+ next('[');
2208
+ white();
2209
+ if (ch === ']') {
2210
+ next(']');
2211
+ return array; // empty array
2212
+ }
2213
+ while (ch) {
2214
+ array.push(value());
2215
+ white();
2216
+ if (ch === ']') {
2217
+ next(']');
2218
+ return array;
2219
+ }
2220
+ next(',');
2221
+ white();
2222
+ }
2223
+ }
2224
+ error("Bad array");
2225
+ },
2226
+
2227
+ object = function () {
2228
+
2229
+ var key,
2230
+ object = {};
2231
+
2232
+ if (ch === '{') {
2233
+ next('{');
2234
+ white();
2235
+ if (ch === '}') {
2236
+ next('}');
2237
+ return object; // empty object
2238
+ }
2239
+ while (ch) {
2240
+ key = string();
2241
+ white();
2242
+ next(':');
2243
+ if (Object.hasOwnProperty.call(object, key)) {
2244
+ error('Duplicate key "' + key + '"');
2245
+ }
2246
+ object[key] = value();
2247
+ white();
2248
+ if (ch === '}') {
2249
+ next('}');
2250
+ return object;
2251
+ }
2252
+ next(',');
2253
+ white();
2254
+ }
2255
+ }
2256
+ error("Bad object");
2257
+ };
2258
+
2259
+ value = function () {
2260
+
2261
+ white();
2262
+ switch (ch) {
2263
+ case '{':
2264
+ return object();
2265
+ case '[':
2266
+ return array();
2267
+ case '"':
2268
+ return string();
2269
+ case '-':
2270
+ return number();
2271
+ default:
2272
+ return ch >= '0' && ch <= '9' ? number() : word();
2273
+ }
2274
+ };
2275
+
2276
+ return function (source, reviver) {
2277
+ var result;
2278
+
2279
+ text = source;
2280
+ at = 0;
2281
+ ch = ' ';
2282
+ result = value();
2283
+ white();
2284
+ if (ch) {
2285
+ error("Syntax error");
2286
+ }
2287
+
2288
+ return typeof reviver === 'function' ? function walk(holder, key) {
2289
+ var k, v, value = holder[key];
2290
+ if (value && typeof value === 'object') {
2291
+ for (k in value) {
2292
+ if (Object.hasOwnProperty.call(value, k)) {
2293
+ v = walk(value, k);
2294
+ if (v !== undefined) {
2295
+ value[k] = v;
2296
+ } else {
2297
+ delete value[k];
2298
+ }
2299
+ }
2300
+ }
2301
+ }
2302
+ return reviver.call(holder, key, value);
2303
+ }({'': result}, '') : result;
2304
+ };
2305
+ });