forked from tholman/console-dot-frog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.unicorn.js
100 lines (91 loc) · 2.59 KB
/
console.unicorn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Console.frog. A better way to log!
* - Logs a frog, saying your log... Yep!
*
* MIT licensed
* Copyright (C) 2016 Tim Holman, http://tholman.com
*/
(function dothething() {
// Act on either the window.console, or the normal console.
var con = console;
if (typeof(window) !== 'undefined') {
con = window.console;
}
con.unicorn = function() {
var i,
css = "color: #FF69B4";
// Should be enough to make this fine in node.
var inBrowser = (typeof window !== 'undefined');
// This looks like a frog, right?
// Taken from here - http://chris.com/ascii/index.php?art=animals/frogs
var frog;
if( inBrowser ) {
frog = ['%c%c',
'%c . %c',
'%c /\' %c',
'%c // %c',
'%c . // %c',
'%c |\\//7 %c',
'%c /\' \" \\ %c',
'%c . . . %c',
'%c | ( \\ \'._ %c',
'%c | \'._ \' \'. \' %c',
'%c / \\\'-\'____. ) ) %c',
'%c . :.\' %c',
'%c | \\ %c',
'%c | . . . . %c',
'%c \' . | | | %c',
'%c \\^ /_-\': / %c',
'%c / | | \'\\ .\\\' %c',
'%c / /| | \\\\ | %c',
'%c \\ \\( ) // / %c',
'%c \\ | | // / %c',
'%c \\! ! // / %c',
'%c [_] /[_| %c',
'%c%c'];
} else {
frog = ['',
' .',
' /\'',
' //',
' . //',
' |\\//7',
' /\' \" \\',
' . . .',
' | ( \\ \'._',
' | \'._ \' \'. ',
' / \'-\'____. ) )',
' . :.\'',
' | \\',
' | . . . .',
' \' . | | |',
' \\^ /_-\': /',
' / | | \'\ .',
' / /| | \\ |',
' \\ \\( ) // /',
' \\ | | // /',
' \\! ! // /',
' [_] /[_|',
''];
}
// Gets args as a string
var args = Array.prototype.slice.call(arguments);
var stringOfArgs = args.join(' ');
// Add the bubble if there is something to log!
if( stringOfArgs.length > 0 ) {
frog[5] = frog[5] + " ---" + ("-".repeat(stringOfArgs.length)) + "-";
frog[6] = frog[6] + " ----( " + stringOfArgs + " )";
frog[7] = frog[7] + " | ---" + ("-".repeat(stringOfArgs.length)) + "-";
}
// Log the frog!
if( inBrowser ) {
for( i = 0; i < frog.length; i++ ) {
console.log(frog[i], css, "");
}
} else {
for( i = 0; i < frog.length; i++ ) {
console.log(frog[i]);
}
}
}
})();