-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.js
More file actions
88 lines (79 loc) · 2.68 KB
/
Copy pathdashboard.js
File metadata and controls
88 lines (79 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//USER = user
function request(url)
{
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.send();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && xhr.status == 200) {
return JSON.parse(xhr.responseText);
}
};
}
$(document).ready(function() {
request('http://35.156.51.182:8000/user_login/user/userp/');
var getExchanges = request('http://35.156.51.182:8000/sphoin/crypto/user/exchanges/');
//var getExchanges = ['FXCM', 'BINANCE'];
// data to populate first selector + FXCM
$('.select-exchange').select2({
placeholder: "Select exchange",
data: getExchanges
//data from getExchanges
});
$('.select-COIN1').select2();
$('.select-COIN2').select2();
$('.select-interval').select2();
});
$('#select-exchange').on('select2:select', function (e) {
// alert(Cookies.get('user'));
//---data from routes---
if (e.params.data.text == 'FXCM') {
var getFxcmCoins = 'http://35.156.51.182:8000/sphoin/fxcm/USER/basecoin/';
var getFxcmIntervals = 'http://35.156.51.182:8000/sphoin/fxcm/USER/intervals/';
var fxcm_coin1 = ['FCOIN1', 'FCOIN2'];
var fxcm_coin2 = ['FCOIN3', 'FCOIN4'];
var fxcm_interval = ['FXCMINTERVAL1','FXCMINTERVAL2'];
/* get data fxcm coins
intervals
*/
$('.select-COIN1').empty();
$(".select-COIN1").select2({
data: fxcm_coin1 // result from exchanges
})
$('.select-COIN2').empty();
$(".select-COIN2").select2({
data: fxcm_coin2 // result from exchanges
})
$('.select-interval').empty();
$('.select-interval').select2({
data: fxcm_interval //result from interval
});
}
else {
var getCryptoCoins = 'http://35.156.51.182:8000/sphoin/crypto/USER/EXCHANGE/basecoin/'; // get data from this url BINANCE = EXCHANGE
var getCryptoIntervals = 'http://35.156.51.182:8000/sphoin/crypto/USER/intervals/';
var crypto_interval = ['CRYPTOINTERVAL1', 'CRYPTOINTERVAL2'];
var crypto_coin1 = ['BTC1', 'ETH1'];
var crypto_coin2 = ['BTC2', 'ETH2'];
/* get data crypto_coin1
crypto_coin2
crypto_interval
*/
$('.select-COIN1').empty();
$(".select-COIN1").select2({
data: crypto_coin1 //result from exchanges
})
$('.select-COIN2').empty();
$(".select-COIN2").select2({
data: crypto_coin2 //result from exchanges
})
$('.select-interval').empty();
$('.select-interval').select2({
data: crypto_interval // result from intervals
});
// .4 /sphoin/crypto/USER/EXCHANGE/COIN1/COIN2/INTERVAL/
// sau /sphoin/fxcm/USER/COIN1/COIN2/INTERVAL/
// BINANCE nume de exchange
// EXCHANGE nume de magazin
}
});