diff options
author | lassulus <lassulus@googlemail.com> | 2013-11-07 13:41:28 +0100 |
---|---|---|
committer | lassulus <lassulus@googlemail.com> | 2013-11-07 13:41:28 +0100 |
commit | e3027c0a6d34b89a2733e27a4be2074e34182288 (patch) | |
tree | 08d841c3ee83c244fd6a4bb75879e30c102c3b6e | |
parent | f6a2242158fe17d33fbf9f292b1e930041bce1d7 (diff) | |
parent | c06a92d72b62fe95fecd67719c605d4408c44838 (diff) |
Merge branch 'master' of github.com:krebscode/painload
-rw-r--r-- | gold/bitcoinwisdom/ticker.js | 18 |
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 + '[m', + '\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; } |