summaryrefslogtreecommitdiffstats
path: root/gold
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2013-11-07 13:41:28 +0100
committerlassulus <lassulus@googlemail.com>2013-11-07 13:41:28 +0100
commite3027c0a6d34b89a2733e27a4be2074e34182288 (patch)
tree08d841c3ee83c244fd6a4bb75879e30c102c3b6e /gold
parentf6a2242158fe17d33fbf9f292b1e930041bce1d7 (diff)
parentc06a92d72b62fe95fecd67719c605d4408c44838 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'gold')
-rw-r--r--gold/bitcoinwisdom/ticker.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/gold/bitcoinwisdom/ticker.js b/gold/bitcoinwisdom/ticker.js
index 95861229..be60ddb8 100644
--- a/gold/bitcoinwisdom/ticker.js
+++ b/gold/bitcoinwisdom/ticker.js
@@ -45,9 +45,9 @@ function ticker_data_handler (data) {
freq = (2000 + 1000000 * diff) | 0;
var out = [
- format_date(data.now) + '+' + pad_left(lag, 2, '0'),
+ format_date(data.now) + '+' + pad(lag, -2, '0'),
'btceltcbtc',
- '[' + diff_color(diff) + 'm' + ticker.last + '',
+ '\e[' + diff_color(diff) + 'm' + pad(ticker.last, 2 + 8, '0') + '\e[m',
lag,
freq,
];
@@ -75,10 +75,18 @@ function format_date (unix) {
.replace(/\.000Z$/, 'Z')
}
-function pad_left (obj, num, char) {
+// num < 0: pad left
+// num > 0: pad right
+function pad (obj, num, char) {
var str = obj.toString();
- while (str.length < num) {
- str += char;
+ if (num < 0) {
+ while (str.length < -num) {
+ str = char + str;
+ }
+ } if (num > 0) {
+ while (str.length < num) {
+ str = str + char;
+ }
}
return str;
}