-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontend.html
332 lines (292 loc) · 10.5 KB
/
frontend.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<script type="text/javascript">
function SendPost(command) {
var url = "/push";
var commandStr="command="
var theParams = commandStr + command
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
//Send the proper header information along with the request
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(theParams);
}
function Auth() {
var userID = document.getElementById("userid").value
var password = document.getElementById(pwd)
console.log("Auth")
console.log(userID)
}
function Add() {
var userID = document.getElementById("userid").value
var addamount = document.getElementById(addamount)
var cmd = "ADD,"+userID+","+addamount
SendPost(cmd)
console.log("Add")
}
function Quote() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(quotestocksymbol)
var cmd = "QUOTE,"+userID+","+stocksymbol
SendPost(cmd)
console.log("Quote")
}
function Buy() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(buystocksymbol)
var amnt = document.getElementById(buyamount)
var cmd = "BUY,"+userID+","+stocksymbol+","+amnt
SendPost(cmd)
console.log("Buy")
}
function CommitBuy() {
var userID = document.getElementById("userid").value
var cmd = "COMMIT_BUY,"+userID
console.log("Commit Buy")
}
function CancelBuy() {
var userID = document.getElementById("userid").value
var cmd = "CANCEL_BUY,"+userID
console.log("Cancel Buy")
}
function Sell() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(sellstocksymbol)
var amnt = document.getElementById(sellamount)
var cmd = "SELL,"+userID+","+stocksymbol+","+amnt
SendPost(cmd)
console.log("Sell")
}
function CommitSell() {
var userID = document.getElementById("userid").value
var cmd = "COMMIT_SELL,"+userID
console.log("Commit Sell")
}
function CancelSell() {
var userID = document.getElementById("userid").value
var cmd = "CANCEL_SELL,"+userID
console.log("Cancel Sell")
}
function SetBuyAmount() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(setbuystocksymbol)
var amnt = document.getElementById(setbuyamount)
var cmd = "SET_BUY_AMOUNT,"+userID+","+stocksymbol+","+amnt
SendPost(cmd)
console.log("Set buy amount")
}
function CancelSetBuy() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(cancelbuystocksymbol)
var cmd = "CANCEL_SET_BUY,"+userID+","+stocksymbol
SendPost(cmd)
console.log("Cancel set buy")
}
function SetBuyTrigger() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(setbuytrigstocksymbol)
var amnt = document.getElementById(setbuytrigamount)
var cmd = "SET_BUY_TRIGGER,"+userID+","+stocksymbol+","+amnt
SendPost(cmd)
console.log("Set buy trigger")
}
function SetSellAmount() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(setsellstocksymbol)
var amnt = document.getElementById(setsellamount)
var cmd = "SET_SELL_AMOUNT,"+userID+","+stocksymbol+","+amnt
SendPost(cmd)
console.log("Set Sell Amount")
}
function CancelSetSell() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(cancelsellstocksymbol)
var cmd = "CANCEL_SET_SELL,"+userID+","+stocksymbol
SendPost(cmd)
console.log("Cancel set sell")
}
function SetSellTrigger() {
var userID = document.getElementById("userid").value
var stocksymbol = document.getElementById(setselltrigstocksymbol)
var amnt = document.getElementById(setselltrigamount)
var cmd = "SET_SELL_TRIGGER,"+userID+","+stocksymbol+","+amnt
SendPost(cmd)
console.log("Set sell trigger")
}
function Dumplog() {
var userID = document.getElementById("userid").value
if(userID === "admin"){
SendPost("DUMPLOG,out.dump")
console.log("Admin Dump")
}
else
{
var fn = document.getElementById(dumplogfile)
var cmd = "DUMPLOG,"+userID+","+fn
SendPost(cmd)
console.log("User Dump")
}
}
function DisplaySummary() {
var userID = document.getElementById("userid").value
var cmd = "DISPLAY_SUMMARY,"+userID
console.log("Display summary")
}
</script>
<div class="container">
<h2>Credentials:</h2>
<form>
<div class="form-group">
<label for="userid">User ID:</label>
<input type="text" class="form-control" id="userid" placeholder="Enter user ID">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password">
</div>
<button type="button" class="btn btn-default" onclick="Auth()">Log In</button>
</form>
<h2>Add:</h2>
<form>
<div class="form-group">
<label for="addamount">Amount:</label>
<input type="text" class="form-control" id="addamount" placeholder="Enter amount">
</div>
<button type="button" class="btn btn-default" onclick="Add()">Submit</button>
</form>
<h2>Quote:</h2>
<form>
<div class="form-group">
<label for="quotestocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="quotestocksymbol" placeholder="Enter stock symbol">
</div>
<button type="button" class="btn btn-default" onclick="Quote()">button</button>
</form>
<h2>Buy:</h2>
<form>
<div class="form-group">
<label for="buystocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="buystocksymbol" placeholder="Enter stock symbol">
</div>
<div class="form-group">
<label for="buyamount">Amount:</label>
<input type="text" class="form-control" id="buyamount" placeholder="Enter amount">
</div>
<button type="button" class="btn btn-default" onclick="Buy()">button</button>
</form>
<h2>Commit Buy:</h2>
<form>
<button type="button" class="btn btn-default" onclick="CommitBuy()">button</button>
</form>
<h2>Cancel Buy:</h2>
<form>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Sell:</h2>
<form>
<div class="form-group">
<label for="sellstocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="sellstocksymbol" placeholder="Enter stock symbol">
</div>
<div class="form-group">
<label for="sellamount">Amount:</label>
<input type="text" class="form-control" id="sellamount" placeholder="Enter amount">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Commit Sell:</h2>
<form>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Cancel Sell:</h2>
<form>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Set Buy Amount:</h2>
<form>
<div class="form-group">
<label for="setbuystocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="setbuystocksymbol" placeholder="Enter stock symbol">
</div>
<div class="form-group">
<label for="setbuyamount">Amount:</label>
<input type="text" class="form-control" id="setbuyamount" placeholder="Enter amount">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Cancel Set Buy:</h2>
<form>
<div class="form-group">
<label for="cancelbuystocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="cancelbuystocksymbol" placeholder="Enter stock symbol">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Set Buy Trigger:</h2>
<form>
<div class="form-group">
<label for="setbuytrigstocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="setbuytrigstocksymbol" placeholder="Enter stock symbol">
</div>
<div class="form-group">
<label for="setbuytrigamount">Amount:</label>
<input type="text" class="form-control" id="setbuytrigamount" placeholder="Enter amount">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Set Sell Amount:</h2>
<form>
<div class="form-group">
<label for="setsellstocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="setsellstocksymbol" placeholder="Enter stock symbol">
</div>
<div class="form-group">
<label for="setsellamount">Amount:</label>
<input type="text" class="form-control" id="setsellamount" placeholder="Enter amount">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Cancel Set Sell:</h2>
<form>
<div class="form-group">
<label for="cancelsellstocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="cancelsellstocksymbol" placeholder="Enter stock symbol">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Set Sell Trigger:</h2>
<form>
<div class="form-group">
<label for="setselltrigstocksymbol">Stock Symbol:</label>
<input type="text" class="form-control" id="setselltrigstocksymbol" placeholder="Enter stock symbol">
</div>
<div class="form-group">
<label for="setselltrigamount">Amount:</label>
<input type="text" class="form-control" id="setselltrigamount" placeholder="Enter amount">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Dumplog:</h2>
<form>
<div class="form-group">
<label for="dumplogfile">Amount:</label>
<input type="text" class="form-control" id="dumplogfile" placeholder="Enter file name">
</div>
<button type="button" class="btn btn-default">button</button>
</form>
<h2>Display Summary:</h2>
<form>
<button type="button" class="btn btn-default">button</button>
</form>
</div>
</body>
</html>