Show More
@@ -61,7 +61,7 b' define([' | |||||
61 | * matched. Fixes browser bugs compared to the native |
|
61 | * matched. Fixes browser bugs compared to the native | |
62 | * `String.prototype.split` and can be used reliably cross-browser. |
|
62 | * `String.prototype.split` and can be used reliably cross-browser. | |
63 | * @param {String} str String to split. |
|
63 | * @param {String} str String to split. | |
64 |
* @param {RegExp |
|
64 | * @param {RegExp} separator Regex to use for separating | |
65 | * the string. |
|
65 | * the string. | |
66 | * @param {Number} [limit] Maximum number of items to include in the result |
|
66 | * @param {Number} [limit] Maximum number of items to include in the result | |
67 | * array. |
|
67 | * array. | |
@@ -81,20 +81,15 b' define([' | |||||
81 | * // -> ['..', 'word', '1', ' ', 'word', '2', '..'] |
|
81 | * // -> ['..', 'word', '1', ' ', 'word', '2', '..'] | |
82 | */ |
|
82 | */ | |
83 | var regex_split = function (str, separator, limit) { |
|
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 | var output = [], |
|
84 | var output = [], | |
89 | flags = (separator.ignoreCase ? "i" : "") + |
|
85 | flags = (separator.ignoreCase ? "i" : "") + | |
90 | (separator.multiline ? "m" : "") + |
|
86 | (separator.multiline ? "m" : "") + | |
91 | (separator.extended ? "x" : "") + // Proposed for ES6 |
|
87 | (separator.extended ? "x" : "") + // Proposed for ES6 | |
92 | (separator.sticky ? "y" : ""), // Firefox 3+ |
|
88 | (separator.sticky ? "y" : ""), // Firefox 3+ | |
93 | lastLastIndex = 0, |
|
89 | lastLastIndex = 0, | |
94 | // Make `global` and avoid `lastIndex` issues by working with a copy |
|
|||
95 | separator = new RegExp(separator.source, flags + "g"), |
|
|||
96 | separator2, match, lastIndex, lastLength; |
|
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 | var compliantExecNpcg = typeof(/()??/.exec("")[1]) === "undefined"; |
|
94 | var compliantExecNpcg = typeof(/()??/.exec("")[1]) === "undefined"; | |
100 | if (!compliantExecNpcg) { |
|
95 | if (!compliantExecNpcg) { | |
@@ -111,7 +106,7 b' define([' | |||||
111 | limit = typeof(limit) === "undefined" ? |
|
106 | limit = typeof(limit) === "undefined" ? | |
112 | -1 >>> 0 : // Math.pow(2, 32) - 1 |
|
107 | -1 >>> 0 : // Math.pow(2, 32) - 1 | |
113 | limit >>> 0; // ToUint32(limit) |
|
108 | limit >>> 0; // ToUint32(limit) | |
114 |
|
|
109 | for (match = separator.exec(str); match; match = separator.exec(str)) { | |
115 | // `separator.lastIndex` is not reliable cross-browser |
|
110 | // `separator.lastIndex` is not reliable cross-browser | |
116 | lastIndex = match.index + match[0].length; |
|
111 | lastIndex = match.index + match[0].length; | |
117 | if (lastIndex > lastLastIndex) { |
|
112 | if (lastIndex > lastLastIndex) { | |
@@ -226,7 +221,7 b' define([' | |||||
226 | var r,g,b; |
|
221 | var r,g,b; | |
227 | if (index_or_rgb == "5") { |
|
222 | if (index_or_rgb == "5") { | |
228 | // 256 color |
|
223 | // 256 color | |
229 | var idx = parseInt(numbers.shift()); |
|
224 | var idx = parseInt(numbers.shift(), 10); | |
230 | if (idx < 16) { |
|
225 | if (idx < 16) { | |
231 | // indexed ANSI |
|
226 | // indexed ANSI | |
232 | // ignore bright / non-bright distinction |
|
227 | // ignore bright / non-bright distinction | |
@@ -310,10 +305,9 b' define([' | |||||
310 | } |
|
305 | } | |
311 |
|
306 | |||
312 | var span = "<span "; |
|
307 | var span = "<span "; | |
313 | for (var attr in attrs) { |
|
308 | Object.keys(attrs).map(function (attr) { | |
314 | var value = attrs[attr]; |
|
|||
315 | span = span + " " + attr + '="' + attrs[attr] + '"'; |
|
309 | span = span + " " + attr + '="' + attrs[attr] + '"'; | |
316 | } |
|
310 | }); | |
317 | return span + ">"; |
|
311 | return span + ">"; | |
318 | } |
|
312 | } | |
319 | }); |
|
313 | }); | |
@@ -324,11 +318,6 b' define([' | |||||
324 | // are set in the css file. |
|
318 | // are set in the css file. | |
325 | function fixConsole(txt) { |
|
319 | function fixConsole(txt) { | |
326 | txt = xmlencode(txt); |
|
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 | // Strip all ANSI codes that are not color related. Matches |
|
322 | // Strip all ANSI codes that are not color related. Matches | |
334 | // all ANSI codes that do not end with "m". |
|
323 | // all ANSI codes that do not end with "m". | |
@@ -363,7 +352,7 b' define([' | |||||
363 | * A reasonably good way of converting between points and pixels. |
|
352 | * A reasonably good way of converting between points and pixels. | |
364 | */ |
|
353 | */ | |
365 | var test = $('<div style="display: none; width: 10000pt; padding:0; border:0;"></div>'); |
|
354 | var test = $('<div style="display: none; width: 10000pt; padding:0; border:0;"></div>'); | |
366 | $(body).append(test); |
|
355 | $('body').append(test); | |
367 | var pixel_per_point = test.width()/10000; |
|
356 | var pixel_per_point = test.width()/10000; | |
368 | test.remove(); |
|
357 | test.remove(); | |
369 | return Math.floor(points*pixel_per_point); |
|
358 | return Math.floor(points*pixel_per_point); | |
@@ -547,7 +536,7 b' define([' | |||||
547 | var get_url_param = function (name) { |
|
536 | var get_url_param = function (name) { | |
548 | // get a URL parameter. I cannot believe we actually need this. |
|
537 | // get a URL parameter. I cannot believe we actually need this. | |
549 | // Based on http://stackoverflow.com/a/25359264/938949 |
|
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 | if (match){ |
|
540 | if (match){ | |
552 | return decodeURIComponent(match[1] || ''); |
|
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 | var reject = function(message, log) { |
|
746 | var reject = function(message, log) { | |
787 | /** |
|
747 | /** | |
788 | * Creates a wrappable Promise rejection function. |
|
748 | * Creates a wrappable Promise rejection function. |
General Comments 0
You need to be logged in to leave comments.
Login now