-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfunctions-proxy.js
51 lines (44 loc) · 2.49 KB
/
functions-proxy.js
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
$.getJSON(endpointAPI, function(data) {
// xmrig and worker info
document.getElementById("version").innerHTML = data.version + ' - ' + data.kind.toUpperCase();
document.getElementById("ua").innerHTML = data.ua;
document.getElementById("worker_id").innerHTML = data.worker_id;
document.getElementById("id").innerHTML = data.id;
// results
document.getElementById("results").innerHTML = data.results.accepted + ' / ' + (data.results.accepted + data.results.rejected + data.results.invalid) + ' (' + Number((data.results.accepted / (data.results.accepted + data.results.rejected + data.results.invalid)) * 100).toFixed(2) + '%)';
document.getElementById("avg_time").innerHTML = data.results.avg_time + ' seconds';
if (typeof(data.results.error_log) == "undefined") {
document.getElementById("error_log_r").innerHTML = '';
} else {
document.getElementById("error_log_r").innerHTML = data.results.error_log;
alert(data.results.error_log);
}
// connection
document.getElementById("miners").innerHTML = data.miners.now + ' miners (max: ' + data.miners.max + ')';
document.getElementById("uptime").innerHTML = (data.uptime / 3600).toFixed(2) + ' hours / ' + (data.uptime / 86400).toFixed(2) + ' days';
document.getElementById("ping").innerHTML = data.results.latency + ' ms';
//totals
document.getElementById("tot10").innerHTML = Number(data.hashrate.total[1] * 1000).toLocaleString('en-GB') + ' H/s';
document.getElementById("tot60").innerHTML = Number(data.hashrate.total[2] * 1000).toLocaleString('en-GB') + ' H/s';
document.getElementById("tot12").innerHTML = Number(data.hashrate.total[3] * 1000).toLocaleString('en-GB') + ' H/s';
document.getElementById("tot24").innerHTML = Number(data.hashrate.total[4] * 1000).toLocaleString('en-GB') + ' H/s';
});
// footer information
document.getElementById("api").innerHTML = endpointAPI;
document.getElementById("alarm").innerHTML = alarmThreshold.toLocaleString('en-GB');
document.getElementById("timer").innerHTML = timer + ' seconds';
// alert for hashrate drop
var audio = new Audio('media/hell.wav');
setInterval(function() {
var tot60 = (document.getElementById("tot60").innerText).replace(/\D/g, '');
if (tot60 < alarmThreshold) {
audio.play();
}
}, 3000);
// create meta tag for auto-refresh
if (timer > 0) {
var meta = document.createElement('meta');
meta.httpEquiv = "refresh";
meta.content = timer;
document.getElementsByTagName('head')[0].appendChild(meta);
}