diff --git a/src/js/amount.js b/src/js/amount.js index 7614e48721..201b3af34d 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -737,7 +737,7 @@ Amount.prototype.to_text = function (allow_nan) { { return "0"; } - else if (this._offset < -25 || this._offset > -4) + else if (this._offset && (this._offset < -25 || this._offset > -4)) { // Use e notation. // XXX Clamp output. @@ -832,6 +832,27 @@ Amount.prototype.to_human = function (opts) return formatted; }; +Amount.prototype.to_human_full = function (opts) { + opts = opts || {}; + + var a = this.to_human(opts); + var c = this._currency.to_human(opts); + var i = this._issuer.to_json(); + + var o; + + if (this._is_native) + { + o = a + "/" + c; + } + else + { + o = a + "/" + c + "/" + i; + } + + return o; +}; + Amount.prototype.to_json = function () { if (this._is_native) { return this.to_text(); @@ -849,11 +870,11 @@ Amount.prototype.to_json = function () { } }; -Amount.prototype.to_text_full = function () { +Amount.prototype.to_text_full = function (opts) { return this._value instanceof BigInteger ? this._is_native ? this.to_text() + "/XRP" - : this.to_text() + "/" + this._currency.to_json() + "/" + this._issuer.to_json() + : this.to_text() + "/" + this._currency.to_json() + "/" + this._issuer.to_json(opts) : NaN; }; diff --git a/src/js/currency.js b/src/js/currency.js index 14e902159d..e4a4e305cd 100644 --- a/src/js/currency.js +++ b/src/js/currency.js @@ -79,3 +79,5 @@ Currency.prototype.to_human = function () { }; exports.Currency = Currency; + +// vim:sw=2:sts=2:ts=8:et diff --git a/src/js/uint.js b/src/js/uint.js index b989b7e847..100dfc9c80 100644 --- a/src/js/uint.js +++ b/src/js/uint.js @@ -219,3 +219,5 @@ UInt.prototype.to_bn = function () { }; exports.UInt = UInt; + +// vim:sw=2:sts=2:ts=8:et diff --git a/src/js/uint160.js b/src/js/uint160.js index b9165e34c3..12c7ff04c6 100644 --- a/src/js/uint160.js +++ b/src/js/uint160.js @@ -51,13 +51,20 @@ UInt160.prototype.parse_json = function (j) { }; // XXX Json form should allow 0 and 1, C++ doesn't currently allow it. -UInt160.prototype.to_json = function () { +UInt160.prototype.to_json = function (opts) { + opts = opts || {}; + if (!(this._value instanceof BigInteger)) return NaN; var output = Base.encode_check(Base.VER_ACCOUNT_ID, this.to_bytes()); + if (opts.gateways && output in opts.gateways) + output = opts.gateways[output]; + return output; }; exports.UInt160 = UInt160; + +// vim:sw=2:sts=2:ts=8:et