Show More
@@ -61,7 +61,7 b' define([' | |||
|
61 | 61 | * matched. Fixes browser bugs compared to the native |
|
62 | 62 | * `String.prototype.split` and can be used reliably cross-browser. |
|
63 | 63 | * @param {String} str String to split. |
|
64 |
* @param {RegExp |
|
|
64 | * @param {RegExp} separator Regex to use for separating | |
|
65 | 65 | * the string. |
|
66 | 66 | * @param {Number} [limit] Maximum number of items to include in the result |
|
67 | 67 | * array. |
@@ -81,20 +81,15 b' define([' | |||
|
81 | 81 | * // -> ['..', 'word', '1', ' ', 'word', '2', '..'] |
|
82 | 82 | */ |
|
83 | 83 | var regex_split = function (str, separator, limit) { |
|
84 | // If `separator` is not a regex, use `split` | |
|
85 | if (Object.prototype.toString.call(separator) !== "[object RegExp]") { | |
|
86 | return split.call(str, separator, limit); | |
|
87 | } | |
|
88 | 84 | var output = [], |
|
89 | 85 | flags = (separator.ignoreCase ? "i" : "") + |
|
90 | 86 | (separator.multiline ? "m" : "") + |
|
91 | 87 | (separator.extended ? "x" : "") + // Proposed for ES6 |
|
92 | 88 | (separator.sticky ? "y" : ""), // Firefox 3+ |
|
93 | 89 | lastLastIndex = 0, |
|
94 | // Make `global` and avoid `lastIndex` issues by working with a copy | |
|
95 | separator = new RegExp(separator.source, flags + "g"), | |
|
96 | 90 | separator2, match, lastIndex, lastLength; |
|
97 | str += ""; // Type-convert | |
|
91 | // Make `global` and avoid `lastIndex` issues by working with a copy | |
|
92 | separator = new RegExp(separator.source, flags + "g"); | |
|
98 | 93 | |
|
99 | 94 | var compliantExecNpcg = typeof(/()??/.exec("")[1]) === "undefined"; |
|
100 | 95 | if (!compliantExecNpcg) { |
@@ -111,7 +106,7 b' define([' | |||
|
111 | 106 | limit = typeof(limit) === "undefined" ? |
|
112 | 107 | -1 >>> 0 : // Math.pow(2, 32) - 1 |
|
113 | 108 | limit >>> 0; // ToUint32(limit) |
|
114 |
|
|
|
109 | for (match = separator.exec(str); match; match = separator.exec(str)) { | |
|
115 | 110 | // `separator.lastIndex` is not reliable cross-browser |
|
116 | 111 | lastIndex = match.index + match[0].length; |
|
117 | 112 | if (lastIndex > lastLastIndex) { |
@@ -226,7 +221,7 b' define([' | |||
|
226 | 221 | var r,g,b; |
|
227 | 222 | if (index_or_rgb == "5") { |
|
228 | 223 | // 256 color |
|
229 | var idx = parseInt(numbers.shift()); | |
|
224 | var idx = parseInt(numbers.shift(), 10); | |
|
230 | 225 | if (idx < 16) { |
|
231 | 226 | // indexed ANSI |
|
232 | 227 | // ignore bright / non-bright distinction |
@@ -310,10 +305,9 b' define([' | |||
|
310 | 305 | } |
|
311 | 306 | |
|
312 | 307 | var span = "<span "; |
|
313 | for (var attr in attrs) { | |
|
314 | var value = attrs[attr]; | |
|
308 | Object.keys(attrs).map(function (attr) { | |
|
315 | 309 | span = span + " " + attr + '="' + attrs[attr] + '"'; |
|
316 | } | |
|
310 | }); | |
|
317 | 311 | return span + ">"; |
|
318 | 312 | } |
|
319 | 313 | }); |
@@ -324,11 +318,6 b' define([' | |||
|
324 | 318 | // are set in the css file. |
|
325 | 319 | function fixConsole(txt) { |
|
326 | 320 | txt = xmlencode(txt); |
|
327 | var re = /\033\[([\dA-Fa-f;]*?)m/; | |
|
328 | var opened = false; | |
|
329 | var cmds = []; | |
|
330 | var opener = ""; | |
|
331 | var closer = ""; | |
|
332 | 321 | |
|
333 | 322 | // Strip all ANSI codes that are not color related. Matches |
|
334 | 323 | // all ANSI codes that do not end with "m". |
@@ -363,7 +352,7 b' define([' | |||
|
363 | 352 | * A reasonably good way of converting between points and pixels. |
|
364 | 353 | */ |
|
365 | 354 | var test = $('<div style="display: none; width: 10000pt; padding:0; border:0;"></div>'); |
|
366 | $(body).append(test); | |
|
355 | $('body').append(test); | |
|
367 | 356 | var pixel_per_point = test.width()/10000; |
|
368 | 357 | test.remove(); |
|
369 | 358 | return Math.floor(points*pixel_per_point); |
@@ -547,7 +536,7 b' define([' | |||
|
547 | 536 | var get_url_param = function (name) { |
|
548 | 537 | // get a URL parameter. I cannot believe we actually need this. |
|
549 | 538 | // Based on http://stackoverflow.com/a/25359264/938949 |
|
550 |
var match = new RegExp('[ |
|
|
539 | var match = new RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search); | |
|
551 | 540 | if (match){ |
|
552 | 541 | return decodeURIComponent(match[1] || ''); |
|
553 | 542 | } |
@@ -754,35 +743,6 b' define([' | |||
|
754 | 743 | }); |
|
755 | 744 | }; |
|
756 | 745 | |
|
757 | var WrappedError = function(message, error){ | |
|
758 | /** | |
|
759 | * Wrappable Error class | |
|
760 | * | |
|
761 | * The Error class doesn't actually act on `this`. Instead it always | |
|
762 | * returns a new instance of Error. Here we capture that instance so we | |
|
763 | * can apply it's properties to `this`. | |
|
764 | */ | |
|
765 | var tmp = Error.apply(this, [message]); | |
|
766 | ||
|
767 | // Copy the properties of the error over to this. | |
|
768 | var properties = Object.getOwnPropertyNames(tmp); | |
|
769 | for (var i = 0; i < properties.length; i++) { | |
|
770 | this[properties[i]] = tmp[properties[i]]; | |
|
771 | } | |
|
772 | ||
|
773 | // Keep a stack of the original error messages. | |
|
774 | if (error instanceof WrappedError) { | |
|
775 | this.error_stack = error.error_stack; | |
|
776 | } else { | |
|
777 | this.error_stack = [error]; | |
|
778 | } | |
|
779 | this.error_stack.push(tmp); | |
|
780 | ||
|
781 | return this; | |
|
782 | }; | |
|
783 | ||
|
784 | WrappedError.prototype = Object.create(Error.prototype, {}); | |
|
785 | ||
|
786 | 746 | var reject = function(message, log) { |
|
787 | 747 | /** |
|
788 | 748 | * Creates a wrappable Promise rejection function. |
General Comments 0
You need to be logged in to leave comments.
Login now