From 9105e99fbe3ef919f2d13da97771881923018be4 Mon Sep 17 00:00:00 2001 From: whitefire0 Date: Mon, 12 Mar 2018 19:12:33 +0000 Subject: [PATCH] commit to suggest change to HTML-like style tags --- log.js | 67 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/log.js b/log.js index 589f2d0..4e0afa8 100644 --- a/log.js +++ b/log.js @@ -1,5 +1,19 @@ (function() { - var exportedLog, ffSupport, formats, getOrderedMatches, hasMatches, isFF, isIE, isOpera, isSafari, log, makeArray, operaSupport, safariSupport, stringToArgs, _log; + var exportedLog, + ffSupport, + formats, + getOrderedMatches, + hasMatches, + isFF, + isIE, + isOpera, + isSafari, + log, + makeArray, + operaSupport, + safariSupport, + stringToArgs, + _log; if (!(window.console && window.console.log)) { return; @@ -10,7 +24,7 @@ args = []; makeArray(arguments).forEach(function(arg) { if (typeof arg === 'string') { - return args = args.concat(stringToArgs(arg)); + return (args = args.concat(stringToArgs(arg))); } else { return args.push(arg); } @@ -19,7 +33,11 @@ }; _log = function() { - return Function.prototype.apply.call(console.log, console, makeArray(arguments)); + return Function.prototype.apply.call( + console.log, + console, + makeArray(arguments) + ); }; makeArray = function(arrayLikeThing) { @@ -30,31 +48,37 @@ { regex: /\*([^\*]+)\*/, replacer: function(m, p1) { - return "%c" + p1 + "%c"; + return '%c' + p1 + '%c'; }, styles: function() { return ['font-style: italic', '']; } - }, { + }, + { regex: /\_([^\_]+)\_/, replacer: function(m, p1) { - return "%c" + p1 + "%c"; + return '%c' + p1 + '%c'; }, styles: function() { return ['font-weight: bold', '']; } - }, { + }, + { regex: /\`([^\`]+)\`/, replacer: function(m, p1) { - return "%c" + p1 + "%c"; + return '%c' + p1 + '%c'; }, styles: function() { - return ['background: rgb(255, 255, 219); padding: 1px 5px; border: 1px solid rgba(0, 0, 0, 0.1)', '']; + return [ + 'background: rgb(255, 255, 219); padding: 1px 5px; border: 1px solid rgba(0, 0, 0, 0.1)', + '' + ]; } - }, { - regex: /\[c\=(?:\"|\')?((?:(?!(?:\"|\')\]).)*)(?:\"|\')?\]((?:(?!\[c\]).)*)\[c\]/, + }, + { + regex: /).)*)(?:\"|\')?>((?:(?!<\/style>).)*)<\/style>/, replacer: function(m, p1, p2) { - return "%c" + p2 + "%c"; + return '%c' + p2 + '%c'; }, styles: function(match) { return [match[1], '']; @@ -67,7 +91,7 @@ _hasMatches = false; formats.forEach(function(format) { if (format.regex.test(str)) { - return _hasMatches = true; + return (_hasMatches = true); } }); return _hasMatches; @@ -104,7 +128,10 @@ }; isSafari = function() { - return /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor); + return ( + /Safari/.test(navigator.userAgent) && + /Apple Computer/.test(navigator.vendor) + ); }; isOpera = function() { @@ -125,7 +152,7 @@ if (!m) { return false; } - return 537.38 <= parseInt(m[1], 10) + (parseInt(m[2], 10) / 100); + return 537.38 <= parseInt(m[1], 10) + parseInt(m[2], 10) / 100; }; operaSupport = function() { @@ -141,7 +168,12 @@ return window.console.firebug || window.console.exception; }; - if (isIE() || (isFF() && !ffSupport()) || (isOpera() && !operaSupport()) || (isSafari() && !safariSupport())) { + if ( + isIE() || + (isFF() && !ffSupport()) || + (isOpera() && !operaSupport()) || + (isSafari() && !safariSupport()) + ) { exportedLog = _log; } else { exportedLog = log; @@ -158,5 +190,4 @@ } else { window.log = exportedLog; } - -}).call(this); +}.call(this));