Skip to content

Commit b3595bc

Browse files
committed
Merge remote-tracking branch 'DavidVorrick/master'
2 parents 3500905 + 72544e5 commit b3595bc

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

bitHopper/templates/stats.html

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,20 @@
7070

7171

7272
function numberWithCommas(x) {
73+
//some of the numbers have a random decimal point in them
74+
//not knowing where the decimal point is actually coming from, I truncated every thing following the decimal point with the next three lines
75+
76+
var indexOfDecimalPoint = x.toString().indexOf('.');
77+
if(indexOfDecimalPoint != -1)
78+
x = x.toString().substring(0,indexOfDecimalPoint);
79+
7380
return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
7481
}
7582

7683
function getShares(payload, srv) {
7784
shares = srv['shares'];
78-
7985
diff = payload["diffs"][srv["coin"]];
8086
if (diff == undefined) { diff = payload["diffs"]["btc"]; }
81-
8287
return numberWithCommas(shares)
8388
+ "<br>"
8489
+ fixLength((shares / diff * 100).toFixed(2), 6)
@@ -132,6 +137,11 @@
132137
if(srv["rejects"] > 0) {
133138
pp = parseFloat(srv["rejects"]) / parseFloat(srv["user_shares"]) * 100;
134139
}
140+
141+
if(srv["user_shares"] == undefined) {
142+
return "0" + "&nbsp;/&nbsp;" + "0<br>" + fixLength(pp.toFixed(2), 5) + "%";
143+
}
144+
135145
return srv["user_shares"]
136146
+ "&nbsp;/&nbsp;"
137147
+ srv["rejects"]
@@ -435,6 +445,30 @@
435445
if( !showInfoPools && row_role == "info" ){
436446
continue; //Skip info pools
437447
}
448+
449+
450+
//this first way of getting shares looks at what would go in the html. It works pretty much flawlessly
451+
var htmlShares = columns['Shares']['data'](payload, row, r);
452+
var endOfShares = htmlShares.indexOf('<');
453+
var poolSharesWCommas = htmlShares.substring(0,endOfShares);
454+
var htmlPoolShares = poolSharesWCommas.replace(/[^0-9]/g, '');
455+
456+
//this second way of getting shares looks at what is in the JSON data.
457+
//the problem is that by this point everything has been sorted alphabetically, and you can't look back into the raw data to get a proper match
458+
/*var htmlServerName = columns['Server']['data'](payload, row, r);
459+
var nameStart = htmlServerName.indexOf('>');
460+
htmlServerName = htmlServerName.substring(nameStart);
461+
var nameEnd = htmlServerName.indexOf('<');
462+
htmlServerName = htmlServerName.substring(1, nameEnd);
463+
JSONserverName = "'" + htmlServerName + "'";
464+
//var dataPoolShares = payload['servers']['abc']['shares'];
465+
alert(JSON.stringify(payload['servers']));
466+
*/
467+
468+
//because htmlPoolShares seems to work better, this is the method chosen, even though it's not 'pure'
469+
if(htmlPoolShares == "undefined" || htmlPoolShares == 0 || htmlPoolShares >= 50000000) {
470+
continue;
471+
}
438472
}
439473

440474
html += "<tr id=\"row_" + i + "\">";

0 commit comments

Comments
 (0)