|
70 | 70 |
|
71 | 71 |
|
72 | 72 | 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 | + |
73 | 80 | return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ","); |
74 | 81 | } |
75 | 82 |
|
76 | 83 | function getShares(payload, srv) { |
77 | 84 | shares = srv['shares']; |
78 | | - |
79 | 85 | diff = payload["diffs"][srv["coin"]]; |
80 | 86 | if (diff == undefined) { diff = payload["diffs"]["btc"]; } |
81 | | - |
82 | 87 | return numberWithCommas(shares) |
83 | 88 | + "<br>" |
84 | 89 | + fixLength((shares / diff * 100).toFixed(2), 6) |
|
132 | 137 | if(srv["rejects"] > 0) { |
133 | 138 | pp = parseFloat(srv["rejects"]) / parseFloat(srv["user_shares"]) * 100; |
134 | 139 | } |
| 140 | + |
| 141 | + if(srv["user_shares"] == undefined) { |
| 142 | + return "0" + " / " + "0<br>" + fixLength(pp.toFixed(2), 5) + "%"; |
| 143 | + } |
| 144 | + |
135 | 145 | return srv["user_shares"] |
136 | 146 | + " / " |
137 | 147 | + srv["rejects"] |
|
435 | 445 | if( !showInfoPools && row_role == "info" ){ |
436 | 446 | continue; //Skip info pools |
437 | 447 | } |
| 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 | + } |
438 | 472 | } |
439 | 473 |
|
440 | 474 | html += "<tr id=\"row_" + i + "\">"; |
|
0 commit comments