nassyafir / Indodax IDR Market

Cloned from adierebel / Indodax IDR Market

15 May 2018 at 15:48

1 .indodax-container .indodax-table {
2 border: 1px solid #ddd;
3 border-spacing: 0;
4 border-collapse: collapse;
5 }
6 .indodax-container .indodax-table thead tr th {
7 vertical-align: bottom;
8 padding: 8px;
9 text-align: left;
10 line-height: 1.42857143;
11 border: 1px solid #ddd;
12 border-top: 0;
13 border-bottom-width: 2px;
14 }
15 .indodax-container .indodax-table tbody tr td {
16 border: 1px solid #ddd;
17 padding: 8px;
18 line-height: 1.42857143;
19 vertical-align: top;
20 }
21 .indodax-container .indodax-table .indodax-data-list .indodax-info-code {
22 font-weight: bold;
23 }
24 .indodax-container .indodax-table .indodax-data-list .indodax-info-name {
25 color: #454545;
26 }
27 .indodax-container .indodax-table .indodax-data-list .indodax-info-last {
28 color: #01579b;
29 font-weight: bold;
30 }
31 .indodax-container .indodax-table .indodax-data-list .indodax-info-high {
32 color: #558b2f;
33 }
34 .indodax-container .indodax-table .indodax-data-list .indodax-info-low {
35 color: #d32f2f;
36 }
37 .indodax-container .indodax-table .indodax-data-list .indodax-info-separator {
38 color: #999;
39 }
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <title>Indodax Trade</title>
6 <meta name="description" content="Indodax">
7 <meta name="author" content="Indodax">
8 <link href="style.css" rel="stylesheet">
9 <!--[if lt IE 9]>
10 <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
11 <![endif]-->
12 </head>
13 <body>
14 <div class="indodax-container">
15 <table class="indodax-table">
16 <thead>
17 <tr>
18 <th>Code</th>
19 <th>Name</th>
20 <th>Last Price</th>
21 <th>High / Low</th>
22 </tr>
23 </thead>
24 <tbody id="indodax-data-list" class="indodax-data-list">
25 </tbody>
26 </table>
27 </div>
28 <script src="indodax.js"></script>
29 </body>
30 </html>
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);

Comments (0)