Skip to content

Commit e7e875b

Browse files
committed
cleaned up the .js files a bit
1 parent e11a0b1 commit e7e875b

File tree

3 files changed

+15
-58
lines changed

3 files changed

+15
-58
lines changed

consolelog.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Prefixes and postfixes can either be strings or functions that
1313
* return strings.
1414
*
15-
* See documentation for more info.
15+
* See documentation in README for more info.
1616
*
1717
* by Chad Etzel - December 11, 2009
1818
*
@@ -100,6 +100,10 @@ var setErrorColor = function(color) {
100100
setColor("error", color);
101101
};
102102

103+
var setDodad = function(type, dodad) {
104+
dodads[type] = dodad;
105+
};
106+
103107
var setLogPrefix = function(prefix) {
104108
setDodad("standard_prefix", prefix);
105109
};
@@ -146,10 +150,6 @@ var setAllPostfix = function(postfix) {
146150
setErrorPostfix(postfix);
147151
};
148152

149-
var setDodad = function(type, dodad) {
150-
dodads[type] = dodad;
151-
};
152-
153153
var restoreDefaultColors = function() {
154154
setLogColor(logColorsDefaults.standard);
155155
setInfoColor(logColorsDefaults.info);
@@ -194,15 +194,15 @@ var dolog = function(type, msg, color, bg, attr) {
194194
tc.terminalSetFontAttr(tc.attrs.RESET);
195195
tc.terminalSetFont(color, bg, attr);
196196
var prefix, postfix;
197-
if (typeof dodads[type + "_prefix"] == "string") {
198-
prefix = dodads[type + "_prefix"];
199-
} else {
197+
if (typeof dodads[type + "_prefix"] == "function") {
200198
prefix = dodads[type + "_prefix"]();
201-
}
202-
if (typeof dodads[type + "_postfix"] == "string") {
203-
postfix = dodads[type + "_postfix"];
204199
} else {
200+
prefix = dodads[type + "_prefix"];
201+
}
202+
if (typeof dodads[type + "_postfix"] == "function") {
205203
postfix = dodads[type + "_postfix"]();
204+
} else {
205+
postfix = dodads[type + "_postfix"];
206206
}
207207

208208
sys.puts(prefix + msg + postfix);
@@ -225,11 +225,6 @@ var error = function(msg) {
225225
dolog("error", msg, logColors.error, tc.colors.RESET, logAttrs.error);
226226
};
227227

228-
/*
229-
var puts = function(msg) {
230-
log(msg);
231-
}
232-
*/
233228
var puts = log;
234229

235230
var test = function() {

example.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ cl.log("8 + 8 = " + (8 + 8));
3232
cl.puts('consolelog.puts is aliased to log for convenience');
3333
cl.info("node.js is nifty");
3434

35+
cl.setLogPrefix("log: ");
36+
cl.log("this message has a new prefix string");
3537

3638
cl.setAllPrefix(function() {
3739
var d = Date.now();

termcolors.js

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* I am not an expert in all terminal emulation flavors. I just ported this
77
* from my C and PHP termcolor libraries which work the same way.
88
*
9-
* See documentation for more info.
9+
* See documentation in README for more info.
1010
*
1111
* by Chad Etzel - December 11, 2009
1212
*
@@ -145,50 +145,10 @@ var test = function(reset) {
145145
};
146146

147147
/*
148-
resetTerminal();
149-
sys.puts("\033[34;22;49m# !\033[39;0;49m ");
150-
sys.puts("normal");
151-
sys.puts("\033[36m@@@@");
152-
sys.puts("\033[0m@@@@@");
153-
sys.puts("\033[47m@@ee@@");
154-
sys.puts("");
155-
terminalFontReset();
156-
terminalSetFont(colors.YELLOW, colors.RED, attrs.DEFAULT);
157-
//terminalSetFontColor(colors.YELLOW);
158-
//terminalSetFontBG(colors.RED);
159-
sys.puts("HELLO!!!!!");
160-
sys.puts("");
161-
terminalFontReset();
162-
terminalSetFont(colors.YELLOW, colors.RED, attrs.BRIGHT);
163-
sys.puts("HELLO!!!!!");
164-
sys.puts("");
165-
terminalFontReset();
166-
terminalSetFont(colors.YELLOW, colors.RED, attrs.DIM);
167-
sys.puts("HELLO!!!!!");
168-
sys.puts("");
169-
terminalFontReset();
170-
terminalSetFont(colors.YELLOW, colors.RED, attrs.UNDERLINE);
171-
sys.puts("HELLO!!!!!");
172-
sys.puts("");
173-
terminalFontReset();
174-
terminalSetFont(colors.YELLOW, colors.RED, attrs.BLINK);
175-
sys.puts("HELLO!!!!!");
176-
sys.puts("");
177-
terminalFontReset();
178-
terminalSetFont(colors.YELLOW, colors.RED, attrs.REVERSE);
179-
sys.puts("HELLO!!!!!");
180-
sys.puts("");
181-
terminalFontReset();
182-
terminalSetFont(colors.YELLOW, colors.RED, attrs.HIDDEN);
183-
sys.puts("HELLO!!!!!");
184-
sys.puts("");
185-
terminalFontReset();
148+
test();
186149
*/
187150

188151

189-
//test();
190-
191-
192152

193153
/* exports */
194154

0 commit comments

Comments
 (0)