ace-rails-ap 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ace/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/ace/ace.js +403 -326
  4. data/vendor/assets/javascripts/ace/ext-language_tools.js +56 -40
  5. data/vendor/assets/javascripts/ace/ext-modelist.js +7 -3
  6. data/vendor/assets/javascripts/ace/ext-settings_menu.js +8 -4
  7. data/vendor/assets/javascripts/ace/ext-static_highlight.js +12 -5
  8. data/vendor/assets/javascripts/ace/keybinding-vim.js +5234 -1558
  9. data/vendor/assets/javascripts/ace/mode-abap.js +1 -1
  10. data/vendor/assets/javascripts/ace/mode-abc.js +261 -0
  11. data/vendor/assets/javascripts/ace/mode-actionscript.js +47 -1
  12. data/vendor/assets/javascripts/ace/mode-apache_conf.js +47 -1
  13. data/vendor/assets/javascripts/ace/mode-applescript.js +47 -1
  14. data/vendor/assets/javascripts/ace/mode-autohotkey.js +47 -1
  15. data/vendor/assets/javascripts/ace/mode-batchfile.js +47 -1
  16. data/vendor/assets/javascripts/ace/mode-c_cpp.js +101 -56
  17. data/vendor/assets/javascripts/ace/mode-coffee.js +3 -3
  18. data/vendor/assets/javascripts/ace/mode-coldfusion.js +114 -63
  19. data/vendor/assets/javascripts/ace/mode-csharp.js +99 -55
  20. data/vendor/assets/javascripts/ace/mode-css.js +98 -53
  21. data/vendor/assets/javascripts/ace/mode-curly.js +114 -63
  22. data/vendor/assets/javascripts/ace/mode-d.js +47 -1
  23. data/vendor/assets/javascripts/ace/mode-dart.js +103 -58
  24. data/vendor/assets/javascripts/ace/mode-diff.js +85 -85
  25. data/vendor/assets/javascripts/ace/mode-django.js +114 -63
  26. data/vendor/assets/javascripts/ace/mode-dockerfile.js +97 -52
  27. data/vendor/assets/javascripts/ace/mode-dot.js +47 -1
  28. data/vendor/assets/javascripts/ace/mode-eiffel.js +30 -37
  29. data/vendor/assets/javascripts/ace/mode-ejs.js +117 -63
  30. data/vendor/assets/javascripts/ace/mode-elm.js +47 -1
  31. data/vendor/assets/javascripts/ace/mode-erlang.js +47 -1
  32. data/vendor/assets/javascripts/ace/mode-forth.js +47 -1
  33. data/vendor/assets/javascripts/ace/mode-ftl.js +10 -7
  34. data/vendor/assets/javascripts/ace/mode-glsl.js +101 -56
  35. data/vendor/assets/javascripts/ace/mode-golang.js +96 -51
  36. data/vendor/assets/javascripts/ace/mode-groovy.js +98 -53
  37. data/vendor/assets/javascripts/ace/mode-haml.js +3 -0
  38. data/vendor/assets/javascripts/ace/mode-handlebars.js +114 -63
  39. data/vendor/assets/javascripts/ace/mode-haskell.js +49 -3
  40. data/vendor/assets/javascripts/ace/mode-haxe.js +96 -51
  41. data/vendor/assets/javascripts/ace/mode-html.js +114 -63
  42. data/vendor/assets/javascripts/ace/mode-html_ruby.js +117 -63
  43. data/vendor/assets/javascripts/ace/mode-io.js +47 -1
  44. data/vendor/assets/javascripts/ace/mode-jack.js +96 -51
  45. data/vendor/assets/javascripts/ace/mode-jade.js +10 -7
  46. data/vendor/assets/javascripts/ace/mode-java.js +98 -53
  47. data/vendor/assets/javascripts/ace/mode-javascript.js +98 -53
  48. data/vendor/assets/javascripts/ace/mode-json.js +99 -54
  49. data/vendor/assets/javascripts/ace/mode-jsoniq.js +98 -51
  50. data/vendor/assets/javascripts/ace/mode-jsp.js +106 -58
  51. data/vendor/assets/javascripts/ace/mode-jsx.js +96 -51
  52. data/vendor/assets/javascripts/ace/mode-julia.js +47 -1
  53. data/vendor/assets/javascripts/ace/mode-latex.js +1 -1
  54. data/vendor/assets/javascripts/ace/mode-lean.js +281 -0
  55. data/vendor/assets/javascripts/ace/mode-less.js +96 -51
  56. data/vendor/assets/javascripts/ace/mode-liquid.js +10 -7
  57. data/vendor/assets/javascripts/ace/mode-live_script.js +481 -0
  58. data/vendor/assets/javascripts/ace/mode-livescript.js +5 -8
  59. data/vendor/assets/javascripts/ace/mode-logiql.js +49 -50
  60. data/vendor/assets/javascripts/ace/mode-lsl.js +96 -51
  61. data/vendor/assets/javascripts/ace/mode-lua.js +3 -3
  62. data/vendor/assets/javascripts/ace/mode-luapage.js +117 -66
  63. data/vendor/assets/javascripts/ace/mode-makefile.js +1 -1
  64. data/vendor/assets/javascripts/ace/mode-markdown.js +134 -67
  65. data/vendor/assets/javascripts/ace/mode-mask.js +1985 -0
  66. data/vendor/assets/javascripts/ace/mode-mel.js +96 -51
  67. data/vendor/assets/javascripts/ace/mode-mips_assembler.js +235 -0
  68. data/vendor/assets/javascripts/ace/mode-mipsassembler.js +196 -0
  69. data/vendor/assets/javascripts/ace/mode-nix.js +101 -56
  70. data/vendor/assets/javascripts/ace/mode-objectivec.js +52 -6
  71. data/vendor/assets/javascripts/ace/mode-perl.js +47 -1
  72. data/vendor/assets/javascripts/ace/mode-pgsql.js +1 -1
  73. data/vendor/assets/javascripts/ace/mode-php.js +139 -85
  74. data/vendor/assets/javascripts/ace/mode-powershell.js +96 -51
  75. data/vendor/assets/javascripts/ace/mode-praat.js +47 -1
  76. data/vendor/assets/javascripts/ace/mode-prolog.js +47 -1
  77. data/vendor/assets/javascripts/ace/mode-protobuf.js +101 -56
  78. data/vendor/assets/javascripts/ace/mode-rdoc.js +1 -1
  79. data/vendor/assets/javascripts/ace/mode-rhtml.js +114 -63
  80. data/vendor/assets/javascripts/ace/mode-ruby.js +52 -50
  81. data/vendor/assets/javascripts/ace/mode-rust.js +57 -18
  82. data/vendor/assets/javascripts/ace/mode-scad.js +96 -51
  83. data/vendor/assets/javascripts/ace/mode-scala.js +98 -53
  84. data/vendor/assets/javascripts/ace/mode-scss.js +96 -51
  85. data/vendor/assets/javascripts/ace/mode-sh.js +97 -52
  86. data/vendor/assets/javascripts/ace/mode-sjs.js +98 -53
  87. data/vendor/assets/javascripts/ace/mode-smarty.js +114 -63
  88. data/vendor/assets/javascripts/ace/mode-soy_template.js +114 -63
  89. data/vendor/assets/javascripts/ace/mode-stylus.js +1 -1
  90. data/vendor/assets/javascripts/ace/mode-svg.js +132 -65
  91. data/vendor/assets/javascripts/ace/mode-tcl.js +47 -1
  92. data/vendor/assets/javascripts/ace/mode-twig.js +114 -63
  93. data/vendor/assets/javascripts/ace/mode-typescript.js +98 -53
  94. data/vendor/assets/javascripts/ace/mode-vala.js +96 -51
  95. data/vendor/assets/javascripts/ace/mode-velocity.js +114 -63
  96. data/vendor/assets/javascripts/ace/mode-vhdl.js +21 -21
  97. data/vendor/assets/javascripts/ace/mode-xml.js +34 -12
  98. data/vendor/assets/javascripts/ace/mode-xquery.js +98 -51
  99. data/vendor/assets/javascripts/ace/snippets/abc.js +38 -0
  100. data/vendor/assets/javascripts/ace/snippets/elixir.js +7 -0
  101. data/vendor/assets/javascripts/ace/snippets/elm.js +7 -0
  102. data/vendor/assets/javascripts/ace/snippets/lean.js +7 -0
  103. data/vendor/assets/javascripts/ace/snippets/live_script.js +7 -0
  104. data/vendor/assets/javascripts/ace/snippets/mask.js +7 -0
  105. data/vendor/assets/javascripts/ace/snippets/mips_assembler.js +7 -0
  106. data/vendor/assets/javascripts/ace/snippets/mipsassembler.js +7 -0
  107. data/vendor/assets/javascripts/ace/snippets/r.js +1 -1
  108. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +1 -1
  109. data/vendor/assets/javascripts/ace/theme-github.js +7 -1
  110. data/vendor/assets/javascripts/ace/theme-katzenmilch.js +3 -0
  111. data/vendor/assets/javascripts/ace/theme-kuroir.js +3 -0
  112. data/vendor/assets/javascripts/ace/worker-coffee.js +6 -7
  113. data/vendor/assets/javascripts/ace/worker-css.js +5 -5
  114. data/vendor/assets/javascripts/ace/worker-html.js +4354 -4354
  115. data/vendor/assets/javascripts/ace/worker-javascript.js +2435 -1397
  116. data/vendor/assets/javascripts/ace/worker-json.js +6 -7
  117. data/vendor/assets/javascripts/ace/worker-lua.js +11 -11
  118. data/vendor/assets/javascripts/ace/worker-php.js +4 -8
  119. data/vendor/assets/javascripts/ace/worker-xml.js +3809 -0
  120. data/vendor/assets/javascripts/ace/worker-xquery.js +38 -47
  121. metadata +18 -9
  122. data/vendor/assets/javascripts/ace/ext-options.js +0 -252
  123. data/vendor/assets/javascripts/ace/mode-html_completions.js +0 -309
  124. data/vendor/assets/javascripts/ace/mode-luahtml.js +0 -2415
  125. data/vendor/assets/javascripts/ace/mode-mushcode_high_rules.js +0 -569
  126. data/vendor/assets/javascripts/ace/mode-tmsnippet.js +0 -200
  127. data/vendor/assets/javascripts/ace/theme-kr.js +0 -105
