-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.js
More file actions
93 lines (92 loc) · 2.71 KB
/
settings.js
File metadata and controls
93 lines (92 loc) · 2.71 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
89
90
91
92
93
var settings = new Vue({
el: '#settings',
data: {
email: '',
uuid: '',
username: '',
xaddress: '',
raddress: '',
withdrawAddress: '',
withdrawAddressError: false,
withdrawConfirm: false,
withdrawConfirmError: false,
withdrawLoading: false,
transactions: []
},
created: function() {
getApi(`/account`, '', function (data, status) {
var account = JSON.parse(data);
settings.uuid = account.uuid;
settings.email = account.email;
settings.username = account.username;
getApi(`/transactions`, '', function (data, status) {
settings.transactions = JSON.parse(data);
for (var i in settings.transactions) {
var transaction = settings.transactions[i];
if (transaction.src_account_uuid == settings.uuid) {
transaction.drops = -transaction.drops;
}
queryAccountsCache(transaction.src_account_uuid, function (account) {
for (var j in settings.transactions) {
if (settings.transactions[j].src_account_uuid == account.uuid) {
settings.transactions[j].src = account.username;
}
}
settings.$forceUpdate();
});
queryAccountsCache(transaction.dest_account_uuid, function (account) {
for (var j in settings.transactions) {
if (settings.transactions[j].dest_account_uuid == account.uuid) {
settings.transactions[j].dest = account.username;
}
}
settings.$forceUpdate();
});
}
});
});
getApi(`/wallet`, '', function (data, status) {
settings.xaddress = JSON.parse(data).addresses.xaddress;
settings.raddress = JSON.parse(data).addresses.raddress;
});
},
filters: {
convert: function (value) {
return moment(value, 'x').fromNow();
}
},
methods: {
withdraw: function() {
if (this.withdrawLoading) {
return;
}
this.withdrawAddressError = false;
this.withdrawConfirmError = false;
if (!this.withdrawConfirm) {
this.withdrawConfirmError = 'Please recognize that this action is irreversable.';
return;
}
this.withdrawLoading = true;
getApi(`/withdraw`, `?address=${this.withdrawAddress}`, function (data, status) {
settings.withdrawLoading = false;
if (status == 500) {
settings.withdrawAddressError = 'Our servers encountered a problem while processing your withdraw.';
}
else if (status == 400) {
settings.withdrawAddressError = JSON.parse(data).message || 'There was a problem withdrawing to this address. Please ensure that this address isn\'t invalid.';
}
else {
location.reload();
}
});
},
copy: function (selector) {
var el = document.querySelector(`${selector}`);
el.select();
document.execCommand('copy');
},
signout: function () {
location.href = '/signout.html';
}
}
})