' + amount + '
' + datetime + '
').appendTo('.tradingOrders_ul'); $compile($el)($scope); counter++; }); } }); } $scope.exchangeOpenOrders = function() { } $scope.exchangeOrderHistory = function() { } $scope.exchangeTradeHistory = function() { } $scope.exchangeFunds = function() { } $scope.currrecyPairs = function() { $http({ headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' }, url: 'https://ns1.tradekax.com/api/v1/allTickers', method: "GET", }).success(function(r) { error_array = JSON.stringify(r); data = JSON.parse(error_array); var FavouritesCurrencyPairs = getCookie("ExchangeFavouritesCurrencyPairs"); var newcurrencyPairs = []; if (data.success == true && data.result.length > 0) { angular.forEach(data.result, function(html, key) { html.lastPrice = Number(html.lastPrice); html.volume = Number(html.volume); html.changeRate = Number(html.changeRate); html.changePrice = Number(html.changePrice); var newData = { markFavourite: (FavouritesCurrencyPairs != "" && FavouritesCurrencyPairs.length > 0 && FavouritesCurrencyPairs.indexOf(html.symbol) !== -1) ? true : false, base_currency: html.baseSymbol, base_currency_name: html.baseCurrency, icon: html.icon, secondary_currency: html.quoteSymbol, secondary_currency_name: html.quoteCurrency, updated_secondary_currency: html.quoteSymbol, symbol: html.symbol, name: html.quoteCurrency, currency_order: html.currencyOrder, secondary_currency_coin_digits: html.quotePrecision, base_currency_coin_digits: html.basePrecision, coin_digits: html.pairPrecision, price: html.lastPrice, change_price: html.changeRate, volume: html.volume }; newcurrencyPairs[key] = newData; $parse(html.quoteSymbol + html.baseSymbol + 'CurrencyPair_price').assign($scope, html.lastPrice); $parse(html.quoteSymbol + html.baseSymbol + 'CurrencyPair_change_price').assign($scope, html.changePrice); $parse(html.quoteSymbol + html.baseSymbol + 'CurrencyPair_volume').assign($scope, html.volume); $parse(html.quoteSymbol + html.baseSymbol + 'CurrencyPair_change_price_per').assign($scope, parseFloat(html.changeRate).toFixed(2)); $parse(html.quoteSymbol + html.baseSymbol + 'miniticker_volume').assign($scope, html.volume); $parse(html.quoteSymbol + html.baseSymbol + 'miniticker_low').assign($scope, html.lowPrice); $parse(html.quoteSymbol + html.baseSymbol + 'miniticker_high').assign($scope, html.highPrice); $parse(html.quoteSymbol + html.baseSymbol + 'miniticker_open_price').assign($scope, html.openPrice); $parse(html.quoteSymbol + html.baseSymbol + 'miniticker_base_precision').assign($scope, html.basePrecision); }); } $scope.currencyPairs = newcurrencyPairs; setTimeout(function() { var counter = $(".currencyDataClassSearchTab.active").find('.currencyDataClassSearch').find('.currencyDataClassSearchLi').length; if (counter 0 && FavouritesCurrencyPairs.indexOf(html.symbol) !== -1) ? true : false; if (markFavourite == true) { var newData = { markFavourite: (FavouritesCurrencyPairs != "" && FavouritesCurrencyPairs.length > 0 && FavouritesCurrencyPairs.indexOf(html.symbol) !== -1) ? true : false, base_currency: html.base_currency, base_currency_name: html.base_currency_name, icon: html.icon, secondary_currency: html.secondary_currency, secondary_currency_name: html.secondary_currency_name, updated_secondary_currency: html.updated_secondary_currency, symbol: html.symbol, name: html.name, currency_order: html.currencyOrder, secondary_currency_coin_digits: html.secondary_currency_coin_digits, base_currency_coin_digits: html.base_currency_coin_digits, coin_digits: html.pairPrecision, price: html.price, change_price: html.change_price, volume: html.volume }; newcurrencyPairs[counter] = newData; counter++; } }); $scope.favCurrencyPairs = newcurrencyPairs; setTimeout(() => { var counter = $(".currencyDataClassSearchTabFav").find('.currencyDataClassSearch').find('.currencyDataClassSearchLi').length; if (counter == 0) { $(".currencyDataClassSearchTabFav").find('.currencyDataClassSearch').find(".no_fav_exchange_li_search").show(); } else { $(".currencyDataClassSearchTabFav").find('.currencyDataClassSearch').find(".no_fav_exchange_li_search").hide(); } var counter = $(".currencyDataClassSearchTabFavMob").find('.currencyDataClassMobSearch').find('.currencyDataClassSearchMobLi').length; if (counter == 0) { $(".currencyDataClassSearchTabFavMob").find('.currencyDataClassMobSearch').find(".no_fav_exchange_li_mob_search").show(); } else { $(".currencyDataClassSearchTabFavMob").find('.currencyDataClassMobSearch').find(".no_fav_exchange_li_mob_search").hide(); } }, 1000); } $scope.currrecyPairs(); $(window).resize(function() { if (this.resizeTO) clearTimeout(this.resizeTO); this.resizeTO = setTimeout(function() { $(this).trigger('resizeEnd'); $scope.updateEmptyOrderBook(); }, 500); }); $(".tradetab").click(function() { $scope.updateEmptyOrderBook(); }) $scope.updateEmptyOrderBook = function() { var sellOrderBookHeight = $(".mCustomScrollbarsellOrder").outerHeight(); var buyOrderBookHeight = $(".mCustomScrollbarBuyOrder").outerHeight(); var perRowHeight = $(".getdinamicheight").outerHeight(); var perRowHeight1 = $(".getdinamicheight1").outerHeight(); var sellTotalRowCount = Number(parseFloat(sellOrderBookHeight / Number(perRowHeight)).toFixed(0)); var buyTotalRowCount = Number(parseFloat(buyOrderBookHeight / Number(perRowHeight1)).toFixed(0)); if ($scope.ORDER_BOOK_COIN_DIGITS != $scope.BASE_CURRENCY_COIN_DIGITS) { var totalBuyRecordCount = ($scope.orderBookBuyOrders).length; var totalSellRecordCount = ($scope.orderBookSellOrders).length; } else { var totalBuyRecordCount = ($scope.buyOrders).length; var totalSellRecordCount = ($scope.sellOrders).length; } $scope.totalRequiredBuyEmptyRow = (Number(buyTotalRowCount - totalBuyRecordCount) > 0) ? Number(buyTotalRowCount - totalBuyRecordCount) : 0; $scope.totalRequiredSellEmptyRow = (Number(sellTotalRowCount - totalSellRecordCount) > 0) ? Number(sellTotalRowCount - totalSellRecordCount) : 0; if ($scope.$root.$$phase != '$apply' && $scope.$root.$$phase != '$digest') { $scope.$apply(); } if ($scope.totalRequiredBuyEmptyRow > 0) { if ($scope.totalRequiredBuyEmptyRow > 0) { $('.mCustomScrollbarBuyOrder').css({ overflow: 'hidden', height: '100%' }); $(".mCustomScrollbarBuyOrder").mCustomScrollbar("destroy"); } else { if ($(window).width() 0) { if ($scope.totalRequiredSellEmptyRow > 0) { $('.mCustomScrollbarsellOrder').css({ overflow: 'hidden', height: '100%' }); $(".mCustomScrollbarsellOrder").mCustomScrollbar("destroy"); } else { if ($(window).width() val; } } $scope.showZeroBalance = function(item) { return item.total > 0; }; function matchFirstChar(c, string) { return (string.charAt(0) == c); } function removeFirstChar(string) { return string.slice(1); } function removeDash(label) { if (matchFirstChar('-', label)) { return removeFirstChar(label); } return label; } function addDash(label) { if (!matchFirstChar('-', label)) { return '-' + label; } return label; } $scope.sortDescend = function(label1, label2) { label2 = label2 || ''; return ($scope.sortType == label1 || $scope.sortType == label2); }; $scope.sortAscend = function(label1, label2) { label2 = label2 || ''; return ($scope.sortType == ('-' + label1) || $scope.sortType == ('-' + label2)); }; //Currency Pair sorting left bar $scope.column = 'currency_order'; // sort ordering (Ascending or Descending). Set true for desending $scope.reverse = false; // called on header click $scope.sortColumn = function(col) { if ($scope.column == col) { $scope.column = col; if ($scope.reverse) { $scope.reverse = false; } else { $scope.reverse = true; } } else { $scope.column = col; $scope.reverse = true; } }; // remove and change class $scope.sortClass = function(col) { if ($scope.column == col) { if ($scope.reverse) { return 'caret-down'; } else { return 'caret-up'; } } else { return ''; } } //Currency Pair sorting Header $scope.columnHeader = 'currency_order'; // sort ordering (Ascending or Descending). Set true for desending $scope.reverseHeader = false; // called on header click $scope.sortColumnHeader = function(col) { if ($scope.columnHeader == col) { $scope.columnHeader = col; if ($scope.reverseHeader) { $scope.reverseHeader = false; } else { $scope.reverseHeader = true; } } else { $scope.columnHeader = col; $scope.reverseHeader = true; } }; // remove and change class $scope.sortClassHeader = function(col) { if ($scope.columnHeader == col) { if ($scope.reverseHeader) { return 'caret-down'; } else { return 'caret-up'; } } else { return ''; } } //Open Order sorting $scope.columnOpenOrder = 'currency_order'; // sort ordering (Ascending or Descending). Set true for desending $scope.reverseOpenOrder = false; // called on header click $scope.sortColumnOpenOrder = function(col) { if ($scope.columnOpenOrder == col) { $scope.columnOpenOrder = col; if ($scope.reverseOpenOrder) { $scope.reverseOpenOrder = false; } else { $scope.reverseOpenOrder = true; } } else { $scope.columnOpenOrder = col; $scope.reverseOpenOrder = true; } }; // remove and change class $scope.sortClassOpenOrder = function(col) { if ($scope.columnOpenOrder == col) { if ($scope.reverseOpenOrder) { return 'caret-down'; } else { return 'caret-up'; } } else { return ''; } } //Order History sorting $scope.columnOrderHistory = 'currency_order'; // sort ordering (Ascending or Descending). Set true for desending $scope.reverseOrderHistory = false; // called on header click $scope.sortColumnOrderHistory = function(col) { if ($scope.columnOrderHistory == col) { $scope.columnOrderHistory = col; if ($scope.reverseOrderHistory) { $scope.reverseOrderHistory = false; } else { $scope.reverseOrderHistory = true; } } else { $scope.columnOrderHistory = col; $scope.reverseOrderHistory = true; } }; // remove and change class $scope.sortClassOrderHistory = function(col) { if ($scope.columnOrderHistory == col) { if ($scope.reverseOrderHistory) { return 'caret-down'; } else { return 'caret-up'; } } else { return ''; } } //Trade History sorting $scope.columnTradeHistory = 'currency_order'; // sort ordering (Ascending or Descending). Set true for desending $scope.reverseTradeHistory = false; // called on header click $scope.sortColumnTradeHistory = function(col) { if ($scope.columnTradeHistory == col) { $scope.columnTradeHistory = col; if ($scope.reverseTradeHistory) { $scope.reverseTradeHistory = false; } else { $scope.reverseTradeHistory = true; } } else { $scope.columnTradeHistory = col; $scope.reverseTradeHistory = true; } }; // remove and change class $scope.sortClassTradeHistory = function(col) { if ($scope.columnTradeHistory == col) { if ($scope.reverseTradeHistory) { return 'caret-down'; } else { return 'caret-up'; } } else { return ''; } } //Funds sorting $scope.columnFunds = 'currency_order'; // sort ordering (Ascending or Descending). Set true for desending $scope.reverseFunds = false; // called on header click $scope.sortColumnFunds = function(col) { if ($scope.columnFunds == col) { $scope.columnFunds = col; if ($scope.reverseFunds) { $scope.reverseFunds = false; } else { $scope.reverseFunds = true; } } else { $scope.columnFunds = col; $scope.reverseFunds = true; } }; // remove and change class $scope.sortClassFunds = function(col) { if ($scope.columnFunds == col) { if ($scope.reverseFunds) { return 'caret-down'; } else { return 'caret-up'; } } else { return ''; } } $scope.query = {} $scope.queryBy = '$'; try { var chart; var startIndex = 0; var endIndex = 1; $scope.buyDepthOrders = []; $scope.buyDepthOrders1 = []; $scope.sellDepthOrders = []; $scope.sellDepthOrders1 = []; client.on('updateAllOpenOrderAferCancellAllOrder', function(data) { var orders = data.orders; if (typeof orders !== 'undefined') { for (var i = 0; i 0) { if (type == "BUY") { if (($scope.buyOrders).length > 0) { newBuyOrdersArr = $scope.buyOrders; loopVal = 0; angular.forEach($scope.buyOrders, function(html, key) { if (parseFloat(data.price) == parseFloat(html.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume -= parseFloat(data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); newData = { price: Number(price), amount: amount, select: true, bold_selected: html.bold_selected }; newBuyOrdersArr[key] = newData; $scope.buyOrders = newBuyOrdersArr; } else { $scope.buyOrders.splice(key, 1); if (typeof $scope.buyOrders[0] === "undefined") { $scope.buyOrders = []; } } loopVal++; } }); } } else { if (($scope.sellOrders).length > 0) { newSellOrdersArr = $scope.sellOrders; loopVal = 0; angular.forEach($scope.sellOrders, function(html, key) { if (parseFloat(data.price) == parseFloat(html.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalSellAmount -= data.trade_amount; $scope.totalSellVolume -= parseFloat(data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); newData = { price: Number(price), amount: amount, select: true, bold_selected: html.bold_selected }; newSellOrdersArr[key] = newData; $scope.sellOrders = newSellOrdersArr; } else { $scope.sellOrders.splice(key, 1); if (typeof $scope.sellOrders[0] === "undefined") { $scope.sellOrders = []; } } loopVal++; } }); } } } if (type == "BUY") { $scope.$apply(); setTimeout(function() { $scope.buyOrders = $filter('orderBy')($scope.buyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.buyOrders, function(html, key) { $scope.buyOrders[key].select = false; $scope.buyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); updateBuydepth(); } else { $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.sellOrders = $filter('orderBy')($scope.sellOrders, 'price'); angular.forEach($scope.sellOrders, function(html, key) { priceVol += Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.sellOrders[key].select = false; $scope.sellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); updateSelldepth(); } $scope.marketBuyPriceCalculation(); $scope.marketSellPriceCalculation(); if ($scope.ORDER_BOOK_COIN_DIGITS != $scope.BASE_CURRENCY_COIN_DIGITS) { type = data.type; if (parseFloat(data.trade_amount) > 0) { if (type == "BUY") { if (($scope.orderBookBuyOrders).length > 0) { newBuyOrdersArr = $scope.orderBookBuyOrders; loopVal = 0; angular.forEach($scope.orderBookBuyOrders, function(html, key) { if (Number(parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) == Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume -= parseFloat(data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) - (parseFloat(data.trade_amount) * parseFloat(data.price)), select: true, bold_selected: html.bold_selected }; newBuyOrdersArr[key] = newData; $scope.orderBookBuyOrders = newBuyOrdersArr; } else { $scope.orderBookBuyOrders.splice(key, 1); if (typeof $scope.orderBookBuyOrders[0] === "undefined") { $scope.orderBookBuyOrders = []; } } loopVal++; } }); } } else { if (($scope.orderBookSellOrders).length > 0) { newSellOrdersArr = $scope.orderBookSellOrders; loopVal = 0; angular.forEach($scope.orderBookSellOrders, function(html, key) { if (Number(parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) == Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalSellAmount -= data.trade_amount; $scope.totalSellVolume -= (data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) - (parseFloat(data.trade_amount) * parseFloat(data.price)), select: true, bold_selected: html.bold_selected }; newSellOrdersArr[key] = newData; $scope.orderBookSellOrders = newSellOrdersArr; } else { $scope.orderBookSellOrders.splice(key, 1); if (typeof $scope.orderBookSellOrders[0] === "undefined") { $scope.orderBookSellOrders = []; } } loopVal++; } }); } } } if (type == "BUY") { $scope.$apply(); setTimeout(function() { $scope.orderBookBuyOrders = $filter('orderBy')($scope.orderBookBuyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.orderBookBuyOrders, function(html, key) { $scope.orderBookBuyOrders[key].select = false; $scope.orderBookBuyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat($scope.orderBookBuyOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); } else { $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.orderBookSellOrders = $filter('orderBy')($scope.orderBookSellOrders, 'price'); angular.forEach($scope.orderBookSellOrders, function(html, key) { priceVol += Number(parseFloat($scope.orderBookSellOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.orderBookSellOrders[key].select = false; $scope.orderBookSellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); } } $scope.updateEmptyOrderBook(); } } }); client.on('updateAllOpenOrderAferCancellAllOrderForUser', function(data) { $(".open_order_list").trigger('click'); }); client.on('updateOrderNew', function(data) { type = data.type; if (parseFloat(data.trade_amount) > 0) { if (type == "SELL") { if (($scope.buyOrders).length > 0) { newBuyOrdersArr = $scope.buyOrders; loopVal = 0; angular.forEach($scope.buyOrders, function(html, key) { if (parseFloat(data.price) == parseFloat(html.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume -= parseFloat(data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); var userCurrentOpenOrderPrices = [] $(".openorder_history").each(function() { if ($(this).attr("data-price") > 0) { userCurrentOpenOrderPrices.push(parseFloat($(this).attr("data-price"))); } }); if (jQuery.inArray(parseFloat(html.price), userCurrentOpenOrderPrices) !== -1) { bold_selected = true; } else { bold_selected = false; } newData = { price: Number(price), amount: amount, select: true, bold_selected: bold_selected }; newBuyOrdersArr[key] = newData; $scope.buyOrders = newBuyOrdersArr; } else { $scope.buyOrders.splice(key, 1); if (typeof $scope.buyOrders[0] === "undefined") { $scope.buyOrders = []; } } loopVal++; } }); } } else { if (($scope.sellOrders).length > 0) { newSellOrdersArr = $scope.sellOrders; loopVal = 0; angular.forEach($scope.sellOrders, function(html, key) { if (parseFloat(data.price) == parseFloat(html.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalSellAmount -= data.trade_amount; $scope.totalSellVolume -= parseFloat(data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); var userCurrentOpenOrderPrices = [] $(".openorder_history").each(function() { if ($(this).attr("data-price") > 0) { userCurrentOpenOrderPrices.push(parseFloat($(this).attr("data-price"))); } }); if (jQuery.inArray(parseFloat(html.price), userCurrentOpenOrderPrices) !== -1) { bold_selected = true; } else { bold_selected = false; } newData = { price: Number(price), amount: amount, select: true, bold_selected: bold_selected }; newSellOrdersArr[key] = newData; $scope.sellOrders = newSellOrdersArr; } else { $scope.sellOrders.splice(key, 1); if (typeof $scope.sellOrders[0] === "undefined") { $scope.sellOrders = []; } } loopVal++; } }); } } } if (type == "SELL") { $scope.$apply(); setTimeout(function() { $scope.buyOrders = $filter('orderBy')($scope.buyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.buyOrders, function(html, key) { $scope.buyOrders[key].select = false; $scope.buyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); updateBuydepth(); } else { $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.sellOrders = $filter('orderBy')($scope.sellOrders, 'price'); angular.forEach($scope.sellOrders, function(html, key) { priceVol += Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.sellOrders[key].select = false; $scope.sellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); updateSelldepth(); } $scope.marketBuyPriceCalculation(); $scope.marketSellPriceCalculation(); if ($scope.ORDER_BOOK_COIN_DIGITS != $scope.BASE_CURRENCY_COIN_DIGITS) { type = data.type; if (parseFloat(data.trade_amount) > 0) { if (type == "SELL") { if (($scope.orderBookBuyOrders).length > 0) { newBuyOrdersArr = $scope.orderBookBuyOrders; loopVal = 0; angular.forEach($scope.orderBookBuyOrders, function(html, key) { if (Number(parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) == Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume -= parseFloat(data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) - (parseFloat(data.trade_amount) * parseFloat(data.price)), select: true, bold_selected: html.bold_selected }; newBuyOrdersArr[key] = newData; $scope.orderBookBuyOrders = newBuyOrdersArr; } else { $scope.orderBookBuyOrders.splice(key, 1); if (typeof $scope.orderBookBuyOrders[0] === "undefined") { $scope.orderBookBuyOrders = []; } } loopVal++; } }); } } else { if (($scope.orderBookSellOrders).length > 0) { newSellOrdersArr = $scope.orderBookSellOrders; loopVal = 0; angular.forEach($scope.orderBookSellOrders, function(html, key) { if (Number(parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) == Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(data.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalSellAmount -= data.trade_amount; $scope.totalSellVolume -= (data.trade_amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) - (parseFloat(data.trade_amount) * parseFloat(data.price)), select: true, bold_selected: html.bold_selected }; newSellOrdersArr[key] = newData; $scope.orderBookSellOrders = newSellOrdersArr; } else { $scope.orderBookSellOrders.splice(key, 1); if (typeof $scope.orderBookSellOrders[0] === "undefined") { $scope.orderBookSellOrders = []; } } loopVal++; } }); } } } if (type == "SELL") { $scope.$apply(); setTimeout(function() { $scope.orderBookBuyOrders = $filter('orderBy')($scope.orderBookBuyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.orderBookBuyOrders, function(html, key) { $scope.orderBookBuyOrders[key].select = false; $scope.orderBookBuyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat($scope.orderBookBuyOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); } else { $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.orderBookSellOrders = $filter('orderBy')($scope.orderBookSellOrders, 'price'); angular.forEach($scope.orderBookSellOrders, function(html, key) { priceVol += Number(parseFloat($scope.orderBookSellOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.orderBookSellOrders[key].select = false; $scope.orderBookSellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); } } $scope.updateEmptyOrderBook(); }); client.on('updateOrder', function(data) { var login_user_id = "0"; var orderBookTradeArr = [] if (typeof data.trades.length !== "undefined" && data.trades.length > 0) { var updatedTradeData = data.trades[parseInt(data.trades.length) - 1]; angular.forEach(data.trades, function(html, key) { var totallicount = $(".tradingOrders_ul").find("trade_history_all").length; if (totallicount >= 50) { $(".tradingOrders_ul").find("trade_history_all:last").remove(); } var match_id = parseInt(totallicount) + 1; var type = html[1]; var price = parseFloat(html[3]).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); var amount = parseFloat(html[2]).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); //lastVol += Number(amount) * Number(price); var datetime = html[4]; var classname = (html[1] == "SELL") ? "selling_order" : "buying_order"; var $el = $('
' + price + '
' + amount + '
' + datetime + '
').prependTo('.tradingOrders_ul'); $compile($el)($scope); v_inserted = 0 if (orderBookTradeArr.length > 0) { for (var i = 0; i 0) { var login_user_id = "0"; if (login_user_id == data.user_id) { $(".loginuserorderinfo").find("a.active").trigger("click"); } angular.forEach(data.trades, function(html, key) { var price = parseFloat(html.price).toFixed(18); var amount = parseFloat(html.amount).toFixed(18); var type = html.transordertype; var user_id = html.order_by_user_id; data = [{ "price": price, "amount": amount, "trade_amount": 0, "buy_total_amount": 0, "buy_total_volume": 0, "buy_total_price": 0, "sell_total_amount": 0, "sell_total_volume": 0, "sell_total_price": 0, "user_id": user_id, "type": type }] $scope.newOrderUpdateOrderBook(data, login_user_id); if ($scope.ORDER_BOOK_COIN_DIGITS != $scope.BASE_CURRENCY_COIN_DIGITS) { $scope.newOrderUpdateOrderBookWithDecimalDropDown(data, login_user_id); } }); } }); $scope.TradeOrderUpdateOrderBook = function(data, type) { angular.forEach(data, function(value, key) { if (parseFloat(value.trade_amount) > 0) { if (type == "SELL") { if (($scope.buyOrders).length > 0) { newBuyOrdersArr = $scope.buyOrders; loopVal = 0; angular.forEach($scope.buyOrders, function(html, key) { if (parseFloat(value.price) == parseFloat(html.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(value.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume -= parseFloat(value.trade_amount * value.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); newData = { price: Number(price), amount: amount, select: true, bold_selected: html.bold_selected }; newBuyOrdersArr[key] = newData; $scope.buyOrders = newBuyOrdersArr; } else { $scope.buyOrders.splice(key, 1); if (typeof $scope.buyOrders[0] === "undefined") { $scope.buyOrders = []; } } loopVal++; } }); } } else { if (($scope.sellOrders).length > 0) { newSellOrdersArr = $scope.sellOrders; loopVal = 0; angular.forEach($scope.sellOrders, function(html, key) { if (parseFloat(value.price) == parseFloat(html.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(value.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalSellAmount -= value.trade_amount; $scope.totalSellVolume -= (value.trade_amount * value.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); newData = { price: Number(price), amount: amount, select: true, bold_selected: html.bold_selected }; newSellOrdersArr[key] = newData; $scope.sellOrders = newSellOrdersArr; } else { $scope.sellOrders.splice(key, 1); if (typeof $scope.sellOrders[0] === "undefined") { $scope.sellOrders = []; } } loopVal++; } }); } } } }); if (type == "SELL") { updateBuydepth(); $scope.$apply(); setTimeout(function() { $scope.buyOrders = $filter('orderBy')($scope.buyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.buyOrders, function(html, key) { $scope.buyOrders[key].select = false; $scope.buyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); } else { updateSelldepth(); $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.sellOrders = $filter('orderBy')($scope.sellOrders, 'price'); angular.forEach($scope.sellOrders, function(html, key) { priceVol += Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.sellOrders[key].select = false; $scope.sellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); } $scope.updateEmptyOrderBook(); $scope.marketBuyPriceCalculation(); $scope.marketSellPriceCalculation(); } $scope.TradeOrderUpdateOrderBookWithDecimalDropDown = function(data, type) { angular.forEach(data, function(value, key) { if (parseFloat(value.trade_amount) > 0) { if (type == "SELL") { if (($scope.orderBookBuyOrders).length > 0) { newBuyOrdersArr = $scope.orderBookBuyOrders; loopVal = 0; angular.forEach($scope.orderBookBuyOrders, function(html, key) { if (Number(parseFloat(value.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) == Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(value.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume -= parseFloat(value.trade_amount * value.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) - (parseFloat(value.trade_amount) * parseFloat(value.price)), select: true, bold_selected: html.bold_selected }; newBuyOrdersArr[key] = newData; $scope.orderBookBuyOrders = newBuyOrdersArr; } else { $scope.orderBookBuyOrders.splice(key, 1); if (typeof $scope.orderBookBuyOrders[0] === "undefined") { $scope.orderBookBuyOrders = []; } } loopVal++; } }); } } else { if (($scope.orderBookSellOrders).length > 0) { newSellOrdersArr = $scope.orderBookSellOrders; loopVal = 0; angular.forEach($scope.orderBookSellOrders, function(html, key) { if (Number(parseFloat(value.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) == Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) - parseFloat(value.trade_amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalSellAmount -= value.trade_amount; $scope.totalSellVolume -= (value.trade_amount * value.price); if (parseFloat(amount) > 0) { var price = parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) - (parseFloat(value.trade_amount) * parseFloat(value.price)), select: true, bold_selected: html.bold_selected }; newSellOrdersArr[key] = newData; $scope.orderBookSellOrders = newSellOrdersArr; } else { $scope.orderBookSellOrders.splice(key, 1); if (typeof $scope.orderBookSellOrders[0] === "undefined") { $scope.orderBookSellOrders = []; } } loopVal++; } }); } } } }); if (type == "SELL") { $scope.$apply(); setTimeout(function() { $scope.orderBookBuyOrders = $filter('orderBy')($scope.orderBookBuyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.orderBookBuyOrders, function(html, key) { $scope.orderBookBuyOrders[key].select = false; $scope.orderBookBuyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat($scope.orderBookBuyOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); } else { $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.orderBookSellOrders = $filter('orderBy')($scope.orderBookSellOrders, 'price'); angular.forEach($scope.orderBookSellOrders, function(html, key) { priceVol += Number(parseFloat($scope.orderBookSellOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.orderBookSellOrders[key].select = false; $scope.orderBookSellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); } $scope.updateEmptyOrderBook(); } $scope.newOrderUpdateOrderBook = function(data, login_user_id) { data = data[0]; if (data.type == "SELL") { if (($scope.sellOrders).length > 0) { newSellOrdersArr = $scope.sellOrders; var loopVal = 0; angular.forEach($scope.sellOrders, function(html, key) { if (parseFloat(html.price) == parseFloat(data.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) + parseFloat(data.amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalSellAmount += parseFloat(data.amount); $scope.totalSellVolume += parseFloat(data.amount * data.price); if (parseFloat(amount) > 0) { var price = parseFloat(data.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); newData = { price: Number(price), amount: amount, select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newSellOrdersArr[key] = newData; $scope.sellOrders = newSellOrdersArr; } else { $scope.sellOrders.splice(key, 1); if (typeof $scope.sellOrders[0] === "undefined") { $scope.sellOrders = []; } } loopVal++; } }); if (loopVal == 0) { var newSellOrders = $scope.sellOrders; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); if (parseFloat(amount) > 0) { newData = { price: Number(price), amount: amount, select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newSellOrders[($scope.sellOrders).length] = newData; $scope.sellOrders = newSellOrders; $scope.totalSellAmount += parseFloat(amount); $scope.totalSellVolume += parseFloat(amount * price); } } } else { var newSellOrders = []; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); if (amount > 0) { newData = { price: Number(price), amount: amount, select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newSellOrders[0] = newData; $scope.sellOrders = newSellOrders; $scope.totalSellAmount += parseFloat(amount); $scope.totalSellVolume += parseFloat(amount * price); } } $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.sellOrders = $filter('orderBy')($scope.sellOrders, 'price'); angular.forEach($scope.sellOrders, function(html, key) { priceVol += Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.sellOrders[key].select = false; $scope.sellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); updateSelldepth(); } else { if (($scope.buyOrders).length > 0) { newBuyOrdersArr = $scope.buyOrders; var loopVal = 0; angular.forEach($scope.buyOrders, function(html, key) { if (parseFloat(html.price) == parseFloat(data.price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) + parseFloat(data.amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume += parseFloat(data.amount * data.price); if (amount > 0) { var price = parseFloat(data.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); newData = { price: Number(price), amount: amount, select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newBuyOrdersArr[key] = newData; $scope.buyOrders = newBuyOrdersArr; } loopVal++; } }); if (loopVal == 0) { var newBuyOrders = $scope.buyOrders; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); if (amount > 0) { newData = { price: Number(price), amount: amount, select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newBuyOrders[($scope.buyOrders).length] = newData; $scope.buyOrders = newBuyOrders; $scope.totalBuyVolume += parseFloat(amount * price);; } } } else { var newBuyOrders = []; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); if (amount > 0) { newData = { price: Number(price), amount: amount, select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newBuyOrders[0] = newData; $scope.buyOrders = newBuyOrders; $scope.totalBuyVolume += parseFloat(amount * price); } } $scope.$apply(); setTimeout(function() { $scope.buyOrders = $filter('orderBy')($scope.buyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.buyOrders, function(html, key) { $scope.buyOrders[key].select = false; $scope.buyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); updateBuydepth(); } $scope.updateEmptyOrderBook(); } $scope.newOrderUpdateOrderBookWithDecimalDropDown = function(data, login_user_id) { data = data[0]; if (data.type == "SELL") { if (($scope.orderBookSellOrders).length > 0) { newSellOrdersArr = $scope.orderBookSellOrders; var loopVal = 0; var price = parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); angular.forEach($scope.orderBookSellOrders, function(html, key) { var loopPrice = Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)); if (loopPrice == Number(price) && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) + parseFloat(data.amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); if (parseFloat(amount) > 0) { newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) + (parseFloat(data.amount) * parseFloat(data.price)), select: true, volume: parseFloat(amount) * parseFloat(value.price), bold_selected: (login_user_id == data.user_id) ? true : false }; newSellOrdersArr[key] = newData; $scope.orderBookSellOrders = newSellOrdersArr; } else { $scope.orderBookSellOrders.splice(key, 1); if (typeof $scope.orderBookSellOrders[0] === "undefined") { $scope.orderBookSellOrders = []; } } loopVal++; } }); if (loopVal == 0) { var newSellOrders = $scope.orderBookSellOrders; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); if (parseFloat(amount) > 0) { newData = { price: Number(price), amount: amount, select: true, volume: parseFloat(amount) * parseFloat(data.price), bold_selected: (login_user_id == data.user_id) ? true : false }; newSellOrders[($scope.orderBookSellOrders).length] = newData; $scope.orderBookSellOrders = newSellOrders; } } } else { var newSellOrders = []; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); if (amount > 0) { newData = { price: Number(price), amount: amount, volume: parseFloat(amount) * parseFloat(data.price), select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newSellOrders[0] = newData; $scope.orderBookSellOrders = newSellOrders; $scope.totalSellAmount += parseFloat(amount); $scope.totalSellVolume += parseFloat(amount * price); } } $scope.$apply(); setTimeout(function() { var priceVol = 0; $scope.orderBookSellOrders = $filter('orderBy')($scope.orderBookSellOrders, 'price'); angular.forEach($scope.orderBookSellOrders, function(html, key) { priceVol += Number(parseFloat($scope.orderBookSellOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.orderBookSellOrders[key].select = false; $scope.orderBookSellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); $scope.$apply(); }, 1000); } else { if (($scope.orderBookBuyOrders).length > 0) { newBuyOrdersArr = $scope.orderBookBuyOrders; var loopVal = 0; var price = Number(parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)); angular.forEach($scope.orderBookBuyOrders, function(html, key) { var loopPrice = Number(parseFloat(html.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS)); if (loopPrice == price && loopVal == 0) { var amount = parseFloat(parseFloat(html.amount) + parseFloat(data.amount)).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.totalBuyVolume += parseFloat(data.amount * data.price); if (amount > 0) { newData = { price: Number(price), amount: amount, volume: parseFloat(html.volume) + (parseFloat(data.amount) * parseFloat(data.price)), select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newBuyOrdersArr[key] = newData; $scope.orderBookBuyOrders = newBuyOrdersArr; } loopVal++; } }); if (loopVal == 0) { var newBuyOrders = $scope.orderBookBuyOrders; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); if (amount > 0) { newData = { price: Number(price), amount: amount, volume: parseFloat(amount) * parseFloat(data.price), select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newBuyOrders[($scope.orderBookBuyOrders).length] = newData; $scope.orderBookBuyOrders = newBuyOrders; $scope.totalBuyVolume += parseFloat(amount * price);; } } } else { var newBuyOrders = []; var amount = parseFloat(data.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var price = parseFloat(data.price).toFixed($scope.ORDER_BOOK_COIN_DIGITS); if (amount > 0) { newData = { price: Number(price), amount: amount, volume: parseFloat(amount) * parseFloat(data.price), select: true, bold_selected: (login_user_id == data.user_id) ? true : false }; newBuyOrders[0] = newData; $scope.orderBookBuyOrders = newBuyOrders; $scope.totalBuyVolume += parseFloat(amount * price); } } $scope.$apply(); setTimeout(function() { $scope.orderBookBuyOrders = $filter('orderBy')($scope.orderBookBuyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.orderBookBuyOrders, function(html, key) { $scope.orderBookBuyOrders[key].select = false; $scope.orderBookBuyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat($scope.orderBookBuyOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); $scope.$apply(); }, 1000); } $scope.updateEmptyOrderBook(); } function updateSelldepth() { var allAsks = $scope.sellOrders; var allAsks = $filter('orderBy')(allAsks, 'price'); var askData = []; var askLength = (allAsks).length; var counter = 0; var askSpread = 0; $scope.askSpread = 0; angular.forEach(allAsks, function(html, key) { var newData = [parseFloat(html.price), parseFloat(html.amount)]; askData[key] = newData; if (askLength > 0 && counter == 0) { askSpread = html.price; $scope.askSpread = html.price; } counter++; }); askData.sort(function(a, b) { return a[0] - b[0] }); var newAskRecords = []; var totalAskVol = 0; if (askData.length > 0) { for (i = 0; i 0) { $scope.totalSpread = parseFloat(askSpread - $scope.bidSpread).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { $scope.totalSpread = parseFloat(0).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } $scope.$apply(); } function updateBuydepth() { var allBids = $scope.buyOrders; var allBids = $filter('orderBy')(allBids, 'price'); var bidData = []; var bidSpread = 0; $scope.bidSpread = 0; var bidLength = (allBids).length; var counter = 0; angular.forEach(allBids, function(html, key) { var newData = [parseFloat(html.price), parseFloat(html.amount)]; bidData[key] = newData; if (bidLength > 0 && bidLength == (counter + 1)) { bidSpread = html.price; $scope.bidSpread = html.price; } counter++; }); bidData.sort(function(a, b) { return b[0] - a[0] }); var newBidRecords = []; var totalBuyVol = 0; if (bidData.length > 0) { for (i = 0; i 0) { $scope.totalSpread = parseFloat($scope.askSpread - bidSpread).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { $scope.totalSpread = parseFloat(0).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } $scope.$apply(); } function createDepthChart(newSellDepthOrders, newBuyDepthOrders) { var depthPanelH = $('.exchange-graph ul.nav.panel-tabs').outerHeight(); var chart = Highcharts.chart('depth-chart', { chart: { type: 'area', zoomType: 'xy', styledMode: true, panning: true, animation: { duration: 200 }, events: { load: function() { var series0 = this.series[0]; var series1 = this.series[1]; } } }, defs: { gradient0: { tagName: 'linearGradient', id: 'gradient-0', x1: 0, y1: 0, x2: 0, y2: 1, children: [{ tagName: 'stop', offset: 0 }, { tagName: 'stop', offset: 1 }] }, gradient1: { tagName: 'linearGradient', id: 'gradient-1', x1: 0, y1: 0, x2: 0, y2: 1, children: [{ tagName: 'stop', offset: 0 }, { tagName: 'stop', offset: 1 }] } }, title: 'none', xAxis: { minPadding: 0, maxPadding: 0, gridLineWidth: 0 }, yAxis: { lineWidth: 1, gridLineWidth: 1, title: null, tickWidth: 1, tickLength: 5, tickPosition: 'inside', gridLineColor: '#197F07' }, legend: { enabled: false }, navigator: { enabled: false, }, scrollbar: { enabled: false, }, plotOptions: { series: { animation: 1, step: 'center', states: { hover: { enabled: true, }, }, marker: { states: { hover: { enabled: true }, }, } }, area: { marker: { enabled: false, states: { hover: { enabled: !0 } } } } }, tooltip: { useHTML: true, formatter: function() { var series = this.series; var canBoughtTo = 0; var index = this.series.data.indexOf(this.point); var currentPrice = this.x; if (series.name == 'Asks') { var textMessage = 'Can be sold'; var allAsks = $scope.sellOrders; var allAsks = $filter('orderBy')(allAsks, 'price'); var askData = []; var askLength = (allAsks).length; angular.forEach(allAsks, function(html, key) { var newData = [parseFloat(html.price), parseFloat(html.amount)]; askData[key] = newData; }); askData.sort(function(a, b) { return a[0] - b[0] }); var totalAskVol = 0; if (askData.length > 0) { for (i = 0; i 0) { for (i = 0; i bidData[i][0]) { break; } else { totalAskVol += bidData[i][0] * bidData[i][1]; canBoughtTo += bidData[i][0]; } } } } var s = '' + parseFloat(this.x).toFixed($scope.BASE_CURRENCY_COIN_DIGITS) + ' ' + $scope.currency1 + '
'; s += '' + '
' + textMessage + ':    For a total of:
' + parseFloat(canBoughtTo).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS) + ' ' + $scope.currency2 + '    ' + parseFloat(totalAskVol).toFixed($scope.BASE_CURRENCY_COIN_DIGITS) + ' ' + $scope.currency1 + '
'; return s; }, headerFormat: '{point.x} BTC
', pointFormat: '' + '', footerFormat: '
Can be bought:
{point.y} BTC
', valueDecimals: 2, borderColor: '#1e232f', backgroundColor: '#1e232f', padding: 12, }, series: [{ name: 'Asks', type: 'area', data: newSellDepthOrders }, { name: 'Bids', type: 'area', data: newBuyDepthOrders }] }); } } catch (e) { } function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^]*)"), results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } $.fn.removeClassStartingWith = function(filter) { $(this).removeClass(function(index, className) { return (className.match(new RegExp("\\S*" + filter + "\\S*", 'g')) || []).join(' ') }); return this; }; function removeClassStartingWith(filter) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^]*)"), results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } $scope.change_price_decimal_value = function() { $scope.needToResetOrderBookScroll = 0; var buyTotalVol = 0; var sellTotalVol = 0; angular.forEach($scope.buyOrders, function(html, key) { buyTotalVol += html.price * html.amount; }); var buyTotalVol = Number(parseFloat(buyTotalVol).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) angular.forEach($scope.sellOrders, function(html, key) { sellTotalVol += html.price * html.amount; }); var sellTotalVol = Number(parseFloat(sellTotalVol).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.ORDER_BOOK_COIN_DIGITS = $scope.decimal_box; var newBuyOrders = []; priceVol = buyTotalVol; if ($scope.buyOrders.length > 0) { var buyOrdersCounter = 0; angular.forEach($scope.buyOrders, function(html, key) { if (parseFloat(html.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS) > 0) { var isFoundKey = -1; if (newBuyOrders.length > 0) { for (var $i = 0; $i = 0) { newBuyOrders[isFoundKey]["amount"] = parseFloat(newBuyOrders[isFoundKey]["amount"]) + parseFloat(html.amount); newBuyOrders[isFoundKey]["volume"] = parseFloat(newBuyOrders[isFoundKey]["volume"]) + (parseFloat(html.amount) * parseFloat(html.price)); } else { var newData = { price: Number(parseFloat(html.price).toFixed($scope.decimal_box)), amount: parseFloat(html.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS) }; newBuyOrders[buyOrdersCounter] = newData; newBuyOrders[buyOrdersCounter].select = false; newBuyOrders[buyOrdersCounter].bold_selected = ((html.bold_selected > 0) ? true : false); newBuyOrders[buyOrdersCounter].total_per = Number(parseFloat(priceVol / buyTotalVol * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); newBuyOrders[buyOrdersCounter].volume = parseFloat(html.amount) * parseFloat(html.price); buyOrdersCounter++; } } priceVol -= Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); } //$scope.orderBookBuyOrders = []; $scope.orderBookBuyOrders = newBuyOrders; var newSellOrders = []; var priceVol = 0; var sellOrdersCounter = 0; if ($scope.sellOrders.length > 0) { angular.forEach($scope.sellOrders, function(html, key) { priceVol += Number(parseFloat(html.price * html.amount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) if (parseFloat(html.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS) > 0) { var isFoundKey = -1; if (newSellOrders.length > 0) { for (var $i = 0; $i = 0) { newSellOrders[isFoundKey]["amount"] = parseFloat(newSellOrders[isFoundKey]["amount"]) + parseFloat(html.amount); newSellOrders[isFoundKey]["volume"] = parseFloat(newSellOrders[isFoundKey]["volume"]) + (parseFloat(html.amount) * parseFloat(html.price)); } else { var newData = { price: Number(parseFloat(html.price).toFixed($scope.decimal_box)), amount: parseFloat(html.amount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS) }; newSellOrders[key] = newData; newSellOrders[key].select = false; newSellOrders[key].bold_selected = ((html.bold_selected > 0) ? true : false); newSellOrders[key].total_per = Number(parseFloat(priceVol / sellTotalVol * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); newSellOrders[key].volume = parseFloat(html.amount) * parseFloat(html.price); sellOrdersCounter++; } } }); } $scope.orderBookSellOrders = newSellOrders; $scope.orderBookBuyOrders = $filter('orderBy')($scope.orderBookBuyOrders, 'price'); priceVol = $scope.totalBuyVolume; angular.forEach($scope.orderBookBuyOrders, function(html, key) { $scope.orderBookBuyOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalBuyVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); priceVol -= Number(parseFloat($scope.orderBookBuyOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) }); var priceVol = 0; $scope.orderBookSellOrders = $filter('orderBy')($scope.orderBookSellOrders, 'price'); angular.forEach($scope.orderBookSellOrders, function(html, key) { priceVol += Number(parseFloat($scope.orderBookSellOrders[key].volume).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)) $scope.orderBookSellOrders[key].total_per = Number(parseFloat(priceVol / $scope.totalSellVolume * 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS)); }); setTimeout(function() { $scope.updateEmptyOrderBook(); }, 10); } $scope.getExchangeCurrencyPair = function(currency1, currency2, base_currency_coin_digits, secondary_currency_coin_digits, base_currency_name, secondary_currency_name) { $scope.needToResetOrderBookScroll = 0; $scope.priceInUsd = $scope.baseCurrencyPricesInUSDT[currency1 + "_BTC"]; $scope.baseCurrencyName = base_currency_name; $scope.secondaryCurrencyName = secondary_currency_name; var browserTitle = currency2 + "/" + currency1 + "| Tradekax | Cryptocurrency Exchange | Buy & Sell " + secondary_currency_name + " or " + base_currency_name; $(document).attr("title", browserTitle); $scope.updateBalaceOnClientSide(); //console.log(base_currency_coin_digits) $scope.BASE_CURRENCY_COIN_DIGITS = base_currency_coin_digits; $scope.ORDER_BOOK_COIN_DIGITS = base_currency_coin_digits; $scope.SECONDARY_CURRENCY_COIN_DIGITS = secondary_currency_coin_digits; var optionArr = ""; var totalloopcounter = (parseInt(base_currency_coin_digits) - 3 > 0) ? parseInt(base_currency_coin_digits) - 3 : 0; for ($i = parseInt(totalloopcounter); $i " + $i + " DECIMALS"; } else { optionArr += ""; } } $(".decimal_box").html(optionArr); $(".secondary_currency_digit_type_field").removeClassStartingWith('numbervalidation_'); $(".secondary_currency_digit_type_field").addClass("numbervalidation_" + $scope.SECONDARY_CURRENCY_COIN_DIGITS); $(".base_currency_digit_type_field").removeClassStartingWith('numbervalidation_'); $(".base_currency_digit_type_field").addClass("numbervalidation_" + $scope.BASE_CURRENCY_COIN_DIGITS); $scope.isAllowTrade = 0; $scope.isAllowTrade = 1; if ($scope.currency1 != "" && $scope.currency2 != "") { var oldChatRoom = $scope.currency1 + "_" + $scope.currency2; } else { var oldChatRoom = ""; } if ($scope.currency1 == currency1 && $scope.currency2 == currency2) { } else { client.emit('currencyPairRoomLogin', { currencyPair: currency1 + "_" + currency2, oldChatRoom: oldChatRoom }); } targetTitle = currency2 + "_" + currency1; window.history.pushState(null, null, site_url + "/" + targetTitle); setTimeout(function() { $("#tradingviewgraph").attr('src', 'https://ns8.tradekax.com/exchange_' + targetTitle); }, 400); $scope.currency1 = currency1; $scope.currency2 = currency2; $scope.activeMenu = currency1; $scope.activeMenu1 = currency2; $scope.buyOrders = []; $scope.sellOrders = []; $scope.tradingOrders = []; $scope.baseCurrencywalletAmount = 0; $scope.secondaryCurrencywalletAmount = 0; $scope.buyFee = 0; $scope.sellFee = 0; $scope.maker_fee = 0; $scope.taker_fee = 0; ///https://get fee information //Convert base currency price in converted currency (LIKE USD) $scope.currencyPairTicker($scope.currency2, $scope.currency1); currentRoom = currency1 + "_" + currency2; /** get all the buy orders**/ setTimeout(function() { $scope.depthOrders(currency1, currency2); }, 100); setTimeout(function() { $scope.exchangeTradeOrders(currency1, currency2); }, 200); $scope.userBalanceInformation(currency1, currency2); setTimeout(function() { $(".loginuserorderinfo").find("a.active").trigger("click"); }, 500); } $(".open_order_list").click(function() { $(".hideshowcheckbox").hide(); $(".showallopenorderpair").show(); $scope.exchangeOpenOrders(); }); $(".showallopenorderpairinput").change(function() { $(".hideshowcheckbox").hide(); $(".showallopenorderpair").show(); $scope.exchangeOpenOrders(); }); $(".my_order_history_list").click(function() { $(".hideshowcheckbox").hide(); $(".showallorderpair").show(); $scope.exchangeOrderHistory(); }); $(".showallorderpairinput").change(function() { $(".hideshowcheckbox").hide(); $(".showallorderpair").show(); $scope.exchangeOrderHistory(); }); $(".my_trade_history_list").click(function() { $(".hideshowcheckbox").hide(); $(".showalltradepair").show(); $scope.exchangeTradeHistory(); }); $(".showalltradepairinput").change(function() { $(".hideshowcheckbox").hide(); $(".showalltradepair").show(); $scope.exchangeTradeHistory(); }); $(".funds_list").click(function() { $(".hideshowcheckbox").hide(); $(".showNoZeroBalance").show(); $scope.exchangeFunds(); }); try { function addZero(digits) { return parseInt(String(1).padEnd(parseInt(digits) + 1, 0)); } client.on('updateShowLastPriceInBox', function(data) { var lastprice = (data.last_price !== null && typeof data.last_price !== "undefined") ? data.last_price : "0.00000000"; var change_price = (data.change_price !== null && typeof data.change_price !== "undefined") ? (data.change_price).toFixed(18) : "0.00000000"; if (change_price > 0 && lastprice > 0) { var changePercentTicker1 = ((change_price - lastprice) / change_price) * 100; } else { var changePercentTicker1 = 0; } var changePercentTicker1 = parseFloat(changePercentTicker1).toFixed(2); $scope.buysellboxlastprice = lastprice; var usdpriceinbtc = $scope.baseCurrencyPricesInUSDT["USD_BTC"]; $scope.buysellboxlastpriceinusd = parseFloat($scope.priceInUsd * lastprice * usdpriceinbtc).toFixed(2); $scope.buysellboxchangeper = changePercentTicker1; $scope.boxChangePrice = change_price; }); } catch (e) { } client.on('updatedeleteStopLimit', function(data) { if (data.status == "success") { show_message_exchange(data.message, "success"); } else { show_message_exchange(data.message, "error"); } jQuery('#loader_img').fadeOut(); }); client.on('NodeUpdateUpdateTradeHistory', function(data) { $(".loginuserorderinfo").find("a.active").trigger("click"); }); client.on('updateUserWalletBalance', function(data) { var started = new Date().getTime(); if ($scope.currency1 == data.currency) { $scope.baseCurrencywalletAmount = 0; $scope.baseCurrencywalletAmount = (Math.floor(data.wallet_avl_bal * addZero($scope.BASE_CURRENCY_COIN_DIGITS))) / addZero($scope.BASE_CURRENCY_COIN_DIGITS); $scope.baseCurrencywalletAmount = parseFloat($scope.baseCurrencywalletAmount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.$apply() } if ($scope.currency2 == data.currency) { $scope.secondaryCurrencywalletAmount = 0; $scope.secondaryCurrencywalletAmount = (Math.floor(data.wallet_avl_bal * addZero($scope.SECONDARY_CURRENCY_COIN_DIGITS))) / addZero($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.secondaryCurrencywalletAmount = parseFloat($scope.secondaryCurrencywalletAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.$apply() } }); client.on('updateUserTradeWalletBalance', function(data) { var started = new Date().getTime(); if ($scope.currency1 == data.to_currcode) { $scope.baseCurrencywalletAmount = 0; $scope.baseCurrencywalletAmount = (Math.floor(data.base_currency_bal * addZero($scope.BASE_CURRENCY_COIN_DIGITS))) / addZero($scope.BASE_CURRENCY_COIN_DIGITS); $scope.baseCurrencywalletAmount = parseFloat($scope.baseCurrencywalletAmount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.$apply() } if ($scope.currency2 == data.from_currcode) { $scope.secondaryCurrencywalletAmount = 0; $scope.secondaryCurrencywalletAmount = (Math.floor(data.sec_currency_bal * addZero($scope.SECONDARY_CURRENCY_COIN_DIGITS))) / addZero($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.secondaryCurrencywalletAmount = parseFloat($scope.secondaryCurrencywalletAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); $scope.$apply() } }); //Show price in usd on hover on price $scope.getpriceinusd = function(id, price) { var dataPrice = parseFloat(parseFloat(price) * parseFloat($scope.priceInUsd)); $(".updatepriceinusd").hide(); $(".updatepriceinusd_" + id).show(); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".updatepriceinusd_" + id).html($scope.currencySymbol + parseFloat(price).toFixed(8)); } else { $(".updatepriceinusd_" + id).html(parseFloat(price).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".updatepriceinusd_" + id).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".updatepriceinusd_" + id).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".updatepriceinusd_" + id).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".updatepriceinusd_" + id).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } } //Hide price in usd on mouseleave on price $scope.removepriceinusd = function(id, price) { $(".updatepriceinusd_" + id).hide(); } //Show price in usd on hover on price $scope.getsellpriceinusd = function(price) { var dataPrice = parseFloat(parseFloat(price) * parseFloat($scope.priceInUsd)); $(".updatesellpriceinusd").hide(); var res = price.replace(".", "_"); $(".updatesellpriceinusd_" + res).show(); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".updatesellpriceinusd_" + res).html($scope.currencySymbol + parseFloat(price).toFixed(8)); } else { $(".updatesellpriceinusd_" + res).html(parseFloat(price).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".updatesellpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".updatesellpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".updatesellpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".updatesellpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } } //Hide price in usd on mouseleave on price $scope.removesellpriceinusd = function(price) { var res = price.replace(".", "_"); $(".updatesellpriceinusd_" + res).hide(); } //Show price in usd on hover on price $scope.getbuypriceinusd = function(price) { var dataPrice = parseFloat(parseFloat(price) * parseFloat($scope.priceInUsd)); $(".updatesellpriceinusd").hide(); var res = price.replace(".", "_"); $(".updatebuypriceinusd_" + res).show(); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".updatebuypriceinusd_" + res).html($scope.currencySymbol + parseFloat(price).toFixed(8)); } else { $(".updatebuypriceinusd_" + res).html(parseFloat(price).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".updatebuypriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".updatebuypriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".updatebuypriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".updatebuypriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } } //Hide price in usd on mouseleave on price $scope.removebuypriceinusd = function(price) { var res = price.replace(".", "_"); $(".updatebuypriceinusd_" + res).hide(); } //Show price in usd on hover on price $scope.gettradepriceinusd = function(id, price) { var dataPrice = parseFloat(parseFloat(price) * parseFloat($scope.priceInUsd)); $(".updatetradepriceinusd").hide(); $(".updatetradepriceinusd_" + id).show(); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".updatetradepriceinusd_" + id).html($scope.currencySymbol + parseFloat(price).toFixed(8)); } else { $(".updatetradepriceinusd_" + id).html(parseFloat(price).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".updatetradepriceinusd_" + id).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".updatetradepriceinusd_" + id).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".updatetradepriceinusd_" + id).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".updatetradepriceinusd_" + id).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } } //Hide price in usd on mouseleave on price $scope.removetradepriceinusd = function(id, price) { $(".updatetradepriceinusd_" + id).hide(); } //Show price in usd on hover on price $scope.getheaderpriceinusd = function(price) { var dataPrice = parseFloat(parseFloat(price) * parseFloat($scope.priceInUsd)); $(".updateheaderpriceinusd").hide(); var res = price.replace(".", "_"); $(".updateheaderpriceinusd_" + res).show(); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".updateheaderpriceinusd_" + res).html($scope.currencySymbol + parseFloat(price).toFixed(8)); } else { $(".updateheaderpriceinusd_" + res).html(parseFloat(price).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".updateheaderpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".updateheaderpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".updateheaderpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".updateheaderpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } } //Hide price in usd on mouseleave on price $scope.removeheaderpriceinusd = function(price) { var res = price.replace(".", "_"); $(".updateheaderpriceinusd_" + res).hide(); } //Show price in usd on hover on price $scope.getheaderhighpriceinusd = function(price) { var dataPrice = parseFloat(parseFloat(price) * parseFloat($scope.priceInUsd)); $(".updateheaderpriceinusd").hide(); var res = price.replace(".", "_"); $(".updateheaderhighpriceinusd_" + res).show(); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".updateheaderhighpriceinusd_" + res).html($scope.currencySymbol + parseFloat(price).toFixed(8)); } else { $(".updateheaderhighpriceinusd_" + res).html(parseFloat(price).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".updateheaderhighpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".updateheaderhighpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".updateheaderhighpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".updateheaderhighpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } } //Hide price in usd on mouseleave on price $scope.removeheaderhighpriceinusd = function(price) { var res = price.replace(".", "_"); $(".updateheaderhighpriceinusd_" + res).hide(); } //Show price in usd on hover on price $scope.getheaderlowpriceinusd = function(price) { var dataPrice = parseFloat(parseFloat(price) * parseFloat($scope.priceInUsd)); $(".updateheaderpriceinusd").hide(); var res = price.replace(".", "_"); $(".updateheaderlowpriceinusd_" + res).show(); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".updateheaderlowpriceinusd_" + res).html($scope.currencySymbol + parseFloat(price).toFixed(8)); } else { $(".updateheaderlowpriceinusd_" + res).html(parseFloat(price).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".updateheaderlowpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".updateheaderlowpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".updateheaderlowpriceinusd_" + res).html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".updateheaderlowpriceinusd_" + res).html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } } //Hide price in usd on mouseleave on price $scope.removeheaderlowpriceinusd = function(price) { var res = price.replace(".", "_"); $(".updateheaderlowpriceinusd_" + res).hide(); } $scope.changeOrderBookLayout = function(item) { $scope.changeTopOrderBookClass = ''; $scope.changeBothOrderBookClass = ''; $scope.changeBottomOrderBookClass = ''; if (item == "top") { $(".bottomtraderow").hide(); $(".toptraderow").show(); $scope.changeTopOrderBookClass = 'orderbookactive'; } else if (item == "both") { $(".bottomtraderow").show(); $(".toptraderow").show(); $scope.changeBothOrderBookClass = 'orderbookactive'; } else if (item == "bottom") { $(".bottomtraderow").show(); $(".toptraderow").hide(); /* $(".buyBook_orders").mCustomScrollbar("destroy"); $('.buyBook_orders').mCustomScrollbar(); */ $scope.changeBottomOrderBookClass = 'orderbookactive'; } $scope.updateEmptyOrderBook(); } $scope.buyOrderRequest = function(price, amount) { var price = parseFloat(price).toFixed(18); var amount = parseFloat(amount).toFixed(18); $scope.buyOrders = $filter('orderBy')($scope.buyOrders, '-price'); if (price != "") { var marketPriceValue = price; var totalVolumeAmount = 0; var exitLoop = 0; var totalsecondaryCurrencyAmount = 0; var totalGetCoin = 0; angular.forEach($scope.buyOrders, function(html, key) { if (exitLoop == 0) { totalVolumeAmount = parseFloat(html.price); if (totalVolumeAmount parseFloat(marketPriceValue)) { exitLoop = 1; var getActiveTab = $(".buySellTab").find(".active").attr("href");; if (getActiveTab == "#Limit") { $scope.buyPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.sellPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.buyPriceCalculation(); $scope.sellPriceCalculation(); } else if (getActiveTab == "#Market") { $scope.MarketbuyPrice = totalsecondaryCurrencyAmount.toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var calculateFee = 0; $scope.totalsecondaryCurrencyAmount = (parseFloat(totalGetCoin) + parseFloat(calculateFee)).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.marketBuyPriceCalculation(); } else if (getActiveTab == "#Scaled") { $scope.limitsellPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.limitBuyPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.limitBuyPriceCalculation(); $scope.limitsellPriceCalculation(); } } else { totalGetCoin += parseFloat(html.amount * html.price); totalsecondaryCurrencyAmount += parseFloat(html.amount); var getActiveTab = $(".buySellTab").find(".active").attr("href");; if (getActiveTab == "#Limit") { $scope.buyPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.sellPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.buyPriceCalculation(); $scope.sellPriceCalculation(); } else if (getActiveTab == "#Market") { $scope.MarketbuyPrice = parseFloat(totalsecondaryCurrencyAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); var calculateFee = 0; $scope.totalsecondaryCurrencyAmount = parseFloat(parseFloat(totalGetCoin) + parseFloat(calculateFee)).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.marketBuyPriceCalculation(); } else if (getActiveTab == "#Scaled") { $scope.limitsellPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.limitBuyPrice = parseFloat(price).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.limitBuyPriceCalculation(); $scope.limitsellPriceCalculation(); } } } }); } else { var getActiveTab = $(".buySellTab").find(".active").attr("href");; if (getActiveTab == "#Limit") { $scope.buyPrice = 0; $scope.buyPriceCalculation(); $scope.sellPriceCalculation(); } else if (getActiveTab == "#Market") { $scope.MarketbuyPrice = 0; $scope.totalsecondaryCurrencyAmount = 0; $scope.marketBuyPriceCalculation(); } else if (getActiveTab == "#Scaled") { $scope.limitBuyPrice = 0; $scope.limitBuyPriceCalculation(); $scope.limitsellPriceCalculation(); } } $('html, body').animate({ scrollTop: 650 }, 1000); } $scope.increment = function() { $scope.buyPrice = (parseFloat($scope.buyPrice) + 1 / ("1e" + $scope.BASE_CURRENCY_COIN_DIGITS)).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); }; $scope.decrement = function() { $scope.buyPrice = (parseFloat($scope.buyPrice) - 1 / ("1e" + $scope.BASE_CURRENCY_COIN_DIGITS)).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); }; $scope.sellIncrement = function() { $scope.sellPrice = (parseFloat($scope.sellPrice) + 1 / ("1e" + $scope.BASE_CURRENCY_COIN_DIGITS)).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); }; $scope.sellDecrement = function() { $scope.sellPrice = (parseFloat($scope.sellPrice) - 1 / ("1e" + $scope.BASE_CURRENCY_COIN_DIGITS)).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); }; $scope.errorMarketFunds = ""; $scope.errorMarketAmount = ""; $scope.errorBuyPrice = ""; $scope.limitErrorBuyPrice = ""; $scope.errorBuyAmount = ""; $scope.errorTotalAmount = ""; $scope.successBuyCoinMsg = ""; $scope.errorBuyCoinMsg = ""; $scope.errorSellPrice = ""; $scope.errorSellAmount = ""; $scope.errorSellTotalAmount = ""; $scope.successSellCoinMsg = ""; $scope.errorSellCoinMsg = ""; $scope.totalerrorBuyAmount = ""; $scope.totalerrorSellAmount = ""; $scope.Random_Buy = function(item, index) { buyPrice = M(Math.random() * (1.120 - 1.000) + 0.0200).toFixed(8); buyAmount = (Math.random() * (1.120 - 1.000) + 0.0200).toFixed(8); var started = new Date().getTime(); $scope.createOrder("BUY", buyPrice, buyAmount, $scope.currency1, $scope.currency2, $scope.buyTotalAmount, "limit"); $scope.updateBalaceOnClientSide("BUY", buyPrice, buyAmount, $scope.currency1, $scope.currency2, "limit"); }; $scope.Random_Sell = function(item, index) { sellPrice = 0.0004; sellAmount = 1; var started = new Date().getTime(); $scope.createOrder("SELL", sellPrice, sellAmount, $scope.currency1, $scope.currency2, $scope.buyTotalAmount, "limit"); $scope.updateBalaceOnClientSide("SELL", sellPrice, sellAmount, $scope.currency1, $scope.currency2, "limit"); }; $scope.buyCoin = function(item, index) { if ($scope.isProcessLastOrder == 0) { return false; } $scope.errorBuyPrice = ""; $scope.errorBuyAmount = ""; $scope.errorTotalAmount = ""; $scope.successBuyCoinMsg = ""; $scope.errorBuyCoinMsg = ""; $scope.totalerrorBuyAmount = ""; $scope.errorLoginBuyCoin = ""; $scope.errorLoginBuyCoin = "Please login to buy coin."; }; $scope.limitbuyCoin = function(item, index) { if ($scope.isProcessLastOrder == 0) { return false; } $scope.limitErrorBuyPrice = ""; $scope.stopBuyPriceError = ""; $scope.limiterrorBuyAmount = ""; $scope.totallimiterrorBuyAmount = ""; $scope.limiterrorTotalAmount = ""; $scope.successBuyCoinMsg = ""; $scope.errorBuyCoinMsg = ""; $scope.limiterrorLoginBuyCoin = ""; $scope.limiterrorLoginBuyCoin = "Please login to buy coin."; }; $scope.buyCoinMarket = function(item, index) { if ($scope.isProcessLastOrder == 0) { return false; } $scope.errorMarketFunds = ""; $scope.errorBuyCoinMsgMarket = ""; $scope.successBuyCoinMsgMarket = ""; $scope.errorLoginBuyCoinMarket = ""; $scope.errortotalsecondaryCurrencyAmount = ""; $scope.errorLoginBuyCoinMarket = "Please login to buy coin."; }; $scope.marketBuyPriceCalculation = function(item, index) { $(".popovercontent").hide(); if (item == 'marketbuyPrice') { if ($scope.MarketbuyPrice != "") { var dataPrice = parseFloat(parseFloat($scope.MarketbuyPrice) * parseFloat($scope.priceInUsd)); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".marketBuyPricePopOver").html($scope.currencySymbol + parseFloat(dataPrice).toFixed(8)); } else { $(".marketBuyPricePopOver").html(parseFloat(dataPrice).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".marketBuyPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".marketBuyPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".marketBuyPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".marketBuyPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } $(".marketBuyPricePopOver").show() } } if ($scope.MarketbuyPrice != "" || $scope.MarketbuyPrice > 0) { calculationMarketMaximumValueInBuy(); var marketPriceValue = $scope.MarketbuyPrice; var totalVolumeAmount = 0; var exitLoop = 0; var totalsecondaryCurrencyAmount = 0; angular.forEach($scope.sellOrders, function(html, key) { if (exitLoop == 0) { totalVolumeAmount += parseFloat(html.amount); if (parseFloat(totalVolumeAmount) >= parseFloat(marketPriceValue)) { exitLoop = 1; if (parseFloat(totalVolumeAmount) == parseFloat(marketPriceValue)) { totalsecondaryCurrencyAmount += parseFloat(html.price * html.amount); var calculateFee = 0; $scope.totalsecondaryCurrencyAmount = (totalsecondaryCurrencyAmount + calculateFee).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { remainingAmount = marketPriceValue - parseFloat(totalVolumeAmount - parseFloat(html.amount)); totalsecondaryCurrencyAmount += html.price * remainingAmount; var calculateFee = 0; $scope.totalsecondaryCurrencyAmount = (totalsecondaryCurrencyAmount + calculateFee).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } } else { totalsecondaryCurrencyAmount += parseFloat(html.amount * html.price); } } }); } else { $scope.totalsecondaryCurrencyAmount = 0; } }; function calculationMarketMaximumValue() { var orderFinalAmountValue = 0; angular.forEach($scope.buyOrders, function(html, key) { orderFinalAmountValue += parseFloat(html.amount); }); if (orderFinalAmountValue > 0) { if ($scope.MarketsellPrice > orderFinalAmountValue) { $scope.MarketsellPrice = parseFloat(orderFinalAmountValue).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } } else { $scope.MarketsellPrice = 0; } } function calculationMarketMaximumValueInBuy() { var orderFinalAmountValue = 0; angular.forEach($scope.sellOrders, function(html, key) { orderFinalAmountValue += parseFloat(html.amount); }); if (orderFinalAmountValue > 0) { if ($scope.MarketbuyPrice > orderFinalAmountValue) { $scope.MarketbuyPrice = orderFinalAmountValue; } } else { $scope.MarketbuyPrice = 0; } } $scope.marketSellPriceCalculation = function(item, index) { $(".popovercontent").hide(); if (item == 'marketsellPrice') { if ($scope.MarketsellPrice != "") { var dataPrice = parseFloat(parseFloat($scope.MarketsellPrice) * parseFloat($scope.priceInUsd)); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".marketSellPricePopOver").html($scope.currencySymbol + parseFloat(dataPrice).toFixed(8)); } else { $(".marketSellPricePopOver").html(parseFloat(dataPrice).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".marketSellPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".marketSellPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".marketSellPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".marketSellPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } $(".marketSellPricePopOver").show() } } $scope.buyOrders = $filter('orderBy')($scope.buyOrders, '-price'); if ($scope.MarketsellPrice != "" || $scope.MarketsellPrice > 0) { calculationMarketMaximumValue(); var marketPriceValue = $scope.MarketsellPrice; var totalVolumeAmount = 0; var exitLoop = 0; var totalBaseCurrencyAmount = 0; angular.forEach($scope.buyOrders, function(html, key) { if (exitLoop == 0) { totalVolumeAmount += parseFloat(html.amount); if (parseFloat(totalVolumeAmount) >= parseFloat(marketPriceValue)) { exitLoop = 1; remainingAmount = marketPriceValue - parseFloat(totalVolumeAmount - parseFloat(html.amount)); totalBaseCurrencyAmount += html.price * remainingAmount; $scope.totalBaseCurrencyAmount = (totalBaseCurrencyAmount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { totalBaseCurrencyAmount += parseFloat(html.price * html.amount); $scope.totalBaseCurrencyAmount = (totalBaseCurrencyAmount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } } }); } else { $scope.totalBaseCurrencyAmount = 0; } }; $scope.sellCoinMarket = function(item, index) { if ($scope.isProcessLastOrder == 0) { return false; } $scope.errorMarketAmount = ""; $scope.errorSellCoinMsgMarket = ""; $scope.successSellCoinMsgMarket = ""; $scope.errorLoginSellCoinMarket = ""; $scope.errortotalBaseCurrencyAmount = ""; $scope.errorLoginSellCoinMarket = "Please login to sell coin."; }; $scope.sellCoin = function(item, index) { if ($scope.isProcessLastOrder == 0) { return false; } $scope.errorSellPrice = ""; $scope.errorSellAmount = ""; $scope.errorSellTotalAmount = ""; $scope.successSellCoinMsg = ""; $scope.errorSellCoinMsg = ""; $scope.errorLoginSellCoin = ""; $scope.totalerrorSellAmount = ""; $scope.errorLoginSellCoin = "Please login to sell coin."; }; $scope.limitsellCoin = function(item, index) { if ($scope.isProcessLastOrder == 0) { return false; } $scope.limiterrorSellPrice = ""; $scope.errorSellAmount = ""; $scope.limiterrorSellAmount = ""; $scope.successSellCoinMsg = ""; $scope.errorSellCoinMsg = ""; $scope.stopSellPriceError = ""; $scope.limiterrorLoginSellCoin = ""; $scope.totallimiterrorSellAmount = ""; $scope.limiterrorLoginSellCoin = "Please login to sell coin."; }; $scope.buyPriceCalculation = function(item, index) { $(".popovercontent").hide(); if (item == 'buyPrice') { if ($scope.buyPrice != "") { var dataPrice = parseFloat(parseFloat($scope.buyPrice) * parseFloat($scope.priceInUsd)); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".buyPricePopOver").html($scope.currencySymbol + parseFloat($scope.buyPrice).toFixed(8)); } else { $(".buyPricePopOver").html(parseFloat($scope.buyPrice).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".buyPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".buyPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".buyPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".buyPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } $(".buyPricePopOver").show() } } $scope.buyTotalFee = 0; var total = (($scope.buyPrice > 0) && ($scope.buyAmount > 0)) ? parseFloat($scope.buyPrice * $scope.buyAmount) + parseFloat($scope.buyTotalFee) : 0; $scope.buyTotalAmount = parseFloat(total).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); }; $scope.removebuyPriceCalculation = function(item) { $(".popovercontent").hide(); } $scope.totalbuyPriceCalculation = function(item, index) { if ($scope.buyPrice > 0 && $scope.buyTotalAmount > 0) { var totalAmountToBePurchase = parseFloat($scope.buyTotalAmount).toFixed(18); var totalAmount = parseFloat(totalAmountToBePurchase) / parseFloat($scope.buyPrice); $scope.buyTotalFee = parseFloat(totalAmountToBePurchase).toFixed(18); $scope.buyAmount = parseFloat(totalAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.buyTotalFee = 0; $scope.buyAmount = 0; } }; $scope.sellPriceCalculation = function(item, index) { $(".popovercontent").hide(); if (item == 'sellPrice') { if ($scope.sellPrice != "") { var dataPrice = parseFloat(parseFloat($scope.sellPrice) * parseFloat($scope.priceInUsd)); if ($scope.convert_currency == "BTC" && $scope.currency1 == 'BTC') { if ($scope.alignCurrency == 'left') { $(".sellPricePopOver").html($scope.currencySymbol + parseFloat($scope.sellPrice).toFixed(8)); } else { $(".sellPricePopOver").html(parseFloat($scope.sellPrice).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.convert_currency == "BTC") { if ($scope.alignCurrency == 'left') { $(".sellPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8)); } else { $(".sellPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(8) + $scope.currencySymbol); } } else { if ($scope.alignCurrency == 'left') { $(".sellPricePopOver").html($scope.currencySymbol + parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2)); } else { $(".sellPricePopOver").html(parseFloat(parseFloat(dataPrice) * parseFloat($scope.convertCurrencyPrice)).toFixed(2) + $scope.currencySymbol); } } } $(".sellPricePopOver").show() } } $scope.sellTotalFee = 0; var total = (($scope.sellPrice > 0) && ($scope.sellAmount > 0)) ? parseFloat($scope.sellPrice * $scope.sellAmount) : 0; $scope.sellTotalAmount = total.toFixed($scope.BASE_CURRENCY_COIN_DIGITS); }; $scope.totalsellPriceCalculation = function(item, index) { if ($scope.sellPrice > 0 && $scope.sellTotalAmount > 0) { var totalAmountToBePurchase = parseFloat($scope.sellTotalAmount).toFixed(18); var totalAmount = parseFloat(totalAmountToBePurchase); $scope.sellTotalFee = 0; $scope.sellAmount = parseFloat(totalAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.sellTotalFee = 0; $scope.sellAmount = 0; } }; $scope.limitBuyPriceCalculation = function(item, index) { $(".popovercontent").hide(); if (item == 'limitBuyPrice') { if ($scope.limitBuyPrice != "") { $(".stopBuyPricePopOver").html("$" + parseFloat(parseFloat($scope.limitBuyPrice) * parseFloat($scope.priceInUsd)).toFixed(2)) $(".stopBuyPricePopOver").show() } } if ($scope.limitBuyPrice > 0 && $scope.limitBuyAmount > 0) { $scope.limitbuyTotalFee = 0; var total = (($scope.limitBuyPrice > 0) && ($scope.limitBuyAmount > 0)) ? parseFloat($scope.limitBuyPrice * $scope.limitBuyAmount) + parseFloat($scope.limitbuyTotalFee) : 0; $scope.limitbuyTotalAmount = parseFloat(total).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { $scope.sellTotalFee = 0; $scope.sellAmount = 0; } }; $scope.limitsellPriceCalculation = function(item, index) { $(".popovercontent").hide(); if (item == 'limitsellPrice') { if ($scope.limitsellPrice != "") { $(".stopSellPricePopOver").html("$" + parseFloat(parseFloat($scope.limitsellPrice) * parseFloat($scope.priceInUsd)).toFixed(2)) $(".stopSellPricePopOver").show() } } $scope.limitsellTotalFee = 0; var total = (($scope.limitsellPrice > 0) && ($scope.limitsellAmount > 0)) ? parseFloat($scope.limitsellPrice * $scope.limitsellAmount) - parseFloat($scope.limitsellTotalFee) : 0; $scope.limitsellTotalAmount = total.toFixed($scope.BASE_CURRENCY_COIN_DIGITS); }; $scope.sellPriceSplit = function(item, index) { if ($scope.sellPrice > 0 && $scope.secondaryCurrencywalletAmount > 0) { if (item == "100") { $scope.sellAmount = parseFloat($scope.secondaryCurrencywalletAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.sellAmount = parseFloat(parseFloat($scope.secondaryCurrencywalletAmount * item) / 100).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } $scope.sellTotalFee = 0; var total = (($scope.sellPrice > 0) && ($scope.sellAmount > 0)) ? parseFloat($scope.sellPrice * $scope.sellAmount) - parseFloat($scope.sellTotalFee) : 0; $scope.sellTotalAmount = total.toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else if ($scope.secondaryCurrencywalletAmount > 0) { if (item == "100") { $scope.sellAmount = parseFloat($scope.secondaryCurrencywalletAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.sellAmount = parseFloat(parseFloat($scope.secondaryCurrencywalletAmount * item) / 100).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } } }; $scope.buyPriceSplit = function(item, index) { if ($scope.buyPrice > 0 && $scope.baseCurrencywalletAmount > 0) { if (item == "100") { $scope.buyTotalAmount = parseFloat($scope.baseCurrencywalletAmount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { $scope.buyTotalAmount = parseFloat(parseFloat($scope.baseCurrencywalletAmount * item) / 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } if ($scope.buyPrice > 0 && $scope.buyTotalAmount > 0) { var totalAmountToBePurchase = parseFloat($scope.buyTotalAmount).toFixed(18); var totalAmount = parseFloat(totalAmountToBePurchase) / parseFloat($scope.buyPrice); $scope.buyTotalFee = parseFloat(totalAmountToBePurchase).toFixed(18); $scope.buyAmount = parseFloat(totalAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.buyTotalFee = 0; $scope.buyAmount = 0; } } else if ($scope.baseCurrencywalletAmount > 0) { if (item == "100") { $scope.buyTotalAmount = parseFloat($scope.baseCurrencywalletAmount).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { $scope.buyTotalAmount = parseFloat(parseFloat($scope.baseCurrencywalletAmount * item) / 100).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } } }; $scope.limitsellPriceSplit = function(item, index) { if ($scope.limitsellPrice > 0 && $scope.secondaryCurrencywalletAmount > 0) { if (item == "100") { $scope.limitsellAmount = parseFloat($scope.secondaryCurrencywalletAmount * item).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.limitsellAmount = parseFloat(parseFloat($scope.secondaryCurrencywalletAmount * item) / 100).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } $scope.limitsellTotalFee = 0; var total = (($scope.limitsellPrice > 0) && ($scope.limitsellAmount > 0)) ? parseFloat($scope.limitsellPrice * $scope.limitsellAmount) - parseFloat($scope.limitsellTotalFee) : 0; $scope.limitsellTotalAmount = parseFloat(total).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else if ($scope.secondaryCurrencywalletAmount > 0) { if (item == "100") { $scope.limitsellAmount = parseFloat($scope.secondaryCurrencywalletAmount * item).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.limitsellAmount = parseFloat(parseFloat($scope.secondaryCurrencywalletAmount * item) / 100).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } } }; $scope.totallimitsellPriceCalculation = function(item, index) { if ($scope.limitsellPrice > 0 && $scope.limitsellTotalAmount > 0) { var totalAmountToBePurchase = parseFloat($scope.limitsellTotalAmount).toFixed(18); var totalAmount = parseFloat(totalAmountToBePurchase) / parseFloat($scope.limitsellPrice); $scope.limitsellAmount = parseFloat(totalAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.limitsellAmount = 0; } }; function youwillgetcalculationBuyCalculation() { } $scope.youwillpaycalculation = function(item, index) { var total = $scope.totalsecondaryCurrencyAmount var marketPriceValue = parseFloat(total).toFixed(18); var totalVolFinalVal = 0; var totalAmtFinalVal = 0; angular.forEach($scope.sellOrders, function(html, key) { totalVolFinalVal += parseFloat(html.amount * html.price); totalAmtFinalVal += parseFloat(html.amount); }); if (parseFloat(marketPriceValue) > totalVolFinalVal) { total = parseFloat(totalVolFinalVal); var calculateFee = 0; marketPriceValue = parseFloat(totalVolFinalVal + calculateFee).toFixed(18); $scope.totalsecondaryCurrencyAmount = parseFloat(marketPriceValue).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.MarketbuyPrice = totalAmtFinalVal.toFixed(18); return false; } var totalVolumeAmount = 0; var exitLoop = 0; var totalsecondaryCurrencyAmount = 0; angular.forEach($scope.sellOrders, function(html, key) { if (exitLoop == 0) { totalVolumeAmount += parseFloat(html.amount * html.price); if (parseFloat(totalVolumeAmount) >= parseFloat(marketPriceValue)) { exitLoop = 1; if (parseFloat(totalVolumeAmount) == parseFloat(marketPriceValue)) { totalsecondaryCurrencyAmount += parseFloat(html.amount); $scope.MarketbuyPrice = (totalsecondaryCurrencyAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { remainingAmount = parseFloat(marketPriceValue - parseFloat(totalVolumeAmount - parseFloat(html.amount * html.price))); totalsecondaryCurrencyAmount += parseFloat(remainingAmount / html.price); $scope.MarketbuyPrice = (totalsecondaryCurrencyAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } } else { totalsecondaryCurrencyAmount += parseFloat(html.amount); } } }); }; $scope.youwillgetcalculation = function(item, index) { $scope.buyOrders = $filter('orderBy')($scope.buyOrders, '-price'); var total = parseFloat($scope.totalBaseCurrencyAmount); var marketPriceValue = parseFloat(total).toFixed(18); if (total != "" || total > 0) { var totalVolFinalVal = 0; var totalAmtFinalVal = 0; angular.forEach($scope.buyOrders, function(html, key) { totalVolFinalVal += parseFloat(html.amount * html.price); totalAmtFinalVal += parseFloat(html.amount); }); if (parseFloat(marketPriceValue) > totalVolFinalVal) { total = parseFloat(totalVolFinalVal); var calculateFee = 0; marketPriceValue = parseFloat(totalVolFinalVal - calculateFee).toFixed(18); $scope.totalBaseCurrencyAmount = parseFloat(marketPriceValue).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.MarketsellPrice = totalAmtFinalVal.toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); return false; } var totalVolumeAmount = 0; var exitLoop = 0; var MarketsellPrice = 0; angular.forEach($scope.buyOrders, function(html, key) { if (exitLoop == 0) { totalVolumeAmount += parseFloat(html.amount * html.price); if (parseFloat(totalVolumeAmount) >= parseFloat(marketPriceValue)) { exitLoop = 1; if (parseFloat(totalVolumeAmount) == parseFloat(marketPriceValue)) { MarketsellPrice += parseFloat(html.amount); $scope.MarketsellPrice = (MarketsellPrice).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { remainingAmount = parseFloat(marketPriceValue - parseFloat(totalVolumeAmount - parseFloat(html.amount * html.price))); MarketsellPrice += parseFloat(remainingAmount / html.price); $scope.MarketsellPrice = (MarketsellPrice).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } } else { MarketsellPrice += parseFloat(html.amount); } } }); } else { $scope.MarketsellPrice = 0; } }; $scope.limitbuyPriceSplit = function(item, index) { if ($scope.limitBuyPrice > 0 && $scope.baseCurrencywalletAmount > 0) { if (item == "100") { var total = parseFloat($scope.baseCurrencywalletAmount).toFixed(18); } else { var total = parseFloat(parseFloat($scope.baseCurrencywalletAmount * item) / 100).toFixed(18); } $scope.limitbuyTotalAmount = parseFloat(total).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); if ($scope.limitBuyPrice > 0 && $scope.limitbuyTotalAmount > 0) { var totalAmountToBePurchase = parseFloat($scope.limitbuyTotalAmount).toFixed(18); var totalAmount = parseFloat(totalAmountToBePurchase) / parseFloat($scope.limitBuyPrice); $scope.limitbuyTotalFee = 0; $scope.limitBuyAmount = parseFloat(totalAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.limitbuyTotalFee = 0; $scope.limitBuyAmount = 0; } } else if ($scope.baseCurrencywalletAmount > 0) { if (item == "100") { var total = parseFloat($scope.baseCurrencywalletAmount).toFixed(18); } else { var total = parseFloat(parseFloat($scope.baseCurrencywalletAmount * item) / 100).toFixed(18); } $scope.limitbuyTotalAmount = parseFloat(total).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } }; $scope.totallimitBuyPriceCalculation = function(item, index) { if ($scope.limitBuyPrice > 0 && $scope.limitbuyTotalAmount > 0) { var totalAmountToBePurchase = parseFloat($scope.limitbuyTotalAmount).toFixed(18); var totalAmount = parseFloat(totalAmountToBePurchase) / parseFloat($scope.limitBuyPrice); $scope.limitbuyTotalFee = parseFloat(totalAmountToBePurchase).toFixed(18); $scope.limitBuyAmount = parseFloat(totalAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.limitbuyTotalFee = 0; $scope.limitBuyAmount = 0; } }; $scope.sellPriceSplitMarket = function(item, index) { if (item == "100") { $scope.MarketsellPrice = parseFloat($scope.secondaryCurrencywalletAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { $scope.MarketsellPrice = parseFloat((item / 100) * $scope.secondaryCurrencywalletAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } $scope.buyOrders = $filter('orderBy')($scope.buyOrders, '-price'); if ($scope.MarketsellPrice != "" || $scope.MarketsellPrice > 0) { calculationMarketMaximumValue(); var marketPriceValue = $scope.MarketsellPrice; var totalVolumeAmount = 0; var exitLoop = 0; var totalBaseCurrencyAmount = 0; angular.forEach($scope.buyOrders, function(html, key) { if (exitLoop == 0) { totalVolumeAmount += parseFloat(html.amount); if (parseFloat(totalVolumeAmount) >= parseFloat(marketPriceValue)) { exitLoop = 1; remainingAmount = marketPriceValue - parseFloat(totalVolumeAmount - parseFloat(html.amount)); totalBaseCurrencyAmount += html.price * remainingAmount; var calculateFee = 0; $scope.totalBaseCurrencyAmount = (totalBaseCurrencyAmount - calculateFee).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } else { totalBaseCurrencyAmount += parseFloat(html.price * html.amount); var calculateFee = 0; $scope.totalBaseCurrencyAmount = (totalBaseCurrencyAmount - calculateFee).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); } } }); } }; $scope.buyPriceSplitMarket = function(item, index) { if (item == "100") { var total = parseFloat($scope.baseCurrencywalletAmount).toFixed(18); } else { var total = parseFloat(parseFloat($scope.baseCurrencywalletAmount * item) / 100).toFixed(18); } $scope.totalsecondaryCurrencyAmount = parseFloat(total).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); var marketPriceValue = parseFloat(total).toFixed(18); var totalVolFinalVal = 0; var totalAmtFinalVal = 0; angular.forEach($scope.sellOrders, function(html, key) { totalVolFinalVal += parseFloat(html.amount * html.price); totalAmtFinalVal += parseFloat(html.amount); }); if (parseFloat(marketPriceValue) > totalVolFinalVal) { total = parseFloat(totalVolFinalVal); var calculateFee = 0; marketPriceValue = parseFloat(totalVolFinalVal + calculateFee).toFixed(18); $scope.totalsecondaryCurrencyAmount = parseFloat(marketPriceValue).toFixed($scope.BASE_CURRENCY_COIN_DIGITS); $scope.MarketbuyPrice = totalAmtFinalVal.toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); return false; } var totalVolumeAmount = 0; var exitLoop = 0; var totalsecondaryCurrencyAmount = 0; angular.forEach($scope.sellOrders, function(html, key) { if (exitLoop == 0) { totalVolumeAmount += parseFloat(html.amount * html.price); if (parseFloat(totalVolumeAmount) >= parseFloat(marketPriceValue)) { exitLoop = 1; if (parseFloat(totalVolumeAmount) == parseFloat(marketPriceValue)) { totalsecondaryCurrencyAmount += parseFloat(html.amount); $scope.MarketbuyPrice = (totalsecondaryCurrencyAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } else { remainingAmount = parseFloat(marketPriceValue - parseFloat(totalVolumeAmount - parseFloat(html.amount * html.price))); totalsecondaryCurrencyAmount += parseFloat(remainingAmount / html.price); $scope.MarketbuyPrice = (totalsecondaryCurrencyAmount).toFixed($scope.SECONDARY_CURRENCY_COIN_DIGITS); } } else { totalsecondaryCurrencyAmount += parseFloat(html.amount); } } }); }; $scope.deleteOrder = function(orderId, type, user_id) { $scope.deleteTradeOrder(orderId, type); $(".openorder_" + orderId + "_" + type).remove(); if ($(".openorder_history").length
Buy Volume <@ totalBuyVolume | number:SECONDARY_CURRENCY_COIN_DIGITS @> <@ currency1 @>
Sell Volume <@ totalSellAmount | number:SECONDARY_CURRENCY_COIN_DIGITS @> <@ currency2 @>
  • Order Book
    Price <@ currency1 @>
    Amount <@ currency2 @>
    Volume <@ currency1 @>
    <@ sellOrder.price | number : BASE_CURRENCY_COIN_DIGITS @>
    <@ sellOrder.amount | number: SECONDARY_CURRENCY_COIN_DIGITS @>
    <@ (sellOrder.price * sellOrder.amount) | number:BASE_CURRENCY_COIN_DIGITS @>
     <@ lastPriceTicker | number:BASE_CURRENCY_COIN_DIGITS @> ≈ $<@ buysellboxlastpriceinusd | number:'2' @>
    <@ buyOrder.price | number : BASE_CURRENCY_COIN_DIGITS @>
    <@ buyOrder.amount | number: SECONDARY_CURRENCY_COIN_DIGITS @>
    <@ (buyOrder.price * buyOrder.amount) | number:BASE_CURRENCY_COIN_DIGITS @>
  • Order History
    Price <@ currency1 @>
    Amount <@ currency2 @>
    Time
× <@ successBuyCoinMsg @>
× <@ errorBuyCoinMsg @>
× <@ successSellCoinMsg @>
× <@ errorSellCoinMsg @>
Buy <@ currency2 @> Available <@ currency1 @>: – –
<@ errorTotalAmount @>
Fee: <@ buyTotalFee | number:BASE_CURRENCY_COIN_DIGITS @> <@ currency1 @>
Log In Or Register Now To Trade
<@ errorLoginBuyCoin @>
Sell <@ currency2 @> Available <@ currency2 @>: – –
<@ errorSellTotalAmount @>
Fee: <@ sellTotalFee @> <@ currency1 @>
Log In Or Register Now To Trade
<@ errorLoginSellCoin @>
Buy <@ currency2 @> Available <@ currency1 @>: – –
<@ errorTotalAmount @>
Log In Or Register Now To Trade
<@ errorLoginBuyCoinMarket @>
Sell <@ currency2 @> Available <@ currency2 @>: – –
<@ errorSellTotalAmount @>
Log In Or Register Now To Trade
<@ errorLoginSellCoinMarket @>