Skip to content

Commit

Permalink
updated stats
Browse files Browse the repository at this point in the history
  • Loading branch information
prismspecs committed Apr 26, 2018
1 parent edd2bf2 commit c2d4396
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 60 deletions.
Binary file added desktop/assets/bb-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop/assets/cute-graph-donation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop/assets/cute-graph-green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added desktop/assets/cute-graph-payout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions desktop/stats.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


#individual {
position:absolute;
width:100%;
Expand Down Expand Up @@ -88,16 +90,16 @@

.payouticon, .donationicon {
position: absolute;
width: 18px;
height: 18px;
background-image: url(assets/payout.png);
width: 14px;
height: 14px;
background-image: url(assets/cute-graph-payout.png);
background-repeat: no-repeat;
background-size: 100%;
z-index:98;
}

.donationicon {
background-image: url(assets/donation.png);
background-image: url(assets/cute-graph-donation.png);
}

#xaxis-label-friends a img, #label-donations a img {
Expand All @@ -111,7 +113,7 @@
}

#xaxis-label-friends, #label-donations {
right: 94px;
left: 550px;
}

#topbox {
Expand Down Expand Up @@ -193,4 +195,8 @@
z-index: 99;
color: #fff;
text-shadow: 1px 1px 2px #888888;
}

#stats-date, #scrub-actual, #scrub-friends, #scrub-line {
opacity:0 !important;
}
25 changes: 12 additions & 13 deletions desktop/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,22 @@
<div id="yaxis-label-bottom">
</div>
<div id="xaxis-label-actual">
<img class="graphicon" src="assets/pages/cute-graph.png">
<!-- <div>MONEY RAISED TO DATE (USD)</div> -->
<div>FUNDS RAISED TO DATE</div>
<img class="graphicon" src="assets/cute-graph.png">
<div>XMR generated</div>
</div>
<div id="label-payouts">
<img class="graphicon" src="assets/payout.png">
<img class="graphicon" src="assets/cute-graph-payout.png">
<div>CHECK CUT TO BAIL FUND</div>
</div>

<div id="xaxis-label-friends">
<img class="graphicon" src="assets/pages/cute-graph-pink.png">
<div>if everyone invited 3 friends</div>
<a href="https://www.facebook.com/dialog/feed?app_id=140586622674265&link=https://bailbloc.thenewinquiry.com&name=BAIL%20BLOC&redirect_uri=http%3A%2F%2Fs7.addthis.com%2Fstatic%2Fpostshare%2Fc00.html" target="_blank"><img src="assets/social/fb.png"></a>
<a href="https://twitter.com/intent/tweet?text=Bail%20people%20out%20of%20jail%20with%20a%20computer%20program%20%23BAILBLOC&url=https://bailbloc.thenewinquiry.com" target="_blank"><img src="assets/social/twitter.png"></a>
<img class="graphicon" src="assets/cute-graph-green.png">
<div>USD raised</div>
<!-- <a href="https://www.facebook.com/dialog/feed?app_id=140586622674265&link=https://bailbloc.thenewinquiry.com&name=BAIL%20BLOC&redirect_uri=http%3A%2F%2Fs7.addthis.com%2Fstatic%2Fpostshare%2Fc00.html" target="_blank"><img src="assets/social/fb.png"></a>
<a href="https://twitter.com/intent/tweet?text=Bail%20people%20out%20of%20jail%20with%20a%20computer%20program%20%23BAILBLOC&url=https://bailbloc.thenewinquiry.com" target="_blank"><img src="assets/social/twitter.png"></a> -->
</div>
<div id="label-donations">
<img class="graphicon" src="assets/donation.png">
<img class="graphicon" src="assets/cute-graph-donation.png">
<div>DONATION RECEIVED</div>
</div>

Expand All @@ -56,11 +55,11 @@
</div>
</div>
<div id="stats-modes">
display as
<div id="stats-text">
<p><a href="#" onclick="changeMode(0);return false;"><img src="assets/pages/redsquare.png">money raised</a></p>
<p><a href="#" onclick="changeMode(2);return false;"><img src="assets/pages/redsquare.png">hashrate</a></p>
<p><a href="#" onclick="changeMode(1);return false;"><img src="assets/pages/redsquare.png">people participating</a></p>
<p><span id="scrub-date" style="color:#000"></span></p>
<p><span id="scrub-usd" style="color:#f00">$1234 USD raised</span> USD</p>
<p><span id="scrub-xmr" style="color:#f00">something</span> XMR</p>
<p><span id="scrub-exrate" style="color:#f00">something else</span> USD:XMR</p>
</div>
</div>
<div id="invite-friends">
Expand Down
123 changes: 82 additions & 41 deletions desktop/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var yMax = 0.0;
var minExRate = 0.0;
var maxExRate = 500.0;
var minUSD = 0.0;
var maxUSD = 10000.0;
var maxUSD = 1000.0;