@@ -870,9 +870,9 @@ var Document = function(text) {
870
870
  this._insertLines = function(row, lines) {
871
871
  if (lines.length == 0)
872
872
  return {row: row, column: 0};
873
- while (lines.length > 0xF000) {
874
- var end = this._insertLines(row, lines.slice(0, 0xF000));
875
- lines = lines.slice(0xF000);
873
+ while (lines.length > 20000) {
874
+ var end = this._insertLines(row, lines.slice(0, 20000));
875
+ lines = lines.slice(20000);
876
876
  row = end.row;
877
877
  }
878
878
 
@@ -1600,21 +1600,20 @@ oop.inherits(JsonWorker, Mirror);
1600
1600
 
1601
1601
  this.onUpdate = function() {
1602
1602
  var value = this.doc.getValue();
1603
-
1603
+ var errors = [];
1604
1604
  try {
1605
1605
  if (value)
1606
1606
  parse(value);
1607
1607
  } catch (e) {
1608
1608
  var pos = this.doc.indexToPosition(e.at-1);
1609
- this.sender.emit("error", {
1609
+ errors.push({
1610
1610
  row: pos.row,
1611
1611
  column: pos.column,
1612
1612
  text: e.message,
1613
1613
  type: "error"
1614
1614
  });
1615
- return;
1616
1615
  }
1617
- this.sender.emit("ok");
1616
+ this.sender.emit("annotate", errors);
1618
1617
  };
1619
1618
 
1620
1619
  }).call(JsonWorker.prototype);
@@ -870,9 +870,9 @@ var Document = function(text) {
870
870
  this._insertLines = function(row, lines) {
871
871
  if (lines.length == 0)
872
872
  return {row: row, column: 0};
873
- while (lines.length > 0xF000) {
874
- var end = this._insertLines(row, lines.slice(0, 0xF000));
875
- lines = lines.slice(0xF000);
873
+ while (lines.length > 20000) {
874
+ var end = this._insertLines(row, lines.slice(0, 20000));
875
+ lines = lines.slice(20000);
876
876
  row = end.row;
877
877
  }
878
878
 
@@ -2836,20 +2836,20 @@ oop.inherits(Worker, Mirror);
2836
2836
 
2837
2837
  this.onUpdate = function() {
2838
2838
  var value = this.doc.getValue();
2839
+ var errors = [];
2839
2840
  try {
2840
2841
  luaparse.parse(value);
2841
2842
  } catch(e) {
2842
2843
  if (e instanceof SyntaxError) {
2843
- this.sender.emit("error", {
2844
- row: e.line - 1,
2845
- column: e.column,
2846
- text: e.message,
2847
- type: "error"
2848
- });
2844
+ errors.push({
2845
+ row: e.line - 1,
2846
+ column: e.column,
2847
+ text: e.message,
2848
+ type: "error"
2849
+ });
2849
2850
  }
2850
- return;
2851
2851
  }
2852
- this.sender.emit("ok");
2852
+ this.sender.emit("annotate", errors);
2853
2853
  };
2854
2854
 
2855
2855
  }).call(Worker.prototype);
@@ -870,9 +870,9 @@ var Document = function(text) {
870
870
  this._insertLines = function(row, lines) {
871
871
  if (lines.length == 0)
872
872
  return {row: row, column: 0};
873
- while (lines.length > 0xF000) {
874
- var end = this._insertLines(row, lines.slice(0, 0xF000));
875
- lines = lines.slice(0xF000);
873
+ while (lines.length > 20000) {
874
+ var end = this._insertLines(row, lines.slice(0, 20000));
875
+ lines = lines.slice(20000);
876
876
  row = end.row;
877
877
  }
878
878
 
@@ -6238,11 +6238,7 @@ oop.inherits(PhpWorker, Mirror);
6238
6238
  });
6239
6239
  }
6240
6240
 
6241
- if (errors.length) {
6242
- this.sender.emit("error", errors);
6243
- } else {
6244
- this.sender.emit("ok");
6245
- }
6241
+ this.sender.emit("annotate", errors);
6246
6242
  };
6247
6243
 
6248
6244
  }).call(PhpWorker.prototype);
@@ -0,0 +1,3809 @@
1
+ "no use strict";
2
+ ;(function(window) {
3
+ if (typeof window.window != "undefined" && window.document) {
4
+ return;
5
+ }
6
+
7
+ window.console = function() {
8
+ var msgs = Array.prototype.slice.call(arguments, 0);
9
+ postMessage({type: "log", data: msgs});
10
+ };
11
+ window.console.error =
12
+ window.console.warn =
13
+ window.console.log =
14
+ window.console.trace = window.console;
15
+
16
+ window.window = window;
17
+ window.ace = window;
18
+
19
+ window.onerror = function(message, file, line, col, err) {
20
+ postMessage({type: "error", data: {
21
+ message: message,
22
+ file: file,
23
+ line: line,
24
+ col: col,
25
+ stack: err.stack
26
+ }});
27
+ };
28
+
29
+ window.normalizeModule = function(parentId, moduleName) {
30
+ // normalize plugin requires
31
+ if (moduleName.indexOf("!") !== -1) {
32
+ var chunks = moduleName.split("!");
33
+ return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
34
+ }
35
+ // normalize relative requires
36
+ if (moduleName.charAt(0) == ".") {
37
+ var base = parentId.split("/").slice(0, -1).join("/");
38
+ moduleName = (base ? base + "/" : "") + moduleName;
39
+
40
+ while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
41
+ var previous = moduleName;
42
+ moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
43
+ }
44
+ }
45
+
46
+ return moduleName;
47
+ };
48
+
49
+ window.require = function(parentId, id) {
50
+ if (!id) {
51
+ id = parentId;
52
+ parentId = null;
53
+ }
54
+ if (!id.charAt)
55
+ throw new Error("worker.js require() accepts only (parentId, id) as arguments");
56
+
57
+ id = window.normalizeModule(parentId, id);
58
+
59
+ var module = window.require.modules[id];
60
+ if (module) {
61
+ if (!module.initialized) {
62
+ module.initialized = true;
63
+ module.exports = module.factory().exports;
64
+ }
65
+ return module.exports;
66
+ }
67
+
68
+ var chunks = id.split("/");
69
+ if (!window.require.tlns)
70
+ return console.log("unable to load " + id);
71
+ chunks[0] = window.require.tlns[chunks[0]] || chunks[0];
72
+ var path = chunks.join("/") + ".js";
73
+
74
+ window.require.id = id;
75
+ importScripts(path);
76
+ return window.require(parentId, id);
77
+ };
78
+ window.require.modules = {};
79
+ window.require.tlns = {};
80
+
81
+ window.define = function(id, deps, factory) {
82
+ if (arguments.length == 2) {
83
+ factory = deps;
84
+ if (typeof id != "string") {
85
+ deps = id;
86
+ id = window.require.id;
87
+ }
88
+ } else if (arguments.length == 1) {
89
+ factory = id;
90
+ deps = [];
91
+ id = window.require.id;
92
+ }
93
+
94
+ if (typeof factory != "function") {
95
+ window.require.modules[id] = {
96
+ exports: factory,
97
+ initialized: true
98
+ };
99
+ return;
100
+ }
101
+
102
+ if (!deps.length)
103
+ // If there is no dependencies, we inject 'require', 'exports' and
104
+ // 'module' as dependencies, to provide CommonJS compatibility.
105
+ deps = ['require', 'exports', 'module'];
106
+
107
+ var req = function(childId) {
108
+ return window.require(id, childId);
109
+ };
110
+
111
+ window.require.modules[id] = {
112
+ exports: {},
113
+ factory: function() {
114
+ var module = this;
115
+ var returnExports = factory.apply(this, deps.map(function(dep) {
116
+ switch(dep) {
117
+ // Because 'require', 'exports' and 'module' aren't actual
118
+ // dependencies, we must handle them seperately.
119
+ case 'require': return req;
120
+ case 'exports': return module.exports;
121
+ case 'module': return module;
122
+ // But for all other dependencies, we can just go ahead and
123
+ // require them.
124
+ default: return req(dep);
125
+ }
126
+ }));
127
+ if (returnExports)
128
+ module.exports = returnExports;
129
+ return module;
130
+ }
131
+ };
132
+ };
133
+ window.define.amd = {};
134
+
135
+ window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
136
+ require.tlns = topLevelNamespaces;
137
+ };
138
+
139
+ window.initSender = function initSender() {
140
+
141
+ var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
142
+ var oop = window.require("ace/lib/oop");
143
+
144
+ var Sender = function() {};
145
+
146
+ (function() {
147
+
148
+ oop.implement(this, EventEmitter);
149
+
150
+ this.callback = function(data, callbackId) {
151
+ postMessage({
152
+ type: "call",
153
+ id: callbackId,
154
+ data: data
155
+ });
156
+ };
157
+
158
+ this.emit = function(name, data) {
159
+ postMessage({
160
+ type: "event",
161
+ name: name,
162
+ data: data
163
+ });
164
+ };
165
+
166
+ }).call(Sender.prototype);
167
+
168
+ return new Sender();
169
+ };
170
+
171
+ var main = window.main = null;
172
+ var sender = window.sender = null;
173
+
174
+ window.onmessage = function(e) {
175
+ var msg = e.data;
176
+ if (msg.command) {
177
+ if (main[msg.command])
178
+ main[msg.command].apply(main, msg.args);
179
+ else
180
+ throw new Error("Unknown command:" + msg.command);
181
+ }
182
+ else if (msg.init) {
183
+ initBaseUrls(msg.tlns);
184
+ require("ace/lib/es5-shim");
185
+ sender = window.sender = initSender();
186
+ var clazz = require(msg.module)[msg.classname];
187
+ main = window.main = new clazz(sender);
188
+ }
189
+ else if (msg.event && sender) {
190
+ sender._signal(msg.event, msg.data);
191
+ }
192
+ };
193
+ })(this);
194
+
195
+ define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
196
+ "use strict";
197
+
198
+ exports.inherits = function(ctor, superCtor) {
199
+ ctor.super_ = superCtor;
200
+ ctor.prototype = Object.create(superCtor.prototype, {
201
+ constructor: {
202
+ value: ctor,
203
+ enumerable: false,
204
+ writable: true,
205
+ configurable: true
206
+ }
207
+ });
208
+ };
209
+
210
+ exports.mixin = function(obj, mixin) {
211
+ for (var key in mixin) {
212
+ obj[key] = mixin[key];
213
+ }
214
+ return obj;
215
+ };
216
+
217
+ exports.implement = function(proto, mixin) {
218
+ exports.mixin(proto, mixin);
219
+ };
220
+
221
+ });
222
+
223
+ define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
224
+ "use strict";
225
+
226
+ exports.last = function(a) {
227
+ return a[a.length - 1];
228
+ };
229
+
230
+ exports.stringReverse = function(string) {
231
+ return string.split("").reverse().join("");
232
+ };
233
+
234
+ exports.stringRepeat = function (string, count) {
235
+ var result = '';
236
+ while (count > 0) {
237
+ if (count & 1)
238
+ result += string;
239
+
240
+ if (count >>= 1)
241
+ string += string;
242
+ }
243
+ return result;
244
+ };
245
+
246
+ var trimBeginRegexp = /^\s\s*/;
247
+ var trimEndRegexp = /\s\s*$/;
248
+
249
+ exports.stringTrimLeft = function (string) {
250
+ return string.replace(trimBeginRegexp, '');
251
+ };
252
+
253
+ exports.stringTrimRight = function (string) {
254
+ return string.replace(trimEndRegexp, '');
255
+ };
256
+
257
+ exports.copyObject = function(obj) {
258
+ var copy = {};
259
+ for (var key in obj) {
260
+ copy[key] = obj[key];
261
+ }
262
+ return copy;
263
+ };
264
+
265
+ exports.copyArray = function(array){
266
+ var copy = [];
267
+ for (var i=0, l=array.length; i<l; i++) {
268
+ if (array[i] && typeof array[i] == "object")
269
+ copy[i] = this.copyObject( array[i] );
270
+ else
271
+ copy[i] = array[i];
272
+ }
273
+ return copy;
274
+ };
275
+
276
+ exports.deepCopy = function (obj) {
277
+ if (typeof obj !== "object" || !obj)
278
+ return obj;
279
+ var cons = obj.constructor;
280
+ if (cons === RegExp)
281
+ return obj;
282
+
283
+ var copy = cons();
284
+ for (var key in obj) {
285
+ if (typeof obj[key] === "object") {
286
+ copy[key] = exports.deepCopy(obj[key]);
287
+ } else {
288
+ copy[key] = obj[key];
289
+ }
290
+ }
291
+ return copy;
292
+ };
293
+
294
+ exports.arrayToMap = function(arr) {
295
+ var map = {};
296
+ for (var i=0; i<arr.length; i++) {
297
+ map[arr[i]] = 1;
298
+ }
299
+ return map;
300
+
301
+ };
302
+
303
+ exports.createMap = function(props) {
304
+ var map = Object.create(null);
305
+ for (var i in props) {
306
+ map[i] = props[i];
307
+ }
308
+ return map;
309
+ };
310
+ exports.arrayRemove = function(array, value) {
311
+ for (var i = 0; i <= array.length; i++) {
312
+ if (value === array[i]) {
313
+ array.splice(i, 1);
314
+ }
315
+ }
316
+ };
317
+
318
+ exports.escapeRegExp = function(str) {
319
+ return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
320
+ };
321
+
322
+ exports.escapeHTML = function(str) {
323
+ return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
324
+ };
325
+
326
+ exports.getMatchOffsets = function(string, regExp) {
327
+ var matches = [];
328
+
329
+ string.replace(regExp, function(str) {
330
+ matches.push({
331
+ offset: arguments[arguments.length-2],
332
+ length: str.length
333
+ });
334
+ });
335
+
336
+ return matches;
337
+ };
338
+ exports.deferredCall = function(fcn) {
339
+ var timer = null;
340
+ var callback = function() {
341
+ timer = null;
342
+ fcn();
343
+ };
344
+
345
+ var deferred = function(timeout) {
346
+ deferred.cancel();
347
+ timer = setTimeout(callback, timeout || 0);
348
+ return deferred;
349
+ };
350
+
351
+ deferred.schedule = deferred;
352
+
353
+ deferred.call = function() {
354
+ this.cancel();
355
+ fcn();
356
+ return deferred;
357
+ };
358
+
359
+ deferred.cancel = function() {
360
+ clearTimeout(timer);
361
+ timer = null;
362
+ return deferred;
363
+ };
364
+
365
+ deferred.isPending = function() {
366
+ return timer;
367
+ };
368
+
369
+ return deferred;
370
+ };
371
+
372
+
373
+ exports.delayedCall = function(fcn, defaultTimeout) {
374
+ var timer = null;
375
+ var callback = function() {
376
+ timer = null;
377
+ fcn();
378
+ };
379
+
380
+ var _self = function(timeout) {
381
+ if (timer == null)
382
+ timer = setTimeout(callback, timeout || defaultTimeout);
383
+ };
384
+
385
+ _self.delay = function(timeout) {
386
+ timer && clearTimeout(timer);
387
+ timer = setTimeout(callback, timeout || defaultTimeout);
388
+ };
389
+ _self.schedule = _self;
390
+
391
+ _self.call = function() {
392
+ this.cancel();
393
+ fcn();
394
+ };
395
+
396
+ _self.cancel = function() {
397
+ timer && clearTimeout(timer);
398
+ timer = null;
399
+ };
400
+
401
+ _self.isPending = function() {
402
+ return timer;
403
+ };
404
+
405
+ return _self;
406
+ };
407
+ });
408
+
409
+ define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
410
+ "use strict";
411
+
412
+ var EventEmitter = {};
413
+ var stopPropagation = function() { this.propagationStopped = true; };
414
+ var preventDefault = function() { this.defaultPrevented = true; };
415
+
416
+ EventEmitter._emit =
417
+ EventEmitter._dispatchEvent = function(eventName, e) {
418
+ this._eventRegistry || (this._eventRegistry = {});
419
+ this._defaultHandlers || (this._defaultHandlers = {});
420
+
421
+ var listeners = this._eventRegistry[eventName] || [];
422
+ var defaultHandler = this._defaultHandlers[eventName];
423
+ if (!listeners.length && !defaultHandler)
424
+ return;
425
+
426
+ if (typeof e != "object" || !e)
427
+ e = {};
428
+
429
+ if (!e.type)
430
+ e.type = eventName;
431
+ if (!e.stopPropagation)
432
+ e.stopPropagation = stopPropagation;
433
+ if (!e.preventDefault)
434
+ e.preventDefault = preventDefault;
435
+
436
+ listeners = listeners.slice();
437
+ for (var i=0; i<listeners.length; i++) {
438
+ listeners[i](e, this);
439
+ if (e.propagationStopped)
440
+ break;
441
+ }
442
+
443
+ if (defaultHandler && !e.defaultPrevented)
444
+ return defaultHandler(e, this);
445
+ };
446
+
447
+
448
+ EventEmitter._signal = function(eventName, e) {
449
+ var listeners = (this._eventRegistry || {})[eventName];
450
+ if (!listeners)
451
+ return;
452
+ listeners = listeners.slice();
453
+ for (var i=0; i<listeners.length; i++)
454
+ listeners[i](e, this);
455
+ };
456
+
457
+ EventEmitter.once = function(eventName, callback) {
458
+ var _self = this;
459
+ callback && this.addEventListener(eventName, function newCallback() {
460
+ _self.removeEventListener(eventName, newCallback);
461
+ callback.apply(null, arguments);
462
+ });
463
+ };
464
+
465
+
466
+ EventEmitter.setDefaultHandler = function(eventName, callback) {
467
+ var handlers = this._defaultHandlers
468
+ if (!handlers)
469
+ handlers = this._defaultHandlers = {_disabled_: {}};
470
+
471
+ if (handlers[eventName]) {
472
+ var old = handlers[eventName];
473
+ var disabled = handlers._disabled_[eventName];
474
+ if (!disabled)
475
+ handlers._disabled_[eventName] = disabled = [];
476
+ disabled.push(old);
477
+ var i = disabled.indexOf(callback);
478
+ if (i != -1)
479
+ disabled.splice(i, 1);
480
+ }
481
+ handlers[eventName] = callback;
482
+ };
483
+ EventEmitter.removeDefaultHandler = function(eventName, callback) {
484
+ var handlers = this._defaultHandlers
485
+ if (!handlers)
486
+ return;
487
+ var disabled = handlers._disabled_[eventName];
488
+
489
+ if (handlers[eventName] == callback) {
490
+ var old = handlers[eventName];
491
+ if (disabled)
492
+ this.setDefaultHandler(eventName, disabled.pop());
493
+ } else if (disabled) {
494
+ var i = disabled.indexOf(callback);
495
+ if (i != -1)
496
+ disabled.splice(i, 1);
497
+ }
498
+ };
499
+
500
+ EventEmitter.on =
501
+ EventEmitter.addEventListener = function(eventName, callback, capturing) {
502
+ this._eventRegistry = this._eventRegistry || {};
503
+
504
+ var listeners = this._eventRegistry[eventName];
505
+ if (!listeners)
506
+ listeners = this._eventRegistry[eventName] = [];
507
+
508
+ if (listeners.indexOf(callback) == -1)
509
+ listeners[capturing ? "unshift" : "push"](callback);
510
+ return callback;
511
+ };
512
+
513
+ EventEmitter.off =
514
+ EventEmitter.removeListener =
515
+ EventEmitter.removeEventListener = function(eventName, callback) {
516
+ this._eventRegistry = this._eventRegistry || {};
517
+
518
+ var listeners = this._eventRegistry[eventName];
519
+ if (!listeners)
520
+ return;
521
+
522
+ var index = listeners.indexOf(callback);
523
+ if (index !== -1)
524
+ listeners.splice(index, 1);
525
+ };
526
+
527
+ EventEmitter.removeAllListeners = function(eventName) {
528
+ if (this._eventRegistry) this._eventRegistry[eventName] = [];
529
+ };
530
+
531
+ exports.EventEmitter = EventEmitter;
532
+
533
+ });
534
+
535
+ define("ace/range",["require","exports","module"], function(require, exports, module) {
536
+ "use strict";
537
+ var comparePoints = function(p1, p2) {
538
+ return p1.row - p2.row || p1.column - p2.column;
539
+ };
540
+ var Range = function(startRow, startColumn, endRow, endColumn) {
541
+ this.start = {
542
+ row: startRow,
543
+ column: startColumn
544
+ };
545
+
546
+ this.end = {
547
+ row: endRow,
548
+ column: endColumn
549
+ };
550
+ };
551
+
552
+ (function() {
553
+ this.isEqual = function(range) {
554
+ return this.start.row === range.start.row &&
555
+ this.end.row === range.end.row &&
556
+ this.start.column === range.start.column &&
557
+ this.end.column === range.end.column;
558
+ };
559
+ this.toString = function() {
560
+ return ("Range: [" + this.start.row + "/" + this.start.column +
561
+ "] -> [" + this.end.row + "/" + this.end.column + "]");
562
+ };
563
+
564
+ this.contains = function(row, column) {
565
+ return this.compare(row, column) == 0;
566
+ };
567
+ this.compareRange = function(range) {
568
+ var cmp,
569
+ end = range.end,
570
+ start = range.start;
571
+
572
+ cmp = this.compare(end.row, end.column);
573
+ if (cmp == 1) {
574
+ cmp = this.compare(start.row, start.column);
575
+ if (cmp == 1) {
576
+ return 2;
577
+ } else if (cmp == 0) {
578
+ return 1;
579
+ } else {
580
+ return 0;
581
+ }
582
+ } else if (cmp == -1) {
583
+ return -2;
584
+ } else {
585
+ cmp = this.compare(start.row, start.column);
586
+ if (cmp == -1) {
587
+ return -1;
588
+ } else if (cmp == 1) {
589
+ return 42;
590
+ } else {
591
+ return 0;
592
+ }
593
+ }
594
+ };
595
+ this.comparePoint = function(p) {
596
+ return this.compare(p.row, p.column);
597
+ };
598
+ this.containsRange = function(range) {
599
+ return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
600
+ };
601
+ this.intersects = function(range) {
602
+ var cmp = this.compareRange(range);
603
+ return (cmp == -1 || cmp == 0 || cmp == 1);
604
+ };
605
+ this.isEnd = function(row, column) {
606
+ return this.end.row == row && this.end.column == column;
607
+ };
608
+ this.isStart = function(row, column) {
609
+ return this.start.row == row && this.start.column == column;
610
+ };
611
+ this.setStart = function(row, column) {
612
+ if (typeof row == "object") {
613
+ this.start.column = row.column;
614
+ this.start.row = row.row;
615
+ } else {
616
+ this.start.row = row;
617
+ this.start.column = column;
618
+ }
619
+ };
620
+ this.setEnd = function(row, column) {
621
+ if (typeof row == "object") {
622
+ this.end.column = row.column;
623
+ this.end.row = row.row;
624
+ } else {
625
+ this.end.row = row;
626
+ this.end.column = column;
627
+ }
628
+ };
629
+ this.inside = function(row, column) {
630
+ if (this.compare(row, column) == 0) {
631
+ if (this.isEnd(row, column) || this.isStart(row, column)) {
632
+ return false;
633
+ } else {
634
+ return true;
635
+ }
636
+ }
637
+ return false;
638
+ };
639
+ this.insideStart = function(row, column) {
640
+ if (this.compare(row, column) == 0) {
641
+ if (this.isEnd(row, column)) {
642
+ return false;
643
+ } else {
644
+ return true;
645
+ }
646
+ }
647
+ return false;
648
+ };
649
+ this.insideEnd = function(row, column) {
650
+ if (this.compare(row, column) == 0) {
651
+ if (this.isStart(row, column)) {
652
+ return false;
653
+ } else {
654
+ return true;
655
+ }
656
+ }
657
+ return false;
658
+ };
659
+ this.compare = function(row, column) {
660
+ if (!this.isMultiLine()) {
661
+ if (row === this.start.row) {
662
+ return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
663
+ };
664
+ }
665
+
666
+ if (row < this.start.row)
667
+ return -1;
668
+
669
+ if (row > this.end.row)
670
+ return 1;
671
+
672
+ if (this.start.row === row)
673
+ return column >= this.start.column ? 0 : -1;
674
+
675
+ if (this.end.row === row)
676
+ return column <= this.end.column ? 0 : 1;
677
+
678
+ return 0;
679
+ };
680
+ this.compareStart = function(row, column) {
681
+ if (this.start.row == row && this.start.column == column) {
682
+ return -1;
683
+ } else {
684
+ return this.compare(row, column);
685
+ }
686
+ };
687
+ this.compareEnd = function(row, column) {
688
+ if (this.end.row == row && this.end.column == column) {
689
+ return 1;
690
+ } else {
691
+ return this.compare(row, column);
692
+ }
693
+ };
694
+ this.compareInside = function(row, column) {
695
+ if (this.end.row == row && this.end.column == column) {
696
+ return 1;
697
+ } else if (this.start.row == row && this.start.column == column) {
698
+ return -1;
699
+ } else {
700
+ return this.compare(row, column);
701
+ }
702
+ };
703
+ this.clipRows = function(firstRow, lastRow) {
704
+ if (this.end.row > lastRow)
705
+ var end = {row: lastRow + 1, column: 0};
706
+ else if (this.end.row < firstRow)
707
+ var end = {row: firstRow, column: 0};
708
+
709
+ if (this.start.row > lastRow)
710
+ var start = {row: lastRow + 1, column: 0};
711
+ else if (this.start.row < firstRow)
712
+ var start = {row: firstRow, column: 0};
713
+
714
+ return Range.fromPoints(start || this.start, end || this.end);
715
+ };
716
+ this.extend = function(row, column) {
717
+ var cmp = this.compare(row, column);
718
+
719
+ if (cmp == 0)
720
+ return this;
721
+ else if (cmp == -1)
722
+ var start = {row: row, column: column};
723
+ else
724
+ var end = {row: row, column: column};
725
+
726
+ return Range.fromPoints(start || this.start, end || this.end);
727
+ };
728
+
729
+ this.isEmpty = function() {
730
+ return (this.start.row === this.end.row && this.start.column === this.end.column);
731
+ };
732
+ this.isMultiLine = function() {
733
+ return (this.start.row !== this.end.row);
734
+ };
735
+ this.clone = function() {
736
+ return Range.fromPoints(this.start, this.end);
737
+ };
738
+ this.collapseRows = function() {
739
+ if (this.end.column == 0)
740
+ return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
741
+ else
742
+ return new Range(this.start.row, 0, this.end.row, 0)
743
+ };
744
+ this.toScreenRange = function(session) {
745
+ var screenPosStart = session.documentToScreenPosition(this.start);
746
+ var screenPosEnd = session.documentToScreenPosition(this.end);
747
+
748
+ return new Range(
749
+ screenPosStart.row, screenPosStart.column,
750
+ screenPosEnd.row, screenPosEnd.column
751
+ );
752
+ };
753
+ this.moveBy = function(row, column) {
754
+ this.start.row += row;
755
+ this.start.column += column;
756
+ this.end.row += row;
757
+ this.end.column += column;
758
+ };
759
+
760
+ }).call(Range.prototype);
761
+ Range.fromPoints = function(start, end) {
762
+ return new Range(start.row, start.column, end.row, end.column);
763
+ };
764
+ Range.comparePoints = comparePoints;
765
+
766
+ Range.comparePoints = function(p1, p2) {
767
+ return p1.row - p2.row || p1.column - p2.column;
768
+ };
769
+
770
+
771
+ exports.Range = Range;
772
+ });
773
+
774
+ define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
775
+ "use strict";
776
+
777
+ var oop = require("./lib/oop");
778
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
779
+
780
+ var Anchor = exports.Anchor = function(doc, row, column) {
781
+ this.$onChange = this.onChange.bind(this);
782
+ this.attach(doc);
783
+
784
+ if (typeof column == "undefined")
785
+ this.setPosition(row.row, row.column);
786
+ else
787
+ this.setPosition(row, column);
788
+ };
789
+
790
+ (function() {
791
+
792
+ oop.implement(this, EventEmitter);
793
+ this.getPosition = function() {
794
+ return this.$clipPositionToDocument(this.row, this.column);
795
+ };
796
+ this.getDocument = function() {
797
+ return this.document;
798
+ };
799
+ this.$insertRight = false;
800
+ this.onChange = function(e) {
801
+ var delta = e.data;
802
+ var range = delta.range;
803
+
804
+ if (range.start.row == range.end.row && range.start.row != this.row)
805
+ return;
806
+
807
+ if (range.start.row > this.row)
808
+ return;
809
+
810
+ if (range.start.row == this.row && range.start.column > this.column)
811
+ return;
812
+
813
+ var row = this.row;
814
+ var column = this.column;
815
+ var start = range.start;
816
+ var end = range.end;
817
+
818
+ if (delta.action === "insertText") {
819
+ if (start.row === row && start.column <= column) {
820
+ if (start.column === column && this.$insertRight) {
821
+ } else if (start.row === end.row) {
822
+ column += end.column - start.column;
823
+ } else {
824
+ column -= start.column;
825
+ row += end.row - start.row;
826
+ }
827
+ } else if (start.row !== end.row && start.row < row) {
828
+ row += end.row - start.row;
829
+ }
830
+ } else if (delta.action === "insertLines") {
831
+ if (start.row === row && column === 0 && this.$insertRight) {
832
+ }
833
+ else if (start.row <= row) {
834
+ row += end.row - start.row;
835
+ }
836
+ } else if (delta.action === "removeText") {
837
+ if (start.row === row && start.column < column) {
838
+ if (end.column >= column)
839
+ column = start.column;
840
+ else
841
+ column = Math.max(0, column - (end.column - start.column));
842
+
843
+ } else if (start.row !== end.row && start.row < row) {
844
+ if (end.row === row)
845
+ column = Math.max(0, column - end.column) + start.column;
846
+ row -= (end.row - start.row);
847
+ } else if (end.row === row) {
848
+ row -= end.row - start.row;
849
+ column = Math.max(0, column - end.column) + start.column;
850
+ }
851
+ } else if (delta.action == "removeLines") {
852
+ if (start.row <= row) {
853
+ if (end.row <= row)
854
+ row -= end.row - start.row;
855
+ else {
856
+ row = start.row;
857
+ column = 0;
858
+ }
859
+ }
860
+ }
861
+
862
+ this.setPosition(row, column, true);
863
+ };
864
+ this.setPosition = function(row, column, noClip) {
865
+ var pos;
866
+ if (noClip) {
867
+ pos = {
868
+ row: row,
869
+ column: column
870
+ };
871
+ } else {
872
+ pos = this.$clipPositionToDocument(row, column);
873
+ }
874
+
875
+ if (this.row == pos.row && this.column == pos.column)
876
+ return;
877
+
878
+ var old = {
879
+ row: this.row,
880
+ column: this.column
881
+ };
882
+
883
+ this.row = pos.row;
884
+ this.column = pos.column;
885
+ this._signal("change", {
886
+ old: old,
887
+ value: pos
888
+ });
889
+ };
890
+ this.detach = function() {
891
+ this.document.removeEventListener("change", this.$onChange);
892
+ };
893
+ this.attach = function(doc) {
894
+ this.document = doc || this.document;
895
+ this.document.on("change", this.$onChange);
896
+ };
897
+ this.$clipPositionToDocument = function(row, column) {
898
+ var pos = {};
899
+
900
+ if (row >= this.document.getLength()) {
901
+ pos.row = Math.max(0, this.document.getLength() - 1);
902
+ pos.column = this.document.getLine(pos.row).length;
903
+ }
904
+ else if (row < 0) {
905
+ pos.row = 0;
906
+ pos.column = 0;
907
+ }
908
+ else {
909
+ pos.row = row;
910
+ pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
911
+ }
912
+
913
+ if (column < 0)
914
+ pos.column = 0;
915
+
916
+ return pos;
917
+ };
918
+
919
+ }).call(Anchor.prototype);
920
+
921
+ });
922
+
923
+ define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
924
+ "use strict";
925
+
926
+ var oop = require("./lib/oop");
927
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
928
+ var Range = require("./range").Range;
929
+ var Anchor = require("./anchor").Anchor;
930
+
931
+ var Document = function(text) {
932
+ this.$lines = [];
933
+ if (text.length === 0) {
934
+ this.$lines = [""];
935
+ } else if (Array.isArray(text)) {
936
+ this._insertLines(0, text);
937
+ } else {
938
+ this.insert({row: 0, column:0}, text);
939
+ }
940
+ };
941
+
942
+ (function() {
943
+
944
+ oop.implement(this, EventEmitter);
945
+ this.setValue = function(text) {
946
+ var len = this.getLength();
947
+ this.remove(new Range(0, 0, len, this.getLine(len-1).length));
948
+ this.insert({row: 0, column:0}, text);
949
+ };
950
+ this.getValue = function() {
951
+ return this.getAllLines().join(this.getNewLineCharacter());
952
+ };
953
+ this.createAnchor = function(row, column) {
954
+ return new Anchor(this, row, column);
955
+ };
956
+ if ("aaa".split(/a/).length === 0)
957
+ this.$split = function(text) {
958
+ return text.replace(/\r\n|\r/g, "\n").split("\n");
959
+ };
960
+ else
961
+ this.$split = function(text) {
962
+ return text.split(/\r\n|\r|\n/);
963
+ };
964
+
965
+
966
+ this.$detectNewLine = function(text) {
967
+ var match = text.match(/^.*?(\r\n|\r|\n)/m);
968
+ this.$autoNewLine = match ? match[1] : "\n";
969
+ this._signal("changeNewLineMode");
970
+ };
971
+ this.getNewLineCharacter = function() {
972
+ switch (this.$newLineMode) {
973
+ case "windows":
974
+ return "\r\n";
975
+ case "unix":
976
+ return "\n";
977
+ default:
978
+ return this.$autoNewLine || "\n";
979
+ }
980
+ };
981
+
982
+ this.$autoNewLine = "";
983
+ this.$newLineMode = "auto";
984
+ this.setNewLineMode = function(newLineMode) {
985
+ if (this.$newLineMode === newLineMode)
986
+ return;
987
+
988
+ this.$newLineMode = newLineMode;
989
+ this._signal("changeNewLineMode");
990
+ };
991
+ this.getNewLineMode = function() {
992
+ return this.$newLineMode;
993
+ };
994
+ this.isNewLine = function(text) {
995
+ return (text == "\r\n" || text == "\r" || text == "\n");
996
+ };
997
+ this.getLine = function(row) {
998
+ return this.$lines[row] || "";
999
+ };
1000
+ this.getLines = function(firstRow, lastRow) {
1001
+ return this.$lines.slice(firstRow, lastRow + 1);
1002
+ };
1003
+ this.getAllLines = function() {
1004
+ return this.getLines(0, this.getLength());
1005
+ };
1006
+ this.getLength = function() {
1007
+ return this.$lines.length;
1008
+ };
1009
+ this.getTextRange = function(range) {
1010
+ if (range.start.row == range.end.row) {
1011
+ return this.getLine(range.start.row)
1012
+ .substring(range.start.column, range.end.column);
1013
+ }
1014
+ var lines = this.getLines(range.start.row, range.end.row);
1015
+ lines[0] = (lines[0] || "").substring(range.start.column);
1016
+ var l = lines.length - 1;
1017
+ if (range.end.row - range.start.row == l)
1018
+ lines[l] = lines[l].substring(0, range.end.column);
1019
+ return lines.join(this.getNewLineCharacter());
1020
+ };
1021
+
1022
+ this.$clipPosition = function(position) {
1023
+ var length = this.getLength();
1024
+ if (position.row >= length) {
1025
+ position.row = Math.max(0, length - 1);
1026
+ position.column = this.getLine(length-1).length;
1027
+ } else if (position.row < 0)
1028
+ position.row = 0;
1029
+ return position;
1030
+ };
1031
+ this.insert = function(position, text) {
1032
+ if (!text || text.length === 0)
1033
+ return position;
1034
+
1035
+ position = this.$clipPosition(position);
1036
+ if (this.getLength() <= 1)
1037
+ this.$detectNewLine(text);
1038
+
1039
+ var lines = this.$split(text);
1040
+ var firstLine = lines.splice(0, 1)[0];
1041
+ var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
1042
+
1043
+ position = this.insertInLine(position, firstLine);
1044
+ if (lastLine !== null) {
1045
+ position = this.insertNewLine(position); // terminate first line
1046
+ position = this._insertLines(position.row, lines);
1047
+ position = this.insertInLine(position, lastLine || "");
1048
+ }
1049
+ return position;
1050
+ };
1051
+ this.insertLines = function(row, lines) {
1052
+ if (row >= this.getLength())
1053
+ return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
1054
+ return this._insertLines(Math.max(row, 0), lines);
1055
+ };
1056
+ this._insertLines = function(row, lines) {
1057
+ if (lines.length == 0)
1058
+ return {row: row, column: 0};
1059
+ while (lines.length > 20000) {
1060
+ var end = this._insertLines(row, lines.slice(0, 20000));
1061
+ lines = lines.slice(20000);
1062
+ row = end.row;
1063
+ }
1064
+
1065
+ var args = [row, 0];
1066
+ args.push.apply(args, lines);
1067
+ this.$lines.splice.apply(this.$lines, args);
1068
+
1069
+ var range = new Range(row, 0, row + lines.length, 0);
1070
+ var delta = {
1071
+ action: "insertLines",
1072
+ range: range,
1073
+ lines: lines
1074
+ };
1075
+ this._signal("change", { data: delta });
1076
+ return range.end;
1077
+ };
1078
+ this.insertNewLine = function(position) {
1079
+ position = this.$clipPosition(position);
1080
+ var line = this.$lines[position.row] || "";
1081
+
1082
+ this.$lines[position.row] = line.substring(0, position.column);
1083
+ this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
1084
+
1085
+ var end = {
1086
+ row : position.row + 1,
1087
+ column : 0
1088
+ };
1089
+
1090
+ var delta = {
1091
+ action: "insertText",
1092
+ range: Range.fromPoints(position, end),
1093
+ text: this.getNewLineCharacter()
1094
+ };
1095
+ this._signal("change", { data: delta });
1096
+
1097
+ return end;
1098
+ };
1099
+ this.insertInLine = function(position, text) {
1100
+ if (text.length == 0)
1101
+ return position;
1102
+
1103
+ var line = this.$lines[position.row] || "";
1104
+
1105
+ this.$lines[position.row] = line.substring(0, position.column) + text
1106
+ + line.substring(position.column);
1107
+
1108
+ var end = {
1109
+ row : position.row,
1110
+ column : position.column + text.length
1111
+ };
1112
+
1113
+ var delta = {
1114
+ action: "insertText",
1115
+ range: Range.fromPoints(position, end),
1116
+ text: text
1117
+ };
1118
+ this._signal("change", { data: delta });
1119
+
1120
+ return end;
1121
+ };
1122
+ this.remove = function(range) {
1123
+ if (!(range instanceof Range))
1124
+ range = Range.fromPoints(range.start, range.end);
1125
+ range.start = this.$clipPosition(range.start);
1126
+ range.end = this.$clipPosition(range.end);
1127
+
1128
+ if (range.isEmpty())
1129
+ return range.start;
1130
+
1131
+ var firstRow = range.start.row;
1132
+ var lastRow = range.end.row;
1133
+
1134
+ if (range.isMultiLine()) {
1135
+ var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
1136
+ var lastFullRow = lastRow - 1;
1137
+
1138
+ if (range.end.column > 0)
1139
+ this.removeInLine(lastRow, 0, range.end.column);
1140
+
1141
+ if (lastFullRow >= firstFullRow)
1142
+ this._removeLines(firstFullRow, lastFullRow);
1143
+
1144
+ if (firstFullRow != firstRow) {
1145
+ this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
1146
+ this.removeNewLine(range.start.row);
1147
+ }
1148
+ }
1149
+ else {
1150
+ this.removeInLine(firstRow, range.start.column, range.end.column);
1151
+ }
1152
+ return range.start;
1153
+ };
1154
+ this.removeInLine = function(row, startColumn, endColumn) {
1155
+ if (startColumn == endColumn)
1156
+ return;
1157
+
1158
+ var range = new Range(row, startColumn, row, endColumn);
1159
+ var line = this.getLine(row);
1160
+ var removed = line.substring(startColumn, endColumn);
1161
+ var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
1162
+ this.$lines.splice(row, 1, newLine);
1163
+
1164
+ var delta = {
1165
+ action: "removeText",
1166
+ range: range,
1167
+ text: removed
1168
+ };
1169
+ this._signal("change", { data: delta });
1170
+ return range.start;
1171
+ };
1172
+ this.removeLines = function(firstRow, lastRow) {
1173
+ if (firstRow < 0 || lastRow >= this.getLength())
1174
+ return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
1175
+ return this._removeLines(firstRow, lastRow);
1176
+ };
1177
+
1178
+ this._removeLines = function(firstRow, lastRow) {
1179
+ var range = new Range(firstRow, 0, lastRow + 1, 0);
1180
+ var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
1181
+
1182
+ var delta = {
1183
+ action: "removeLines",
1184
+ range: range,
1185
+ nl: this.getNewLineCharacter(),
1186
+ lines: removed
1187
+ };
1188
+ this._signal("change", { data: delta });
1189
+ return removed;
1190
+ };
1191
+ this.removeNewLine = function(row) {
1192
+ var firstLine = this.getLine(row);
1193
+ var secondLine = this.getLine(row+1);
1194
+
1195
+ var range = new Range(row, firstLine.length, row+1, 0);
1196
+ var line = firstLine + secondLine;
1197
+
1198
+ this.$lines.splice(row, 2, line);
1199
+
1200
+ var delta = {
1201
+ action: "removeText",
1202
+ range: range,
1203
+ text: this.getNewLineCharacter()
1204
+ };
1205
+ this._signal("change", { data: delta });
1206
+ };
1207
+ this.replace = function(range, text) {
1208
+ if (!(range instanceof Range))
1209
+ range = Range.fromPoints(range.start, range.end);
1210
+ if (text.length == 0 && range.isEmpty())
1211
+ return range.start;
1212
+ if (text == this.getTextRange(range))
1213
+ return range.end;
1214
+
1215
+ this.remove(range);
1216
+ if (text) {
1217
+ var end = this.insert(range.start, text);
1218
+ }
1219
+ else {
1220
+ end = range.start;
1221
+ }
1222
+
1223
+ return end;
1224
+ };
1225
+ this.applyDeltas = function(deltas) {
1226
+ for (var i=0; i<deltas.length; i++) {
1227
+ var delta = deltas[i];
1228
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
1229
+
1230
+ if (delta.action == "insertLines")
1231
+ this.insertLines(range.start.row, delta.lines);
1232
+ else if (delta.action == "insertText")
1233
+ this.insert(range.start, delta.text);
1234
+ else if (delta.action == "removeLines")
1235
+ this._removeLines(range.start.row, range.end.row - 1);
1236
+ else if (delta.action == "removeText")
1237
+ this.remove(range);
1238
+ }
1239
+ };
1240
+ this.revertDeltas = function(deltas) {
1241
+ for (var i=deltas.length-1; i>=0; i--) {
1242
+ var delta = deltas[i];
1243
+
1244
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
1245
+
1246
+ if (delta.action == "insertLines")
1247
+ this._removeLines(range.start.row, range.end.row - 1);
1248
+ else if (delta.action == "insertText")
1249
+ this.remove(range);
1250
+ else if (delta.action == "removeLines")
1251
+ this._insertLines(range.start.row, delta.lines);
1252
+ else if (delta.action == "removeText")
1253
+ this.insert(range.start, delta.text);
1254
+ }
1255
+ };
1256
+ this.indexToPosition = function(index, startRow) {
1257
+ var lines = this.$lines || this.getAllLines();
1258
+ var newlineLength = this.getNewLineCharacter().length;
1259
+ for (var i = startRow || 0, l = lines.length; i < l; i++) {
1260
+ index -= lines[i].length + newlineLength;
1261
+ if (index < 0)
1262
+ return {row: i, column: index + lines[i].length + newlineLength};
1263
+ }
1264
+ return {row: l-1, column: lines[l-1].length};
1265
+ };
1266
+ this.positionToIndex = function(pos, startRow) {
1267
+ var lines = this.$lines || this.getAllLines();
1268
+ var newlineLength = this.getNewLineCharacter().length;
1269
+ var index = 0;
1270
+ var row = Math.min(pos.row, lines.length);
1271
+ for (var i = startRow || 0; i < row; ++i)
1272
+ index += lines[i].length + newlineLength;
1273
+
1274
+ return index + pos.column;
1275
+ };
1276
+
1277
+ }).call(Document.prototype);
1278
+
1279
+ exports.Document = Document;
1280
+ });
1281
+
1282
+ define("ace/worker/mirror",["require","exports","module","ace/document","ace/lib/lang"], function(require, exports, module) {
1283
+ "use strict";
1284
+
1285
+ var Document = require("../document").Document;
1286
+ var lang = require("../lib/lang");
1287
+
1288
+ var Mirror = exports.Mirror = function(sender) {
1289
+ this.sender = sender;
1290
+ var doc = this.doc = new Document("");
1291
+
1292
+ var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1293
+
1294
+ var _self = this;
1295
+ sender.on("change", function(e) {
1296
+ doc.applyDeltas(e.data);
1297
+ if (_self.$timeout)
1298
+ return deferredUpdate.schedule(_self.$timeout);
1299
+ _self.onUpdate();
1300
+ });
1301
+ };
1302
+
1303
+ (function() {
1304
+
1305
+ this.$timeout = 500;
1306
+
1307
+ this.setTimeout = function(timeout) {
1308
+ this.$timeout = timeout;
1309
+ };
1310
+
1311
+ this.setValue = function(value) {
1312
+ this.doc.setValue(value);
1313
+ this.deferredUpdate.schedule(this.$timeout);
1314
+ };
1315
+
1316
+ this.getValue = function(callbackId) {
1317
+ this.sender.callback(this.doc.getValue(), callbackId);
1318
+ };
1319
+
1320
+ this.onUpdate = function() {
1321
+ };
1322
+
1323
+ this.isPending = function() {
1324
+ return this.deferredUpdate.isPending();
1325
+ };
1326
+
1327
+ }).call(Mirror.prototype);
1328
+
1329
+ });
1330
+
1331
+ define("ace/mode/xml/sax",["require","exports","module"], function(require, exports, module) {
1332
+ var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
1333
+ var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\u00B7\u0300-\u036F\\ux203F-\u2040]");
1334
+ var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
1335
+ var S_TAG = 0;//tag name offerring
1336
+ var S_ATTR = 1;//attr name offerring
1337
+ var S_ATTR_S=2;//attr name end and space offer
1338
+ var S_EQ = 3;//=space?
1339
+ var S_V = 4;//attr value(no quot value only)
1340
+ var S_E = 5;//attr value end and no space(quot end)
1341
+ var S_S = 6;//(attr value end || tag end ) && (space offer)
1342
+ var S_C = 7;//closed el<el />
1343
+
1344
+ function XMLReader(){
1345
+
1346
+ }
1347
+
1348
+ XMLReader.prototype = {
1349
+ parse:function(source,defaultNSMap,entityMap){
1350
+ var domBuilder = this.domBuilder;
1351
+ domBuilder.startDocument();
1352
+ _copy(defaultNSMap ,defaultNSMap = {})
1353
+ parse(source,defaultNSMap,entityMap,
1354
+ domBuilder,this.errorHandler);
1355
+ domBuilder.endDocument();
1356
+ }
1357
+ }
1358
+ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
1359
+ function fixedFromCharCode(code) {
1360
+ if (code > 0xffff) {
1361
+ code -= 0x10000;
1362
+ var surrogate1 = 0xd800 + (code >> 10)
1363
+ , surrogate2 = 0xdc00 + (code & 0x3ff);
1364
+
1365
+ return String.fromCharCode(surrogate1, surrogate2);
1366
+ } else {
1367
+ return String.fromCharCode(code);
1368
+ }
1369
+ }
1370
+ function entityReplacer(a){
1371
+ var k = a.slice(1,-1);
1372
+ if(k in entityMap){
1373
+ return entityMap[k];
1374
+ }else if(k.charAt(0) === '#'){
1375
+ return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
1376
+ }else{
1377
+ errorHandler.error('entity not found:'+a);
1378
+ return a;
1379
+ }
1380
+ }
1381
+ function appendText(end){//has some bugs
1382
+ var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
1383
+ locator&&position(start);
1384
+ domBuilder.characters(xt,0,end-start);
1385
+ start = end
1386
+ }
1387
+ function position(start,m){
1388
+ while(start>=endPos && (m = linePattern.exec(source))){
1389
+ startPos = m.index;
1390
+ endPos = startPos + m[0].length;
1391
+ locator.lineNumber++;
1392
+ }
1393
+ locator.columnNumber = start-startPos+1;
1394
+ }
1395
+ var startPos = 0;
1396
+ var endPos = 0;
1397
+ var linePattern = /.+(?:\r\n?|\n)|.*$/g
1398
+ var locator = domBuilder.locator;
1399
+
1400
+ var parseStack = [{currentNSMap:defaultNSMapCopy}]
1401
+ var closeMap = {};
1402
+ var start = 0;
1403
+ while(true){
1404
+ var i = source.indexOf('<',start);
1405
+ if(i<0){
1406
+ if(!source.substr(start).match(/^\s*$/)){
1407
+ var doc = domBuilder.document;
1408
+ var text = doc.createTextNode(source.substr(start));
1409
+ doc.appendChild(text);
1410
+ domBuilder.currentElement = text;
1411
+ }
1412
+ return;
1413
+ }
1414
+ if(i>start){
1415
+ appendText(i);
1416
+ }
1417
+ switch(source.charAt(i+1)){
1418
+ case '/':
1419
+ var end = source.indexOf('>',i+3);
1420
+ var tagName = source.substring(i+2,end);
1421
+ var config;
1422
+ if (parseStack.length > 1) {
1423
+ config = parseStack.pop();
1424
+ } else {
1425
+ errorHandler.fatalError("end tag name not found for: "+tagName);
1426
+ break;
1427
+ }
1428
+ var localNSMap = config.localNSMap;
1429
+
1430
+ if(config.tagName != tagName){
1431
+ errorHandler.fatalError("end tag name: " + tagName + " does not match the current start tagName: "+config.tagName );
1432
+ }
1433
+ domBuilder.endElement(config.uri,config.localName,tagName);
1434
+ if(localNSMap){
1435
+ for(var prefix in localNSMap){
1436
+ domBuilder.endPrefixMapping(prefix) ;
1437
+ }
1438
+ }
1439
+ end++;
1440
+ break;
1441
+ case '?':// <?...?>
1442
+ locator&&position(i);
1443
+ end = parseInstruction(source,i,domBuilder);
1444
+ break;
1445
+ case '!':// <!doctype,<![CDATA,<!--
1446
+ locator&&position(i);
1447
+ end = parseDCC(source,i,domBuilder,errorHandler);
1448
+ break;
1449
+ default:
1450
+ try{
1451
+ locator&&position(i);
1452
+
1453
+ var el = new ElementAttributes();
1454
+ var end = parseElementStartPart(source,i,el,entityReplacer,errorHandler);
1455
+ var len = el.length;
1456
+ if(len && locator){
1457
+ var backup = copyLocator(locator,{});
1458
+ for(var i = 0;i<len;i++){
1459
+ var a = el[i];
1460
+ position(a.offset);
1461
+ a.offset = copyLocator(locator,{});
1462
+ }
1463
+ copyLocator(backup,locator);
1464
+ }
1465
+ if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
1466
+ el.closed = true;
1467
+ if(!entityMap.nbsp){
1468
+ errorHandler.warning('unclosed xml attribute');
1469
+ }
1470
+ }
1471
+ appendElement(el,domBuilder,parseStack);
1472
+
1473
+
1474
+ if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
1475
+ end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
1476
+ }else{
1477
+ end++;
1478
+ }
1479
+ }catch(e){
1480
+ errorHandler.error('element parse error: '+e);
1481
+ end = -1;
1482
+ }
1483
+
1484
+ }
1485
+ if(end<0){
1486
+ appendText(i+1);
1487
+ }else{
1488
+ start = end;
1489
+ }
1490
+ }
1491
+ }
1492
+ function copyLocator(f,t){
1493
+ t.lineNumber = f.lineNumber;
1494
+ t.columnNumber = f.columnNumber;
1495
+ return t;
1496
+
1497
+ }
1498
+ function parseElementStartPart(source,start,el,entityReplacer,errorHandler){
1499
+ var attrName;
1500
+ var value;
1501
+ var p = ++start;
1502
+ var s = S_TAG;//status
1503
+ while(true){
1504
+ var c = source.charAt(p);
1505
+ switch(c){
1506
+ case '=':
1507
+ if(s === S_ATTR){//attrName
1508
+ attrName = source.slice(start,p);
1509
+ s = S_EQ;
1510
+ }else if(s === S_ATTR_S){
1511
+ s = S_EQ;
1512
+ }else{
1513
+ throw new Error('attribute equal must after attrName');
1514
+ }
1515
+ break;
1516
+ case '\'':
1517
+ case '"':
1518
+ if(s === S_EQ){//equal
1519
+ start = p+1;
1520
+ p = source.indexOf(c,start)
1521
+ if(p>0){
1522
+ value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1523
+ el.add(attrName,value,start-1);
1524
+ s = S_E;
1525
+ }else{
1526
+ throw new Error('attribute value no end \''+c+'\' match');
1527
+ }
1528
+ }else if(s == S_V){
1529
+ value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1530
+ el.add(attrName,value,start);
1531
+ errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
1532
+ start = p+1;
1533
+ s = S_E
1534
+ }else{
1535
+ throw new Error('attribute value must after "="');
1536
+ }
1537
+ break;
1538
+ case '/':
1539
+ switch(s){
1540
+ case S_TAG:
1541
+ el.setTagName(source.slice(start,p));
1542
+ case S_E:
1543
+ case S_S:
1544
+ case S_C:
1545
+ s = S_C;
1546
+ el.closed = true;
1547
+ case S_V:
1548
+ case S_ATTR:
1549
+ case S_ATTR_S:
1550
+ break;
1551
+ default:
1552
+ throw new Error("attribute invalid close char('/')")
1553
+ }
1554
+ break;
1555
+ case ''://end document
1556
+ errorHandler.error('unexpected end of input');
1557
+ case '>':
1558
+ switch(s){
1559
+ case S_TAG:
1560
+ el.setTagName(source.slice(start,p));
1561
+ case S_E:
1562
+ case S_S:
1563
+ case S_C:
1564
+ break;//normal
1565
+ case S_V://Compatible state
1566
+ case S_ATTR:
1567
+ value = source.slice(start,p);
1568
+ if(value.slice(-1) === '/'){
1569
+ el.closed = true;
1570
+ value = value.slice(0,-1)
1571
+ }
1572
+ case S_ATTR_S:
1573
+ if(s === S_ATTR_S){
1574
+ value = attrName;
1575
+ }
1576
+ if(s == S_V){
1577
+ errorHandler.warning('attribute "'+value+'" missed quot(")!!');
1578
+ el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
1579
+ }else{
1580
+ errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
1581
+ el.add(value,value,start)
1582
+ }
1583
+ break;
1584
+ case S_EQ:
1585
+ throw new Error('attribute value missed!!');
1586
+ }
1587
+ return p;
1588
+ case '\u0080':
1589
+ c = ' ';
1590
+ default:
1591
+ if(c<= ' '){//space
1592
+ switch(s){
1593
+ case S_TAG:
1594
+ el.setTagName(source.slice(start,p));//tagName
1595
+ s = S_S;
1596
+ break;
1597
+ case S_ATTR:
1598
+ attrName = source.slice(start,p)
1599
+ s = S_ATTR_S;
1600
+ break;
1601
+ case S_V:
1602
+ var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
1603
+ errorHandler.warning('attribute "'+value+'" missed quot(")!!');
1604
+ el.add(attrName,value,start)
1605
+ case S_E:
1606
+ s = S_S;
1607
+ break;
1608
+ }
1609
+ }else{//not space
1610
+ switch(s){
1611
+ case S_ATTR_S:
1612
+ errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead!!')
1613
+ el.add(attrName,attrName,start);
1614
+ start = p;
1615
+ s = S_ATTR;
1616
+ break;
1617
+ case S_E:
1618
+ errorHandler.warning('attribute space is required"'+attrName+'"!!')
1619
+ case S_S:
1620
+ s = S_ATTR;
1621
+ start = p;
1622
+ break;
1623
+ case S_EQ:
1624
+ s = S_V;
1625
+ start = p;
1626
+ break;
1627
+ case S_C:
1628
+ throw new Error("elements closed character '/' and '>' must be connected to");
1629
+ }
1630
+ }
1631
+ }
1632
+ p++;
1633
+ }
1634
+ }
1635
+ function appendElement(el,domBuilder,parseStack){
1636
+ var tagName = el.tagName;
1637
+ var localNSMap = null;
1638
+ var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
1639
+ var i = el.length;
1640
+ while(i--){
1641
+ var a = el[i];
1642
+ var qName = a.qName;
1643
+ var value = a.value;
1644
+ var nsp = qName.indexOf(':');
1645
+ if(nsp>0){
1646
+ var prefix = a.prefix = qName.slice(0,nsp);
1647
+ var localName = qName.slice(nsp+1);
1648
+ var nsPrefix = prefix === 'xmlns' && localName
1649
+ }else{
1650
+ localName = qName;
1651
+ prefix = null
1652
+ nsPrefix = qName === 'xmlns' && ''
1653
+ }
1654
+ a.localName = localName ;
1655
+ if(nsPrefix !== false){//hack!!
1656
+ if(localNSMap == null){
1657
+ localNSMap = {}
1658
+ _copy(currentNSMap,currentNSMap={})
1659
+ }
1660
+ currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
1661
+ a.uri = 'http://www.w3.org/2000/xmlns/'
1662
+ domBuilder.startPrefixMapping(nsPrefix, value)
1663
+ }
1664
+ }
1665
+ var i = el.length;
1666
+ while(i--){
1667
+ a = el[i];
1668
+ var prefix = a.prefix;
1669
+ if(prefix){//no prefix attribute has no namespace
1670
+ if(prefix === 'xml'){
1671
+ a.uri = 'http://www.w3.org/XML/1998/namespace';
1672
+ }if(prefix !== 'xmlns'){
1673
+ a.uri = currentNSMap[prefix]
1674
+ }
1675
+ }
1676
+ }
1677
+ var nsp = tagName.indexOf(':');
1678
+ if(nsp>0){
1679
+ prefix = el.prefix = tagName.slice(0,nsp);
1680
+ localName = el.localName = tagName.slice(nsp+1);
1681
+ }else{
1682
+ prefix = null;//important!!
1683
+ localName = el.localName = tagName;
1684
+ }
1685
+ var ns = el.uri = currentNSMap[prefix || ''];
1686
+ domBuilder.startElement(ns,localName,tagName,el);
1687
+ if(el.closed){
1688
+ domBuilder.endElement(ns,localName,tagName);
1689
+ if(localNSMap){
1690
+ for(prefix in localNSMap){
1691
+ domBuilder.endPrefixMapping(prefix)
1692
+ }
1693
+ }
1694
+ }else{
1695
+ el.currentNSMap = currentNSMap;
1696
+ el.localNSMap = localNSMap;
1697
+ parseStack.push(el);
1698
+ }
1699
+ }
1700
+ function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
1701
+ if(/^(?:script|textarea)$/i.test(tagName)){
1702
+ var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
1703
+ var text = source.substring(elStartEnd+1,elEndStart);
1704
+ if(/[&<]/.test(text)){
1705
+ if(/^script$/i.test(tagName)){
1706
+ domBuilder.characters(text,0,text.length);
1707
+ return elEndStart;
1708
+ }//}else{//text area
1709
+ text = text.replace(/&#?\w+;/g,entityReplacer);
1710
+ domBuilder.characters(text,0,text.length);
1711
+ return elEndStart;
1712
+
1713
+ }
1714
+ }
1715
+ return elStartEnd+1;
1716
+ }
1717
+ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
1718
+ var pos = closeMap[tagName];
1719
+ if(pos == null){
1720
+ pos = closeMap[tagName] = source.lastIndexOf('</'+tagName+'>')
1721
+ }
1722
+ return pos<elStartEnd;
1723
+ }
1724
+ function _copy(source,target){
1725
+ for(var n in source){target[n] = source[n]}
1726
+ }
1727
+ function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
1728
+ var next= source.charAt(start+2)
1729
+ switch(next){
1730
+ case '-':
1731
+ if(source.charAt(start + 3) === '-'){
1732
+ var end = source.indexOf('-->',start+4);
1733
+ if(end>start){
1734
+ domBuilder.comment(source,start+4,end-start-4);
1735
+ return end+3;
1736
+ }else{
1737
+ errorHandler.error("Unclosed comment");
1738
+ return -1;
1739
+ }
1740
+ }else{
1741
+ return -1;
1742
+ }
1743
+ default:
1744
+ if(source.substr(start+3,6) == 'CDATA['){
1745
+ var end = source.indexOf(']]>',start+9);
1746
+ domBuilder.startCDATA();
1747
+ domBuilder.characters(source,start+9,end-start-9);
1748
+ domBuilder.endCDATA()
1749
+ return end+3;
1750
+ }
1751
+ var matchs = split(source,start);
1752
+ var len = matchs.length;
1753
+ if(len>1 && /!doctype/i.test(matchs[0][0])){
1754
+ var name = matchs[1][0];
1755
+ var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
1756
+ var sysid = len>4 && matchs[4][0];
1757
+ var lastMatch = matchs[len-1]
1758
+ domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
1759
+ sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
1760
+ domBuilder.endDTD();
1761
+
1762
+ return lastMatch.index+lastMatch[0].length
1763
+ }
1764
+ }
1765
+ return -1;
1766
+ }
1767
+
1768
+
1769
+
1770
+ function parseInstruction(source,start,domBuilder){
1771
+ var end = source.indexOf('?>',start);
1772
+ if(end){
1773
+ var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
1774
+ if(match){
1775
+ var len = match[0].length;
1776
+ domBuilder.processingInstruction(match[1], match[2]) ;
1777
+ return end+2;
1778
+ }else{//error
1779
+ return -1;
1780
+ }
1781
+ }
1782
+ return -1;
1783
+ }
1784
+ function ElementAttributes(source){
1785
+
1786
+ }
1787
+ ElementAttributes.prototype = {
1788
+ setTagName:function(tagName){
1789
+ if(!tagNamePattern.test(tagName)){
1790
+ throw new Error('invalid tagName:'+tagName)
1791
+ }
1792
+ this.tagName = tagName
1793
+ },
1794
+ add:function(qName,value,offset){
1795
+ if(!tagNamePattern.test(qName)){
1796
+ throw new Error('invalid attribute:'+qName)
1797
+ }
1798
+ this[this.length++] = {qName:qName,value:value,offset:offset}
1799
+ },
1800
+ length:0,
1801
+ getLocalName:function(i){return this[i].localName},
1802
+ getOffset:function(i){return this[i].offset},
1803
+ getQName:function(i){return this[i].qName},
1804
+ getURI:function(i){return this[i].uri},
1805
+ getValue:function(i){return this[i].value}
1806
+ }
1807
+
1808
+
1809
+
1810
+
1811
+ function _set_proto_(thiz,parent){
1812
+ thiz.__proto__ = parent;
1813
+ return thiz;
1814
+ }
1815
+ if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
1816
+ _set_proto_ = function(thiz,parent){
1817
+ function p(){};
1818
+ p.prototype = parent;
1819
+ p = new p();
1820
+ for(parent in thiz){
1821
+ p[parent] = thiz[parent];
1822
+ }
1823
+ return p;
1824
+ }
1825
+ }
1826
+
1827
+ function split(source,start){
1828
+ var match;
1829
+ var buf = [];
1830
+ var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
1831
+ reg.lastIndex = start;
1832
+ reg.exec(source);//skip <
1833
+ while(match = reg.exec(source)){
1834
+ buf.push(match);
1835
+ if(match[1])return buf;
1836
+ }
1837
+ }
1838
+
1839
+ return XMLReader;
1840
+ });
1841
+
1842
+ define("ace/mode/xml/dom",["require","exports","module"], function(require, exports, module) {
1843
+
1844
+ function copy(src,dest){
1845
+ for(var p in src){
1846
+ dest[p] = src[p];
1847
+ }
1848
+ }
1849
+ function _extends(Class,Super){
1850
+ var pt = Class.prototype;
1851
+ if(Object.create){
1852
+ var ppt = Object.create(Super.prototype)
1853
+ pt.__proto__ = ppt;
1854
+ }
1855
+ if(!(pt instanceof Super)){
1856
+ function t(){};
1857
+ t.prototype = Super.prototype;
1858
+ t = new t();
1859
+ copy(pt,t);
1860
+ Class.prototype = pt = t;
1861
+ }
1862
+ if(pt.constructor != Class){
1863
+ if(typeof Class != 'function'){
1864
+ console.error("unknow Class:"+Class)
1865
+ }
1866
+ pt.constructor = Class
1867
+ }
1868
+ }
1869
+ var htmlns = 'http://www.w3.org/1999/xhtml' ;
1870
+ var NodeType = {}
1871
+ var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
1872
+ var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
1873
+ var TEXT_NODE = NodeType.TEXT_NODE = 3;
1874
+ var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
1875
+ var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
1876
+ var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
1877
+ var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
1878
+ var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
1879
+ var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
1880
+ var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
1881
+ var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
1882
+ var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
1883
+ var ExceptionCode = {}
1884
+ var ExceptionMessage = {};
1885
+ var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
1886
+ var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
1887
+ var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
1888
+ var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
1889
+ var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
1890
+ var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
1891
+ var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
1892
+ var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
1893
+ var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
1894
+ var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
1895
+ var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
1896
+ var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
1897
+ var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
1898
+ var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
1899
+ var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
1900
+
1901
+
1902
+ function DOMException(code, message) {
1903
+ if(message instanceof Error){
1904
+ var error = message;
1905
+ }else{
1906
+ error = this;
1907
+ Error.call(this, ExceptionMessage[code]);
1908
+ this.message = ExceptionMessage[code];
1909
+ if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
1910
+ }
1911
+ error.code = code;
1912
+ if(message) this.message = this.message + ": " + message;
1913
+ return error;
1914
+ };
1915
+ DOMException.prototype = Error.prototype;
1916
+ copy(ExceptionCode,DOMException)
1917
+ function NodeList() {
1918
+ };
1919
+ NodeList.prototype = {
1920
+ length:0,
1921
+ item: function(index) {
1922
+ return this[index] || null;
1923
+ }
1924
+ };
1925
+ function LiveNodeList(node,refresh){
1926
+ this._node = node;
1927
+ this._refresh = refresh
1928
+ _updateLiveList(this);
1929
+ }
1930
+ function _updateLiveList(list){
1931
+ var inc = list._node._inc || list._node.ownerDocument._inc;
1932
+ if(list._inc != inc){
1933
+ var ls = list._refresh(list._node);
1934
+ __set__(list,'length',ls.length);
1935
+ copy(ls,list);
1936
+ list._inc = inc;
1937
+ }
1938
+ }
1939
+ LiveNodeList.prototype.item = function(i){
1940
+ _updateLiveList(this);
1941
+ return this[i];
1942
+ }
1943
+
1944
+ _extends(LiveNodeList,NodeList);
1945
+ function NamedNodeMap() {
1946
+ };
1947
+
1948
+ function _findNodeIndex(list,node){
1949
+ var i = list.length;
1950
+ while(i--){
1951
+ if(list[i] === node){return i}
1952
+ }
1953
+ }
1954
+
1955
+ function _addNamedNode(el,list,newAttr,oldAttr){
1956
+ if(oldAttr){
1957
+ list[_findNodeIndex(list,oldAttr)] = newAttr;
1958
+ }else{
1959
+ list[list.length++] = newAttr;
1960
+ }
1961
+ if(el){
1962
+ newAttr.ownerElement = el;
1963
+ var doc = el.ownerDocument;
1964
+ if(doc){
1965
+ oldAttr && _onRemoveAttribute(doc,el,oldAttr);
1966
+ _onAddAttribute(doc,el,newAttr);
1967
+ }
1968
+ }
1969
+ }
1970
+ function _removeNamedNode(el,list,attr){
1971
+ var i = _findNodeIndex(list,attr);
1972
+ if(i>=0){
1973
+ var lastIndex = list.length-1
1974
+ while(i<lastIndex){
1975
+ list[i] = list[++i]
1976
+ }
1977
+ list.length = lastIndex;
1978
+ if(el){
1979
+ var doc = el.ownerDocument;
1980
+ if(doc){
1981
+ _onRemoveAttribute(doc,el,attr);
1982
+ attr.ownerElement = null;
1983
+ }
1984
+ }
1985
+ }else{
1986
+ throw DOMException(NOT_FOUND_ERR,new Error())
1987
+ }
1988
+ }
1989
+ NamedNodeMap.prototype = {
1990
+ length:0,
1991
+ item:NodeList.prototype.item,
1992
+ getNamedItem: function(key) {
1993
+ var i = this.length;
1994
+ while(i--){
1995
+ var attr = this[i];
1996
+ if(attr.nodeName == key){
1997
+ return attr;
1998
+ }
1999
+ }
2000
+ },
2001
+ setNamedItem: function(attr) {
2002
+ var el = attr.ownerElement;
2003
+ if(el && el!=this._ownerElement){
2004
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
2005
+ }
2006
+ var oldAttr = this.getNamedItem(attr.nodeName);
2007
+ _addNamedNode(this._ownerElement,this,attr,oldAttr);
2008
+ return oldAttr;
2009
+ },
2010
+ setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
2011
+ var el = attr.ownerElement, oldAttr;
2012
+ if(el && el!=this._ownerElement){
2013
+ throw new DOMException(INUSE_ATTRIBUTE_ERR);
2014
+ }
2015
+ oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
2016
+ _addNamedNode(this._ownerElement,this,attr,oldAttr);
2017
+ return oldAttr;
2018
+ },
2019
+ removeNamedItem: function(key) {
2020
+ var attr = this.getNamedItem(key);
2021
+ _removeNamedNode(this._ownerElement,this,attr);
2022
+ return attr;
2023
+
2024
+
2025
+ },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
2026
+ removeNamedItemNS:function(namespaceURI,localName){
2027
+ var attr = this.getNamedItemNS(namespaceURI,localName);
2028
+ _removeNamedNode(this._ownerElement,this,attr);
2029
+ return attr;
2030
+ },
2031
+ getNamedItemNS: function(namespaceURI, localName) {
2032
+ var i = this.length;
2033
+ while(i--){
2034
+ var node = this[i];
2035
+ if(node.localName == localName && node.namespaceURI == namespaceURI){
2036
+ return node;
2037
+ }
2038
+ }
2039
+ return null;
2040
+ }
2041
+ };
2042
+ function DOMImplementation(/* Object */ features) {
2043
+ this._features = {};
2044
+ if (features) {
2045
+ for (var feature in features) {
2046
+ this._features = features[feature];
2047
+ }
2048
+ }
2049
+ };
2050
+
2051
+ DOMImplementation.prototype = {
2052
+ hasFeature: function(/* string */ feature, /* string */ version) {
2053
+ var versions = this._features[feature.toLowerCase()];
2054
+ if (versions && (!version || version in versions)) {
2055
+ return true;
2056
+ } else {
2057
+ return false;
2058
+ }
2059
+ },
2060
+ createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
2061
+ var doc = new Document();
2062
+ doc.implementation = this;
2063
+ doc.childNodes = new NodeList();
2064
+ doc.doctype = doctype;
2065
+ if(doctype){
2066
+ doc.appendChild(doctype);
2067
+ }
2068
+ if(qualifiedName){
2069
+ var root = doc.createElementNS(namespaceURI,qualifiedName);
2070
+ doc.appendChild(root);
2071
+ }
2072
+ return doc;
2073
+ },
2074
+ createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
2075
+ var node = new DocumentType();
2076
+ node.name = qualifiedName;
2077
+ node.nodeName = qualifiedName;
2078
+ node.publicId = publicId;
2079
+ node.systemId = systemId;
2080
+ return node;
2081
+ }
2082
+ };
2083
+
2084
+ function Node() {
2085
+ };
2086
+
2087
+ Node.prototype = {
2088
+ firstChild : null,
2089
+ lastChild : null,
2090
+ previousSibling : null,
2091
+ nextSibling : null,
2092
+ attributes : null,
2093
+ parentNode : null,
2094
+ childNodes : null,
2095
+ ownerDocument : null,
2096
+ nodeValue : null,
2097
+ namespaceURI : null,
2098
+ prefix : null,
2099
+ localName : null,
2100
+ insertBefore:function(newChild, refChild){//raises
2101
+ return _insertBefore(this,newChild,refChild);
2102
+ },
2103
+ replaceChild:function(newChild, oldChild){//raises
2104
+ this.insertBefore(newChild,oldChild);
2105
+ if(oldChild){
2106
+ this.removeChild(oldChild);
2107
+ }
2108
+ },
2109
+ removeChild:function(oldChild){
2110
+ return _removeChild(this,oldChild);
2111
+ },
2112
+ appendChild:function(newChild){
2113
+ return this.insertBefore(newChild,null);
2114
+ },
2115
+ hasChildNodes:function(){
2116
+ return this.firstChild != null;
2117
+ },
2118
+ cloneNode:function(deep){
2119
+ return cloneNode(this.ownerDocument||this,this,deep);
2120
+ },
2121
+ normalize:function(){
2122
+ var child = this.firstChild;
2123
+ while(child){
2124
+ var next = child.nextSibling;
2125
+ if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
2126
+ this.removeChild(next);
2127
+ child.appendData(next.data);
2128
+ }else{
2129
+ child.normalize();
2130
+ child = next;
2131
+ }
2132
+ }
2133
+ },
2134
+ isSupported:function(feature, version){
2135
+ return this.ownerDocument.implementation.hasFeature(feature,version);
2136
+ },
2137
+ hasAttributes:function(){
2138
+ return this.attributes.length>0;
2139
+ },
2140
+ lookupPrefix:function(namespaceURI){
2141
+ var el = this;
2142
+ while(el){
2143
+ var map = el._nsMap;
2144
+ if(map){
2145
+ for(var n in map){
2146
+ if(map[n] == namespaceURI){
2147
+ return n;
2148
+ }
2149
+ }
2150
+ }
2151
+ el = el.nodeType == 2?el.ownerDocument : el.parentNode;
2152
+ }
2153
+ return null;
2154
+ },
2155
+ lookupNamespaceURI:function(prefix){
2156
+ var el = this;
2157
+ while(el){
2158
+ var map = el._nsMap;
2159
+ if(map){
2160
+ if(prefix in map){
2161
+ return map[prefix] ;
2162
+ }
2163
+ }
2164
+ el = el.nodeType == 2?el.ownerDocument : el.parentNode;
2165
+ }
2166
+ return null;
2167
+ },
2168
+ isDefaultNamespace:function(namespaceURI){
2169
+ var prefix = this.lookupPrefix(namespaceURI);
2170
+ return prefix == null;
2171
+ }
2172
+ };
2173
+
2174
+
2175
+ function _xmlEncoder(c){
2176
+ return c == '<' && '&lt;' ||
2177
+ c == '>' && '&gt;' ||
2178
+ c == '&' && '&amp;' ||
2179
+ c == '"' && '&quot;' ||
2180
+ '&#'+c.charCodeAt()+';'
2181
+ }
2182
+
2183
+
2184
+ copy(NodeType,Node);
2185
+ copy(NodeType,Node.prototype);
2186
+ function _visitNode(node,callback){
2187
+ if(callback(node)){
2188
+ return true;
2189
+ }
2190
+ if(node = node.firstChild){
2191
+ do{
2192
+ if(_visitNode(node,callback)){return true}
2193
+ }while(node=node.nextSibling)
2194
+ }
2195
+ }
2196
+
2197
+
2198
+
2199
+ function Document(){
2200
+ }
2201
+ function _onAddAttribute(doc,el,newAttr){
2202
+ doc && doc._inc++;
2203
+ var ns = newAttr.namespaceURI ;
2204
+ if(ns == 'http://www.w3.org/2000/xmlns/'){
2205
+ el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
2206
+ }
2207
+ }
2208
+ function _onRemoveAttribute(doc,el,newAttr,remove){
2209
+ doc && doc._inc++;
2210
+ var ns = newAttr.namespaceURI ;
2211
+ if(ns == 'http://www.w3.org/2000/xmlns/'){
2212
+ delete el._nsMap[newAttr.prefix?newAttr.localName:'']
2213
+ }
2214
+ }
2215
+ function _onUpdateChild(doc,el,newChild){
2216
+ if(doc && doc._inc){
2217
+ doc._inc++;
2218
+ var cs = el.childNodes;
2219
+ if(newChild){
2220
+ cs[cs.length++] = newChild;
2221
+ }else{
2222
+ var child = el.firstChild;
2223
+ var i = 0;
2224
+ while(child){
2225
+ cs[i++] = child;
2226
+ child =child.nextSibling;
2227
+ }
2228
+ cs.length = i;
2229
+ }
2230
+ }
2231
+ }
2232
+ function _removeChild(parentNode,child){
2233
+ var previous = child.previousSibling;
2234
+ var next = child.nextSibling;
2235
+ if(previous){
2236
+ previous.nextSibling = next;
2237
+ }else{
2238
+ parentNode.firstChild = next
2239
+ }
2240
+ if(next){
2241
+ next.previousSibling = previous;
2242
+ }else{
2243
+ parentNode.lastChild = previous;
2244
+ }
2245
+ _onUpdateChild(parentNode.ownerDocument,parentNode);
2246
+ return child;
2247
+ }
2248
+ function _insertBefore(parentNode,newChild,nextChild){
2249
+ var cp = newChild.parentNode;
2250
+ if(cp){
2251
+ cp.removeChild(newChild);//remove and update
2252
+ }
2253
+ if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
2254
+ var newFirst = newChild.firstChild;
2255
+ if (newFirst == null) {
2256
+ return newChild;
2257
+ }
2258
+ var newLast = newChild.lastChild;
2259
+ }else{
2260
+ newFirst = newLast = newChild;
2261
+ }
2262
+ var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
2263
+
2264
+ newFirst.previousSibling = pre;
2265
+ newLast.nextSibling = nextChild;
2266
+
2267
+
2268
+ if(pre){
2269
+ pre.nextSibling = newFirst;
2270
+ }else{
2271
+ parentNode.firstChild = newFirst;
2272
+ }
2273
+ if(nextChild == null){
2274
+ parentNode.lastChild = newLast;
2275
+ }else{
2276
+ nextChild.previousSibling = newLast;
2277
+ }
2278
+ do{
2279
+ newFirst.parentNode = parentNode;
2280
+ }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
2281
+ _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
2282
+ if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
2283
+ newChild.firstChild = newChild.lastChild = null;
2284
+ }
2285
+ return newChild;
2286
+ }
2287
+ function _appendSingleChild(parentNode,newChild){
2288
+ var cp = newChild.parentNode;
2289
+ if(cp){
2290
+ var pre = parentNode.lastChild;
2291
+ cp.removeChild(newChild);//remove and update
2292
+ var pre = parentNode.lastChild;
2293
+ }
2294
+ var pre = parentNode.lastChild;
2295
+ newChild.parentNode = parentNode;
2296
+ newChild.previousSibling = pre;
2297
+ newChild.nextSibling = null;
2298
+ if(pre){
2299
+ pre.nextSibling = newChild;
2300
+ }else{
2301
+ parentNode.firstChild = newChild;
2302
+ }
2303
+ parentNode.lastChild = newChild;
2304
+ _onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
2305
+ return newChild;
2306
+ }
2307
+ Document.prototype = {
2308
+ nodeName : '#document',
2309
+ nodeType : DOCUMENT_NODE,
2310
+ doctype : null,
2311
+ documentElement : null,
2312
+ _inc : 1,
2313
+
2314
+ insertBefore : function(newChild, refChild){//raises
2315
+ if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
2316
+ var child = newChild.firstChild;
2317
+ while(child){
2318
+ var next = child.nextSibling;
2319
+ this.insertBefore(child,refChild);
2320
+ child = next;
2321
+ }
2322
+ return newChild;
2323
+ }
2324
+ if(this.documentElement == null && newChild.nodeType == 1){
2325
+ this.documentElement = newChild;
2326
+ }
2327
+
2328
+ return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
2329
+ },
2330
+ removeChild : function(oldChild){
2331
+ if(this.documentElement == oldChild){
2332
+ this.documentElement = null;
2333
+ }
2334
+ return _removeChild(this,oldChild);
2335
+ },
2336
+ importNode : function(importedNode,deep){
2337
+ return importNode(this,importedNode,deep);
2338
+ },
2339
+ getElementById : function(id){
2340
+ var rtv = null;
2341
+ _visitNode(this.documentElement,function(node){
2342
+ if(node.nodeType == 1){
2343
+ if(node.getAttribute('id') == id){
2344
+ rtv = node;
2345
+ return true;
2346
+ }
2347
+ }
2348
+ })
2349
+ return rtv;
2350
+ },
2351
+ createElement : function(tagName){
2352
+ var node = new Element();
2353
+ node.ownerDocument = this;
2354
+ node.nodeName = tagName;
2355
+ node.tagName = tagName;
2356
+ node.childNodes = new NodeList();
2357
+ var attrs = node.attributes = new NamedNodeMap();
2358
+ attrs._ownerElement = node;
2359
+ return node;
2360
+ },
2361
+ createDocumentFragment : function(){
2362
+ var node = new DocumentFragment();
2363
+ node.ownerDocument = this;
2364
+ node.childNodes = new NodeList();
2365
+ return node;
2366
+ },
2367
+ createTextNode : function(data){
2368
+ var node = new Text();
2369
+ node.ownerDocument = this;
2370
+ node.appendData(data)
2371
+ return node;
2372
+ },
2373
+ createComment : function(data){
2374
+ var node = new Comment();
2375
+ node.ownerDocument = this;
2376
+ node.appendData(data)
2377
+ return node;
2378
+ },
2379
+ createCDATASection : function(data){
2380
+ var node = new CDATASection();
2381
+ node.ownerDocument = this;
2382
+ node.appendData(data)
2383
+ return node;
2384
+ },
2385
+ createProcessingInstruction : function(target,data){
2386
+ var node = new ProcessingInstruction();
2387
+ node.ownerDocument = this;
2388
+ node.tagName = node.target = target;
2389
+ node.nodeValue= node.data = data;
2390
+ return node;
2391
+ },
2392
+ createAttribute : function(name){
2393
+ var node = new Attr();
2394
+ node.ownerDocument = this;
2395
+ node.name = name;
2396
+ node.nodeName = name;
2397
+ node.localName = name;
2398
+ node.specified = true;
2399
+ return node;
2400
+ },
2401
+ createEntityReference : function(name){
2402
+ var node = new EntityReference();
2403
+ node.ownerDocument = this;
2404
+ node.nodeName = name;
2405
+ return node;
2406
+ },
2407
+ createElementNS : function(namespaceURI,qualifiedName){
2408
+ var node = new Element();
2409
+ var pl = qualifiedName.split(':');
2410
+ var attrs = node.attributes = new NamedNodeMap();
2411
+ node.childNodes = new NodeList();
2412
+ node.ownerDocument = this;
2413
+ node.nodeName = qualifiedName;
2414
+ node.tagName = qualifiedName;
2415
+ node.namespaceURI = namespaceURI;
2416
+ if(pl.length == 2){
2417
+ node.prefix = pl[0];
2418
+ node.localName = pl[1];
2419
+ }else{
2420
+ node.localName = qualifiedName;
2421
+ }
2422
+ attrs._ownerElement = node;
2423
+ return node;
2424
+ },
2425
+ createAttributeNS : function(namespaceURI,qualifiedName){
2426
+ var node = new Attr();
2427
+ var pl = qualifiedName.split(':');
2428
+ node.ownerDocument = this;
2429
+ node.nodeName = qualifiedName;
2430
+ node.name = qualifiedName;
2431
+ node.namespaceURI = namespaceURI;
2432
+ node.specified = true;
2433
+ if(pl.length == 2){
2434
+ node.prefix = pl[0];
2435
+ node.localName = pl[1];
2436
+ }else{
2437
+ node.localName = qualifiedName;
2438
+ }
2439
+ return node;
2440
+ }
2441
+ };
2442
+ _extends(Document,Node);
2443
+
2444
+
2445
+ function Element() {
2446
+ this._nsMap = {};
2447
+ };
2448
+ Element.prototype = {
2449
+ nodeType : ELEMENT_NODE,
2450
+ hasAttribute : function(name){
2451
+ return this.getAttributeNode(name)!=null;
2452
+ },
2453
+ getAttribute : function(name){
2454
+ var attr = this.getAttributeNode(name);
2455
+ return attr && attr.value || '';
2456
+ },
2457
+ getAttributeNode : function(name){
2458
+ return this.attributes.getNamedItem(name);
2459
+ },
2460
+ setAttribute : function(name, value){
2461
+ var attr = this.ownerDocument.createAttribute(name);
2462
+ attr.value = attr.nodeValue = "" + value;
2463
+ this.setAttributeNode(attr)
2464
+ },
2465
+ removeAttribute : function(name){
2466
+ var attr = this.getAttributeNode(name)
2467
+ attr && this.removeAttributeNode(attr);
2468
+ },
2469
+ appendChild:function(newChild){
2470
+ if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
2471
+ return this.insertBefore(newChild,null);
2472
+ }else{
2473
+ return _appendSingleChild(this,newChild);
2474
+ }
2475
+ },
2476
+ setAttributeNode : function(newAttr){
2477
+ return this.attributes.setNamedItem(newAttr);
2478
+ },
2479
+ setAttributeNodeNS : function(newAttr){
2480
+ return this.attributes.setNamedItemNS(newAttr);
2481
+ },
2482
+ removeAttributeNode : function(oldAttr){
2483
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
2484
+ },
2485
+ removeAttributeNS : function(namespaceURI, localName){
2486
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
2487
+ old && this.removeAttributeNode(old);
2488
+ },
2489
+
2490
+ hasAttributeNS : function(namespaceURI, localName){
2491
+ return this.getAttributeNodeNS(namespaceURI, localName)!=null;
2492
+ },
2493
+ getAttributeNS : function(namespaceURI, localName){
2494
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
2495
+ return attr && attr.value || '';
2496
+ },
2497
+ setAttributeNS : function(namespaceURI, qualifiedName, value){
2498
+ var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
2499
+ attr.value = attr.nodeValue = "" + value;
2500
+ this.setAttributeNode(attr)
2501
+ },
2502
+ getAttributeNodeNS : function(namespaceURI, localName){
2503
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
2504
+ },
2505
+
2506
+ getElementsByTagName : function(tagName){
2507
+ return new LiveNodeList(this,function(base){
2508
+ var ls = [];
2509
+ _visitNode(base,function(node){
2510
+ if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
2511
+ ls.push(node);
2512
+ }
2513
+ });
2514
+ return ls;
2515
+ });
2516
+ },
2517
+ getElementsByTagNameNS : function(namespaceURI, localName){
2518
+ return new LiveNodeList(this,function(base){
2519
+ var ls = [];
2520
+ _visitNode(base,function(node){
2521
+ if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
2522
+ ls.push(node);
2523
+ }
2524
+ });
2525
+ return ls;
2526
+ });
2527
+ }
2528
+ };
2529
+ Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
2530
+ Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
2531
+
2532
+
2533
+ _extends(Element,Node);
2534
+ function Attr() {
2535
+ };
2536
+ Attr.prototype.nodeType = ATTRIBUTE_NODE;
2537
+ _extends(Attr,Node);
2538
+
2539
+
2540
+ function CharacterData() {
2541
+ };
2542
+ CharacterData.prototype = {
2543
+ data : '',
2544
+ substringData : function(offset, count) {
2545
+ return this.data.substring(offset, offset+count);
2546
+ },
2547
+ appendData: function(text) {
2548
+ text = this.data+text;
2549
+ this.nodeValue = this.data = text;
2550
+ this.length = text.length;
2551
+ },
2552
+ insertData: function(offset,text) {
2553
+ this.replaceData(offset,0,text);
2554
+
2555
+ },
2556
+ appendChild:function(newChild){
2557
+ throw new Error(ExceptionMessage[3])
2558
+ return Node.prototype.appendChild.apply(this,arguments)
2559
+ },
2560
+ deleteData: function(offset, count) {
2561
+ this.replaceData(offset,count,"");
2562
+ },
2563
+ replaceData: function(offset, count, text) {
2564
+ var start = this.data.substring(0,offset);
2565
+ var end = this.data.substring(offset+count);
2566
+ text = start + text + end;
2567
+ this.nodeValue = this.data = text;
2568
+ this.length = text.length;
2569
+ }
2570
+ }
2571
+ _extends(CharacterData,Node);
2572
+ function Text() {
2573
+ };
2574
+ Text.prototype = {
2575
+ nodeName : "#text",
2576
+ nodeType : TEXT_NODE,
2577
+ splitText : function(offset) {
2578
+ var text = this.data;
2579
+ var newText = text.substring(offset);
2580
+ text = text.substring(0, offset);
2581
+ this.data = this.nodeValue = text;
2582
+ this.length = text.length;
2583
+ var newNode = this.ownerDocument.createTextNode(newText);
2584
+ if(this.parentNode){
2585
+ this.parentNode.insertBefore(newNode, this.nextSibling);
2586
+ }
2587
+ return newNode;
2588
+ }
2589
+ }
2590
+ _extends(Text,CharacterData);
2591
+ function Comment() {
2592
+ };
2593
+ Comment.prototype = {
2594
+ nodeName : "#comment",
2595
+ nodeType : COMMENT_NODE
2596
+ }
2597
+ _extends(Comment,CharacterData);
2598
+
2599
+ function CDATASection() {
2600
+ };
2601
+ CDATASection.prototype = {
2602
+ nodeName : "#cdata-section",
2603
+ nodeType : CDATA_SECTION_NODE
2604
+ }
2605
+ _extends(CDATASection,CharacterData);
2606
+
2607
+
2608
+ function DocumentType() {
2609
+ };
2610
+ DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
2611
+ _extends(DocumentType,Node);
2612
+
2613
+ function Notation() {
2614
+ };
2615
+ Notation.prototype.nodeType = NOTATION_NODE;
2616
+ _extends(Notation,Node);
2617
+
2618
+ function Entity() {
2619
+ };
2620
+ Entity.prototype.nodeType = ENTITY_NODE;
2621
+ _extends(Entity,Node);
2622
+
2623
+ function EntityReference() {
2624
+ };
2625
+ EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
2626
+ _extends(EntityReference,Node);
2627
+
2628
+ function DocumentFragment() {
2629
+ };
2630
+ DocumentFragment.prototype.nodeName = "#document-fragment";
2631
+ DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
2632
+ _extends(DocumentFragment,Node);
2633
+
2634
+
2635
+ function ProcessingInstruction() {
2636
+ }
2637
+ ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
2638
+ _extends(ProcessingInstruction,Node);
2639
+ function XMLSerializer(){}
2640
+ XMLSerializer.prototype.serializeToString = function(node){
2641
+ var buf = [];
2642
+ serializeToString(node,buf);
2643
+ return buf.join('');
2644
+ }
2645
+ Node.prototype.toString =function(){
2646
+ return XMLSerializer.prototype.serializeToString(this);
2647
+ }
2648
+ function serializeToString(node,buf){
2649
+ switch(node.nodeType){
2650
+ case ELEMENT_NODE:
2651
+ var attrs = node.attributes;
2652
+ var len = attrs.length;
2653
+ var child = node.firstChild;
2654
+ var nodeName = node.tagName;
2655
+ var isHTML = htmlns === node.namespaceURI
2656
+ buf.push('<',nodeName);
2657
+ for(var i=0;i<len;i++){
2658
+ serializeToString(attrs.item(i),buf,isHTML);
2659
+ }
2660
+ if(child || isHTML && !/^(?:meta|link|img|br|hr|input|button)$/i.test(nodeName)){
2661
+ buf.push('>');
2662
+ if(isHTML && /^script$/i.test(nodeName)){
2663
+ if(child){
2664
+ buf.push(child.data);
2665
+ }
2666
+ }else{
2667
+ while(child){
2668
+ serializeToString(child,buf);
2669
+ child = child.nextSibling;
2670
+ }
2671
+ }
2672
+ buf.push('</',nodeName,'>');
2673
+ }else{
2674
+ buf.push('/>');
2675
+ }
2676
+ return;
2677
+ case DOCUMENT_NODE:
2678
+ case DOCUMENT_FRAGMENT_NODE:
2679
+ var child = node.firstChild;
2680
+ while(child){
2681
+ serializeToString(child,buf);
2682
+ child = child.nextSibling;
2683
+ }
2684
+ return;
2685
+ case ATTRIBUTE_NODE:
2686
+ return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
2687
+ case TEXT_NODE:
2688
+ return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
2689
+ case CDATA_SECTION_NODE:
2690
+ return buf.push( '<![CDATA[',node.data,']]>');
2691
+ case COMMENT_NODE:
2692
+ return buf.push( "<!--",node.data,"-->");
2693
+ case DOCUMENT_TYPE_NODE:
2694
+ var pubid = node.publicId;
2695
+ var sysid = node.systemId;
2696
+ buf.push('<!DOCTYPE ',node.name);
2697
+ if(pubid){
2698
+ buf.push(' PUBLIC "',pubid);
2699
+ if (sysid && sysid!='.') {
2700
+ buf.push( '" "',sysid);
2701
+ }
2702
+ buf.push('">');
2703
+ }else if(sysid && sysid!='.'){
2704
+ buf.push(' SYSTEM "',sysid,'">');
2705
+ }else{
2706
+ var sub = node.internalSubset;
2707
+ if(sub){
2708
+ buf.push(" [",sub,"]");
2709
+ }
2710
+ buf.push(">");
2711
+ }
2712
+ return;
2713
+ case PROCESSING_INSTRUCTION_NODE:
2714
+ return buf.push( "<?",node.target," ",node.data,"?>");
2715
+ case ENTITY_REFERENCE_NODE:
2716
+ return buf.push( '&',node.nodeName,';');
2717
+ default:
2718
+ buf.push('??',node.nodeName);
2719
+ }
2720
+ }
2721
+ function importNode(doc,node,deep){
2722
+ var node2;
2723
+ switch (node.nodeType) {
2724
+ case ELEMENT_NODE:
2725
+ node2 = node.cloneNode(false);
2726
+ node2.ownerDocument = doc;
2727
+ case DOCUMENT_FRAGMENT_NODE:
2728
+ break;
2729
+ case ATTRIBUTE_NODE:
2730
+ deep = true;
2731
+ break;
2732
+ }
2733
+ if(!node2){
2734
+ node2 = node.cloneNode(false);//false
2735
+ }
2736
+ node2.ownerDocument = doc;
2737
+ node2.parentNode = null;
2738
+ if(deep){
2739
+ var child = node.firstChild;
2740
+ while(child){
2741
+ node2.appendChild(importNode(doc,child,deep));
2742
+ child = child.nextSibling;
2743
+ }
2744
+ }
2745
+ return node2;
2746
+ }
2747
+ function cloneNode(doc,node,deep){
2748
+ var node2 = new node.constructor();
2749
+ for(var n in node){
2750
+ var v = node[n];
2751
+ if(typeof v != 'object' ){
2752
+ if(v != node2[n]){
2753
+ node2[n] = v;
2754
+ }
2755
+ }
2756
+ }
2757
+ if(node.childNodes){
2758
+ node2.childNodes = new NodeList();
2759
+ }
2760
+ node2.ownerDocument = doc;
2761
+ switch (node2.nodeType) {
2762
+ case ELEMENT_NODE:
2763
+ var attrs = node.attributes;
2764
+ var attrs2 = node2.attributes = new NamedNodeMap();
2765
+ var len = attrs.length
2766
+ attrs2._ownerElement = node2;
2767
+ for(var i=0;i<len;i++){
2768
+ node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
2769
+ }
2770
+ break;;
2771
+ case ATTRIBUTE_NODE:
2772
+ deep = true;
2773
+ }
2774
+ if(deep){
2775
+ var child = node.firstChild;
2776
+ while(child){
2777
+ node2.appendChild(cloneNode(doc,child,deep));
2778
+ child = child.nextSibling;
2779
+ }
2780
+ }
2781
+ return node2;
2782
+ }
2783
+
2784
+ function __set__(object,key,value){
2785
+ object[key] = value
2786
+ }
2787
+ try{
2788
+ if(Object.defineProperty){
2789
+ Object.defineProperty(LiveNodeList.prototype,'length',{
2790
+ get:function(){
2791
+ _updateLiveList(this);
2792
+ return this.$$length;
2793
+ }
2794
+ });
2795
+ Object.defineProperty(Node.prototype,'textContent',{
2796
+ get:function(){
2797
+ return getTextContent(this);
2798
+ },
2799
+ set:function(data){
2800
+ switch(this.nodeType){
2801
+ case 1:
2802
+ case 11:
2803
+ while(this.firstChild){
2804
+ this.removeChild(this.firstChild);
2805
+ }
2806
+ if(data || String(data)){
2807
+ this.appendChild(this.ownerDocument.createTextNode(data));
2808
+ }
2809
+ break;
2810
+ default:
2811
+ this.data = data;
2812
+ this.value = value;
2813
+ this.nodeValue = data;
2814
+ }
2815
+ }
2816
+ })
2817
+
2818
+ function getTextContent(node){
2819
+ switch(node.nodeType){
2820
+ case 1:
2821
+ case 11:
2822
+ var buf = [];
2823
+ node = node.firstChild;
2824
+ while(node){
2825
+ if(node.nodeType!==7 && node.nodeType !==8){
2826
+ buf.push(getTextContent(node));
2827
+ }
2828
+ node = node.nextSibling;
2829
+ }
2830
+ return buf.join('');
2831
+ default:
2832
+ return node.nodeValue;
2833
+ }
2834
+ }
2835
+ __set__ = function(object,key,value){
2836
+ object['$$'+key] = value
2837
+ }
2838
+ }
2839
+ }catch(e){//ie8
2840
+ }
2841
+
2842
+ return DOMImplementation;
2843
+ });
2844
+
2845
+ define("ace/mode/xml/dom-parser",["require","exports","module","ace/mode/xml/sax","ace/mode/xml/dom"], function(require, exports, module) {
2846
+ 'use strict';
2847
+
2848
+ var XMLReader = require('./sax'),
2849
+ DOMImplementation = require('./dom');
2850
+
2851
+ function DOMParser(options){
2852
+ this.options = options ||{locator:{}};
2853
+
2854
+ }
2855
+ DOMParser.prototype.parseFromString = function(source,mimeType){
2856
+ var options = this.options;
2857
+ var sax = new XMLReader();
2858
+ var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
2859
+ var errorHandler = options.errorHandler;
2860
+ var locator = options.locator;
2861
+ var defaultNSMap = options.xmlns||{};
2862
+ var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"}
2863
+ if(locator){
2864
+ domBuilder.setDocumentLocator(locator)
2865
+ }
2866
+
2867
+ sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
2868
+ sax.domBuilder = options.domBuilder || domBuilder;
2869
+ if(/\/x?html?$/.test(mimeType)){
2870
+ entityMap.nbsp = '\xa0';
2871
+ entityMap.copy = '\xa9';
2872
+ defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
2873
+ }
2874
+ if(source){
2875
+ sax.parse(source,defaultNSMap,entityMap);
2876
+ }else{
2877
+ sax.errorHandler.error("invalid document source");
2878
+ }
2879
+ return domBuilder.document;
2880
+ }
2881
+ function buildErrorHandler(errorImpl,domBuilder,locator){
2882
+ if(!errorImpl){
2883
+ if(domBuilder instanceof DOMHandler){
2884
+ return domBuilder;
2885
+ }
2886
+ errorImpl = domBuilder ;
2887
+ }
2888
+ var errorHandler = {}
2889
+ var isCallback = errorImpl instanceof Function;
2890
+ locator = locator||{}
2891
+ function build(key){
2892
+ var fn = errorImpl[key];
2893
+ if(!fn){
2894
+ if(isCallback){
2895
+ fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
2896
+ }else{
2897
+ var i=arguments.length;
2898
+ while(--i){
2899
+ if(fn = errorImpl[arguments[i]]){
2900
+ break;
2901
+ }
2902
+ }
2903
+ }
2904
+ }
2905
+ errorHandler[key] = fn && function(msg){
2906
+ fn(msg+_locator(locator), msg, locator);
2907
+ }||function(){};
2908
+ }
2909
+ build('warning','warn');
2910
+ build('error','warn','warning');
2911
+ build('fatalError','warn','warning','error');
2912
+ return errorHandler;
2913
+ }
2914
+ function DOMHandler() {
2915
+ this.cdata = false;
2916
+ }
2917
+ function position(locator,node){
2918
+ node.lineNumber = locator.lineNumber;
2919
+ node.columnNumber = locator.columnNumber;
2920
+ }
2921
+ DOMHandler.prototype = {
2922
+ startDocument : function() {
2923
+ this.document = new DOMImplementation().createDocument(null, null, null);
2924
+ if (this.locator) {
2925
+ this.document.documentURI = this.locator.systemId;
2926
+ }
2927
+ },
2928
+ startElement:function(namespaceURI, localName, qName, attrs) {
2929
+ var doc = this.document;
2930
+ var el = doc.createElementNS(namespaceURI, qName||localName);
2931
+ var len = attrs.length;
2932
+ appendElement(this, el);
2933
+ this.currentElement = el;
2934
+
2935
+ this.locator && position(this.locator,el)
2936
+ for (var i = 0 ; i < len; i++) {
2937
+ var namespaceURI = attrs.getURI(i);
2938
+ var value = attrs.getValue(i);
2939
+ var qName = attrs.getQName(i);
2940
+ var attr = doc.createAttributeNS(namespaceURI, qName);
2941
+ if( attr.getOffset){
2942
+ position(attr.getOffset(1),attr)
2943
+ }
2944
+ attr.value = attr.nodeValue = value;
2945
+ el.setAttributeNode(attr)
2946
+ }
2947
+ },
2948
+ endElement:function(namespaceURI, localName, qName) {
2949
+ var current = this.currentElement
2950
+ var tagName = current.tagName;
2951
+ this.currentElement = current.parentNode;
2952
+ },
2953
+ startPrefixMapping:function(prefix, uri) {
2954
+ },
2955
+ endPrefixMapping:function(prefix) {
2956
+ },
2957
+ processingInstruction:function(target, data) {
2958
+ var ins = this.document.createProcessingInstruction(target, data);
2959
+ this.locator && position(this.locator,ins)
2960
+ appendElement(this, ins);
2961
+ },
2962
+ ignorableWhitespace:function(ch, start, length) {
2963
+ },
2964
+ characters:function(chars, start, length) {
2965
+ chars = _toString.apply(this,arguments)
2966
+ if(this.currentElement && chars){
2967
+ if (this.cdata) {
2968
+ var charNode = this.document.createCDATASection(chars);
2969
+ this.currentElement.appendChild(charNode);
2970
+ } else {
2971
+ var charNode = this.document.createTextNode(chars);
2972
+ this.currentElement.appendChild(charNode);
2973
+ }
2974
+ this.locator && position(this.locator,charNode)
2975
+ }
2976
+ },
2977
+ skippedEntity:function(name) {
2978
+ },
2979
+ endDocument:function() {
2980
+ this.document.normalize();
2981
+ },
2982
+ setDocumentLocator:function (locator) {
2983
+ if(this.locator = locator){// && !('lineNumber' in locator)){
2984
+ locator.lineNumber = 0;
2985
+ }
2986
+ },
2987
+ comment:function(chars, start, length) {
2988
+ chars = _toString.apply(this,arguments)
2989
+ var comm = this.document.createComment(chars);
2990
+ this.locator && position(this.locator,comm)
2991
+ appendElement(this, comm);
2992
+ },
2993
+
2994
+ startCDATA:function() {
2995
+ this.cdata = true;
2996
+ },
2997
+ endCDATA:function() {
2998
+ this.cdata = false;
2999
+ },
3000
+
3001
+ startDTD:function(name, publicId, systemId) {
3002
+ var impl = this.document.implementation;
3003
+ if (impl && impl.createDocumentType) {
3004
+ var dt = impl.createDocumentType(name, publicId, systemId);
3005
+ this.locator && position(this.locator,dt)
3006
+ appendElement(this, dt);
3007
+ }
3008
+ },
3009
+ warning:function(error) {
3010
+ console.warn(error,_locator(this.locator));
3011
+ },
3012
+ error:function(error) {
3013
+ console.error(error,_locator(this.locator));
3014
+ },
3015
+ fatalError:function(error) {
3016
+ console.error(error,_locator(this.locator));
3017
+ throw error;
3018
+ }
3019
+ }
3020
+ function _locator(l){
3021
+ if(l){
3022
+ return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
3023
+ }
3024
+ }
3025
+ function _toString(chars,start,length){
3026
+ if(typeof chars == 'string'){
3027
+ return chars.substr(start,length)
3028
+ }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
3029
+ if(chars.length >= start+length || start){
3030
+ return new java.lang.String(chars,start,length)+'';
3031
+ }
3032
+ return chars;
3033
+ }
3034
+ }
3035
+ "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
3036
+ DOMHandler.prototype[key] = function(){return null}
3037
+ })
3038
+ function appendElement (hander,node) {
3039
+ if (!hander.currentElement) {
3040
+ hander.document.appendChild(node);
3041
+ } else {
3042
+ hander.currentElement.appendChild(node);
3043
+ }
3044
+ }//appendChild and setAttributeNS are preformance key
3045
+
3046
+ return {
3047
+ DOMParser: DOMParser
3048
+ };
3049
+ });
3050
+
3051
+ define("ace/mode/xml_worker",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/worker/mirror","ace/mode/xml/dom-parser"], function(require, exports, module) {
3052
+ "use strict";
3053
+
3054
+ var oop = require("../lib/oop");
3055
+ var lang = require("../lib/lang");
3056
+ var Mirror = require("../worker/mirror").Mirror;
3057
+ var DOMParser = require("./xml/dom-parser").DOMParser;
3058
+
3059
+ var Worker = exports.Worker = function(sender) {
3060
+ Mirror.call(this, sender);
3061
+ this.setTimeout(400);
3062
+ this.context = null;
3063
+ };
3064
+
3065
+ oop.inherits(Worker, Mirror);
3066
+
3067
+ (function() {
3068
+
3069
+ this.setOptions = function(options) {
3070
+ this.context = options.context;
3071
+ };
3072
+
3073
+ this.onUpdate = function() {
3074
+ var value = this.doc.getValue();
3075
+ if (!value)
3076
+ return;
3077
+ var parser = new DOMParser();
3078
+ var errors = [];
3079
+ parser.options.errorHandler = {
3080
+ fatalError: function(fullMsg, errorMsg, locator) {
3081
+ errors.push({
3082
+ row: locator.lineNumber,
3083
+ column: locator.columnNumber,
3084
+ text: errorMsg,
3085
+ type: "error"
3086
+ });
3087
+ },
3088
+ error: function(fullMsg, errorMsg, locator) {
3089
+ errors.push({
3090
+ row: locator.lineNumber,
3091
+ column: locator.columnNumber,
3092
+ text: errorMsg,
3093
+ type: "error"
3094
+ });
3095
+ },
3096
+ warning: function(fullMsg, errorMsg, locator) {
3097
+ errors.push({
3098
+ row: locator.lineNumber,
3099
+ column: locator.columnNumber,
3100
+ text: errorMsg,
3101
+ type: "warning"
3102
+ });
3103
+ }
3104
+ };
3105
+
3106
+ parser.parseFromString(value);
3107
+ this.sender.emit("error", errors);
3108
+ };
3109
+
3110
+ }).call(Worker.prototype);
3111
+
3112
+ });
3113
+
3114
+ define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
3115
+
3116
+ function Empty() {}
3117
+
3118
+ if (!Function.prototype.bind) {
3119
+ Function.prototype.bind = function bind(that) { // .length is 1
3120
+ var target = this;
3121
+ if (typeof target != "function") {
3122
+ throw new TypeError("Function.prototype.bind called on incompatible " + target);
3123
+ }
3124
+ var args = slice.call(arguments, 1); // for normal call
3125
+ var bound = function () {
3126
+
3127
+ if (this instanceof bound) {
3128
+
3129
+ var result = target.apply(
3130
+ this,
3131
+ args.concat(slice.call(arguments))
3132
+ );
3133
+ if (Object(result) === result) {
3134
+ return result;
3135
+ }
3136
+ return this;
3137
+
3138
+ } else {
3139
+ return target.apply(
3140
+ that,
3141
+ args.concat(slice.call(arguments))
3142
+ );
3143
+
3144
+ }
3145
+
3146
+ };
3147
+ if(target.prototype) {
3148
+ Empty.prototype = target.prototype;
3149
+ bound.prototype = new Empty();
3150
+ Empty.prototype = null;
3151
+ }
3152
+ return bound;
3153
+ };
3154
+ }
3155
+ var call = Function.prototype.call;
3156
+ var prototypeOfArray = Array.prototype;
3157
+ var prototypeOfObject = Object.prototype;
3158
+ var slice = prototypeOfArray.slice;
3159
+ var _toString = call.bind(prototypeOfObject.toString);
3160
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
3161
+ var defineGetter;
3162
+ var defineSetter;
3163
+ var lookupGetter;
3164
+ var lookupSetter;
3165
+ var supportsAccessors;
3166
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
3167
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
3168
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
3169
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
3170
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
3171
+ }
3172
+ if ([1,2].splice(0).length != 2) {
3173
+ if(function() { // test IE < 9 to splice bug - see issue #138
3174
+ function makeArray(l) {
3175
+ var a = new Array(l+2);
3176
+ a[0] = a[1] = 0;
3177
+ return a;
3178
+ }
3179
+ var array = [], lengthBefore;
3180
+
3181
+ array.splice.apply(array, makeArray(20));
3182
+ array.splice.apply(array, makeArray(26));
3183
+
3184
+ lengthBefore = array.length; //46
3185
+ array.splice(5, 0, "XXX"); // add one element
3186
+
3187
+ lengthBefore + 1 == array.length
3188
+
3189
+ if (lengthBefore + 1 == array.length) {
3190
+ return true;// has right splice implementation without bugs
3191
+ }
3192
+ }()) {//IE 6/7
3193
+ var array_splice = Array.prototype.splice;
3194
+ Array.prototype.splice = function(start, deleteCount) {
3195
+ if (!arguments.length) {
3196
+ return [];
3197
+ } else {
3198
+ return array_splice.apply(this, [
3199
+ start === void 0 ? 0 : start,
3200
+ deleteCount === void 0 ? (this.length - start) : deleteCount
3201
+ ].concat(slice.call(arguments, 2)))
3202
+ }
3203
+ };
3204
+ } else {//IE8
3205
+ Array.prototype.splice = function(pos, removeCount){
3206
+ var length = this.length;
3207
+ if (pos > 0) {
3208
+ if (pos > length)
3209
+ pos = length;
3210
+ } else if (pos == void 0) {
3211
+ pos = 0;
3212
+ } else if (pos < 0) {
3213
+ pos = Math.max(length + pos, 0);
3214
+ }
3215
+
3216
+ if (!(pos+removeCount < length))
3217
+ removeCount = length - pos;
3218
+
3219
+ var removed = this.slice(pos, pos+removeCount);
3220
+ var insert = slice.call(arguments, 2);
3221
+ var add = insert.length;
3222
+ if (pos === length) {
3223
+ if (add) {
3224
+ this.push.apply(this, insert);
3225
+ }
3226
+ } else {
3227
+ var remove = Math.min(removeCount, length - pos);
3228
+ var tailOldPos = pos + remove;
3229
+ var tailNewPos = tailOldPos + add - remove;
3230
+ var tailCount = length - tailOldPos;
3231
+ var lengthAfterRemove = length - remove;
3232
+
3233
+ if (tailNewPos < tailOldPos) { // case A
3234
+ for (var i = 0; i < tailCount; ++i) {
3235
+ this[tailNewPos+i] = this[tailOldPos+i];
3236
+ }
3237
+ } else if (tailNewPos > tailOldPos) { // case B
3238
+ for (i = tailCount; i--; ) {
3239
+ this[tailNewPos+i] = this[tailOldPos+i];
3240
+ }
3241
+ } // else, add == remove (nothing to do)
3242
+
3243
+ if (add && pos === lengthAfterRemove) {
3244
+ this.length = lengthAfterRemove; // truncate array
3245
+ this.push.apply(this, insert);
3246
+ } else {
3247
+ this.length = lengthAfterRemove + add; // reserves space
3248
+ for (i = 0; i < add; ++i) {
3249
+ this[pos+i] = insert[i];
3250
+ }
3251
+ }
3252
+ }
3253
+ return removed;
3254
+ };
3255
+ }
3256
+ }
3257
+ if (!Array.isArray) {
3258
+ Array.isArray = function isArray(obj) {
3259
+ return _toString(obj) == "[object Array]";
3260
+ };
3261
+ }
3262
+ var boxedString = Object("a"),
3263
+ splitString = boxedString[0] != "a" || !(0 in boxedString);
3264
+
3265
+ if (!Array.prototype.forEach) {
3266
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
3267
+ var object = toObject(this),
3268
+ self = splitString && _toString(this) == "[object String]" ?
3269
+ this.split("") :
3270
+ object,
3271
+ thisp = arguments[1],
3272
+ i = -1,
3273
+ length = self.length >>> 0;
3274
+ if (_toString(fun) != "[object Function]") {
3275
+ throw new TypeError(); // TODO message
3276
+ }
3277
+
3278
+ while (++i < length) {
3279
+ if (i in self) {
3280
+ fun.call(thisp, self[i], i, object);
3281
+ }
3282
+ }
3283
+ };
3284
+ }
3285
+ if (!Array.prototype.map) {
3286
+ Array.prototype.map = function map(fun /*, thisp*/) {
3287
+ var object = toObject(this),
3288
+ self = splitString && _toString(this) == "[object String]" ?
3289
+ this.split("") :
3290
+ object,
3291
+ length = self.length >>> 0,
3292
+ result = Array(length),
3293
+ thisp = arguments[1];
3294
+ if (_toString(fun) != "[object Function]") {
3295
+ throw new TypeError(fun + " is not a function");
3296
+ }
3297
+
3298
+ for (var i = 0; i < length; i++) {
3299
+ if (i in self)
3300
+ result[i] = fun.call(thisp, self[i], i, object);
3301
+ }
3302
+ return result;
3303
+ };
3304
+ }
3305
+ if (!Array.prototype.filter) {
3306
+ Array.prototype.filter = function filter(fun /*, thisp */) {
3307
+ var object = toObject(this),
3308
+ self = splitString && _toString(this) == "[object String]" ?
3309
+ this.split("") :
3310
+ object,
3311
+ length = self.length >>> 0,
3312
+ result = [],
3313
+ value,
3314
+ thisp = arguments[1];
3315
+ if (_toString(fun) != "[object Function]") {
3316
+ throw new TypeError(fun + " is not a function");
3317
+ }
3318
+
3319
+ for (var i = 0; i < length; i++) {
3320
+ if (i in self) {
3321
+ value = self[i];
3322
+ if (fun.call(thisp, value, i, object)) {
3323
+ result.push(value);
3324
+ }
3325
+ }
3326
+ }
3327
+ return result;
3328
+ };
3329
+ }
3330
+ if (!Array.prototype.every) {
3331
+ Array.prototype.every = function every(fun /*, thisp */) {
3332
+ var object = toObject(this),
3333
+ self = splitString && _toString(this) == "[object String]" ?
3334
+ this.split("") :
3335
+ object,
3336
+ length = self.length >>> 0,
3337
+ thisp = arguments[1];
3338
+ if (_toString(fun) != "[object Function]") {
3339
+ throw new TypeError(fun + " is not a function");
3340
+ }
3341
+
3342
+ for (var i = 0; i < length; i++) {
3343
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
3344
+ return false;
3345
+ }
3346
+ }
3347
+ return true;
3348
+ };
3349
+ }
3350
+ if (!Array.prototype.some) {
3351
+ Array.prototype.some = function some(fun /*, thisp */) {
3352
+ var object = toObject(this),
3353
+ self = splitString && _toString(this) == "[object String]" ?
3354
+ this.split("") :
3355
+ object,
3356
+ length = self.length >>> 0,
3357
+ thisp = arguments[1];
3358
+ if (_toString(fun) != "[object Function]") {
3359
+ throw new TypeError(fun + " is not a function");
3360
+ }
3361
+
3362
+ for (var i = 0; i < length; i++) {
3363
+ if (i in self && fun.call(thisp, self[i], i, object)) {
3364
+ return true;
3365
+ }
3366
+ }
3367
+ return false;
3368
+ };
3369
+ }
3370
+ if (!Array.prototype.reduce) {
3371
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
3372
+ var object = toObject(this),
3373
+ self = splitString && _toString(this) == "[object String]" ?
3374
+ this.split("") :
3375
+ object,
3376
+ length = self.length >>> 0;
3377
+ if (_toString(fun) != "[object Function]") {
3378
+ throw new TypeError(fun + " is not a function");
3379
+ }
3380
+ if (!length && arguments.length == 1) {
3381
+ throw new TypeError("reduce of empty array with no initial value");
3382
+ }
3383
+
3384
+ var i = 0;
3385
+ var result;
3386
+ if (arguments.length >= 2) {
3387
+ result = arguments[1];
3388
+ } else {
3389
+ do {
3390
+ if (i in self) {
3391
+ result = self[i++];
3392
+ break;
3393
+ }
3394
+ if (++i >= length) {
3395
+ throw new TypeError("reduce of empty array with no initial value");
3396
+ }
3397
+ } while (true);
3398
+ }
3399
+
3400
+ for (; i < length; i++) {
3401
+ if (i in self) {
3402
+ result = fun.call(void 0, result, self[i], i, object);
3403
+ }
3404
+ }
3405
+
3406
+ return result;
3407
+ };
3408
+ }
3409
+ if (!Array.prototype.reduceRight) {
3410
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
3411
+ var object = toObject(this),
3412
+ self = splitString && _toString(this) == "[object String]" ?
3413
+ this.split("") :
3414
+ object,
3415
+ length = self.length >>> 0;
3416
+ if (_toString(fun) != "[object Function]") {
3417
+ throw new TypeError(fun + " is not a function");
3418
+ }
3419
+ if (!length && arguments.length == 1) {
3420
+ throw new TypeError("reduceRight of empty array with no initial value");
3421
+ }
3422
+
3423
+ var result, i = length - 1;
3424
+ if (arguments.length >= 2) {
3425
+ result = arguments[1];
3426
+ } else {
3427
+ do {
3428
+ if (i in self) {
3429
+ result = self[i--];
3430
+ break;
3431
+ }
3432
+ if (--i < 0) {
3433
+ throw new TypeError("reduceRight of empty array with no initial value");
3434
+ }
3435
+ } while (true);
3436
+ }
3437
+
3438
+ do {
3439
+ if (i in this) {
3440
+ result = fun.call(void 0, result, self[i], i, object);
3441
+ }
3442
+ } while (i--);
3443
+
3444
+ return result;
3445
+ };
3446
+ }
3447
+ if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
3448
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
3449
+ var self = splitString && _toString(this) == "[object String]" ?
3450
+ this.split("") :
3451
+ toObject(this),
3452
+ length = self.length >>> 0;
3453
+
3454
+ if (!length) {
3455
+ return -1;
3456
+ }
3457
+
3458
+ var i = 0;
3459
+ if (arguments.length > 1) {
3460
+ i = toInteger(arguments[1]);
3461
+ }
3462
+ i = i >= 0 ? i : Math.max(0, length + i);
3463
+ for (; i < length; i++) {
3464
+ if (i in self && self[i] === sought) {
3465
+ return i;
3466
+ }
3467
+ }
3468
+ return -1;
3469
+ };
3470
+ }
3471
+ if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
3472
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
3473
+ var self = splitString && _toString(this) == "[object String]" ?
3474
+ this.split("") :
3475
+ toObject(this),
3476
+ length = self.length >>> 0;
3477
+
3478
+ if (!length) {
3479
+ return -1;
3480
+ }
3481
+ var i = length - 1;
3482
+ if (arguments.length > 1) {
3483
+ i = Math.min(i, toInteger(arguments[1]));
3484
+ }
3485
+ i = i >= 0 ? i : length - Math.abs(i);
3486
+ for (; i >= 0; i--) {
3487
+ if (i in self && sought === self[i]) {
3488
+ return i;
3489
+ }
3490
+ }
3491
+ return -1;
3492
+ };
3493
+ }
3494
+ if (!Object.getPrototypeOf) {
3495
+ Object.getPrototypeOf = function getPrototypeOf(object) {
3496
+ return object.__proto__ || (
3497
+ object.constructor ?
3498
+ object.constructor.prototype :
3499
+ prototypeOfObject
3500
+ );
3501
+ };
3502
+ }
3503
+ if (!Object.getOwnPropertyDescriptor) {
3504
+ var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
3505
+ "non-object: ";
3506
+ Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
3507
+ if ((typeof object != "object" && typeof object != "function") || object === null)
3508
+ throw new TypeError(ERR_NON_OBJECT + object);
3509
+ if (!owns(object, property))
3510
+ return;
3511
+
3512
+ var descriptor, getter, setter;
3513
+ descriptor = { enumerable: true, configurable: true };
3514
+ if (supportsAccessors) {
3515
+ var prototype = object.__proto__;
3516
+ object.__proto__ = prototypeOfObject;
3517
+
3518
+ var getter = lookupGetter(object, property);
3519
+ var setter = lookupSetter(object, property);
3520
+ object.__proto__ = prototype;
3521
+
3522
+ if (getter || setter) {
3523
+ if (getter) descriptor.get = getter;
3524
+ if (setter) descriptor.set = setter;
3525
+ return descriptor;
3526
+ }
3527
+ }
3528
+ descriptor.value = object[property];
3529
+ return descriptor;
3530
+ };
3531
+ }
3532
+ if (!Object.getOwnPropertyNames) {
3533
+ Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
3534
+ return Object.keys(object);
3535
+ };
3536
+ }
3537
+ if (!Object.create) {
3538
+ var createEmpty;
3539
+ if (Object.prototype.__proto__ === null) {
3540
+ createEmpty = function () {
3541
+ return { "__proto__": null };
3542
+ };
3543
+ } else {
3544
+ createEmpty = function () {
3545
+ var empty = {};
3546
+ for (var i in empty)
3547
+ empty[i] = null;
3548
+ empty.constructor =
3549
+ empty.hasOwnProperty =
3550
+ empty.propertyIsEnumerable =
3551
+ empty.isPrototypeOf =
3552
+ empty.toLocaleString =
3553
+ empty.toString =
3554
+ empty.valueOf =
3555
+ empty.__proto__ = null;
3556
+ return empty;
3557
+ }
3558
+ }
3559
+
3560
+ Object.create = function create(prototype, properties) {
3561
+ var object;
3562
+ if (prototype === null) {
3563
+ object = createEmpty();
3564
+ } else {
3565
+ if (typeof prototype != "object")
3566
+ throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
3567
+ var Type = function () {};
3568
+ Type.prototype = prototype;
3569
+ object = new Type();
3570
+ object.__proto__ = prototype;
3571
+ }
3572
+ if (properties !== void 0)
3573
+ Object.defineProperties(object, properties);
3574
+ return object;
3575
+ };
3576
+ }
3577
+
3578
+ function doesDefinePropertyWork(object) {
3579
+ try {
3580
+ Object.defineProperty(object, "sentinel", {});
3581
+ return "sentinel" in object;
3582
+ } catch (exception) {
3583
+ }
3584
+ }
3585
+ if (Object.defineProperty) {
3586
+ var definePropertyWorksOnObject = doesDefinePropertyWork({});
3587
+ var definePropertyWorksOnDom = typeof document == "undefined" ||
3588
+ doesDefinePropertyWork(document.createElement("div"));
3589
+ if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
3590
+ var definePropertyFallback = Object.defineProperty;
3591
+ }
3592
+ }
3593
+
3594
+ if (!Object.defineProperty || definePropertyFallback) {
3595
+ var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
3596
+ var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
3597
+ var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
3598
+ "on this javascript engine";
3599
+
3600
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
3601
+ if ((typeof object != "object" && typeof object != "function") || object === null)
3602
+ throw new TypeError(ERR_NON_OBJECT_TARGET + object);
3603
+ if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
3604
+ throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
3605
+ if (definePropertyFallback) {
3606
+ try {
3607
+ return definePropertyFallback.call(Object, object, property, descriptor);
3608
+ } catch (exception) {
3609
+ }
3610
+ }
3611
+ if (owns(descriptor, "value")) {
3612
+
3613
+ if (supportsAccessors && (lookupGetter(object, property) ||
3614
+ lookupSetter(object, property)))
3615
+ {
3616
+ var prototype = object.__proto__;
3617
+ object.__proto__ = prototypeOfObject;
3618
+ delete object[property];
3619
+ object[property] = descriptor.value;
3620
+ object.__proto__ = prototype;
3621
+ } else {
3622
+ object[property] = descriptor.value;
3623
+ }
3624
+ } else {
3625
+ if (!supportsAccessors)
3626
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
3627
+ if (owns(descriptor, "get"))
3628
+ defineGetter(object, property, descriptor.get);
3629
+ if (owns(descriptor, "set"))
3630
+ defineSetter(object, property, descriptor.set);
3631
+ }
3632
+
3633
+ return object;
3634
+ };
3635
+ }
3636
+ if (!Object.defineProperties) {
3637
+ Object.defineProperties = function defineProperties(object, properties) {
3638
+ for (var property in properties) {
3639
+ if (owns(properties, property))
3640
+ Object.defineProperty(object, property, properties[property]);
3641
+ }
3642
+ return object;
3643
+ };
3644
+ }
3645
+ if (!Object.seal) {
3646
+ Object.seal = function seal(object) {
3647
+ return object;
3648
+ };
3649
+ }
3650
+ if (!Object.freeze) {
3651
+ Object.freeze = function freeze(object) {
3652
+ return object;
3653
+ };
3654
+ }
3655
+ try {
3656
+ Object.freeze(function () {});
3657
+ } catch (exception) {
3658
+ Object.freeze = (function freeze(freezeObject) {
3659
+ return function freeze(object) {
3660
+ if (typeof object == "function") {
3661
+ return object;
3662
+ } else {
3663
+ return freezeObject(object);
3664
+ }
3665
+ };
3666
+ })(Object.freeze);
3667
+ }
3668
+ if (!Object.preventExtensions) {
3669
+ Object.preventExtensions = function preventExtensions(object) {
3670
+ return object;
3671
+ };
3672
+ }
3673
+ if (!Object.isSealed) {
3674
+ Object.isSealed = function isSealed(object) {
3675
+ return false;
3676
+ };
3677
+ }
3678
+ if (!Object.isFrozen) {
3679
+ Object.isFrozen = function isFrozen(object) {
3680
+ return false;
3681
+ };
3682
+ }
3683
+ if (!Object.isExtensible) {
3684
+ Object.isExtensible = function isExtensible(object) {
3685
+ if (Object(object) === object) {
3686
+ throw new TypeError(); // TODO message
3687
+ }
3688
+ var name = '';
3689
+ while (owns(object, name)) {
3690
+ name += '?';
3691
+ }
3692
+ object[name] = true;
3693
+ var returnValue = owns(object, name);
3694
+ delete object[name];
3695
+ return returnValue;
3696
+ };
3697
+ }
3698
+ if (!Object.keys) {
3699
+ var hasDontEnumBug = true,
3700
+ dontEnums = [
3701
+ "toString",
3702
+ "toLocaleString",
3703
+ "valueOf",
3704
+ "hasOwnProperty",
3705
+ "isPrototypeOf",
3706
+ "propertyIsEnumerable",
3707
+ "constructor"
3708
+ ],
3709
+ dontEnumsLength = dontEnums.length;
3710
+
3711
+ for (var key in {"toString": null}) {
3712
+ hasDontEnumBug = false;
3713
+ }
3714
+
3715
+ Object.keys = function keys(object) {
3716
+
3717
+ if (
3718
+ (typeof object != "object" && typeof object != "function") ||
3719
+ object === null
3720
+ ) {
3721
+ throw new TypeError("Object.keys called on a non-object");
3722
+ }
3723
+
3724
+ var keys = [];
3725
+ for (var name in object) {
3726
+ if (owns(object, name)) {
3727
+ keys.push(name);
3728
+ }
3729
+ }
3730
+
3731
+ if (hasDontEnumBug) {
3732
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
3733
+ var dontEnum = dontEnums[i];
3734
+ if (owns(object, dontEnum)) {
3735
+ keys.push(dontEnum);
3736
+ }
3737
+ }
3738
+ }
3739
+ return keys;
3740
+ };
3741
+
3742
+ }
3743
+ if (!Date.now) {
3744
+ Date.now = function now() {
3745
+ return new Date().getTime();
3746
+ };
3747
+ }
3748
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
3749
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
3750
+ "\u2029\uFEFF";
3751
+ if (!String.prototype.trim || ws.trim()) {
3752
+ ws = "[" + ws + "]";
3753
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
3754
+ trimEndRegexp = new RegExp(ws + ws + "*$");
3755
+ String.prototype.trim = function trim() {
3756
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
3757
+ };
3758
+ }
3759
+
3760
+ function toInteger(n) {
3761
+ n = +n;
3762
+ if (n !== n) { // isNaN
3763
+ n = 0;
3764
+ } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
3765
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
3766
+ }
3767
+ return n;
3768
+ }
3769
+
3770
+ function isPrimitive(input) {
3771
+ var type = typeof input;
3772
+ return (
3773
+ input === null ||
3774
+ type === "undefined" ||
3775
+ type === "boolean" ||
3776
+ type === "number" ||
3777
+ type === "string"
3778
+ );
3779
+ }
3780
+
3781
+ function toPrimitive(input) {
3782
+ var val, valueOf, toString;
3783
+ if (isPrimitive(input)) {
3784
+ return input;
3785
+ }
3786
+ valueOf = input.valueOf;
3787
+ if (typeof valueOf === "function") {
3788
+ val = valueOf.call(input);
3789
+ if (isPrimitive(val)) {
3790
+ return val;
3791
+ }
3792
+ }
3793
+ toString = input.toString;
3794
+ if (typeof toString === "function") {
3795
+ val = toString.call(input);
3796
+ if (isPrimitive(val)) {
3797
+ return val;
3798
+ }
3799
+ }
3800
+ throw new TypeError();
3801
+ }
3802
+ var toObject = function (o) {
3803
+ if (o == null) { // this matches both null and undefined
3804
+ throw new TypeError("can't convert "+o+" to object");
3805
+ }
3806
+ return Object(o);
3807
+ };
3808
+
3809
+ });