-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathconsole.frog.js
More file actions
69 lines (59 loc) · 1.7 KB
/
console.frog.js
File metadata and controls
69 lines (59 loc) · 1.7 KB
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
/**
* 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.frog = function() {
var i,
css = "color: green";
// 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 ,-. ,--' o ) %c",
"%c \\(,' ' ,,-' %c",
"%c,-.\\-.__,\\\\_%c",
"%c\\(`--' `\\ %c",
'%c%c'];
} else {
frog = ['',
" _,-. ",
" ,-. ,--' o ) ",
" \\(,' ' ,,-' ",
",-.\\-.__,\\\\_",
"\\(`--' `\\ ",
''];
}
// 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[1] = frog[1] + " ---" + ("-".repeat(stringOfArgs.length)) + "-";
frog[2] = frog[2] + "-( " + stringOfArgs + " )";
frog[3] = frog[3] + " ---" + ("-".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]);
}
}
}
})();