From 028ed442b436cbc22f3c1b147f5429f228934640 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 10 Jan 2011 14:59:56 -0500 Subject: [PATCH 2/2] formatBitcoin guesses BTC or TBC --- bitcoinapp.js | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/bitcoinapp.js b/bitcoinapp.js index b5b82de..ee1f992 100644 --- a/bitcoinapp.js +++ b/bitcoinapp.js @@ -514,6 +514,10 @@ function BitcoinApp() { return s; } + Number.prototype.Bitcoin2BTC = function(addSign) { + return this / 100000000.; + }; + Number.prototype.formatTBC = function(addSign) { var s = this.toString(16); s = s.replace(/9/g, "\ue9d9").replace(/a/gi, "\ue9da").replace(/b/gi, "\ue9db").replace(/c/gi, "\ue9dc").replace(/d/gi, "\ue9dd").replace(/e/gi, "\ue9de").replace(/f/gi, "\ue9df"); @@ -525,6 +529,26 @@ function BitcoinApp() { return s; } + + Number.prototype.Bitcoin2TBC = function(addSign) { + return this / 65536.; + }; + + Number.prototype.formatBitcoin = function(addSign) { + if ( ! ( this % 0x10000 ) ) + return this.Bitcoin2TBC().formatTBC(addSign); + if ( ! ( this % 1000000 ) ) + return this.Bitcoin2BTC().formatBTC(addSign); + if ( ! ( this % 0x100 ) ) + return this.Bitcoin2TBC().formatTBC(addSign); + + s = this + " uBTCents"; + + if(addSign && this > 0) + s = "+" + s; + + return s; + }; } this.serializeSettings = function(request) { -- 1.7.2.2