Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions handlebars-intl.min.js

Large diffs are not rendered by default.

230 changes: 230 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ZCashProxy</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="//cdn.polyfill.io/v2/polyfill.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.min.js"></script>
<script src="handlebars-intl.min.js"></script>
<link href="style.css" rel="stylesheet">
<script src="script.js"></script>
</head>
<body>
<script id="stats-template" type="text/x-handlebars-template">
<div class="row marketing">
<div class="col-xs-6">
<dl class="dl-horizontal">
<dt>Solutions/s</dt>
<dd><span class="badge alert-info">{{formatNumber solutionRate maximumFractionDigits=4}}</span></dd>
<dt>Solutions/s 24h</dt>
<dd><span class="badge alert-info">{{formatNumber solutionRate24h maximumFractionDigits=4}}</span></dd>
<dt>Total Miners</dt>
<dd><span class="badge alert-info">{{totalMiners}}</span></dd>
<dt>Miners Online</dt>
<dd><span class="badge alert-success">{{totalOnline}}</span></dd>
</dl>
</div>
<div class="col-xs-6">
<dl class="dl-horizontal">
<dt>Accepted</dt>
<dd><span class="badge alert-success">{{formatNumber current.accepts}}</span></dd>
<dt>Rejected</dt>
<dd><span class="badge alert-danger">{{formatNumber current.rejects}}</span></dd>
<dt>Miners Timed Out</dt>
<dd><span class="badge alert-danger">{{formatNumber timedOut}}</span></dd>
{{#if current.lastSubmissionAt}}
<dt>Last Submission</dt>
<dd><span class="badge alert-info">{{formatRelative current.lastSubmissionAt now=now}}</span></dd>
{{/if}}
</dl>
</div>
<div class="col-xs-12">
{{#if errors}}
<div id="alert" class="alert alert-danger" role="alert">
<strong>{{errors}}</strong>
</div>
{{/if}}
{{#if info}}
<p>
{{#if template}}
<strong>Block Height:</strong> <span class="label label-primary">{{height}}</span>
<strong>Difficulty:</strong> <span class="label label-primary">{{formatNumber diff maximumFractionDigits=4}}</span>
{{/if}}
{{#if info}}
{{#if testnet}}
<span class="label label-danger">TESTNET</span>
{{else}}
<span class="label label-success">MAINNET</span>
{{/if}}
<strong>Connections:</strong> <span class="label label-primary">{{formatNumber connections}}</span>
{{/if}}
</p>
{{/if}}
</div>
<div class="col-xs-12">
<p>
<strong>Blocks {{luck.window}}:</strong> <span class="label label-primary">{{formatNumber luck.blocksCount}}</span>
<strong>Shares/Diff {{luck.window}}:</strong>
<span class="label label-primary">{{formatNumber luck.variance style="percent" minimumFractionDigits=2 maximumFractionDigits=2}}</span>
<strong>Blocks {{luck.largeWindow}}:</strong> <span class="label label-primary">{{formatNumber luck.totalBlocksCount}}</span>
<strong>Shares/Diff {{luck.largeWindow}}:</strong>
<span class="label label-primary">{{formatNumber luck.totalVariance style="percent" minimumFractionDigits=2 maximumFractionDigits=2}}</span>
{{#if template}}
<strong>Round Progress:</strong>
<span class="label label-primary">{{formatNumber variance style="percent" minimumFractionDigits=2 maximumFractionDigits=2}}</span>
{{/if}}
</p>
</div>
<div class="col-xs-12">
<h4>Upstream</h4>
<div class="table-responsive">
<table class="table table-condensed">
<tr>
<th>Name</th>
<th>Url</th>
<th>Accepted</th>
<th>Rejected</th>
<th>Fails</th>
</tr>
{{#each upstreams}}
{{#if sick}}
<tr class="danger">
{{else}}
<tr class="success">
{{/if}}
{{#if current}}
<td><strong>{{name}}</strong></td>
{{else}}
<td>{{name}}</td>
{{/if}}
<td>{{url}}</td>
<td>{{formatNumber accepts}}</td>
<td><strong>{{formatNumber rejects}}</strong></td>
<td>{{failsCount}}</td>
</tr>
{{/each}}
</table>
</div>
</div>
<div id="miners" class="col-xs-12">
<h4>Miners</h4>
<div class="table-responsive">
<table class="table table-condensed">
<tr>
<th>ID</th>
<th>IP</th>
<th>Sol/s</th>
<th>Sol/s 24h</th>
<th>Last Share</th>
<th>Accepted</th>
<th>Rejected</th>
<th>Blocks Accepted</th>
<th>Blocks Rejected</th>
</tr>
{{#each miners}}
{{#if timeout}}
<tr class="danger">
{{else}}
{{#if warning}}
<tr class="warning">
{{else}}
<tr class="success">
{{/if}}
{{/if}}
<td>{{name}}</td>
<td>
{{#if ip}}
{{ip}}
{{else}}
&mdash;
{{/if}}
</td>
<td>{{formatNumber solutionRate maximumFractionDigits=4}}</td>
<td>{{formatNumber solutionRate24h maximumFractionDigits=4}}</td>
<td>{{formatRelative lastBeat now=../now}}</td>
<td>{{formatNumber validShares}}</td>
<td><strong>{{formatNumber invalidShares}}</strong></td>
<td>{{formatNumber accepts}}</td>
<td>{{formatNumber rejects}}</td>
</tr>
{{/each}}
</table>
</div>
</div>
</div>
</script>
<script id="blocks-template" type="text/x-handlebars-template">
<div class="row marketing">
<div class="col-xs-12">
<p>
<strong>Blocks {{luck.window}}:</strong> <span class="label label-primary">{{formatNumber luck.blocksCount}}</span>
<strong>Shares/Diff {{luck.window}}:</strong>
<span class="label label-primary">{{formatNumber luck.variance style="percent" minimumFractionDigits=2 maximumFractionDigits=2}}</span>
<strong>Blocks {{luck.largeWindow}}:</strong> <span class="label label-primary">{{formatNumber luck.totalBlocksCount}}</span>
<strong>Shares/Diff {{luck.largeWindow}}:</strong>
<span class="label label-primary">{{formatNumber luck.totalVariance style="percent" minimumFractionDigits=2 maximumFractionDigits=2}}</span>
{{#if template}}
<strong>Round Progress:</strong>
<span class="label label-primary">{{formatNumber variance style="percent" minimumFractionDigits=2 maximumFractionDigits=2}}</span>
{{/if}}
</p>
</div>
<div id="blocks" class="col-xs-12">
<h4>Blocks</h4>
<div class="table-responsive">
<table class="table table-condensed table-striped">
<tr>
<th>Height</th>
<th>Time</th>
<th>Hash</th>
<th>Shares/Diff</th>
</tr>
{{#each blocks}}
<tr>
<td>{{formatNumber height}}</td>
<td>{{formatDate timestamp year="numeric" month="numeric" day="numeric" hour="numeric" minute="numeric"}}</td>
<td class="hash">{{hash}}</td>
<td>{{formatNumber variance style="percent" minimumFractionDigits=2 maximumFractionDigits=2}}</td>
</tr>
{{/each}}
</table>
</div>
</div>
</div>
</script>

<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation"><a href="#" id="homeTab">Home</a></li>
<li role="presentation"><a href="#blocks" id="blocksTab">Blocks</a></li>
</ul>
</nav>
<h3 class="text-muted">ZCashProxy</h3>
</div>
<div id="alert" class="alert alert-danger hide" role="alert">
<strong>An error occured while polling proxy state.</strong>
Make sure proxy is running.
</div>
<div id="stats"></div>
</div>
<footer class="footer">
<div class="container">
<p>
By <a href="https://github.com/sammy007" target="_blank">sammy007</a>.<br/>
<span><strong>ZEC</strong>: t1K9CtKh4rZXEVfjhNovozLeLysyx9AwYrH</span><br/>
<span><strong>ZEC</strong>: zcKeV5YwqgsE6VKYN64duRXoc1CuiSgXUP7Tb7oip7ux4nCojMZenCfd54BHfdSa5toyiz8nGYdu4BbCCxhG8FDKXT1Tbts</span>
</p>
<p>
<strong>JSON stats available at: <code>/stats</code>.
</p>
</div>
</footer>
</body>
</html>
2 changes: 2 additions & 0 deletions robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
107 changes: 107 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
HandlebarsIntl.registerWith(Handlebars);

$(function() {
switch (location.hash) {
case '#blocks':
window.homeTab = false;
break;
default:
window.homeTab = true;
}
var userLang = (navigator.language || navigator.userLanguage) || 'en-US';
window.intlData = { locales: userLang };

Notification.requestPermission();

var statsSource = $("#stats-template").html();
var statsTemplate = Handlebars.compile(statsSource);
var blocksSource = $("#blocks-template").html();
var blocksTemplate = Handlebars.compile(blocksSource);
refreshStats(statsTemplate, blocksTemplate);

$('#homeTab').on('click', function() {
window.homeTab = true;
refreshStats(statsTemplate, blocksTemplate);
});
$('#blocksTab').on('click', function() {
window.homeTab = false;
refreshStats(statsTemplate, blocksTemplate);
});
setInterval(function() {
refreshStats(statsTemplate, blocksTemplate);
}, 5000)
});

function refreshStats(statsTemplate, blocksTemplate) {
$.getJSON("/stats", function(stats) {
$("#alert").addClass('hide');

// Sort miners by ID
if (stats.miners) {
stats.miners = stats.miners.sort(compareMiners);
}
// Reverse sort blocks by height
if (stats.blocks) {
stats.blocks = stats.blocks.sort(compareBlocks);
}

var html = null;
$('.nav-pills > li').removeClass('active');

if (window.homeTab) {
html = statsTemplate(stats, { data: { intl: window.intlData } });
$('.nav-pills > li > #homeTab').parent().addClass('active');
} else {
html = blocksTemplate(stats, { data: { intl: window.intlData } });
$('.nav-pills > li > #blocksTab').parent().addClass('active');
}
$('#stats').html(html);

processNotifications(stats);
}).fail(function() {
$("#alert").removeClass('hide');
});
}

function compareMiners(a, b) {
if (a.name < b.name)
return -1;
if (a.name > b.name)
return 1;
return 0;
}

function compareBlocks(a, b) {
if (a.height > b.height)
return -1;
if (a.height < b.height)
return 1;
return 0;
}

function processNotifications(stats) {
if (!window.statsCache) {
window.statsCache = stats;
return;
}

if (stats.current.accepts > window.statsCache.current.accepts) {
spawnNotification('New Block', 'New block found');
}

if (stats.current.rejects > window.statsCache.current.rejects) {
spawnNotification('Block Reject', 'Block rejected by daemon');
}

if (stats.timedOut > window.statsCache.timedOut) {
spawnNotification('Worker Offline Alert', 'Worker(s) timed out. Total offline: ' + stats.timedOut);
}
window.statsCache = stats;
}

function spawnNotification(title, body) {
var n = new Notification(title, {
body: body,
icon: 'zcash-logo.png'
});
}
Loading