var myFont;
var fontS = 18.7;
Expand Down Expand Up @@ -162,45 +162,77 @@ function draw() {

// NEW------
var y = 0.0;
// draw XMR graph
// stroke(255, 0, 0);
// strokeWeight(8);
noStroke();
fill(255, 0, 0);

beginShape();
vertex(mL, height);
vertex(gp[0].x, gp[0].y);

for (var i = 1; i < gp.length; i++) {
vertex(gp[i].x, gp[i].y);
}
vertex(mR, height);
endShape();
// // draw XMR graph
// // stroke(255, 0, 0);
// // strokeWeight(8);
// noStroke();
// fill(255, 0, 0);

// beginShape();
// vertex(mL, height);
// vertex(gp[0].x, gp[0].y);

// draw exchange rate graph
stroke(100, 100, 255, 200);
noFill();
beginShape();
// for (var i = 1; i < gp.length; i++) {
// vertex(gp[i].x, gp[i].y);
// }
// vertex(mR, height);
// endShape();

// USD as vertical bars
strokeWeight(4);
stroke(100,255,100);
for (var i = 0; i < gp.length; i++) {
y = map(gp[i].eRate, minExRate, maxExRate, height, 0);
vertex(gp[i].x, y);
y = map(gp[i].usd, minUSD, maxUSD, height, 0);
line(gp[i].x - 1, height, gp[i].x - 1, y);
}
endShape();

// XMR as vertical bars
stroke(255,80,80);
for (var i = 0; i < gp.length; i++) {
line(gp[i].x - 1, height, gp[i].x - 1, gp[i].y);
}

// turn nearest bar to mouse yellow
var nearestBar = int(map(mouseX,0,width,0,gp.length-1));
nearestBar = constrain(nearestBar,0,gp.length-1);
stroke(255,255,100);
// usd
y = map(gp[nearestBar].usd, minUSD, maxUSD, height, 0);
line(gp[nearestBar].x - 1, height, gp[nearestBar].x - 1, y);
// xmr
line(gp[nearestBar].x - 1, height, gp[nearestBar].x - 1, gp[nearestBar].y);

// clean lines between
// stroke(255);
// strokeWeight(1);
// for (var i = 0; i < gp.length; i++) {
// line(gp[i].x + 2, height, gp[i].x + 2, 0);
// }

// draw USD graph
stroke(100, 255, 100, 200);
noFill();
beginShape();
// // draw exchange rate graph
// stroke(100, 100, 255, 200);
// noFill();
// beginShape();

// for (var i = 0; i < gp.length; i++) {
// y = map(gp[i].eRate, minExRate, maxExRate, height, 0);
// vertex(gp[i].x, y);
// }
// endShape();



// // draw USD graph
// stroke(100, 255, 100, 200);
// noFill();
// beginShape();

// for (var i = 0; i < gp.length; i++) {
// y = map(gp[i].usd, minUSD, maxUSD, height, 0);
// vertex(gp[i].x, y);
// }
// endShape();

for (var i = 0; i < gp.length; i++) {
y = map(gp[i].usd, minUSD, maxUSD, height, 0);
vertex(gp[i].x, y);
}
endShape();


for (var i = 0; i < gp.length; i++) {
Expand All @@ -227,9 +259,9 @@ function mouseMoved() {
mouseReady = true;
}

// check mouse
var pointInQuestion = int(map(mouseX, 0, width, 0, numPoints));
pointInQuestion = constrain(pointInQuestion, 0, numPoints - 1);
// check mouse (4 pixel offset helps)
var pointInQuestion = int(map(mouseX, 0, width + 4, 0, gp.length));
// pointInQuestion = constrain(pointInQuestion, 0, gp.length - 1);

//console.log(pointInQuestion);

Expand All @@ -245,6 +277,12 @@ function mouseMoved() {
$("#scrub-actual").offset({ top: y, left: x });
$("#scrub-actual").html(valToPrint);

$("#scrub-date").html(gp[pointInQuestion].date);
$("#scrub-usd").html(gp[pointInQuestion].usd);
$("#scrub-xmr").html(gp[pointInQuestion].xmr.toFixed(1));
$("#scrub-exrate").html(gp[pointInQuestion].eRate.toFixed(0));


y = height - (height - gp[pointInQuestion].y) * friendsMultiplier;
y += $("#defaultCanvas0").offset().top - 18;
y = constrain(y, 150, height);
Expand Down Expand Up @@ -304,7 +342,7 @@ function redrawGraph(stats, numWorkers) {
minExRate = maxExRate = stats[0].ticker.price;
minUSD = ((stats[stats.length - 1].stats.amtPaid + stats[stats.length - 1].stats.amtDue) / 1000000000000) * stats[stats.length - 1].ticker.price;
console.log(stats[stats.length - 1].ticker.price);
maxUSD = (stats[0].stats.amtPaid + stats[0].stats.amtDue) / 1000000000000 * stats[0].ticker.price;
// maxUSD = (stats[0].stats.amtPaid + stats[0].stats.amtDue) / 1000000000000 * stats[0].ticker.price;

// add points to array
for (var i = stats.length - 1; i >= 0; i--) {
Expand All @@ -315,13 +353,12 @@ function redrawGraph(stats, numWorkers) {
var usd = 0;
var hashrate = stats[i].stats.hash / 1000.0;
var nMiners = stats[i].n_miners;
var eRate = stats[i].ticker.price;
var eRate = parseFloat(stats[i].ticker.price);

if (eRate > maxExRate) maxExRate = eRate;
if (eRate < minExRate) minExRate = eRate;

if (usd > maxUSD) maxUSD = usd;
if (usd < minUSD) minUSD = usd;


var date = new Date(convertTimestamp(stats[i].timestamp));
var month = date.getMonth();
Expand All @@ -348,6 +385,10 @@ function redrawGraph(stats, numWorkers) {

totalUSD = usd; // !

// use for min/max graph stuff
if (usd > maxUSD) maxUSD = usd;
if (usd < minUSD) minUSD = usd;

// y = map(usd, yMin, yMax, height, 0);
y = map(xmr, yMin, yMax, height, 0);

Expand Down Expand Up @@ -486,8 +527,8 @@ function pullStatsData() {

// get all the bb. server data
$.ajax({

url: "https://bb.darkinquiry.com/?step=65&n=120",
// was step=65, n=120
url: "https://bb.darkinquiry.com/?step=130&n=80",
type: 'get',
cache: false,
success: function(stats) {
Expand Down

0 comments on commit c2d4396

Please sign in to comment.