-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.html
318 lines (286 loc) · 12.2 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
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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="herominers.com" />
<link href="https://herominers.com/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<title>HeroMiners Proxy Mining Control</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.6.3/jquery.timeago.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
</head>
<body>
<div class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">HeroMiners Proxy Mining Control</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#" id="rel"><span class="glyphicon glyphicon-refresh"></span> Reload Config</a></li>
<!--<li><a href="#" data-toggle="modal" data-target="#modalReload"><span class="glyphicon glyphicon-refresh"></span> Reload Config</a></li>-->
</ul>
<div class="navbar-form navbar-right" role="search">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control grey" id="user" placeholder="Load User..." autocomplete="off"/>
<span class="input-group-btn">
<button class="btn btn-success" type="button" id="loaduser">Load</button>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div id="msg"></div>
<div class="row">
<div class="col-md-12">
<div id="page-title">
<h3><span>Coin List</span></h3>
</div>
<div class="table-responsive">
<table class="table table-hover" id="coins"></table>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div id="page-title">
<h3><span>Worker List</span></h3>
</div>
<div class="table-responsive">
<table class="table table-hover" id="workers"></table>
</div>
</div>
</div>
</div>
<!--
<div id="modalReload" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Reload Config</h4>
</div>
<div class="modal-body">
<input type="password" id="password" class="form-control" placeholder="Reload password" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning" id="rel" data-dismiss="modal">Reload</button>
<button type="button" class="btn btn-success" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
-->
<footer class="py-5">
<table align="center">
<tr align="center">
<td align="center">
<br/>
<br/>
<br/>
<strong><a href="mailto:[email protected]">Contact</a></strong>
-
<strong><a href="https://discord.gg/gvWSs84">Discord</a></strong>
-
<strong><a href="https://t.me/Hero%20Miners">Telegram</a></strong>
<br/>
<strong>HeroMiners Pool</strong>
<br/>
<i class="fa fa-copyright" aria-hidden="true"></i> 2018
</td>
</tr>
</table>
<!-- /.container -->
</footer>
<script type="text/javascript">
function getReadableHashRateString(hashrate){
var i = 0;
var byteUnits = [' H', ' KH', ' MH', ' GH', ' TH', ' PH' ];
while (hashrate > 1000){
hashrate = hashrate / 1000;
i++;
}
return hashrate.toFixed(2) + byteUnits[i];
}
function getReadableDiffString(diff){
var i = 0;
var byteUnits = ['', ' K', ' M', ' G', ' T', ' P' ];
while (diff > 1000){
diff = diff / 1000;
i++;
}
return diff.toFixed(2) + byteUnits[i];
}
var docCookies = {
getItem: function (sKey) {
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
},
setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
var sExpires = "";
if (vEnd) {
switch (vEnd.constructor) {
case Number:
sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
break;
case String:
sExpires = "; expires=" + vEnd;
break;
case Date:
sExpires = "; expires=" + vEnd.toUTCString();
break;
}
}
document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
return true;
},
removeItem: function (sKey, sPath, sDomain) {
if (!sKey || !this.hasItem(sKey)) { return false; }
document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + ( sDomain ? "; domain=" + sDomain : "") + ( sPath ? "; path=" + sPath : "");
return true;
},
hasItem: function (sKey) {
return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
}
};
var socket;
var user;
$(function(){
socket = io();
socket.on('coins',function(coins){
$('#coins').empty();
$('#coins').append($(
'<tr>'+
'<th>Coin</th>'+
'<th>Difficulty</th>'+
'<th>Network Hashrate</th>'+
'<th>Pool Hashrate</th>'+
'<th>Pool Last Block</th>'+
'<th>Block Height</th>'+
'<th>Block Found</th>'+
'<th>Miners (Workers)</th>'+
'<th>Actions</th>'+
'</tr>'));
for (var coin of coins){
$('#coins').append($(
'<tr class="coin" id="coin_'+(coin.symbol)+'" data-api="'+coin.api+'">'+
'<td>'+(coin.symbol)+'</td>'+
'<td class="diff"></td>'+
'<td class="nethash"></td>'+
'<td class="poolhash"></td>'+
'<td class="poolblock"></td>'+
'<td class="blockheight"></td>'+
'<td class="blockfound"></td>'+
'<td><span class="miners"></span> (<span class="workers"></span>)</td>'+
'<td><button id="switch_'+(coin.symbol)+'" class="btn btn-warning btn-xs" title="Active This Coin"><span class="glyphicon glyphicon-ok"></span> Select</button> '+
'<a target="_blank" class="btn btn-success btn-xs" title="View Stats" href="'+coin.url+'/?wallet='+coin.login+'"><span class="glyphicon glyphicon-search"></span> Wallet</a></td>'+
'</tr>'));
if(coin.active)
$('#coin_'+coin.symbol).addClass('selected');
$('#switch_'+coin.symbol).click(function(){
user = $('#user').val();
socket.emit('switch',user,this.id.substr(7));
});
}
});
socket.on('active',function(coin){
$('tr[id^="coin_"]').removeClass('selected');
$('#coin_'+coin).addClass('selected');
});
socket.on('workers',function(list,servertime){
$('#workers').empty();
$('#workers').append($(
'<tr>'+
'<th>#</th>'+
'<th>Worker</th>'+
'<th>Last Submit</th>'+
'<th>Hashrate</th>'+
'</tr>'));
var combined=0;
var keys = Object.keys(list);
var n = 1;
for(var worker of keys){
$('#workers').append($(
'<tr>'+
'<td>'+n+'</td>'+
'<td>'+worker+'</td>'+
'<td>'+jQuery.timeago(new Date(list[worker].time * 1000))+'</td>'+
'<td>'+getReadableHashRateString(list[worker].hashrate*1000)+'/s'+'</td>'+
'</tr>'));
n++;
combined += list[worker].hashrate;
}
$('#workers').append($(
'<tr class="worker">'+
'<td colspan="3">Combined Hasrate</td>'+
'<td>'+getReadableHashRateString(combined*1000)+'/s'+'</td>'+
'</tr>'));
});
socket.on('msg', function(msg){
$('#msg').prepend($(
'<div class="alert alert-'+msg['type']+' alert-dismissible" role="alert">'+
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×'+
'</span></button>'+msg['text']+
'</div>'));
});
$('#rel').click(function(){
user = $('#user').val()||'';
password = $('#password').val()||'';
$('#coins').empty();
socket.emit('reload',user, password);
});
if(docCookies.getItem('login'))
{
$('#user').val(docCookies.getItem('login'));
$('#coins').empty();
socket.emit('user',docCookies.getItem('login'));
}
$('#loaduser').click(function(){
user = $('#user').val();
docCookies.setItem('login',user);
$('#coins').empty();
socket.emit('user',user);
});
var xhrPoolApi;
setInterval(() => {
$(".coin").each(function() {
if($(this).data('api'))
{
var row = $(this);
xhrPoolApi = $.ajax({
url: row.data('api') + '/stats',
dataType: 'json',
cache: 'false'
}).done(function(data){
row.find(".diff").text(getReadableDiffString(data.network.difficulty));
row.find(".nethash").text(getReadableHashRateString(data.network.difficulty/data.config.coinDifficultyTarget)+'/s');
row.find(".poolhash").text(getReadableHashRateString(data.pool.hashrate)+'/s');
row.find(".netblock").text(jQuery.timeago(new Date(data.lastblock.timestamp * 1000)));
row.find(".poolblock").text(jQuery.timeago(new Date(parseInt(data.pool.lastBlockFound))));
row.find(".blockheight").text((parseInt(data.network.height)));
row.find(".blockfound").text((parseInt(data.pool.totalBlocks)));
row.find(".miners").text((parseInt(data.pool.miners)));
row.find(".workers").text((parseInt(data.pool.workers)));
});
}
});
}, 5000);
});
</script>
</body>
</html>