| 1 |
var assets_list = [ |
| 2 |
{ |
| 3 |
"Name": "Bitcoin", |
| 4 |
"Pair": "btc_idr", |
| 5 |
"Code": "BTC" |
| 6 |
}, |
| 7 |
{ |
| 8 |
"Name": "Cardano", |
| 9 |
"Pair": "ada_idr", |
| 10 |
"Code": "ADA" |
| 11 |
}, |
| 12 |
{ |
| 13 |
"Name": "Bitcoin Diamon", |
| 14 |
"Pair": "bcd_idr", |
| 15 |
"Code": "BCD" |
| 16 |
}, |
| 17 |
{ |
| 18 |
"Name": "Bitcoin Cash", |
| 19 |
"Pair": "bch_idr", |
| 20 |
"Code": "BCH" |
| 21 |
}, |
| 22 |
{ |
| 23 |
"Name": "Bitcoin Gold", |
| 24 |
"Pair": "btg_idr", |
| 25 |
"Code": "BTG" |
| 26 |
}, |
| 27 |
{ |
| 28 |
"Name": "Ethereum", |
| 29 |
"Pair": "eth_idr", |
| 30 |
"Code": "ETH" |
| 31 |
}, |
| 32 |
{ |
| 33 |
"Name": "Ethereum Classic", |
| 34 |
"Pair": "etc_idr", |
| 35 |
"Code": "ETC" |
| 36 |
}, |
| 37 |
{ |
| 38 |
"Name": "IGNIS", |
| 39 |
"Pair": "ignis_idr", |
| 40 |
"Code": "IGNIS" |
| 41 |
}, |
| 42 |
{ |
| 43 |
"Name": "Litecoin", |
| 44 |
"Pair": "ltc_idr", |
| 45 |
"Code": "LTC" |
| 46 |
}, |
| 47 |
{ |
| 48 |
"Name": "NXT", |
| 49 |
"Pair": "nxt_idr", |
| 50 |
"Code": "NXT" |
| 51 |
}, |
| 52 |
{ |
| 53 |
"Name": "Stellar Lumens", |
| 54 |
"Pair": "str_idr", |
| 55 |
"Code": "XLM" |
| 56 |
}, |
| 57 |
{ |
| 58 |
"Name": "Tokenomy", |
| 59 |
"Pair": "ten_idr", |
| 60 |
"Code": "TEN" |
| 61 |
}, |
| 62 |
{ |
| 63 |
"Name": "Waves", |
| 64 |
"Pair": "waves_idr", |
| 65 |
"Code": "WAVES" |
| 66 |
}, |
| 67 |
{ |
| 68 |
"Name": "Ripple", |
| 69 |
"Pair": "xrp_idr", |
| 70 |
"Code": "XRP" |
| 71 |
}, |
| 72 |
{ |
| 73 |
"Name": "ZCoin", |
| 74 |
"Pair": "xzc_idr", |
| 75 |
"Code": "XZC" |
| 76 |
} |
| 77 |
]; |
| 78 |
|
| 79 |
function indodax_thousand_separator(nStr) { |
| 80 |
nStr += ''; |
| 81 |
x = nStr.split('.'); |
| 82 |
x1 = x[0]; |
| 83 |
x2 = x.length > 1 ? '.' + x[1] : ''; |
| 84 |
var rgx = /(\d+)(\d{3})/; |
| 85 |
while (rgx.test(x1)) { |
| 86 |
x1 = x1.replace(rgx, '$1' + '.' + '$2'); |
| 87 |
} |
| 88 |
return x1 + x2; |
| 89 |
} |
| 90 |
|
| 91 |
function indodax_http_get_async(Url, callback, item) { |
| 92 |
var xmlHttp = new XMLHttpRequest(); |
| 93 |
xmlHttp.onreadystatechange = function() { |
| 94 |
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) |
| 95 |
callback(JSON.parse(xmlHttp.responseText), item); |
| 96 |
} |
| 97 |
xmlHttp.open("GET", Url, true); // true for asynchronous |
| 98 |
xmlHttp.send(null); |
| 99 |
} |
| 100 |
|
| 101 |
function indodax_render_data(response, data) { |
| 102 |
var table_list = document.getElementById("indodax-data-list"); |
| 103 |
table_list.innerHTML += '<tr><td><span class="indodax-info-code">' |
| 104 |
+data.Code+ |
| 105 |
'</span></td><td><span class="indodax-info-name">' |
| 106 |
+data.Name+ |
| 107 |
'</span></td><td><span class="indodax-info-last">IDR ' |
| 108 |
+indodax_thousand_separator(response.ticker.last)+ |
| 109 |
'</span></td><td><span class="indodax-info-high">' |
| 110 |
+indodax_thousand_separator(response.ticker.high)+ |
| 111 |
'</span> <span class="indodax-info-separator">/</span><span class="indodax-info-low">' |
| 112 |
+indodax_thousand_separator(response.ticker.low)+ |
| 113 |
'</span></td></tr>'; |
| 114 |
} |
| 115 |
|
| 116 |
function indodax_get_data(assets) { |
| 117 |
for (var i in assets) { |
| 118 |
var item = assets[i]; |
| 119 |
var a_pair = item.Pair; |
| 120 |
var Url = "https://indodax.com/api/" +a_pair+ "/ticker"; |
| 121 |
indodax_http_get_async(Url, indodax_render_data, item); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
// Action |
| 126 |
indodax_get_data(assets_list); |
To add a comment, please login or register first.
Register or Login