/Scripts/ace/noconflict/worker-php.js

http://orchardscriptingext.codeplex.com · JavaScript · 6751 lines · 5688 code · 1060 blank · 3 comment · 681 complexity · 8bbe66418e63d5c07b77876841e31bc0 MD5 · raw file

Large files are truncated click here to view the full file

  1. "no use strict";
  2. if (typeof window != "undefined" && window.document)
  3. throw "atempt to load ace worker into main window instead of webWorker";
  4. var console = {
  5. log: function() {
  6. var msgs = Array.prototype.slice.call(arguments, 0);
  7. postMessage({type: "log", data: msgs});
  8. },
  9. error: function() {
  10. var msgs = Array.prototype.slice.call(arguments, 0);
  11. postMessage({type: "log", data: msgs});
  12. }
  13. };
  14. var window = {
  15. console: console
  16. };
  17. var normalizeModule = function(parentId, moduleName) {
  18. // normalize plugin requires
  19. if (moduleName.indexOf("!") !== -1) {
  20. var chunks = moduleName.split("!");
  21. return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
  22. }
  23. // normalize relative requires
  24. if (moduleName.charAt(0) == ".") {
  25. var base = parentId.split("/").slice(0, -1).join("/");
  26. moduleName = base + "/" + moduleName;
  27. while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
  28. var previous = moduleName;
  29. moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  30. }
  31. }
  32. return moduleName;
  33. };
  34. var require = function(parentId, id) {
  35. if (!id.charAt)
  36. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  37. id = normalizeModule(parentId, id);
  38. var module = require.modules[id];
  39. if (module) {
  40. if (!module.initialized) {
  41. module.initialized = true;
  42. module.exports = module.factory().exports;
  43. }
  44. return module.exports;
  45. }
  46. var chunks = id.split("/");
  47. chunks[0] = require.tlns[chunks[0]] || chunks[0];
  48. var path = chunks.join("/") + ".js";
  49. require.id = id;
  50. importScripts(path);
  51. return require(parentId, id);
  52. };
  53. require.modules = {};
  54. require.tlns = {};
  55. var define = function(id, deps, factory) {
  56. if (arguments.length == 2) {
  57. factory = deps;
  58. if (typeof id != "string") {
  59. deps = id;
  60. id = require.id;
  61. }
  62. } else if (arguments.length == 1) {
  63. factory = id;
  64. id = require.id;
  65. }
  66. if (id.indexOf("text!") === 0)
  67. return;
  68. var req = function(deps, factory) {
  69. return require(id, deps, factory);
  70. };
  71. require.modules[id] = {
  72. factory: function() {
  73. var module = {
  74. exports: {}
  75. };
  76. var returnExports = factory(req, module.exports, module);
  77. if (returnExports)
  78. module.exports = returnExports;
  79. return module;
  80. }
  81. };
  82. };
  83. function initBaseUrls(topLevelNamespaces) {
  84. require.tlns = topLevelNamespaces;
  85. }
  86. function initSender() {
  87. var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
  88. var oop = require(null, "ace/lib/oop");
  89. var Sender = function() {};
  90. (function() {
  91. oop.implement(this, EventEmitter);
  92. this.callback = function(data, callbackId) {
  93. postMessage({
  94. type: "call",
  95. id: callbackId,
  96. data: data
  97. });
  98. };
  99. this.emit = function(name, data) {
  100. postMessage({
  101. type: "event",
  102. name: name,
  103. data: data
  104. });
  105. };
  106. }).call(Sender.prototype);
  107. return new Sender();
  108. }
  109. var main;
  110. var sender;
  111. onmessage = function(e) {
  112. var msg = e.data;
  113. if (msg.command) {
  114. if (main[msg.command])
  115. main[msg.command].apply(main, msg.args);
  116. else
  117. throw new Error("Unknown command:" + msg.command);
  118. }
  119. else if (msg.init) {
  120. initBaseUrls(msg.tlns);
  121. require(null, "ace/lib/fixoldbrowsers");
  122. sender = initSender();
  123. var clazz = require(null, msg.module)[msg.classname];
  124. main = new clazz(sender);
  125. }
  126. else if (msg.event && sender) {
  127. sender._emit(msg.event, msg.data);
  128. }
  129. };
  130. // vim:set ts=4 sts=4 sw=4 st:
  131. define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
  132. require("./regexp");
  133. require("./es5-shim");
  134. });
  135. define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
  136. var real = {
  137. exec: RegExp.prototype.exec,
  138. test: RegExp.prototype.test,
  139. match: String.prototype.match,
  140. replace: String.prototype.replace,
  141. split: String.prototype.split
  142. },
  143. compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
  144. compliantLastIndexIncrement = function () {
  145. var x = /^/g;
  146. real.test.call(x, "");
  147. return !x.lastIndex;
  148. }();
  149. if (compliantLastIndexIncrement && compliantExecNpcg)
  150. return;
  151. RegExp.prototype.exec = function (str) {
  152. var match = real.exec.apply(this, arguments),
  153. name, r2;
  154. if ( typeof(str) == 'string' && match) {
  155. if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
  156. r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
  157. real.replace.call(str.slice(match.index), r2, function () {
  158. for (var i = 1; i < arguments.length - 2; i++) {
  159. if (arguments[i] === undefined)
  160. match[i] = undefined;
  161. }
  162. });
  163. }
  164. if (this._xregexp && this._xregexp.captureNames) {
  165. for (var i = 1; i < match.length; i++) {
  166. name = this._xregexp.captureNames[i - 1];
  167. if (name)
  168. match[name] = match[i];
  169. }
  170. }
  171. if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
  172. this.lastIndex--;
  173. }
  174. return match;
  175. };
  176. if (!compliantLastIndexIncrement) {
  177. RegExp.prototype.test = function (str) {
  178. var match = real.exec.call(this, str);
  179. if (match && this.global && !match[0].length && (this.lastIndex > match.index))
  180. this.lastIndex--;
  181. return !!match;
  182. };
  183. }
  184. function getNativeFlags (regex) {
  185. return (regex.global ? "g" : "") +
  186. (regex.ignoreCase ? "i" : "") +
  187. (regex.multiline ? "m" : "") +
  188. (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
  189. (regex.sticky ? "y" : "");
  190. }
  191. function indexOf (array, item, from) {
  192. if (Array.prototype.indexOf) // Use the native array method if available
  193. return array.indexOf(item, from);
  194. for (var i = from || 0; i < array.length; i++) {
  195. if (array[i] === item)
  196. return i;
  197. }
  198. return -1;
  199. }
  200. });
  201. define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
  202. function Empty() {}
  203. if (!Function.prototype.bind) {
  204. Function.prototype.bind = function bind(that) { // .length is 1
  205. var target = this;
  206. if (typeof target != "function") {
  207. throw new TypeError("Function.prototype.bind called on incompatible " + target);
  208. }
  209. var args = slice.call(arguments, 1); // for normal call
  210. var bound = function () {
  211. if (this instanceof bound) {
  212. var result = target.apply(
  213. this,
  214. args.concat(slice.call(arguments))
  215. );
  216. if (Object(result) === result) {
  217. return result;
  218. }
  219. return this;
  220. } else {
  221. return target.apply(
  222. that,
  223. args.concat(slice.call(arguments))
  224. );
  225. }
  226. };
  227. if(target.prototype) {
  228. Empty.prototype = target.prototype;
  229. bound.prototype = new Empty();
  230. Empty.prototype = null;
  231. }
  232. return bound;
  233. };
  234. }
  235. var call = Function.prototype.call;
  236. var prototypeOfArray = Array.prototype;
  237. var prototypeOfObject = Object.prototype;
  238. var slice = prototypeOfArray.slice;
  239. var _toString = call.bind(prototypeOfObject.toString);
  240. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  241. var defineGetter;
  242. var defineSetter;
  243. var lookupGetter;
  244. var lookupSetter;
  245. var supportsAccessors;
  246. if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
  247. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  248. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  249. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  250. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  251. }
  252. if ([1,2].splice(0).length != 2) {
  253. if(function() { // test IE < 9 to splice bug - see issue #138
  254. function makeArray(l) {
  255. var a = new Array(l+2);
  256. a[0] = a[1] = 0;
  257. return a;
  258. }
  259. var array = [], lengthBefore;
  260. array.splice.apply(array, makeArray(20));
  261. array.splice.apply(array, makeArray(26));
  262. lengthBefore = array.length; //46
  263. array.splice(5, 0, "XXX"); // add one element
  264. lengthBefore + 1 == array.length
  265. if (lengthBefore + 1 == array.length) {
  266. return true;// has right splice implementation without bugs
  267. }
  268. }()) {//IE 6/7
  269. var array_splice = Array.prototype.splice;
  270. Array.prototype.splice = function(start, deleteCount) {
  271. if (!arguments.length) {
  272. return [];
  273. } else {
  274. return array_splice.apply(this, [
  275. start === void 0 ? 0 : start,
  276. deleteCount === void 0 ? (this.length - start) : deleteCount
  277. ].concat(slice.call(arguments, 2)))
  278. }
  279. };
  280. } else {//IE8
  281. Array.prototype.splice = function(pos, removeCount){
  282. var length = this.length;
  283. if (pos > 0) {
  284. if (pos > length)
  285. pos = length;
  286. } else if (pos == void 0) {
  287. pos = 0;
  288. } else if (pos < 0) {
  289. pos = Math.max(length + pos, 0);
  290. }
  291. if (!(pos+removeCount < length))
  292. removeCount = length - pos;
  293. var removed = this.slice(pos, pos+removeCount);
  294. var insert = slice.call(arguments, 2);
  295. var add = insert.length;
  296. if (pos === length) {
  297. if (add) {
  298. this.push.apply(this, insert);
  299. }
  300. } else {
  301. var remove = Math.min(removeCount, length - pos);
  302. var tailOldPos = pos + remove;
  303. var tailNewPos = tailOldPos + add - remove;
  304. var tailCount = length - tailOldPos;
  305. var lengthAfterRemove = length - remove;
  306. if (tailNewPos < tailOldPos) { // case A
  307. for (var i = 0; i < tailCount; ++i) {
  308. this[tailNewPos+i] = this[tailOldPos+i];
  309. }
  310. } else if (tailNewPos > tailOldPos) { // case B
  311. for (i = tailCount; i--; ) {
  312. this[tailNewPos+i] = this[tailOldPos+i];
  313. }
  314. } // else, add == remove (nothing to do)
  315. if (add && pos === lengthAfterRemove) {
  316. this.length = lengthAfterRemove; // truncate array
  317. this.push.apply(this, insert);
  318. } else {
  319. this.length = lengthAfterRemove + add; // reserves space
  320. for (i = 0; i < add; ++i) {
  321. this[pos+i] = insert[i];
  322. }
  323. }
  324. }
  325. return removed;
  326. };
  327. }
  328. }
  329. if (!Array.isArray) {
  330. Array.isArray = function isArray(obj) {
  331. return _toString(obj) == "[object Array]";
  332. };
  333. }
  334. var boxedString = Object("a"),
  335. splitString = boxedString[0] != "a" || !(0 in boxedString);
  336. if (!Array.prototype.forEach) {
  337. Array.prototype.forEach = function forEach(fun /*, thisp*/) {
  338. var object = toObject(this),
  339. self = splitString && _toString(this) == "[object String]" ?
  340. this.split("") :
  341. object,
  342. thisp = arguments[1],
  343. i = -1,
  344. length = self.length >>> 0;
  345. if (_toString(fun) != "[object Function]") {
  346. throw new TypeError(); // TODO message
  347. }
  348. while (++i < length) {
  349. if (i in self) {
  350. fun.call(thisp, self[i], i, object);
  351. }
  352. }
  353. };
  354. }
  355. if (!Array.prototype.map) {
  356. Array.prototype.map = function map(fun /*, thisp*/) {
  357. var object = toObject(this),
  358. self = splitString && _toString(this) == "[object String]" ?
  359. this.split("") :
  360. object,
  361. length = self.length >>> 0,
  362. result = Array(length),
  363. thisp = arguments[1];
  364. if (_toString(fun) != "[object Function]") {
  365. throw new TypeError(fun + " is not a function");
  366. }
  367. for (var i = 0; i < length; i++) {
  368. if (i in self)
  369. result[i] = fun.call(thisp, self[i], i, object);
  370. }
  371. return result;
  372. };
  373. }
  374. if (!Array.prototype.filter) {
  375. Array.prototype.filter = function filter(fun /*, thisp */) {
  376. var object = toObject(this),
  377. self = splitString && _toString(this) == "[object String]" ?
  378. this.split("") :
  379. object,
  380. length = self.length >>> 0,
  381. result = [],
  382. value,
  383. thisp = arguments[1];
  384. if (_toString(fun) != "[object Function]") {
  385. throw new TypeError(fun + " is not a function");
  386. }
  387. for (var i = 0; i < length; i++) {
  388. if (i in self) {
  389. value = self[i];
  390. if (fun.call(thisp, value, i, object)) {
  391. result.push(value);
  392. }
  393. }
  394. }
  395. return result;
  396. };
  397. }
  398. if (!Array.prototype.every) {
  399. Array.prototype.every = function every(fun /*, thisp */) {
  400. var object = toObject(this),
  401. self = splitString && _toString(this) == "[object String]" ?
  402. this.split("") :
  403. object,
  404. length = self.length >>> 0,
  405. thisp = arguments[1];
  406. if (_toString(fun) != "[object Function]") {
  407. throw new TypeError(fun + " is not a function");
  408. }
  409. for (var i = 0; i < length; i++) {
  410. if (i in self && !fun.call(thisp, self[i], i, object)) {
  411. return false;
  412. }
  413. }
  414. return true;
  415. };
  416. }
  417. if (!Array.prototype.some) {
  418. Array.prototype.some = function some(fun /*, thisp */) {
  419. var object = toObject(this),
  420. self = splitString && _toString(this) == "[object String]" ?
  421. this.split("") :
  422. object,
  423. length = self.length >>> 0,
  424. thisp = arguments[1];
  425. if (_toString(fun) != "[object Function]") {
  426. throw new TypeError(fun + " is not a function");
  427. }
  428. for (var i = 0; i < length; i++) {
  429. if (i in self && fun.call(thisp, self[i], i, object)) {
  430. return true;
  431. }
  432. }
  433. return false;
  434. };
  435. }
  436. if (!Array.prototype.reduce) {
  437. Array.prototype.reduce = function reduce(fun /*, initial*/) {
  438. var object = toObject(this),
  439. self = splitString && _toString(this) == "[object String]" ?
  440. this.split("") :
  441. object,
  442. length = self.length >>> 0;
  443. if (_toString(fun) != "[object Function]") {
  444. throw new TypeError(fun + " is not a function");
  445. }
  446. if (!length && arguments.length == 1) {
  447. throw new TypeError("reduce of empty array with no initial value");
  448. }
  449. var i = 0;
  450. var result;
  451. if (arguments.length >= 2) {
  452. result = arguments[1];
  453. } else {
  454. do {
  455. if (i in self) {
  456. result = self[i++];
  457. break;
  458. }
  459. if (++i >= length) {
  460. throw new TypeError("reduce of empty array with no initial value");
  461. }
  462. } while (true);
  463. }
  464. for (; i < length; i++) {
  465. if (i in self) {
  466. result = fun.call(void 0, result, self[i], i, object);
  467. }
  468. }
  469. return result;
  470. };
  471. }
  472. if (!Array.prototype.reduceRight) {
  473. Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
  474. var object = toObject(this),
  475. self = splitString && _toString(this) == "[object String]" ?
  476. this.split("") :
  477. object,
  478. length = self.length >>> 0;
  479. if (_toString(fun) != "[object Function]") {
  480. throw new TypeError(fun + " is not a function");
  481. }
  482. if (!length && arguments.length == 1) {
  483. throw new TypeError("reduceRight of empty array with no initial value");
  484. }
  485. var result, i = length - 1;
  486. if (arguments.length >= 2) {
  487. result = arguments[1];
  488. } else {
  489. do {
  490. if (i in self) {
  491. result = self[i--];
  492. break;
  493. }
  494. if (--i < 0) {
  495. throw new TypeError("reduceRight of empty array with no initial value");
  496. }
  497. } while (true);
  498. }
  499. do {
  500. if (i in this) {
  501. result = fun.call(void 0, result, self[i], i, object);
  502. }
  503. } while (i--);
  504. return result;
  505. };
  506. }
  507. if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
  508. Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
  509. var self = splitString && _toString(this) == "[object String]" ?
  510. this.split("") :
  511. toObject(this),
  512. length = self.length >>> 0;
  513. if (!length) {
  514. return -1;
  515. }
  516. var i = 0;
  517. if (arguments.length > 1) {
  518. i = toInteger(arguments[1]);
  519. }
  520. i = i >= 0 ? i : Math.max(0, length + i);
  521. for (; i < length; i++) {
  522. if (i in self && self[i] === sought) {
  523. return i;
  524. }
  525. }
  526. return -1;
  527. };
  528. }
  529. if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
  530. Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
  531. var self = splitString && _toString(this) == "[object String]" ?
  532. this.split("") :
  533. toObject(this),
  534. length = self.length >>> 0;
  535. if (!length) {
  536. return -1;
  537. }
  538. var i = length - 1;
  539. if (arguments.length > 1) {
  540. i = Math.min(i, toInteger(arguments[1]));
  541. }
  542. i = i >= 0 ? i : length - Math.abs(i);
  543. for (; i >= 0; i--) {
  544. if (i in self && sought === self[i]) {
  545. return i;
  546. }
  547. }
  548. return -1;
  549. };
  550. }
  551. if (!Object.getPrototypeOf) {
  552. Object.getPrototypeOf = function getPrototypeOf(object) {
  553. return object.__proto__ || (
  554. object.constructor ?
  555. object.constructor.prototype :
  556. prototypeOfObject
  557. );
  558. };
  559. }
  560. if (!Object.getOwnPropertyDescriptor) {
  561. var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
  562. "non-object: ";
  563. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  564. if ((typeof object != "object" && typeof object != "function") || object === null)
  565. throw new TypeError(ERR_NON_OBJECT + object);
  566. if (!owns(object, property))
  567. return;
  568. var descriptor, getter, setter;
  569. descriptor = { enumerable: true, configurable: true };
  570. if (supportsAccessors) {
  571. var prototype = object.__proto__;
  572. object.__proto__ = prototypeOfObject;
  573. var getter = lookupGetter(object, property);
  574. var setter = lookupSetter(object, property);
  575. object.__proto__ = prototype;
  576. if (getter || setter) {
  577. if (getter) descriptor.get = getter;
  578. if (setter) descriptor.set = setter;
  579. return descriptor;
  580. }
  581. }
  582. descriptor.value = object[property];
  583. return descriptor;
  584. };
  585. }
  586. if (!Object.getOwnPropertyNames) {
  587. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  588. return Object.keys(object);
  589. };
  590. }
  591. if (!Object.create) {
  592. var createEmpty;
  593. if (Object.prototype.__proto__ === null) {
  594. createEmpty = function () {
  595. return { "__proto__": null };
  596. };
  597. } else {
  598. createEmpty = function () {
  599. var empty = {};
  600. for (var i in empty)
  601. empty[i] = null;
  602. empty.constructor =
  603. empty.hasOwnProperty =
  604. empty.propertyIsEnumerable =
  605. empty.isPrototypeOf =
  606. empty.toLocaleString =
  607. empty.toString =
  608. empty.valueOf =
  609. empty.__proto__ = null;
  610. return empty;
  611. }
  612. }
  613. Object.create = function create(prototype, properties) {
  614. var object;
  615. if (prototype === null) {
  616. object = createEmpty();
  617. } else {
  618. if (typeof prototype != "object")
  619. throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
  620. var Type = function () {};
  621. Type.prototype = prototype;
  622. object = new Type();
  623. object.__proto__ = prototype;
  624. }
  625. if (properties !== void 0)
  626. Object.defineProperties(object, properties);
  627. return object;
  628. };
  629. }
  630. function doesDefinePropertyWork(object) {
  631. try {
  632. Object.defineProperty(object, "sentinel", {});
  633. return "sentinel" in object;
  634. } catch (exception) {
  635. }
  636. }
  637. if (Object.defineProperty) {
  638. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  639. var definePropertyWorksOnDom = typeof document == "undefined" ||
  640. doesDefinePropertyWork(document.createElement("div"));
  641. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  642. var definePropertyFallback = Object.defineProperty;
  643. }
  644. }
  645. if (!Object.defineProperty || definePropertyFallback) {
  646. var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
  647. var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
  648. var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
  649. "on this javascript engine";
  650. Object.defineProperty = function defineProperty(object, property, descriptor) {
  651. if ((typeof object != "object" && typeof object != "function") || object === null)
  652. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  653. if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
  654. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  655. if (definePropertyFallback) {
  656. try {
  657. return definePropertyFallback.call(Object, object, property, descriptor);
  658. } catch (exception) {
  659. }
  660. }
  661. if (owns(descriptor, "value")) {
  662. if (supportsAccessors && (lookupGetter(object, property) ||
  663. lookupSetter(object, property)))
  664. {
  665. var prototype = object.__proto__;
  666. object.__proto__ = prototypeOfObject;
  667. delete object[property];
  668. object[property] = descriptor.value;
  669. object.__proto__ = prototype;
  670. } else {
  671. object[property] = descriptor.value;
  672. }
  673. } else {
  674. if (!supportsAccessors)
  675. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  676. if (owns(descriptor, "get"))
  677. defineGetter(object, property, descriptor.get);
  678. if (owns(descriptor, "set"))
  679. defineSetter(object, property, descriptor.set);
  680. }
  681. return object;
  682. };
  683. }
  684. if (!Object.defineProperties) {
  685. Object.defineProperties = function defineProperties(object, properties) {
  686. for (var property in properties) {
  687. if (owns(properties, property))
  688. Object.defineProperty(object, property, properties[property]);
  689. }
  690. return object;
  691. };
  692. }
  693. if (!Object.seal) {
  694. Object.seal = function seal(object) {
  695. return object;
  696. };
  697. }
  698. if (!Object.freeze) {
  699. Object.freeze = function freeze(object) {
  700. return object;
  701. };
  702. }
  703. try {
  704. Object.freeze(function () {});
  705. } catch (exception) {
  706. Object.freeze = (function freeze(freezeObject) {
  707. return function freeze(object) {
  708. if (typeof object == "function") {
  709. return object;
  710. } else {
  711. return freezeObject(object);
  712. }
  713. };
  714. })(Object.freeze);
  715. }
  716. if (!Object.preventExtensions) {
  717. Object.preventExtensions = function preventExtensions(object) {
  718. return object;
  719. };
  720. }
  721. if (!Object.isSealed) {
  722. Object.isSealed = function isSealed(object) {
  723. return false;
  724. };
  725. }
  726. if (!Object.isFrozen) {
  727. Object.isFrozen = function isFrozen(object) {
  728. return false;
  729. };
  730. }
  731. if (!Object.isExtensible) {
  732. Object.isExtensible = function isExtensible(object) {
  733. if (Object(object) === object) {
  734. throw new TypeError(); // TODO message
  735. }
  736. var name = '';
  737. while (owns(object, name)) {
  738. name += '?';
  739. }
  740. object[name] = true;
  741. var returnValue = owns(object, name);
  742. delete object[name];
  743. return returnValue;
  744. };
  745. }
  746. if (!Object.keys) {
  747. var hasDontEnumBug = true,
  748. dontEnums = [
  749. "toString",
  750. "toLocaleString",
  751. "valueOf",
  752. "hasOwnProperty",
  753. "isPrototypeOf",
  754. "propertyIsEnumerable",
  755. "constructor"
  756. ],
  757. dontEnumsLength = dontEnums.length;
  758. for (var key in {"toString": null}) {
  759. hasDontEnumBug = false;
  760. }
  761. Object.keys = function keys(object) {
  762. if (
  763. (typeof object != "object" && typeof object != "function") ||
  764. object === null
  765. ) {
  766. throw new TypeError("Object.keys called on a non-object");
  767. }
  768. var keys = [];
  769. for (var name in object) {
  770. if (owns(object, name)) {
  771. keys.push(name);
  772. }
  773. }
  774. if (hasDontEnumBug) {
  775. for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
  776. var dontEnum = dontEnums[i];
  777. if (owns(object, dontEnum)) {
  778. keys.push(dontEnum);
  779. }
  780. }
  781. }
  782. return keys;
  783. };
  784. }
  785. if (!Date.now) {
  786. Date.now = function now() {
  787. return new Date().getTime();
  788. };
  789. }
  790. if("0".split(void 0, 0).length) {
  791. var string_split = String.prototype.split;
  792. String.prototype.split = function(separator, limit) {
  793. if(separator === void 0 && limit === 0)return [];
  794. return string_split.apply(this, arguments);
  795. }
  796. }
  797. if("".substr && "0b".substr(-1) !== "b") {
  798. var string_substr = String.prototype.substr;
  799. String.prototype.substr = function(start, length) {
  800. return string_substr.call(
  801. this,
  802. start < 0 ? (start = this.length + start) < 0 ? 0 : start : start,
  803. length
  804. );
  805. }
  806. }
  807. var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
  808. "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
  809. "\u2029\uFEFF";
  810. if (!String.prototype.trim || ws.trim()) {
  811. ws = "[" + ws + "]";
  812. var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
  813. trimEndRegexp = new RegExp(ws + ws + "*$");
  814. String.prototype.trim = function trim() {
  815. if (this === undefined || this === null) {
  816. throw new TypeError("can't convert "+this+" to object");
  817. }
  818. return String(this)
  819. .replace(trimBeginRegexp, "")
  820. .replace(trimEndRegexp, "");
  821. };
  822. }
  823. function toInteger(n) {
  824. n = +n;
  825. if (n !== n) { // isNaN
  826. n = 0;
  827. } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
  828. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  829. }
  830. return n;
  831. }
  832. function isPrimitive(input) {
  833. var type = typeof input;
  834. return (
  835. input === null ||
  836. type === "undefined" ||
  837. type === "boolean" ||
  838. type === "number" ||
  839. type === "string"
  840. );
  841. }
  842. function toPrimitive(input) {
  843. var val, valueOf, toString;
  844. if (isPrimitive(input)) {
  845. return input;
  846. }
  847. valueOf = input.valueOf;
  848. if (typeof valueOf === "function") {
  849. val = valueOf.call(input);
  850. if (isPrimitive(val)) {
  851. return val;
  852. }
  853. }
  854. toString = input.toString;
  855. if (typeof toString === "function") {
  856. val = toString.call(input);
  857. if (isPrimitive(val)) {
  858. return val;
  859. }
  860. }
  861. throw new TypeError();
  862. }
  863. var toObject = function (o) {
  864. if (o == null) { // this matches both null and undefined
  865. throw new TypeError("can't convert "+o+" to object");
  866. }
  867. return Object(o);
  868. };
  869. });
  870. define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
  871. var EventEmitter = {};
  872. EventEmitter._emit =
  873. EventEmitter._dispatchEvent = function(eventName, e) {
  874. this._eventRegistry = this._eventRegistry || {};
  875. this._defaultHandlers = this._defaultHandlers || {};
  876. var listeners = this._eventRegistry[eventName] || [];
  877. var defaultHandler = this._defaultHandlers[eventName];
  878. if (!listeners.length && !defaultHandler)
  879. return;
  880. if (typeof e != "object" || !e)
  881. e = {};
  882. if (!e.type)
  883. e.type = eventName;
  884. if (!e.stopPropagation) {
  885. e.stopPropagation = function() {
  886. this.propagationStopped = true;
  887. };
  888. }
  889. if (!e.preventDefault) {
  890. e.preventDefault = function() {
  891. this.defaultPrevented = true;
  892. };
  893. }
  894. for (var i=0; i<listeners.length; i++) {
  895. listeners[i](e);
  896. if (e.propagationStopped)
  897. break;
  898. }
  899. if (defaultHandler && !e.defaultPrevented)
  900. return defaultHandler(e);
  901. };
  902. EventEmitter.setDefaultHandler = function(eventName, callback) {
  903. this._defaultHandlers = this._defaultHandlers || {};
  904. if (this._defaultHandlers[eventName])
  905. throw new Error("The default handler for '" + eventName + "' is already set");
  906. this._defaultHandlers[eventName] = callback;
  907. };
  908. EventEmitter.on =
  909. EventEmitter.addEventListener = function(eventName, callback) {
  910. this._eventRegistry = this._eventRegistry || {};
  911. var listeners = this._eventRegistry[eventName];
  912. if (!listeners)
  913. listeners = this._eventRegistry[eventName] = [];
  914. if (listeners.indexOf(callback) == -1)
  915. listeners.push(callback);
  916. };
  917. EventEmitter.removeListener =
  918. EventEmitter.removeEventListener = function(eventName, callback) {
  919. this._eventRegistry = this._eventRegistry || {};
  920. var listeners = this._eventRegistry[eventName];
  921. if (!listeners)
  922. return;
  923. var index = listeners.indexOf(callback);
  924. if (index !== -1)
  925. listeners.splice(index, 1);
  926. };
  927. EventEmitter.removeAllListeners = function(eventName) {
  928. if (this._eventRegistry) this._eventRegistry[eventName] = [];
  929. };
  930. exports.EventEmitter = EventEmitter;
  931. });
  932. define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
  933. exports.inherits = (function() {
  934. var tempCtor = function() {};
  935. return function(ctor, superCtor) {
  936. tempCtor.prototype = superCtor.prototype;
  937. ctor.super_ = superCtor.prototype;
  938. ctor.prototype = new tempCtor();
  939. ctor.prototype.constructor = ctor;
  940. };
  941. }());
  942. exports.mixin = function(obj, mixin) {
  943. for (var key in mixin) {
  944. obj[key] = mixin[key];
  945. }
  946. };
  947. exports.implement = function(proto, mixin) {
  948. exports.mixin(proto, mixin);
  949. };
  950. });
  951. define('ace/mode/php_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/php/php'], function(require, exports, module) {
  952. var oop = require("../lib/oop");
  953. var Mirror = require("../worker/mirror").Mirror;
  954. var PHP = require("./php/php").PHP;
  955. var PhpWorker = exports.PhpWorker = function(sender) {
  956. Mirror.call(this, sender);
  957. this.setTimeout(500);
  958. };
  959. oop.inherits(PhpWorker, Mirror);
  960. (function() {
  961. this.onUpdate = function() {
  962. var value = this.doc.getValue();
  963. var errors = [];
  964. var tokens = PHP.Lexer(value, {short_open_tag: 1});
  965. try {
  966. new PHP.Parser(tokens);
  967. } catch(e) {
  968. errors.push({
  969. row: e.line - 1,
  970. column: null,
  971. text: e.message.charAt(0).toUpperCase() + e.message.substring(1),
  972. type: "error"
  973. });
  974. }
  975. if (errors.length) {
  976. this.sender.emit("error", errors);
  977. } else {
  978. this.sender.emit("ok");
  979. }
  980. };
  981. }).call(PhpWorker.prototype);
  982. });
  983. define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) {
  984. var Document = require("../document").Document;
  985. var lang = require("../lib/lang");
  986. var Mirror = exports.Mirror = function(sender) {
  987. this.sender = sender;
  988. var doc = this.doc = new Document("");
  989. var deferredUpdate = this.deferredUpdate = lang.deferredCall(this.onUpdate.bind(this));
  990. var _self = this;
  991. sender.on("change", function(e) {
  992. doc.applyDeltas([e.data]);
  993. deferredUpdate.schedule(_self.$timeout);
  994. });
  995. };
  996. (function() {
  997. this.$timeout = 500;
  998. this.setTimeout = function(timeout) {
  999. this.$timeout = timeout;
  1000. };
  1001. this.setValue = function(value) {
  1002. this.doc.setValue(value);
  1003. this.deferredUpdate.schedule(this.$timeout);
  1004. };
  1005. this.getValue = function(callbackId) {
  1006. this.sender.callback(this.doc.getValue(), callbackId);
  1007. };
  1008. this.onUpdate = function() {
  1009. };
  1010. }).call(Mirror.prototype);
  1011. });
  1012. define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
  1013. var oop = require("./lib/oop");
  1014. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  1015. var Range = require("./range").Range;
  1016. var Anchor = require("./anchor").Anchor;
  1017. var Document = function(text) {
  1018. this.$lines = [];
  1019. if (text.length == 0) {
  1020. this.$lines = [""];
  1021. } else if (Array.isArray(text)) {
  1022. this.insertLines(0, text);
  1023. } else {
  1024. this.insert({row: 0, column:0}, text);
  1025. }
  1026. };
  1027. (function() {
  1028. oop.implement(this, EventEmitter);
  1029. this.setValue = function(text) {
  1030. var len = this.getLength();
  1031. this.remove(new Range(0, 0, len, this.getLine(len-1).length));
  1032. this.insert({row: 0, column:0}, text);
  1033. };
  1034. this.getValue = function() {
  1035. return this.getAllLines().join(this.getNewLineCharacter());
  1036. };
  1037. this.createAnchor = function(row, column) {
  1038. return new Anchor(this, row, column);
  1039. };
  1040. if ("aaa".split(/a/).length == 0)
  1041. this.$split = function(text) {
  1042. return text.replace(/\r\n|\r/g, "\n").split("\n");
  1043. }
  1044. else
  1045. this.$split = function(text) {
  1046. return text.split(/\r\n|\r|\n/);
  1047. };
  1048. this.$detectNewLine = function(text) {
  1049. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  1050. if (match) {
  1051. this.$autoNewLine = match[1];
  1052. } else {
  1053. this.$autoNewLine = "\n";
  1054. }
  1055. };
  1056. this.getNewLineCharacter = function() {
  1057. switch (this.$newLineMode) {
  1058. case "windows":
  1059. return "\r\n";
  1060. case "unix":
  1061. return "\n";
  1062. default:
  1063. return this.$autoNewLine;
  1064. }
  1065. };
  1066. this.$autoNewLine = "\n";
  1067. this.$newLineMode = "auto";
  1068. this.setNewLineMode = function(newLineMode) {
  1069. if (this.$newLineMode === newLineMode)
  1070. return;
  1071. this.$newLineMode = newLineMode;
  1072. };
  1073. this.getNewLineMode = function() {
  1074. return this.$newLineMode;
  1075. };
  1076. this.isNewLine = function(text) {
  1077. return (text == "\r\n" || text == "\r" || text == "\n");
  1078. };
  1079. this.getLine = function(row) {
  1080. return this.$lines[row] || "";
  1081. };
  1082. this.getLines = function(firstRow, lastRow) {
  1083. return this.$lines.slice(firstRow, lastRow + 1);
  1084. };
  1085. this.getAllLines = function() {
  1086. return this.getLines(0, this.getLength());
  1087. };
  1088. this.getLength = function() {
  1089. return this.$lines.length;
  1090. };
  1091. this.getTextRange = function(range) {
  1092. if (range.start.row == range.end.row) {
  1093. return this.$lines[range.start.row].substring(range.start.column,
  1094. range.end.column);
  1095. }
  1096. else {
  1097. var lines = this.getLines(range.start.row+1, range.end.row-1);
  1098. lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
  1099. lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
  1100. return lines.join(this.getNewLineCharacter());
  1101. }
  1102. };
  1103. this.$clipPosition = function(position) {
  1104. var length = this.getLength();
  1105. if (position.row >= length) {
  1106. position.row = Math.max(0, length - 1);
  1107. position.column = this.getLine(length-1).length;
  1108. }
  1109. return position;
  1110. };
  1111. this.insert = function(position, text) {
  1112. if (!text || text.length === 0)
  1113. return position;
  1114. position = this.$clipPosition(position);
  1115. if (this.getLength() <= 1)
  1116. this.$detectNewLine(text);
  1117. var lines = this.$split(text);
  1118. var firstLine = lines.splice(0, 1)[0];
  1119. var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
  1120. position = this.insertInLine(position, firstLine);
  1121. if (lastLine !== null) {
  1122. position = this.insertNewLine(position); // terminate first line
  1123. position = this.insertLines(position.row, lines);
  1124. position = this.insertInLine(position, lastLine || "");
  1125. }
  1126. return position;
  1127. };
  1128. this.insertLines = function(row, lines) {
  1129. if (lines.length == 0)
  1130. return {row: row, column: 0};
  1131. if (lines.length > 0xFFFF) {
  1132. var end = this.insertLines(row, lines.slice(0xFFFF));
  1133. lines = lines.slice(0, 0xFFFF);
  1134. }
  1135. var args = [row, 0];
  1136. args.push.apply(args, lines);
  1137. this.$lines.splice.apply(this.$lines, args);
  1138. var range = new Range(row, 0, row + lines.length, 0);
  1139. var delta = {
  1140. action: "insertLines",
  1141. range: range,
  1142. lines: lines
  1143. };
  1144. this._emit("change", { data: delta });
  1145. return end || range.end;
  1146. };
  1147. this.insertNewLine = function(position) {
  1148. position = this.$clipPosition(position);
  1149. var line = this.$lines[position.row] || "";
  1150. this.$lines[position.row] = line.substring(0, position.column);
  1151. this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
  1152. var end = {
  1153. row : position.row + 1,
  1154. column : 0
  1155. };
  1156. var delta = {
  1157. action: "insertText",
  1158. range: Range.fromPoints(position, end),
  1159. text: this.getNewLineCharacter()
  1160. };
  1161. this._emit("change", { data: delta });
  1162. return end;
  1163. };
  1164. this.insertInLine = function(position, text) {
  1165. if (text.length == 0)
  1166. return position;
  1167. var line = this.$lines[position.row] || "";
  1168. this.$lines[position.row] = line.substring(0, position.column) + text
  1169. + line.substring(position.column);
  1170. var end = {
  1171. row : position.row,
  1172. column : position.column + text.length
  1173. };
  1174. var delta = {
  1175. action: "insertText",
  1176. range: Range.fromPoints(position, end),
  1177. text: text
  1178. };
  1179. this._emit("change", { data: delta });
  1180. return end;
  1181. };
  1182. this.remove = function(range) {
  1183. range.start = this.$clipPosition(range.start);
  1184. range.end = this.$clipPosition(range.end);
  1185. if (range.isEmpty())
  1186. return range.start;
  1187. var firstRow = range.start.row;
  1188. var lastRow = range.end.row;
  1189. if (range.isMultiLine()) {
  1190. var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
  1191. var lastFullRow = lastRow - 1;
  1192. if (range.end.column > 0)
  1193. this.removeInLine(lastRow, 0, range.end.column);
  1194. if (lastFullRow >= firstFullRow)
  1195. this.removeLines(firstFullRow, lastFullRow);
  1196. if (firstFullRow != firstRow) {
  1197. this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
  1198. this.removeNewLine(range.start.row);
  1199. }
  1200. }
  1201. else {
  1202. this.removeInLine(firstRow, range.start.column, range.end.column);
  1203. }
  1204. return range.start;
  1205. };
  1206. this.removeInLine = function(row, startColumn, endColumn) {
  1207. if (startColumn == endColumn)
  1208. return;
  1209. var range = new Range(row, startColumn, row, endColumn);
  1210. var line = this.getLine(row);
  1211. var removed = line.substring(startColumn, endColumn);
  1212. var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
  1213. this.$lines.splice(row, 1, newLine);
  1214. var delta = {
  1215. action: "removeText",
  1216. range: range,
  1217. text: removed
  1218. };
  1219. this._emit("change", { data: delta });
  1220. return range.start;
  1221. };
  1222. this.removeLines = function(firstRow, lastRow) {
  1223. var range = new Range(firstRow, 0, lastRow + 1, 0);
  1224. var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
  1225. var delta = {
  1226. action: "removeLines",
  1227. range: range,
  1228. nl: this.getNewLineCharacter(),
  1229. lines: removed
  1230. };
  1231. this._emit("change", { data: delta });
  1232. return removed;
  1233. };
  1234. this.removeNewLine = function(row) {
  1235. var firstLine = this.getLine(row);
  1236. var secondLine = this.getLine(row+1);
  1237. var range = new Range(row, firstLine.length, row+1, 0);
  1238. var line = firstLine + secondLine;
  1239. this.$lines.splice(row, 2, line);
  1240. var delta = {
  1241. action: "removeText",
  1242. range: range,
  1243. text: this.getNewLineCharacter()
  1244. };
  1245. this._emit("change", { data: delta });
  1246. };
  1247. this.replace = function(range, text) {
  1248. if (text.length == 0 && range.isEmpty())
  1249. return range.start;
  1250. if (text == this.getTextRange(range))
  1251. return range.end;
  1252. this.remove(range);
  1253. if (text) {
  1254. var end = this.insert(range.start, text);
  1255. }
  1256. else {
  1257. end = range.start;
  1258. }
  1259. return end;
  1260. };
  1261. this.applyDeltas = function(deltas) {
  1262. for (var i=0; i<deltas.length; i++) {
  1263. var delta = deltas[i];
  1264. var range = Range.fromPoints(delta.range.start, delta.range.end);
  1265. if (delta.action == "insertLines")
  1266. this.insertLines(range.start.row, delta.lines);
  1267. else if (delta.action == "insertText")
  1268. this.insert(range.start, delta.text);
  1269. else if (delta.action == "removeLines")
  1270. this.removeLines(range.start.row, range.end.row - 1);
  1271. else if (delta.action == "removeText")
  1272. this.remove(range);
  1273. }
  1274. };
  1275. this.revertDeltas = function(deltas) {
  1276. for (var i=deltas.length-1; i>=0; i--) {
  1277. var delta = deltas[i];
  1278. var range = Range.fromPoints(delta.range.start, delta.range.end);
  1279. if (delta.action == "insertLines")
  1280. this.removeLines(range.start.row, range.end.row - 1);
  1281. else if (delta.action == "insertText")
  1282. this.remove(range);
  1283. else if (delta.action == "removeLines")
  1284. this.insertLines(range.start.row, delta.lines);
  1285. else if (delta.action == "removeText")
  1286. this.insert(range.start, delta.text);
  1287. }
  1288. };
  1289. this.indexToPosition = function(index, startRow) {
  1290. var lines = this.$lines || this.getAllLines();
  1291. var newlineLength = this.getNewLineCharacter().length;
  1292. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1293. index -= lines[i].length + newlineLength;
  1294. if (index < 0)
  1295. return {row: i, column: index + lines[i].length + newlineLength};
  1296. }
  1297. return {row: l-1, column: lines[l-1].length};
  1298. };
  1299. this.positionToIndex = function(pos, startRow) {
  1300. var lines = this.$lines || this.getAllLines();
  1301. var newlineLength = this.getNewLineCharacter().length;
  1302. var index = 0;
  1303. var row = Math.min(pos.row, lines.length);
  1304. for (var i = startRow || 0; i < row; ++i)
  1305. index += lines[i].length;
  1306. return index + newlineLength * i + pos.column;
  1307. };
  1308. }).call(Document.prototype);
  1309. exports.Document = Document;
  1310. });
  1311. define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
  1312. var Range = function(startRow, startColumn, endRow, endColumn) {
  1313. this.start = {
  1314. row: startRow,
  1315. column: startColumn
  1316. };
  1317. this.end = {
  1318. row: endRow,
  1319. column: endColumn
  1320. };
  1321. };
  1322. (function() {
  1323. this.isEqual = function(range) {
  1324. return this.start.row == range.start.row &&
  1325. this.end.row == range.end.row &&
  1326. this.start.column == range.start.column &&
  1327. this.end.column == range.end.column
  1328. };
  1329. this.toString = function() {
  1330. return ("Range: [" + this.start.row + "/" + this.start.column +
  1331. "] -> [" + this.end.row + "/" + this.end.column + "]");
  1332. };
  1333. this.contains = function(row, column) {
  1334. return this.compare(row, column) == 0;
  1335. };
  1336. this.compareRange = function(range) {
  1337. var cmp,
  1338. end = range.end,
  1339. start = range.start;
  1340. cmp = this.compare(end.row, end.column);
  1341. if (cmp == 1) {
  1342. cmp = this.compare(start.row, start.column);
  1343. if (cmp == 1) {
  1344. return 2;
  1345. } else if (cmp == 0) {
  1346. return 1;
  1347. } else {
  1348. return 0;
  1349. }
  1350. } else if (cmp == -1) {
  1351. return -2;
  1352. } else {
  1353. cmp = this.compare(start.row, start.column);
  1354. if (cmp == -1) {
  1355. return -1;
  1356. } else if (cmp == 1) {
  1357. return 42;
  1358. } else {
  1359. return 0;
  1360. }
  1361. }
  1362. };
  1363. this.comparePoint = function(p) {
  1364. return this.compare(p.row, p.column);
  1365. };
  1366. this.containsRange = function(range) {
  1367. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  1368. };
  1369. this.intersects = function(range) {
  1370. var cmp = this.compareRange(range);
  1371. return (cmp == -1 || cmp == 0 || cmp == 1);
  1372. };
  1373. this.isEnd = function(row, column) {
  1374. return this.end.row == row && this.end.column == column;
  1375. };
  1376. this.isStart = function(row, column) {
  1377. return this.start.row == row && this.start.column == column;
  1378. };
  1379. this.setStart = function(row, column) {
  1380. if (typeof row == "object") {
  1381. this.start.column = row.column;
  1382. this.start.row = row.row;
  1383. } else {
  1384. this.start.row = row;
  1385. this.start.column = column;
  1386. }
  1387. };
  1388. this.setEnd = function(row, column) {
  1389. if (typeof row == "object") {
  1390. this.end.column = row.column;
  1391. this.end.row = row.row;
  1392. } else {
  1393. this.end.row = row;
  1394. this.end.column = column;
  1395. }
  1396. };
  1397. this.inside = function(row, column) {
  1398. if (this.compare(row, column) == 0) {
  1399. if (this.isEnd(row, column) || this.isStart(row, column)) {
  1400. return false;
  1401. } else {
  1402. return true;
  1403. }
  1404. }
  1405. return false;
  1406. };
  1407. this.insideStart = function(row, column) {
  1408. if (this.compare(row, column) == 0) {
  1409. if (this.isEnd(row, column)) {
  1410. return false;
  1411. } else {
  1412. return true;
  1413. }
  1414. }
  1415. return false;
  1416. };
  1417. this.insideEnd = function(row, column) {
  1418. if (this.compare(row, column) == 0) {
  1419. if (this.isStart(row, column)) {
  1420. return false;
  1421. } else {
  1422. return true;
  1423. }
  1424. }
  1425. return false;
  1426. };
  1427. this.compare = function(row, column) {
  1428. if (!this.isMultiLine()) {
  1429. if (row === this.start.row) {