From aa9d84c21bb9b8c7cc4e74663eec1090190624a7 Mon Sep 17 00:00:00 2001 From: Damian Jones Date: Mon, 15 Apr 2019 22:40:26 +0100 Subject: [PATCH 1/2] Added buy sell convenience optios --- views/market_view.html | 75 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/views/market_view.html b/views/market_view.html index 789011e..149677e 100644 --- a/views/market_view.html +++ b/views/market_view.html @@ -45,6 +45,19 @@

Buy <%= data.token %>

+
+
+
+ +
+ + + + +
+
+
+
@@ -100,6 +113,19 @@

Sell <%= data.token %>

+
+
+
+ +
+ + + + +
+
+
+
@@ -177,8 +203,55 @@

Trade History

function UpdateBuyOrderTotal() { return UpdateOrderTotal('buy') } function UpdateSellOrderTotal() { return UpdateOrderTotal('sell') } + function UpdateQuantity(type, rate) { + var quanity = type === 'buy' ? data.buy_orders[0].quantity : data.sell_orders[0].quantity; + var currentQuantity = parseFloat(quanity); + var newQuantity = currentQuantity * rate; + + $('#' + type + 'Quantity').val(newQuantity.toFixed(data.precision)); + } + + function GetBestPrice(type) { + if (type === 'buy') { + return data.buy_orders[0] && data.buy_orders[0].price || 0; + } + + if (type === 'sell') { + return data.sell_orders[0] && data.sell_orders[0].price || 0; + } + } + + function GetQuantity(type) { + if (type === 'buy') { + return data.buy_orders[0] && data.buy_orders[0].quantity || 0; + } + + if (type === 'sell') { + return data.sell_orders[0] && data.sell_orders[0].quantity || 0; + } + } + console.log(data); + $('#buyPrice').val(() => GetBestPrice('buy')); + $('#buyQuantity').val(() => GetQuantity('buy')); + UpdateBuyOrderTotal(); + + $('#sellPrice').val(() => GetBestPrice('sell')); + $('#sellQuantity').val(() => GetQuantity('sell')); + UpdateSellOrderTotal(); + + $('#buyQty25Percent').on('click', () => UpdateQuantity('buy', 0.25)); + $('#buyQty50Percent').on('click', () => UpdateQuantity('buy', 0.5)); + $('#buyQty75Percent').on('click', () => UpdateQuantity('buy', 0.75)); + $('#buyQty100Percent').on('click', () => UpdateQuantity('buy', 1)); + + $('#sellQty25Percent').on('click', () => UpdateQuantity('sell', 0.25)); + $('#sellQty50Percent').on('click', () => UpdateQuantity('sell', 0.5)); + $('#sellQty75Percent').on('click', () => UpdateQuantity('sell', 0.75)); + $('#sellQty100Percent').on('click', () => UpdateQuantity('sell', 1)); + + $('#buyPrice').on('input', UpdateBuyOrderTotal); $('#buyQuantity').on('input', UpdateBuyOrderTotal); @@ -390,4 +463,4 @@

Trade History

SE.ShowMarketCancelDialog(type, orderId); } - \ No newline at end of file + From 9ca17d695221c3f353ef829b41b5ccf97f89b418 Mon Sep 17 00:00:00 2001 From: Damian Jones Date: Mon, 15 Apr 2019 22:45:50 +0100 Subject: [PATCH 2/2] Fixed margin bottom on buy side buttons --- views/market_view.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/market_view.html b/views/market_view.html index 149677e..9b58cd2 100644 --- a/views/market_view.html +++ b/views/market_view.html @@ -114,7 +114,7 @@

Sell <%= data.token %>

-
+