Created
October 31, 2012 03:37
-
-
Save passcod/3984651 to your computer and use it in GitHub Desktop.
woot color2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Source: */ | |
String.prototype.color2 = function(fg,bg) { | |
var conv = function(thing, _default) { | |
if (+thing < 16 && +thing > -1) { return +thing; } | |
thing = "white black blue green red brown purple orange yellow lime teal cyan royal pink grey silver".split(" ").indexOf(thing); | |
if (thing != -1) { return thing; } | |
return _default; | |
}; | |
fg = conv(fg, 2); | |
bg = conv(bg, ""); | |
bg = bg && ","+bg; | |
return "\x03" + fg + bg + this + "\x0F"; | |
}; | |
/* Minified: */ | |
String.prototype.color2=function(d,b){function c(a,b){if(16>+a&&-1<+a)return+a;a="white black blue green red brown purple orange yellow lime teal cyan royal pink grey silver".split(" ").indexOf(a);return-1!=a?a:b}b=c(b,"");return"\x03"+c(d,2)+(b&&","+b)+this+"\x0f"}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment