-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.html
194 lines (191 loc) · 10.7 KB
/
index.html
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Eleos - Equihash Wallet and Messaging</title>
<link rel="stylesheet" href="resources/w3.css">
<link rel="stylesheet" href="resources/styles.css">
</head>
<body>
<div class="containerDiv w3-light-gray">
<div class="tabsBar">
<ul class="w3-navbar w3-light-gray">
<!--<li><a class="navLink" id="networkTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('networkPage')">Network</a></li>-->
<li><a class="navLink" id="historyTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('historyPage')">History</a></li>
<li><a class="navLink" id="memoTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('memoPage')">Memos</a></li>
<li><a class="navLink" id="sendTTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('sendTransparentPage')">Send Transparent</a></li>
<li><a class="navLink" id="sendPTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('sendPrivatePage')">Send Private</a></li>
<li><a class="navLink" id="receiveTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('receivePage')">Receive</a></li>
<li><a class="navLink" id="addressesTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('addressesPage')">Addresses</a></li>
<!--<li><a class="navLink" id="consoleTab" href="javascript:void(0)" onclick="setActiveNav(this); openPage('consolePage')">Console</a></li>-->
</ul>
</div>
<div class="bodyDiv" id="bodyDiv">
<span class="alertSpan" id="alertSpan"></span>
<div class="page" id="networkPage"></div>
<div class="page" id="historyPage">
<span id="transactionTransparentSpan"></span>
<span id="transactionPrivateSpan"></span>
</div>
<div class="page" id="memoPage"></div>
<div class="page w3-container" id="sendTransparentPage">
<form class="w3-container w3-margin-top w3-medium">
<div class="w3-container">
<label id="transparentAvailableField">Available Transparent Balance: </label><span class="" id="transparentAvailableValue"> </span><br /><br />
<label id="transparentSendToField">Send To</label><input class="w3-input w3-round" type="text" id="transparentSendToValue"> </input>
<label id="transparentAmountField">Amount</label><input class="w3-input w3-round" type="number" id="transparentAmountValue"> </input>
</div>
<div class="w3-container w3-center w3-margin-top">
<button type="button" id="transparentSendButton" onclick="sendTransparentTransaction()">Send</button>
<button type="button" id="transparentResetButton" onclick="transparentReset()">Reset</button>
</div>
</form>
</div>
<div class="page w3-container" id="sendPrivatePage">
<form class="w3-container w3-margin-top w3-medium">
<div class="w3-container">
<label id="privateFromField">From</label><select class="w3-select w3-round w3-small" id="privateFromSelect"></select>
<label id="privateSendToField">Send To</label><input class="w3-input w3-round" type="text" id="privateSendToValue"> </input>
<label id="privateAmountField">Amount</label><input class="w3-input w3-round" type="number" id="privateAmountValue"> </input>
<label id="privateMemoField">Encrypted Memo</label><input class="w3-input w3-round" type="text" id="privateMemoValue"> </input>
</div>
<div class="w3-container w3-center w3-margin-top">
<button type="button" id="privateSendButton" onclick="sendPrivateTransaction()">Send</button>
<button type="button" id="privateResetButton" onclick="privateReset()">Reset</button>
</div>
</form>
</div>
<div class="page w3-container" id="receivePage">
<form class="w3-container w3-margin-top w3-medium">
<div class="w3-container">
<label id="receivingAddressField">Receiving Address</label><input class="w3-input w3-round" type="text" id="receivingAddressValue"> </input>
<label id="descriptionField">Description</label><input class="w3-input w3-round" type="text" id="descriptionValue"> </input>
<label id="requestedAmountField">Requested Amount</label><input class="w3-input w3-round" type="number" id="requestedAmountValue"></input>
</div>
<div class="w3-container w3-center w3-margin-top">
<button type="button" id="newTransparentAddress" onclick="getNewTransparentAddress()">New Transparent Address</button>
<button type="button" id="existingPrivateAddress" onclick="getNewPrivateAddress()">Re-use Private Address</button>
<button type="button" id="newPrivateAddress" onclick="getNewPrivateAddress()">New Private Address</button>
</div>
<div class="w3-container w3-center w3-margin-top">
<!--<button type="button" id="generateQR" onclick="">Generate QR Code</button>-->
</div>
</form>
</div>
<div class="page" id="addressesPage">
<span id="addressTransparentSpan"></span>
<span id="addressPrivateSpan"></span>
</div>
<div class="page" id="consolePage"></div>
</div>
<div class="statusBar">
<span class="w3-small" id="statusBar">Current Balance: <span class="w3-small" id="currentBalanceValue"></span> <span class="w3-small" id="coin"></span>
(Transparent: <span class="w3-small" id="transparentBalanceValue"></span> / Private: <span class="w3-small" id="privateBalanceValue"></span> )
<span class="w3-small w3-right-align" id="connectionsField">| Connections: <span class="w3-small" id="connectionsValue"></span></span>
</span>
</div>
</div>
</body>
<script>
const renderer = require('./renderer.js');
function openPage(pageName) {
if (document.getElementById("alertSpan").innerHTML.length < 2) {
var i;
var x = document.getElementsByClassName("page");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
document.getElementById(pageName).style.display = "block";
}
}
function setActiveNav(element) {
for (let i = 0; i < document.getElementsByClassName('navLink').length; i ++) {
document.getElementsByClassName('navLink')[i].className = 'navLink';
}
element.className += ' w3-green';
}
/* // TODO: add emoji support
function stringToHex(s)
{
let hex = '';
let append = '';
for (let i = 0; i < s.length; i++) {
let cp = s.codePointAt(i).toString(16);
append = '';
if (cp.length / 6 !== 1) {
for (let n = 0; n < (6 - cp.length); n++) {
append += '0';
}
cp = append + cp;
}
hex += cp;
console.log(hex);
}
return(hex);
}
*/
function stringToHex(s)
{
let hex = '';
let append = '';
for (let i = 0; i < s.length; i++) {
let cp = s.codePointAt(i).toString(16);
append = '';
if (cp.length / 2 !== 1) {
for (let n = 0; n < (2 - cp.length); n++) {
append += '0';
}
cp = append + cp;
}
hex += cp;
}
return(hex);
}
function hexToString(s) {
let str = '';
for (let i = 0; i < s.length; i++) {
let charCode = parseInt(s[(i*2)] + s[(i*2)+1], 16);
str += String.fromCharCode(charCode);
}
return str;
}
function transparentReset() {
document.getElementById("transparentSendToValue").value = "";
document.getElementById("transparentAmountValue").value = "";
}
function privateReset() {
document.getElementById("privateSendToValue").value = "";
document.getElementById("privateAmountValue").value = "";
document.getElementById("privateMemoValue").value = "";
}
function getNewTransparentAddress() {
document.getElementById("receivingAddressValue").value = renderer.generateQuerySync('getnewaddress', []).result;
}
function getNewPrivateAddress() {
document.getElementById("receivingAddressValue").value = renderer.generateQuerySync('z_getnewaddress', []).result;
}
function sendTransparentTransaction() {
let sendTo = document.getElementById("transparentSendToValue").value;
let amount = document.getElementById("transparentAmountValue").value;
let tx = {};
tx[sendTo] = Number(amount);
renderer.generateQuery('sendmany', ["", tx]);
document.getElementById("transparentResetButton").click();
}
function sendPrivateTransaction() {
let from = document.getElementById("privateFromSelect").value;
let address = document.getElementById("privateSendToValue").value;
let amount = Number(document.getElementById("privateAmountValue").value);
if (document.getElementById("privateMemoValue").value === '') {
renderer.generateQuery('z_sendmany', [from, [{'address': address, 'amount': amount}]]);
}
else {
let memo = stringToHex(document.getElementById("privateMemoValue").value);
renderer.generateQuery('z_sendmany', [from, [{'address': address, 'amount': amount, 'memo': memo}]]);
}
document.getElementById("privateResetButton").click();
}
// set default tab
document.getElementById("historyTab").click();
</script>
</html>