After retrieving values from a JSON URL, using the following code:
$(document).ready(function () {
function price(){
$.getJSON('https://poloniex.com/public?command=returnTicker', function(data){
document.getElementById('PoloniexLastNXT').innerHTML = (data.BTC_NXT.last);
document.getElementById('PoloniexBidNXT').innerHTML = (data.BTC_NXT.highestBid);
document.getElementById('PoloniexAskNXT').innerHTML = (data.BTC_NXT.lowestAsk);
});
$.getJSON('trade/libs/bittrex.php?i=nxt', function(data){
document.getElementById('BittrexLastNXT').innerHTML = (data.Bittrex);
document.getElementById('BittrexBidNXT').innerHTML = (data.BittrexBid);
document.getElementById('BittrexAskNXT').innerHTML = (data.BittrexAsk);
});
$.getJSON('trade/libs/hitbtc2.php?i=NXT', function(data){
document.getElementById('HitbtcLastNXT').innerHTML = (data.hitbtc);
document.getElementById('HitbtcBidNXT').innerHTML = (data.hitbtcbid);
document.getElementById('HitbtcAskNXT').innerHTML = (data.hitbtcask);
});
$.getJSON('https://vip.bitcoin.co.id/api/nxt_btc/ticker', function(data) {
document.getElementById('priceLastNXT').innerHTML = (data.ticker.last);
document.getElementById('priceLashBuyNXT').innerHTML = (data.ticker.buy);
document.getElementById('priceLashSellNXT').innerHTML = (data.ticker.sell);
document.title = "NXT " + (data.ticker.last);
});
}
setInterval(price, 3000);
});
Is it possible to do the following?
function getMax(array){
return Math.max.apply(Math,array);
}
var NxtBid = document.getElementById("PoloniexBidNXT");
var NxtBid2 = document.getElementById("BittrexBidNXT");
var NxtBid3 = document.getElementById("HitbtcBidNXT");
var NxtBid4 = document.getElementById("priceLashBuyNXT");
var NxtBid5 = [NxtBid, NxtBid2, NxtBid3, NxtBid4];
var NxtBid6 = getMax(NxtBid5);
document.getElementById("NxtBidMax").innerHTML = NxtBid6;
I am looking to set both low and high prices from PoloniexLastNXT, BittrexLastNXT, HitbtcLastNXT, and priceLastNXT. Can someone assist me with this?