3
if (typeof window.window != "undefined" && window.document) {
9
var msgs = Array.prototype.slice.call(arguments, 0);
10
postMessage({type: "log", data: msgs});
13
var msgs = Array.prototype.slice.call(arguments, 0);
14
postMessage({type: "log", data: msgs});
17
window.window = window;
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]);
26
// normalize relative requires
27
if (moduleName.charAt(0) == ".") {
28
var base = parentId.split("/").slice(0, -1).join("/");
29
moduleName = base + "/" + moduleName;
31
while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
32
var previous = moduleName;
33
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
40
window.require = function(parentId, id) {
42
throw new Error("worker.js require() accepts only (parentId, id) as arguments");
44
id = normalizeModule(parentId, id);
46
var module = require.modules[id];
48
if (!module.initialized) {
49
module.initialized = true;
50
module.exports = module.factory().exports;
52
return module.exports;
55
var chunks = id.split("/");
56
chunks[0] = require.tlns[chunks[0]] || chunks[0];
57
var path = chunks.join("/") + ".js";
61
return require(parentId, id);
67
window.define = function(id, deps, factory) {
68
if (arguments.length == 2) {
70
if (typeof id != "string") {
74
} else if (arguments.length == 1) {
79
if (id.indexOf("text!") === 0)
82
var req = function(deps, factory) {
83
return require(id, deps, factory);
86
require.modules[id] = {
91
var returnExports = factory(req, module.exports, module);
93
module.exports = returnExports;
99
window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
100
require.tlns = topLevelNamespaces;
103
window.initSender = function initSender() {
105
var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
106
var oop = require(null, "ace/lib/oop");
108
var Sender = function() {};
112
oop.implement(this, EventEmitter);
114
this.callback = function(data, callbackId) {
122
this.emit = function(name, data) {
130
}).call(Sender.prototype);
136
window.sender = null;
138
window.onmessage = function(e) {
141
if (main[msg.command])
142
main[msg.command].apply(main, msg.args);
144
throw new Error("Unknown command:" + msg.command);
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);
153
else if (msg.event && sender) {
154
sender._emit(msg.event, msg.data);
157
})(this);// vim:set ts=4 sts=4 sw=4 st:
159
define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
163
require("./es5-shim");
167
define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
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
176
compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
177
compliantLastIndexIncrement = function () {
179
real.test.call(x, "");
183
if (compliantLastIndexIncrement && compliantExecNpcg)
185
RegExp.prototype.exec = function (str) {
186
var match = real.exec.apply(this, arguments),
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;
198
if (this._xregexp && this._xregexp.captureNames) {
199
for (var i = 1; i < match.length; i++) {
200
name = this._xregexp.captureNames[i - 1];
202
match[name] = match[i];
205
if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
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))
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" : "");
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)
239
define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
243
if (!Function.prototype.bind) {
244
Function.prototype.bind = function bind(that) { // .length is 1
246
if (typeof target != "function") {
247
throw new TypeError("Function.prototype.bind called on incompatible " + target);
249
var args = slice.call(arguments, 1); // for normal call
250
var bound = function () {
252
if (this instanceof bound) {
254
var result = target.apply(
256
args.concat(slice.call(arguments))
258
if (Object(result) === result) {
266
args.concat(slice.call(arguments))
272
if(target.prototype) {
273
Empty.prototype = target.prototype;
274
bound.prototype = new Empty();
275
Empty.prototype = null;
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);
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__);
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);
304
var array = [], lengthBefore;
306
array.splice.apply(array, makeArray(20));
307
array.splice.apply(array, makeArray(26));
309
lengthBefore = array.length; //46
310
array.splice(5, 0, "XXX"); // add one element
312
lengthBefore + 1 == array.length
314
if (lengthBefore + 1 == array.length) {
315
return true;// has right splice implementation without bugs
318
var array_splice = Array.prototype.splice;
319
Array.prototype.splice = function(start, deleteCount) {
320
if (!arguments.length) {
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)))
330
Array.prototype.splice = function(pos, removeCount){
331
var length = this.length;
335
} else if (pos == void 0) {
337
} else if (pos < 0) {
338
pos = Math.max(length + pos, 0);
341
if (!(pos+removeCount < length))
342
removeCount = length - pos;
344
var removed = this.slice(pos, pos+removeCount);
345
var insert = slice.call(arguments, 2);
346
var add = insert.length;
347
if (pos === length) {
349
this.push.apply(this, insert);
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;
358
if (tailNewPos < tailOldPos) { // case A
359
for (var i = 0; i < tailCount; ++i) {
360
this[tailNewPos+i] = this[tailOldPos+i];
362
} else if (tailNewPos > tailOldPos) { // case B
363
for (i = tailCount; i--; ) {
364
this[tailNewPos+i] = this[tailOldPos+i];
366
} // else, add == remove (nothing to do)
368
if (add && pos === lengthAfterRemove) {
369
this.length = lengthAfterRemove; // truncate array
370
this.push.apply(this, insert);
372
this.length = lengthAfterRemove + add; // reserves space
373
for (i = 0; i < add; ++i) {
374
this[pos+i] = insert[i];
382
if (!Array.isArray) {
383
Array.isArray = function isArray(obj) {
384
return _toString(obj) == "[object Array]";
387
var boxedString = Object("a"),
388
splitString = boxedString[0] != "a" || !(0 in boxedString);
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]" ?
396
thisp = arguments[1],
398
length = self.length >>> 0;
399
if (_toString(fun) != "[object Function]") {
400
throw new TypeError(); // TODO message
403
while (++i < length) {
405
fun.call(thisp, self[i], i, object);
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]" ?
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");
423
for (var i = 0; i < length; i++) {
425
result[i] = fun.call(thisp, self[i], i, object);
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]" ?
436
length = self.length >>> 0,
439
thisp = arguments[1];
440
if (_toString(fun) != "[object Function]") {
441
throw new TypeError(fun + " is not a function");
444
for (var i = 0; i < length; i++) {
447
if (fun.call(thisp, value, i, object)) {
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]" ?
461
length = self.length >>> 0,
462
thisp = arguments[1];
463
if (_toString(fun) != "[object Function]") {
464
throw new TypeError(fun + " is not a function");
467
for (var i = 0; i < length; i++) {
468
if (i in self && !fun.call(thisp, self[i], i, object)) {
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]" ?
481
length = self.length >>> 0,
482
thisp = arguments[1];
483
if (_toString(fun) != "[object Function]") {
484
throw new TypeError(fun + " is not a function");
487
for (var i = 0; i < length; i++) {
488
if (i in self && fun.call(thisp, self[i], i, object)) {
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]" ?
501
length = self.length >>> 0;
502
if (_toString(fun) != "[object Function]") {
503
throw new TypeError(fun + " is not a function");
505
if (!length && arguments.length == 1) {
506
throw new TypeError("reduce of empty array with no initial value");
511
if (arguments.length >= 2) {
512
result = arguments[1];
520
throw new TypeError("reduce of empty array with no initial value");
525
for (; i < length; i++) {
527
result = fun.call(void 0, result, self[i], i, object);
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]" ?
540
length = self.length >>> 0;
541
if (_toString(fun) != "[object Function]") {
542
throw new TypeError(fun + " is not a function");
544
if (!length && arguments.length == 1) {
545
throw new TypeError("reduceRight of empty array with no initial value");
548
var result, i = length - 1;
549
if (arguments.length >= 2) {
550
result = arguments[1];
558
throw new TypeError("reduceRight of empty array with no initial value");
565
result = fun.call(void 0, result, self[i], i, object);
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]" ?
577
length = self.length >>> 0;
584
if (arguments.length > 1) {
585
i = toInteger(arguments[1]);
587
i = i >= 0 ? i : Math.max(0, length + i);
588
for (; i < length; i++) {
589
if (i in self && self[i] === sought) {
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]" ?
601
length = self.length >>> 0;
607
if (arguments.length > 1) {
608
i = Math.min(i, toInteger(arguments[1]));
610
i = i >= 0 ? i : length - Math.abs(i);
611
for (; i >= 0; i--) {
612
if (i in self && sought === self[i]) {
619
if (!Object.getPrototypeOf) {
620
Object.getPrototypeOf = function getPrototypeOf(object) {
621
return object.__proto__ || (
623
object.constructor.prototype :
628
if (!Object.getOwnPropertyDescriptor) {
629
var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
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))
637
var descriptor, getter, setter;
638
descriptor = { enumerable: true, configurable: true };
639
if (supportsAccessors) {
640
var prototype = object.__proto__;
641
object.__proto__ = prototypeOfObject;
643
var getter = lookupGetter(object, property);
644
var setter = lookupSetter(object, property);
645
object.__proto__ = prototype;
647
if (getter || setter) {
648
if (getter) descriptor.get = getter;
649
if (setter) descriptor.set = setter;
653
descriptor.value = object[property];
657
if (!Object.getOwnPropertyNames) {
658
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
659
return Object.keys(object);
662
if (!Object.create) {
664
if (Object.prototype.__proto__ === null) {
665
createEmpty = function () {
666
return { "__proto__": null };
669
createEmpty = function () {
674
empty.hasOwnProperty =
675
empty.propertyIsEnumerable =
676
empty.isPrototypeOf =
677
empty.toLocaleString =
680
empty.__proto__ = null;
685
Object.create = function create(prototype, properties) {
687
if (prototype === null) {
688
object = createEmpty();
690
if (typeof prototype != "object")
691
throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
692
var Type = function () {};
693
Type.prototype = prototype;
695
object.__proto__ = prototype;
697
if (properties !== void 0)
698
Object.defineProperties(object, properties);
703
function doesDefinePropertyWork(object) {
705
Object.defineProperty(object, "sentinel", {});
706
return "sentinel" in object;
707
} catch (exception) {
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;
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";
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) {
732
return definePropertyFallback.call(Object, object, property, descriptor);
733
} catch (exception) {
736
if (owns(descriptor, "value")) {
738
if (supportsAccessors && (lookupGetter(object, property) ||
739
lookupSetter(object, property)))
741
var prototype = object.__proto__;
742
object.__proto__ = prototypeOfObject;
743
delete object[property];
744
object[property] = descriptor.value;
745
object.__proto__ = prototype;
747
object[property] = descriptor.value;
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);
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]);
771
Object.seal = function seal(object) {
775
if (!Object.freeze) {
776
Object.freeze = function freeze(object) {
781
Object.freeze(function () {});
782
} catch (exception) {
783
Object.freeze = (function freeze(freezeObject) {
784
return function freeze(object) {
785
if (typeof object == "function") {
788
return freezeObject(object);
793
if (!Object.preventExtensions) {
794
Object.preventExtensions = function preventExtensions(object) {
798
if (!Object.isSealed) {
799
Object.isSealed = function isSealed(object) {
803
if (!Object.isFrozen) {
804
Object.isFrozen = function isFrozen(object) {
808
if (!Object.isExtensible) {
809
Object.isExtensible = function isExtensible(object) {
810
if (Object(object) === object) {
811
throw new TypeError(); // TODO message
814
while (owns(object, name)) {
818
var returnValue = owns(object, name);
824
var hasDontEnumBug = true,
831
"propertyIsEnumerable",
834
dontEnumsLength = dontEnums.length;
836
for (var key in {"toString": null}) {
837
hasDontEnumBug = false;
840
Object.keys = function keys(object) {
843
(typeof object != "object" && typeof object != "function") ||
846
throw new TypeError("Object.keys called on a non-object");
850
for (var name in object) {
851
if (owns(object, name)) {
856
if (hasDontEnumBug) {
857
for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
858
var dontEnum = dontEnums[i];
859
if (owns(object, dontEnum)) {
869
Date.now = function now() {
870
return new Date().getTime();
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" +
876
if (!String.prototype.trim || ws.trim()) {
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, "");
885
function toInteger(n) {
887
if (n !== n) { // isNaN
889
} else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
890
n = (n > 0 || -1) * Math.floor(Math.abs(n));
895
function isPrimitive(input) {
896
var type = typeof input;
899
type === "undefined" ||
900
type === "boolean" ||
906
function toPrimitive(input) {
907
var val, valueOf, toString;
908
if (isPrimitive(input)) {
911
valueOf = input.valueOf;
912
if (typeof valueOf === "function") {
913
val = valueOf.call(input);
914
if (isPrimitive(val)) {
918
toString = input.toString;
919
if (typeof toString === "function") {
920
val = toString.call(input);
921
if (isPrimitive(val)) {
925
throw new TypeError();
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");
936
define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
939
var EventEmitter = {};
940
var stopPropagation = function() { this.propagationStopped = true; };
941
var preventDefault = function() { this.defaultPrevented = true; };
944
EventEmitter._dispatchEvent = function(eventName, e) {
945
this._eventRegistry || (this._eventRegistry = {});
946
this._defaultHandlers || (this._defaultHandlers = {});
948
var listeners = this._eventRegistry[eventName] || [];
949
var defaultHandler = this._defaultHandlers[eventName];
950
if (!listeners.length && !defaultHandler)
953
if (typeof e != "object" || !e)
958
if (!e.stopPropagation)
959
e.stopPropagation = stopPropagation;
960
if (!e.preventDefault)
961
e.preventDefault = preventDefault;
965
for (var i=0; i<listeners.length; i++) {
967
if (e.propagationStopped)
971
if (defaultHandler && !e.defaultPrevented)
972
return defaultHandler(e);
976
EventEmitter._signal = function(eventName, e) {
977
var listeners = (this._eventRegistry || {})[eventName];
981
for (var i=0; i<listeners.length; i++)
985
EventEmitter.once = function(eventName, callback) {
987
var newCallback = function() {
988
fun && fun.apply(null, arguments);
989
_self.removeEventListener(event, newCallback);
991
this.addEventListener(event, newCallback);
995
EventEmitter.setDefaultHandler = function(eventName, callback) {
996
this._defaultHandlers = this._defaultHandlers || {};
998
if (this._defaultHandlers[eventName])
999
throw new Error("The default handler for '" + eventName + "' is already set");
1001
this._defaultHandlers[eventName] = callback;
1005
EventEmitter.addEventListener = function(eventName, callback, capturing) {
1006
this._eventRegistry = this._eventRegistry || {};
1008
var listeners = this._eventRegistry[eventName];
1010
listeners = this._eventRegistry[eventName] = [];
1012
if (listeners.indexOf(callback) == -1)
1013
listeners[capturing ? "unshift" : "push"](callback);
1017
EventEmitter.removeListener =
1018
EventEmitter.removeEventListener = function(eventName, callback) {
1019
this._eventRegistry = this._eventRegistry || {};
1021
var listeners = this._eventRegistry[eventName];
1025
var index = listeners.indexOf(callback);
1027
listeners.splice(index, 1);
1030
EventEmitter.removeAllListeners = function(eventName) {
1031
if (this._eventRegistry) this._eventRegistry[eventName] = [];
1034
exports.EventEmitter = EventEmitter;
1038
define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
1041
exports.inherits = (function() {
1042
var tempCtor = function() {};
1043
return function(ctor, superCtor) {
1044
tempCtor.prototype = superCtor.prototype;
1045
ctor.super_ = superCtor.prototype;
1046
ctor.prototype = new tempCtor();
1047
ctor.prototype.constructor = ctor;
1051
exports.mixin = function(obj, mixin) {
1052
for (var key in mixin) {
1053
obj[key] = mixin[key];
1057
exports.implement = function(proto, mixin) {
1058
exports.mixin(proto, mixin);
1063
define('ace/mode/json_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/json/json_parse'], function(require, exports, module) {
1066
var oop = require("../lib/oop");
1067
var Mirror = require("../worker/mirror").Mirror;
1068
var parse = require("./json/json_parse");
1070
var JsonWorker = exports.JsonWorker = function(sender) {
1071
Mirror.call(this, sender);
1072
this.setTimeout(200);
1075
oop.inherits(JsonWorker, Mirror);
1079
this.onUpdate = function() {
1080
var value = this.doc.getValue();
1083
var result = parse(value);
1085
var pos = this.doc.indexToPosition(e.at-1);
1086
this.sender.emit("error", {
1094
this.sender.emit("ok");
1097
}).call(JsonWorker.prototype);
1100
define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) {
1103
var Document = require("../document").Document;
1104
var lang = require("../lib/lang");
1106
var Mirror = exports.Mirror = function(sender) {
1107
this.sender = sender;
1108
var doc = this.doc = new Document("");
1110
var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1113
sender.on("change", function(e) {
1114
doc.applyDeltas([e.data]);
1115
deferredUpdate.schedule(_self.$timeout);
1121
this.$timeout = 500;
1123
this.setTimeout = function(timeout) {
1124
this.$timeout = timeout;
1127
this.setValue = function(value) {
1128
this.doc.setValue(value);
1129
this.deferredUpdate.schedule(this.$timeout);
1132
this.getValue = function(callbackId) {
1133
this.sender.callback(this.doc.getValue(), callbackId);
1136
this.onUpdate = function() {
1139
}).call(Mirror.prototype);
1143
define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
1146
var oop = require("./lib/oop");
1147
var EventEmitter = require("./lib/event_emitter").EventEmitter;
1148
var Range = require("./range").Range;
1149
var Anchor = require("./anchor").Anchor;
1151
var Document = function(text) {
1153
if (text.length == 0) {
1155
} else if (Array.isArray(text)) {
1156
this.insertLines(0, text);
1158
this.insert({row: 0, column:0}, text);
1164
oop.implement(this, EventEmitter);
1165
this.setValue = function(text) {
1166
var len = this.getLength();
1167
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
1168
this.insert({row: 0, column:0}, text);
1170
this.getValue = function() {
1171
return this.getAllLines().join(this.getNewLineCharacter());
1173
this.createAnchor = function(row, column) {
1174
return new Anchor(this, row, column);
1176
if ("aaa".split(/a/).length == 0)
1177
this.$split = function(text) {
1178
return text.replace(/\r\n|\r/g, "\n").split("\n");
1181
this.$split = function(text) {
1182
return text.split(/\r\n|\r|\n/);
1187
this.$detectNewLine = function(text) {
1188
var match = text.match(/^.*?(\r\n|\r|\n)/m);
1190
this.$autoNewLine = match[1];
1192
this.$autoNewLine = "\n";
1195
this.getNewLineCharacter = function() {
1196
switch (this.$newLineMode) {
1204
return this.$autoNewLine;
1208
this.$autoNewLine = "\n";
1209
this.$newLineMode = "auto";
1210
this.setNewLineMode = function(newLineMode) {
1211
if (this.$newLineMode === newLineMode)
1214
this.$newLineMode = newLineMode;
1216
this.getNewLineMode = function() {
1217
return this.$newLineMode;
1219
this.isNewLine = function(text) {
1220
return (text == "\r\n" || text == "\r" || text == "\n");
1222
this.getLine = function(row) {
1223
return this.$lines[row] || "";
1225
this.getLines = function(firstRow, lastRow) {
1226
return this.$lines.slice(firstRow, lastRow + 1);
1228
this.getAllLines = function() {
1229
return this.getLines(0, this.getLength());
1231
this.getLength = function() {
1232
return this.$lines.length;
1234
this.getTextRange = function(range) {
1235
if (range.start.row == range.end.row) {
1236
return this.$lines[range.start.row].substring(range.start.column,
1240
var lines = this.getLines(range.start.row+1, range.end.row-1);
1241
lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
1242
lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
1243
return lines.join(this.getNewLineCharacter());
1247
this.$clipPosition = function(position) {
1248
var length = this.getLength();
1249
if (position.row >= length) {
1250
position.row = Math.max(0, length - 1);
1251
position.column = this.getLine(length-1).length;
1255
this.insert = function(position, text) {
1256
if (!text || text.length === 0)
1259
position = this.$clipPosition(position);
1260
if (this.getLength() <= 1)
1261
this.$detectNewLine(text);
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];
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 || "");
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);
1283
var args = [row, 0];
1284
args.push.apply(args, lines);
1285
this.$lines.splice.apply(this.$lines, args);
1287
var range = new Range(row, 0, row + lines.length, 0);
1289
action: "insertLines",
1293
this._emit("change", { data: delta });
1294
return end || range.end;
1296
this.insertNewLine = function(position) {
1297
position = this.$clipPosition(position);
1298
var line = this.$lines[position.row] || "";
1300
this.$lines[position.row] = line.substring(0, position.column);
1301
this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
1304
row : position.row + 1,
1309
action: "insertText",
1310
range: Range.fromPoints(position, end),
1311
text: this.getNewLineCharacter()
1313
this._emit("change", { data: delta });
1317
this.insertInLine = function(position, text) {
1318
if (text.length == 0)
1321
var line = this.$lines[position.row] || "";
1323
this.$lines[position.row] = line.substring(0, position.column) + text
1324
+ line.substring(position.column);
1328
column : position.column + text.length
1332
action: "insertText",
1333
range: Range.fromPoints(position, end),
1336
this._emit("change", { data: delta });
1340
this.remove = function(range) {
1341
range.start = this.$clipPosition(range.start);
1342
range.end = this.$clipPosition(range.end);
1344
if (range.isEmpty())
1347
var firstRow = range.start.row;
1348
var lastRow = range.end.row;
1350
if (range.isMultiLine()) {
1351
var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
1352
var lastFullRow = lastRow - 1;
1354
if (range.end.column > 0)
1355
this.removeInLine(lastRow, 0, range.end.column);
1357
if (lastFullRow >= firstFullRow)
1358
this.removeLines(firstFullRow, lastFullRow);
1360
if (firstFullRow != firstRow) {
1361
this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
1362
this.removeNewLine(range.start.row);
1366
this.removeInLine(firstRow, range.start.column, range.end.column);
1370
this.removeInLine = function(row, startColumn, endColumn) {
1371
if (startColumn == endColumn)
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);
1381
action: "removeText",
1385
this._emit("change", { data: delta });
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);
1393
action: "removeLines",
1395
nl: this.getNewLineCharacter(),
1398
this._emit("change", { data: delta });
1401
this.removeNewLine = function(row) {
1402
var firstLine = this.getLine(row);
1403
var secondLine = this.getLine(row+1);
1405
var range = new Range(row, firstLine.length, row+1, 0);
1406
var line = firstLine + secondLine;
1408
this.$lines.splice(row, 2, line);
1411
action: "removeText",
1413
text: this.getNewLineCharacter()
1415
this._emit("change", { data: delta });
1417
this.replace = function(range, text) {
1418
if (text.length == 0 && range.isEmpty())
1420
if (text == this.getTextRange(range))
1425
var end = this.insert(range.start, text);
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);
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")
1448
this.revertDeltas = function(deltas) {
1449
for (var i=deltas.length-1; i>=0; i--) {
1450
var delta = deltas[i];
1452
var range = Range.fromPoints(delta.range.start, delta.range.end);
1454
if (delta.action == "insertLines")
1455
this.removeLines(range.start.row, range.end.row - 1);
1456
else if (delta.action == "insertText")
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);
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;
1470
return {row: i, column: index + lines[i].length + newlineLength};
1472
return {row: l-1, column: lines[l-1].length};
1474
this.positionToIndex = function(pos, startRow) {
1475
var lines = this.$lines || this.getAllLines();
1476
var newlineLength = this.getNewLineCharacter().length;
1478
var row = Math.min(pos.row, lines.length);
1479
for (var i = startRow || 0; i < row; ++i)
1480
index += lines[i].length;
1482
return index + newlineLength * i + pos.column;
1485
}).call(Document.prototype);
1487
exports.Document = Document;
1490
define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
1492
var comparePoints = function(p1, p2) {
1493
return p1.row - p2.row || p1.column - p2.column;
1495
var Range = function(startRow, startColumn, endRow, endColumn) {
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;
1514
this.toString = function() {
1515
return ("Range: [" + this.start.row + "/" + this.start.column +
1516
"] -> [" + this.end.row + "/" + this.end.column + "]");
1519
this.contains = function(row, column) {
1520
return this.compare(row, column) == 0;
1522
this.compareRange = function(range) {
1525
start = range.start;
1527
cmp = this.compare(end.row, end.column);
1529
cmp = this.compare(start.row, start.column);
1532
} else if (cmp == 0) {
1537
} else if (cmp == -1) {
1540
cmp = this.compare(start.row, start.column);
1543
} else if (cmp == 1) {
1550
this.comparePoint = function(p) {
1551
return this.compare(p.row, p.column);
1553
this.containsRange = function(range) {
1554
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
1556
this.intersects = function(range) {
1557
var cmp = this.compareRange(range);
1558
return (cmp == -1 || cmp == 0 || cmp == 1);
1560
this.isEnd = function(row, column) {
1561
return this.end.row == row && this.end.column == column;
1563
this.isStart = function(row, column) {
1564
return this.start.row == row && this.start.column == column;
1566
this.setStart = function(row, column) {
1567
if (typeof row == "object") {
1568
this.start.column = row.column;
1569
this.start.row = row.row;
1571
this.start.row = row;
1572
this.start.column = column;
1575
this.setEnd = function(row, column) {
1576
if (typeof row == "object") {
1577
this.end.column = row.column;
1578
this.end.row = row.row;
1581
this.end.column = column;
1584
this.inside = function(row, column) {
1585
if (this.compare(row, column) == 0) {
1586
if (this.isEnd(row, column) || this.isStart(row, column)) {
1594
this.insideStart = function(row, column) {
1595
if (this.compare(row, column) == 0) {
1596
if (this.isEnd(row, column)) {
1604
this.insideEnd = function(row, column) {
1605
if (this.compare(row, column) == 0) {
1606
if (this.isStart(row, column)) {
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);
1621
if (row < this.start.row)
1624
if (row > this.end.row)
1627
if (this.start.row === row)
1628
return column >= this.start.column ? 0 : -1;
1630
if (this.end.row === row)
1631
return column <= this.end.column ? 0 : 1;
1635
this.compareStart = function(row, column) {
1636
if (this.start.row == row && this.start.column == column) {
1639
return this.compare(row, column);
1642
this.compareEnd = function(row, column) {
1643
if (this.end.row == row && this.end.column == column) {
1646
return this.compare(row, column);
1649
this.compareInside = function(row, column) {
1650
if (this.end.row == row && this.end.column == column) {
1652
} else if (this.start.row == row && this.start.column == column) {
1655
return this.compare(row, column);
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};
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};
1669
return Range.fromPoints(start || this.start, end || this.end);
1671
this.extend = function(row, column) {
1672
var cmp = this.compare(row, column);
1677
var start = {row: row, column: column};
1679
var end = {row: row, column: column};
1681
return Range.fromPoints(start || this.start, end || this.end);
1684
this.isEmpty = function() {
1685
return (this.start.row === this.end.row && this.start.column === this.end.column);
1687
this.isMultiLine = function() {
1688
return (this.start.row !== this.end.row);
1690
this.clone = function() {
1691
return Range.fromPoints(this.start, this.end);
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)
1697
return new Range(this.start.row, 0, this.end.row, 0)
1699
this.toScreenRange = function(session) {
1700
var screenPosStart = session.documentToScreenPosition(this.start);
1701
var screenPosEnd = session.documentToScreenPosition(this.end);
1704
screenPosStart.row, screenPosStart.column,
1705
screenPosEnd.row, screenPosEnd.column
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;
1715
}).call(Range.prototype);
1716
Range.fromPoints = function(start, end) {
1717
return new Range(start.row, start.column, end.row, end.column);
1719
Range.comparePoints = comparePoints;
1721
exports.Range = Range;
1724
define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
1727
var oop = require("./lib/oop");
1728
var EventEmitter = require("./lib/event_emitter").EventEmitter;
1730
var Anchor = exports.Anchor = function(doc, row, column) {
1731
this.document = doc;
1733
if (typeof column == "undefined")
1734
this.setPosition(row.row, row.column);
1736
this.setPosition(row, column);
1738
this.$onChange = this.onChange.bind(this);
1739
doc.on("change", this.$onChange);
1744
oop.implement(this, EventEmitter);
1746
this.getPosition = function() {
1747
return this.$clipPositionToDocument(this.row, this.column);
1750
this.getDocument = function() {
1751
return this.document;
1754
this.onChange = function(e) {
1756
var range = delta.range;
1758
if (range.start.row == range.end.row && range.start.row != this.row)
1761
if (range.start.row > this.row)
1764
if (range.start.row == this.row && range.start.column > this.column)
1768
var column = this.column;
1770
if (delta.action === "insertText") {
1771
if (range.start.row === row && range.start.column <= column) {
1772
if (range.start.row === range.end.row) {
1773
column += range.end.column - range.start.column;
1776
column -= range.start.column;
1777
row += range.end.row - range.start.row;
1780
else if (range.start.row !== range.end.row && range.start.row < row) {
1781
row += range.end.row - range.start.row;
1783
} else if (delta.action === "insertLines") {
1784
if (range.start.row <= row) {
1785
row += range.end.row - range.start.row;
1788
else if (delta.action == "removeText") {
1789
if (range.start.row == row && range.start.column < column) {
1790
if (range.end.column >= column)
1791
column = range.start.column;
1793
column = Math.max(0, column - (range.end.column - range.start.column));
1795
} else if (range.start.row !== range.end.row && range.start.row < row) {
1796
if (range.end.row == row) {
1797
column = Math.max(0, column - range.end.column) + range.start.column;
1799
row -= (range.end.row - range.start.row);
1801
else if (range.end.row == row) {
1802
row -= range.end.row - range.start.row;
1803
column = Math.max(0, column - range.end.column) + range.start.column;
1805
} else if (delta.action == "removeLines") {
1806
if (range.start.row <= row) {
1807
if (range.end.row <= row)
1808
row -= range.end.row - range.start.row;
1810
row = range.start.row;
1816
this.setPosition(row, column, true);
1819
this.setPosition = function(row, column, noClip) {
1828
pos = this.$clipPositionToDocument(row, column);
1831
if (this.row == pos.row && this.column == pos.column)
1840
this.column = pos.column;
1841
this._emit("change", {
1847
this.detach = function() {
1848
this.document.removeEventListener("change", this.$onChange);
1850
this.$clipPositionToDocument = function(row, column) {
1853
if (row >= this.document.getLength()) {
1854
pos.row = Math.max(0, this.document.getLength() - 1);
1855
pos.column = this.document.getLine(pos.row).length;
1863
pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
1872
}).call(Anchor.prototype);
1876
define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
1879
exports.stringReverse = function(string) {
1880
return string.split("").reverse().join("");
1883
exports.stringRepeat = function (string, count) {
1895
var trimBeginRegexp = /^\s\s*/;
1896
var trimEndRegexp = /\s\s*$/;
1898
exports.stringTrimLeft = function (string) {
1899
return string.replace(trimBeginRegexp, '');
1902
exports.stringTrimRight = function (string) {
1903
return string.replace(trimEndRegexp, '');
1906
exports.copyObject = function(obj) {
1908
for (var key in obj) {
1909
copy[key] = obj[key];
1914
exports.copyArray = function(array){
1916
for (var i=0, l=array.length; i<l; i++) {
1917
if (array[i] && typeof array[i] == "object")
1918
copy[i] = this.copyObject( array[i] );
1925
exports.deepCopy = function (obj) {
1926
if (typeof obj != "object") {
1930
var copy = obj.constructor();
1931
for (var key in obj) {
1932
if (typeof obj[key] == "object") {
1933
copy[key] = this.deepCopy(obj[key]);
1935
copy[key] = obj[key];
1941
exports.arrayToMap = function(arr) {
1943
for (var i=0; i<arr.length; i++) {
1950
exports.createMap = function(props) {
1951
var map = Object.create(null);
1952
for (var i in props) {
1957
exports.arrayRemove = function(array, value) {
1958
for (var i = 0; i <= array.length; i++) {
1959
if (value === array[i]) {
1965
exports.escapeRegExp = function(str) {
1966
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
1969
exports.escapeHTML = function(str) {
1970
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
1973
exports.getMatchOffsets = function(string, regExp) {
1976
string.replace(regExp, function(str) {
1978
offset: arguments[arguments.length-2],
1985
exports.deferredCall = function(fcn) {
1988
var callback = function() {
1993
var deferred = function(timeout) {
1995
timer = setTimeout(callback, timeout || 0);
1999
deferred.schedule = deferred;
2001
deferred.call = function() {
2007
deferred.cancel = function() {
2008
clearTimeout(timer);
2017
exports.delayedCall = function(fcn, defaultTimeout) {
2019
var callback = function() {
2024
var _self = function(timeout) {
2025
timer && clearTimeout(timer);
2026
timer = setTimeout(callback, timeout || defaultTimeout);
2029
_self.delay = _self;
2030
_self.schedule = function(timeout) {
2032
timer = setTimeout(callback, timeout || 0);
2035
_self.call = function() {
2040
_self.cancel = function() {
2041
timer && clearTimeout(timer);
2045
_self.isPending = function() {
2053
define('ace/mode/json/json_parse', ['require', 'exports', 'module' ], function(require, exports, module) {
2055
var at, // The index of the current character
2056
ch, // The current character
2069
error = function (m) {
2072
name: 'SyntaxError',
2079
next = function (c) {
2081
if (c && c !== ch) {
2082
error("Expected '" + c + "' instead of '" + ch + "'");
2085
ch = text.charAt(at);
2090
number = function () {
2099
while (ch >= '0' && ch <= '9') {
2105
while (next() && ch >= '0' && ch <= '9') {
2109
if (ch === 'e' || ch === 'E') {
2112
if (ch === '-' || ch === '+') {
2116
while (ch >= '0' && ch <= '9') {
2122
if (isNaN(number)) {
2123
error("Bad number");
2129
string = function () {
2141
} else if (ch === '\\') {
2145
for (i = 0; i < 4; i += 1) {
2146
hex = parseInt(next(), 16);
2147
if (!isFinite(hex)) {
2150
uffff = uffff * 16 + hex;
2152
string += String.fromCharCode(uffff);
2153
} else if (typeof escapee[ch] === 'string') {
2154
string += escapee[ch];
2163
error("Bad string");
2166
white = function () {
2168
while (ch && ch <= ' ') {
2173
word = function () {
2196
error("Unexpected '" + ch + "'");
2199
value, // Place holder for the value function.
2201
array = function () {
2210
return array; // empty array
2213
array.push(value());
2226
object = function () {
2236
return object; // empty object
2242
if (Object.hasOwnProperty.call(object, key)) {
2243
error('Duplicate key "' + key + '"');
2245
object[key] = value();
2255
error("Bad object");
2258
value = function () {
2271
return ch >= '0' && ch <= '9' ? number() : word();
2275
return function (source, reviver) {
2284
error("Syntax error");
2287
return typeof reviver === 'function' ? function walk(holder, key) {
2288
var k, v, value = holder[key];
2289
if (value && typeof value === 'object') {
2291
if (Object.hasOwnProperty.call(value, k)) {
2293
if (v !== undefined) {
2301
return reviver.call(holder, key, value);
2302
}({'': result}, '') : result;