-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathindex.html
221 lines (199 loc) · 6.47 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
<!doctype html>
<html>
<head>
<title>CryptoKnight Proxy Mining Switch</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<script src="/socket.io/socket.io.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-timeago/1.4.0/jquery.timeago.min.js"></script>
<script>
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];
}
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 () {
$('#user').val(docCookies.getItem('login')||'');
socket = io();
socket.on('coins',function(coins){
$('#coins').empty();
$('#coins').append($(
'<tr class="coin">'+
'<td></td>'+
'<td>Nethash</td>'+
'<td>LastBlock</td>'+
'<td></td>'+
'</tr>'));
for (var coin of coins){
$('#coins').append($(
'<tr class="coin" data-api="'+coin.api+'">'+
'<td class="swit" id="switch_'+(coin.symbol)+'">'+(coin.symbol)+'</td>'+
'<td class="diff"></td>'+
'<td class="netblock"></td>'+
'<td>'+(coin.url?('<a target="_blank" class="pool" href="'+coin.url+'/?wallet='+coin.login+'">Poolstats</a>'):coin.login)+' </td>'+
'</tr>'));
if(coin.active)
$('#switch_'+coin.symbol).css('color', 'red');
$('#switch_'+coin.symbol).click(function(){
user = $('#user').val();
socket.emit('switch',user,this.id.substr(7));
});
}
});
socket.on('active',function(coin){
$('.coin > .swit').css('color', 'white');
$('#switch_'+coin).css('color', 'red');
});
socket.on('workers',function(list,servertime){
$('#workers').empty();
var combined=0;
var keys = Object.keys(list);
for(var worker of keys){
var date = jQuery.timeago(new Date(list[worker].time * 1000));
$('#workers').append($('<span>'+worker+' : '+date+' : '+list[worker].hashrate.toFixed(2)+' kH/s<br/></span>'));
if( list[worker].time > (servertime-(60*5))) combined+=list[worker].hashrate;
}
$('#workers').append($('<span>combined : '+combined.toFixed(2)+' kH/s<br/></span>'));
});
$('#rel').click(function(){
user = $('#user').val();
$('#coins').empty();
socket.emit('reload',user);
});
$('#loaduser').click(function(){
user = $('#user').val();
docCookies.setItem('login',user);
$('#coins').empty();
socket.emit('user',user);
});
setInterval(() => {
$( ".coin" ).each(function() {
if($( this ).data('api'))
{
var row = $( this );
$.ajax({
url: row.data('api') + '/stats',
dataType: 'json',
cache: 'false'
}).done(function(data){
var seconds = new Date().getTime() / 1000;
row.find( ".diff" ).text(getReadableHashRateString(data.network.difficulty / data.config.coinDifficultyTarget) + '/sec');
row.find( ".netblock" ).text( (seconds - data.network.timestamp).toFixed(0)+'s');
});
}
});
}, 5000);
});
</script>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<STYLE TYPE="text/css">
a{
color:#ff0000;
text-decoration:none;
}
a.pool {
color:#0000ff !important;
}
a:hover{
color:#000000;
text-decoration:none;
}
.coin {
text-align: left;
font-size: 50%;
}
.workers {
text-align: left;
font-size: 50%;
}
.coin > td{
font-size: 100%;
padding:5px;
line-height:1.5em;
}
.coin > .swit{
cursor:pointer;
background-color:blue;
color:white;
}
.menu{
margin:20px 10px;
padding:0;
}
.menu > a{
font-size:12px;
font-weight:normal;
text-align:center;
display:block;
background:#eeeeee;
border:1px solid #dddddd;
color:#000000;
padding:10px;
margin:10px 0;
-moz-border-radius:2px;
-webkit-border-radius:2px;
border-radius:2px;
-moz-box-shadow:0 2px 4px #aaaaaa;
-webkit-box-shadow:0 2px 4px #aaaaaa;
box-shadow:0 2px 4px #aaaaaa;
}
.menu > a:hover{
color:#bbbbbb;
-moz-box-shadow:none;
-webkit-box-shadow:none;
box-shadow:none;
}
</STYLE>
</head>
<body>
<DIV STYLE="text-align: center;font-size:2em;font-family:Consolas, Andale Mono, Lucida Console, Lucida Sans Typewriter, Monaco, Courier New, monospace">
<input STYLE="width: 75%;height: 100%; border-color: #ff0000 #0000ff; text-align: center;font-size:1em;font-family:Consolas, Andale Mono, Lucida Console, Lucida Sans Typewriter, Monaco, Courier New, monospace" id="user" type="text" value=""/>
<div class="menu">
<a id="loaduser" href="javascript:void(0);">Load</a>
</div>
<table id="coins"></table>
<div class="menu">
<a id="rel">Reload Config</a>
</div>
<div class="workers" id="workers"></div>
</DIV>
</body>
</html>