added compiled files. postinstall script removed from package.json

This commit is contained in:
Mario Colque 2014-02-24 08:34:52 -03:00
parent 055cdf4286
commit 64cfacb945
10 changed files with 3745 additions and 18 deletions

4
.gitignore vendored
View File

@ -37,7 +37,7 @@ db/blocks
db/testnet/blocks/*
db/testnet/blocks
public/js/*
public/css/*
#public/js/*
#public/css/*
README.html

View File

@ -47,8 +47,7 @@
"node": "*"
},
"scripts": {
"start": "node node_modules/grunt-cli/bin/grunt",
"postinstall": "node node_modules/bower/bin/bower install; node ./node_modules/grunt-cli/bin/grunt compile "
"start": "node node_modules/grunt-cli/bin/grunt"
},
"dependencies": {
"base58-native": "0.1.2",
@ -62,16 +61,7 @@
"express": "~3.4.7",
"jade": "~1.0.2",
"lodash": "~2.4.1",
"bower": "~1.2.8",
"buffertools": "*",
"grunt": "~0.4.2",
"grunt-cli": "~0.1.11",
"grunt-env": "~0.4.1",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-concurrent": "~0.4.2",
"grunt-nodemon": "~0.1.2",
"grunt-mocha-test": "~0.8.1",
"should": "~2.1.1",
"view-helpers": "latest",
"socket.io": "~0.9.16",
@ -83,13 +73,17 @@
"xmlhttprequest": "~1.6.0"
},
"devDependencies": {
"grunt-contrib-watch": "latest",
"grunt-contrib-jshint": "latest",
"bower": "~1.2.8",
"grunt": "~0.4.2",
"grunt-cli": "~0.1.11",
"grunt-env": "~0.4.1",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-concurrent": "~0.4.2",
"grunt-nodemon": "~0.2.0",
"grunt-mocha-test": "~0.8.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.3.2",
"grunt-nodemon": "latest",
"grunt-concurrent": "latest",
"grunt-mocha-test": "latest",
"should": "latest",
"grunt-css": "~0.5.4",
"grunt-markdown": "~0.5.0"

648
public/css/main.css Normal file
View File

@ -0,0 +1,648 @@
/* Sticky footer styles
-------------------------------------------------- */
@charset "UTF-8";
html,
body {
color: #373D42;
font-family: 'Ubuntu', sans-serif;
height: 100%;
/* The html and body elements cannot have any padding or margin. */
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
color: #373D42;
font-family: 'Ubuntu', sans-serif;
}
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak],
.ng-cloak, .x-ng-cloak,
.ng-hide {
display: none !important;
}
/* Styling for the ngProgress itself */
#ngProgress {
background-color: #6C9032 !important;
box-shadow: none !important;
color: #373D42 !important;
height: 3px !important;
margin: 0;
opacity: 0;
padding: 0;
z-index: 99998;
/* Add CSS3 styles for transition smoothing */
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
/* Styling for the ngProgress-container */
#ngProgress-container {
position: fixed;
margin: 0;
padding: 0;
top: 63px;
left: 0;
right: 0;
z-index: 99999;
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto;
/* Negative indent footer by its height */
margin: 0 auto -51px;
/* Pad bottom by footer height */
padding: 0 0 75px;
}
.m10h { margin: 0 10px; }
.m20h { margin: 0 20px; }
.m5v { margin: 5px 0; }
.m20v { margin: 20px 0; }
.m10v { margin: 10px 0; }
.m50v { margin: 50px 0; }
.m10b { margin-bottom: 10px; }
.m10l { margin-left: 10px; }
.vm { vertical-align: middle; }
.btn-group .btn+.btn, .btn-group .btn+.btn-group, .btn-group .btn-group+.btn, .btn-group .btn-group+.btn-group {
margin-left: 0;
}
.table-hover>tbody>tr:hover>td, .table-hover>tbody>tr:hover>th {
background-color: #F0F7E2;
}
.navbar-default .navbar-toggle {
border-color: #fff;
margin-top: 15px;
}
.navbar-default .navbar-toggle .icon-bar { background-color: #fff; }
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {background-color: #373D42;}
.navbar-default {
background-color: #8DC429;
margin: 0;
}
.navbar-default .navbar-nav>li>a {
color: #F4FBE8;
font-family: 'Ubuntu', sans-serif;
padding-left: 25px;
padding-right: 25px;
}
.navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:focus {
background-color: #6C9032;
color: #fff;
}
.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>.active>a:hover {
background-color: #fff;
}
.navbar-form .form-group {
display: block;
}
.navbar-form {
margin-left: 20px;
width: 35%;
margin-top: 15px;
}
@media (max-width: 991px) {
.status {
margin: 0;
}
.navbar-form {
width: 20%;
}
}
@media (max-width: 768px) {
.navbar-form {
width: auto;
}
}
.nav-tabs.nav-justified>li>a:hover {
cursor: pointer;
}
.insight {
font-family: 'Ubuntu', sans-serif;
font-size: 34px;
font-style: italic;
font-weight: 700;
}
.navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus {
color: #fffffe;
}
.navbar-default .navbar-brand {
color: #FFFFFF;
margin-right: 20px;
padding: 22px 15px;
}
.navbar-form .form-control {
background-color: #7CAD23;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border: 0;
-webkit-box-shadow: 1px 1px 0px 0px rgba(255,255,255,0.41), inset 1px 1px 3px 0px rgba(0,0,0,0.10);
-moz-box-shadow: 1px 1px 0px 0px rgba(255,255,255,0.41), inset 1px 1px 3px 0px rgba(0,0,0,0.10);
box-shadow: 1px 1px 0px 0px rgba(255,255,255,0.41), inset 1px 1px 3px 0px rgba(0,0,0,0.10);
}
.navbar-nav>li>a {
padding-top: 22px;
padding-bottom: 22px;
}
#search {
color: #fff;
font-family: 'Ubuntu', sans-serif;
}
#search.loading {
background-image: url('/img/loading.gif');
background-position: 5px center;
background-repeat: no-repeat;
padding-left: 25px;
}
#search::-webkit-input-placeholder {
color: #BCDF7E;
font-family: 'Ubuntu', sans-serif;
font-size: 14px;
font-style: italic;
font-weight: 100;
}
#search::-moz-placeholder {
color: #BCDF7E;
font-family: 'Ubuntu', sans-serif;
font-size: 14px;
font-weight: 100;
}
.status {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
background-color: #597338;
border-radius: 3px;
margin: 15px 0;
padding: 8px 10px;
font-size: 12px;
color: #eee;
text-align: center;
}
.status .tooltip {
margin: 0;
}
.col-gray {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
background-color: #F4F4F4;
border-radius: 5px;
padding: 14px;
border: 1px solid #eee;
}
.col-gray-responsive {
width: auto;
}
.col-gray-fixed {
margin-top: 15px;
position: fixed;
width: 250px;
border: 1px solid #eee;
z-index: 1;
}
@media (max-width: 768px) {
.col-gray-fixed {
width:100%;
}
}
@media (max-width: 995px) {
.col-gray-fixed {
position:static;
width: 100%;
}
}
@media (min-width: 1200px) {
.col-gray-fixed {
width: 280px;
}
}
.ellipsis {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.line20 {
border: 1px solid #D4D4D4;
margin-bottom: 15px;
}
.line10 {
border: 1px solid #EAEAEA;
margin: 10px 0;
}
.block-id {
background-color: #373D42;
border: 3px solid #FFFFFF;
margin: 0 auto;
width: 165px;
color: #fff;
text-align: center;
}
.block-id span {
font-size: 40px;
margin: 30px 0;
}
.block-id h2 {
color: #FFFFFF;
font-weight: bold;
line-height: 30px;
font-size: 24px;
margin-top: 0;
margin-bottom: 10px;
}
.icon-block {
color: #FFFFFF;
font-size: 35px;
margin-top: 10px;
}
.icon-block h3 {
color: #fff;
}
.block-tx {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
background-color: #F4F4F4;
border-radius: 2px;
margin: 20px 0 10px;
overflow: hidden;
padding: 15px;
border: 1px solid #eee;
}
.btn {
border-radius: 2px;
}
.btn-primary {
background-color: #8DC429;
border: 2px solid #76AF0F;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active,
.btn-primary.active, .open .dropdown-toggle.btn-primary,
.btn-success:hover, .btn-success:focus, .btn-success:active,
.btn-success.active, .open .dropdown-toggle.btn-success,
.btn-danger:hover, .btn-danger:focus, .btn-danger:active,
.btn-danger.active, .open .dropdown-toggle.btn-danger {
background-color: #fff;
border: 2px solid #ccc;
color: #373D42;
}
.btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open .dropdown-toggle.btn-default {
background-color: #fff;
}
.btn-default {
background-color: #E7E7E7;
}
.btn-success {
background-color: #2FA4D7;
border: 2px solid #237FA7;
}
.btn-danger {
background-color: #AC0015;
border: 2px solid #6C0000;
}
.txvalues {
display: inline-block;
padding: .7em 2em;
font-size: 13px;
text-transform: uppercase;
font-weight:100;
color: #fff;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25em;
}
@media (max-width: 768px) {
.txvalues {
display: block;
margin: 5px;
}
}
.txvalues-primary {
background-color: #8DC429;
}
.txvalues-default {
background-color: #EBEBEB;
color: #333;
}
.txvalues-success {
background-color: #2FA4D7;
}
.txvalues-danger {
background-color: #AC0015;
}
.progress-bar-info { background-color: #8DC429; }
/* Set the fixed height of the footer here */
#footer {
background-color: #373D42;
color: #fff;
height: 51px;
overflow: hidden;
}
#footer a.insight {
font-size: 20px;
text-decoration: none;
color: #fff;
}
#footer a.insight:hover {
color: #fffffe;
}
#footer a.insight small { font-size: 11px; }
.line-footer { border-top: 2px dashed #ccc; }
.line-bot {
border-bottom: 2px solid #EAEAEA;
padding: 0 0 10px 0;
}
.line-mid { padding: 15px 0;}
.line-top {
border-top: 1px solid #EAEAEA;
padding: 15px 0 0 0;
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
#wrap > .container { padding: 70px 15px 0; }
#footer > .container { padding: auto 15px; }
.code { font-size: 80%; }
.address { font-size: 11px; }
.no_matching {
-moz-border-radius-bottomleft: 2px;
-moz-border-radius-bottomright: 2px;
-webkit-border-bottom-left-radius: 2px;
-webkit-border-bottom-right-radius: 2px;
background-color: #FFFFFF;
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
border-top: none;
border: 1px solid #64920F;
padding: 10px 20px;
position: absolute;
text-align: center;
top: 45px;
width: 300px;
}
/*Animations*/
.fader.ng-enter {
opacity: 0;
-webkit-transition: opacity 1s;
-moz-transition: opacity 1s;
-o-transition: opacity 1s;
transition: opacity 1s;
}
.fader.ng-enter-active { opacity: 1; }
.tx-bg {
background-color: #F4F4F4;
left: 0;
min-height: 340px;
position: absolute;
top: 0;
width: 100%;
z-index: -9999;
}
.badge {
-moz-border-radius: 9px;
-webkit-border-radius: 9px;
background-color: #999999;
border-radius: 9px;
color: #ffffff;
font-size: 12.025px;
font-weight: bold;
padding: 1px 9px 2px;
white-space: nowrap;
}
.badge:hover {
color: #ffffff;
text-decoration: none;
cursor: pointer;
}
.badge-error { background-color: #b94a48; }
.badge-error:hover { background-color: #953b39; }
.badge-warning { background-color: #f89406; }
.badge-warning:hover { background-color: #c67605; }
.badge-success { background-color: #468847; }
.badge-success:hover { background-color: #356635; }
.badge-info { background-color: #3a87ad; }
.badge-info:hover { background-color: #2d6987; }
.badge-inverse { background-color: #333333; }
.badge-inverse:hover { background-color: #1a1a1a; }
.status .t {
color: white;
}
.status .text-danger { background: red; }
.status .text-warning {
background: yellow;
color: black;
}
.btn-copy, .btn-expand {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
background-color: #FFFFFF;
border-radius: 2px;
border: 2px solid #E4E4E4;
color: #9b9b9b;
display: inline-block;
height: 25px;
padding: 0;
outline: none;
text-align: center;
width: 30px;
}
.btn-copy:hover, .btn-expand:hover {
background-color: #f2f2f2;
}
.btn-copy {
background: #fff url('/img/icons/copy.png') center center no-repeat;
margin-left: 5px;
}
.btn-copy .tooltip {
display: inline-block;
margin-left: 10px;
margin-top: -2px;
opacity: 0;
}
.btn-copy.zeroclipboard-is-hover { color: #2a6496; }
.btn-copy.zeroclipboard-is-active .tooltip { opacity: 1; }
.btn-expand { margin-right: 5px; }
@media (max-width: 991px) {
.btn-copy {
display: none;
}
}
.txid {
line-height: 26px;
}
.tx-id {
background-color: #373D42;
border: 3px solid #FFFFFF;
margin: 0 auto;
width: 165px;
color: #FFFFFF;
text-align: center;
}
.tx-id span {
font-size: 40px;
margin: 30px 0;
}
.transaction-vin-vout .ellipsis { margin-bottom: 10px; }
.transaction-vin-vout .btc-value { margin-left: 15px; }
.page-header { margin-top: 0; }
/* Index */
#home .btn-more {
border-top: 1px solid #ddd;
margin: 30px auto 0;
text-align: center;
width: 90%;
}
#home .btn-more .btn-default {
margin-top: -23px;
}
#powered .powered-text {
border-top: 1px solid #ddd;
margin: 30px auto 0;
text-align: center;
width: 90%;
}
#powered .powered-text small {
background-color: #f4f4f4;
padding: 4px;
position: relative;
top: -12px;
}
#powered a {
background-repeat: no-repeat;
background-position: center center;
display: inline-block;
float: left;
height: 45px;
}
#powered a.bitcore {
background-image: url('http://bitcore.io/images/logo.svg');
background-size: 80px;
width: 30%;
}
#powered a.nodejs {
background-image: url('/img/nodejs.png');
background-size: 80px;
width: 30%;
}
#powered a.angularjs {
background-image: url('/img/angularjs.png');
background-size: 50px;
width: 20%;
}
#powered a.leveldb {
background-image: url('/img/leveldb.png');
background-size: 50px;
width: 20%;
}
@keyframes rotateThis {
from { transform: scale( 1 ) rotate( 0deg ); }
to { transform: scale( 1 ) rotate( 360deg ); }
}
@-webkit-keyframes rotateThis {
from { -webkit-transform: scale( 1 ) rotate( 0deg ); }
to { -webkit-transform: scale( 1 ) rotate( 360deg ); }
}
.icon-rotate {
animation-name: rotateThis;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-timing-function: linear;
-webkit-animation-name: rotateThis;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}

1
public/css/main.min.css vendored Normal file

File diff suppressed because one or more lines are too long

434
public/js/angularjs-all.js vendored Normal file

File diff suppressed because one or more lines are too long

9
public/js/angularjs-all.min.js vendored Normal file

File diff suppressed because one or more lines are too long

983
public/js/main.js Normal file
View File

@ -0,0 +1,983 @@
// Source: public/src/js/app.js
angular.module('insight',[
'ngAnimate',
'ngResource',
'ngRoute',
'ngProgress',
'ui.bootstrap',
'ui.route',
'monospaced.qrcode',
'insight.system',
'insight.socket',
'insight.blocks',
'insight.transactions',
'insight.address',
'insight.search',
'insight.status',
'insight.connection',
'insight.currency'
]);
angular.module('insight.system', []);
angular.module('insight.socket', []);
angular.module('insight.blocks', []);
angular.module('insight.transactions', []);
angular.module('insight.address', []);
angular.module('insight.search', []);
angular.module('insight.status', []);
angular.module('insight.connection', []);
angular.module('insight.currency', []);
// Source: public/src/js/controllers/address.js
angular.module('insight.address').controller('AddressController',
function($scope, $rootScope, $routeParams, $location, Global, Address, getSocket) {
$scope.global = Global;
$scope.findOne = function() {
$rootScope.currentAddr = $routeParams.addrStr;
Address.get({
addrStr: $routeParams.addrStr
},
function(address) {
$rootScope.titleDetail = address.addrStr.substring(0, 7) + '...';
$rootScope.flashMessage = null;
$scope.address = address;
},
function(e) {
if (e.status === 400) {
$rootScope.flashMessage = 'Invalid Address: ' + $routeParams.addrStr;
} else if (e.status === 503) {
$rootScope.flashMessage = 'Backend Error. ' + e.data;
} else {
$rootScope.flashMessage = 'Address Not Found';
}
$location.path('/');
});
};
var socket = getSocket($scope);
socket.on('connect', function() {
socket.emit('subscribe', $routeParams.addrStr);
socket.on($routeParams.addrStr, function(tx) {
console.log('AddressTx event received ' + tx);
$rootScope.$broadcast('tx', tx);
});
});
$scope.params = $routeParams;
});
// Source: public/src/js/controllers/blocks.js
angular.module('insight.blocks').controller('BlocksController',
function($scope, $rootScope, $routeParams, $location, Global, Block, Blocks, BlockByHeight) {
$scope.global = Global;
$scope.loading = false;
if ($routeParams.blockHeight) {
BlockByHeight.get({
blockHeight: $routeParams.blockHeight
}, function(hash) {
$location.path('/block/' + hash.blockHash);
}, function() {
$rootScope.flashMessage = 'Bad Request';
$location.path('/');
});
}
//Datepicker
var _formatTimestamp = function (date) {
var yyyy = date.getUTCFullYear().toString();
var mm = (date.getUTCMonth() + 1).toString(); // getMonth() is zero-based
var dd = date.getUTCDate().toString();
return yyyy + '-' + (mm[1] ? mm : '0' + mm[0]) + '-' + (dd[1] ? dd : '0' + dd[0]); //padding
};
$scope.$watch('dt', function(newValue, oldValue) {
if (newValue !== oldValue) {
$location.path('/blocks-date/' + _formatTimestamp(newValue));
}
});
$scope.openCalendar = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened = true;
};
$scope.humanSince = function(time) {
var m = moment.unix(time).startOf('day');
var b = moment().startOf('day');
return m.max().from(b);
};
$scope.list = function() {
$scope.loading = true;
if ($routeParams.blockDate) {
$rootScope.titleDetail = 'on ' + $routeParams.blockDate;
}
Blocks.get({
blockDate: $routeParams.blockDate
}, function(res) {
$scope.loading = false;
$scope.blocks = res.blocks;
$scope.pagination = res.pagination;
});
};
$scope.findOne = function() {
$scope.loading = true;
Block.get({
blockHash: $routeParams.blockHash
}, function(block) {
$rootScope.titleDetail = block.height;
$rootScope.flashMessage = null;
$scope.loading = false;
$scope.block = block;
}, function(e) {
if (e.status === 400) {
$rootScope.flashMessage = 'Invalid Transaction ID: ' + $routeParams.txId;
}
else if (e.status === 503) {
$rootScope.flashMessage = 'Backend Error. ' + e.data;
}
else {
$rootScope.flashMessage = 'Block Not Found';
}
$location.path('/');
});
};
$scope.params = $routeParams;
});
// Source: public/src/js/controllers/connection.js
angular.module('insight.connection').controller('ConnectionController',
function($scope, $window, Status, getSocket, PeerSync) {
// Set initial values
$scope.apiOnline = true;
$scope.serverOnline = true;
$scope.clienteOnline = true;
var socket = getSocket($scope);
// Check for the node server connection
socket.on('connect', function() {
$scope.serverOnline = true;
socket.on('disconnect', function() {
$scope.serverOnline = false;
});
});
// Check for the api connection
$scope.getConnStatus = function() {
PeerSync.get({},
function(peer) {
$scope.apiOnline = peer.connected;
$scope.host = peer.host;
$scope.port = peer.port;
},
function() {
$scope.apiOnline = false;
});
};
socket.emit('subscribe', 'sync');
socket.on('status', function(sync) {
$scope.sync = sync;
$scope.apiOnline = (sync.status !== 'aborted' && sync.status !== 'error');
});
// Check for the client conneciton
$window.addEventListener('offline', function() {
$scope.$apply(function() {
$scope.clienteOnline = false;
});
}, true);
$window.addEventListener('online', function() {
$scope.$apply(function() {
$scope.clienteOnline = true;
});
}, true);
});
// Source: public/src/js/controllers/currency.js
angular.module('insight.currency').controller('CurrencyController',
function($scope, $rootScope, Currency) {
var _roundFloat = function(x, n) {
if(!parseInt(n, 10) || !parseFloat(x)) n = 0;
return Math.round(x * Math.pow(10, n)) / Math.pow(10, n);
};
$rootScope.currency.getConvertion = function(value) {
if (typeof value !== 'undefined' && value !== null) {
var response;
if (this.symbol === 'USD') {
response = _roundFloat((value * this.factor), 2);
} else if (this.symbol === 'mBTC') {
this.factor = 1000;
response = _roundFloat((value * this.factor), 5);
} else {
this.factor = 1;
response = value;
}
return response + ' ' + this.symbol;
}
return 'value error';
};
$scope.setCurrency = function(currency) {
$rootScope.currency.symbol = currency;
if (currency === 'USD') {
Currency.get({}, function(res) {
$rootScope.currency.factor = $rootScope.currency.bitstamp = res.data.bitstamp;
});
} else if (currency === 'mBTC') {
$rootScope.currency.factor = 1000;
} else {
$rootScope.currency.factor = 1;
}
};
// Get initial value
Currency.get({}, function(res) {
$rootScope.currency.bitstamp = res.data.bitstamp;
});
});
// Source: public/src/js/controllers/footer.js
angular.module('insight.system').controller('FooterController',
function($scope, Version) {
var _getVersion = function() {
Version.get({},
function(res) {
$scope.version = res.version;
});
};
$scope.version = _getVersion();
});
// Source: public/src/js/controllers/header.js
angular.module('insight.system').controller('HeaderController',
function($scope, $rootScope, getSocket, Global, Block) {
$scope.global = Global;
$rootScope.currency = {
factor: 1,
bitstamp: 0,
symbol: 'BTC'
};
$scope.menu = [{
'title': 'Blocks',
'link': 'blocks'
}, {
'title': 'Status',
'link': 'status'
}];
var _getBlock = function(hash) {
Block.get({
blockHash: hash
}, function(res) {
$scope.totalBlocks = res.height;
});
};
var socket = getSocket($scope);
socket.on('connect', function() {
socket.emit('subscribe', 'inv');
socket.on('block', function(block) {
var blockHash = block.toString();
_getBlock(blockHash);
});
});
$rootScope.isCollapsed = true;
});
// Source: public/src/js/controllers/index.js
var TRANSACTION_DISPLAYED = 10;
var BLOCKS_DISPLAYED = 5;
angular.module('insight.system').controller('IndexController',
function($scope, Global, getSocket, Blocks) {
$scope.global = Global;
var _getBlocks = function() {
Blocks.get({
limit: BLOCKS_DISPLAYED
}, function(res) {
$scope.blocks = res.blocks;
$scope.blocksLength = res.lenght;
});
};
var socket = getSocket($scope);
socket.on('connect', function() {
socket.emit('subscribe', 'inv');
socket.on('tx', function(tx) {
$scope.txs.unshift(tx);
if (parseInt($scope.txs.length, 10) >= parseInt(TRANSACTION_DISPLAYED, 10)) {
$scope.txs = $scope.txs.splice(0, TRANSACTION_DISPLAYED);
}
});
socket.on('block', function() {
_getBlocks();
});
});
$scope.humanSince = function(time) {
var m = moment.unix(time);
return m.max().fromNow();
};
$scope.index = function() {
_getBlocks();
};
$scope.txs = [];
$scope.blocks = [];
});
// Source: public/src/js/controllers/search.js
angular.module('insight.search').controller('SearchController',
function($scope, $routeParams, $location, $timeout, Global, Block, Transaction, Address, BlockByHeight) {
$scope.global = Global;
$scope.loading = false;
var _badQuery = function() {
$scope.badQuery = true;
$timeout(function() {
$scope.badQuery = false;
}, 2000);
};
var _resetSearch = function() {
$scope.q = '';
$scope.loading = false;
};
$scope.search = function() {
var q = $scope.q;
$scope.badQuery = false;
$scope.loading = true;
Block.get({
blockHash: q
}, function() {
_resetSearch();
$location.path('block/' + q);
}, function() { //block not found, search on TX
Transaction.get({
txId: q
}, function() {
_resetSearch();
$location.path('tx/' + q);
}, function() { //tx not found, search on Address
Address.get({
addrStr: q
}, function() {
_resetSearch();
$location.path('address/' + q);
}, function() { // block by height not found
if (isFinite(q)) { // ensure that q is a finite number. A logical height value.
BlockByHeight.get({
blockHeight: q
}, function(hash) {
_resetSearch();
$location.path('/block/' + hash.blockHash);
}, function() { //not found, fail :(
_badQuery();
});
}
else {
$scope.loading = false;
_badQuery();
}
});
});
});
};
});
// Source: public/src/js/controllers/status.js
angular.module('insight.status').controller('StatusController',
function($scope, $routeParams, $location, Global, Status, Sync, getSocket) {
$scope.global = Global;
$scope.getStatus = function(q) {
Status.get({
q: 'get' + q
},
function(d) {
$scope.loaded = 1;
angular.extend($scope, d);
},
function(e) {
$scope.error = 'API ERROR: ' + e.data;
});
};
$scope.humanSince = function(time) {
var m = moment.unix(time / 1000);
return m.max().fromNow();
};
var _onSyncUpdate = function(sync) {
$scope.sync = sync;
};
$scope.getSync = function() {
Sync.get({},
function(sync) {
_onSyncUpdate(sync);
},
function(e) {
var err = 'Could not get sync information' + e.toString();
$scope.sync = {
error: err
};
});
};
var socket = getSocket($scope);
socket.on('connect', function() {
socket.emit('subscribe', 'sync');
socket.on('status', function(sync) {
_onSyncUpdate(sync);
});
});
});
// Source: public/src/js/controllers/transactions.js
angular.module('insight.transactions').controller('transactionsController',
function($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress) {
$scope.global = Global;
$scope.loading = false;
$scope.loadedBy = null;
var pageNum = 0;
var pagesTotal = 1;
var COIN = 100000000;
var _aggregateItems = function(items) {
if (!items) return [];
var l = items.length;
var ret = [];
var tmp = {};
var u = 0;
for(var i=0; i < l; i++) {
var notAddr = false;
// non standard input
if (items[i].scriptSig && !items[i].addr) {
items[i].addr = 'Unparsed address [' + u++ + ']';
items[i].notAddr = true;
notAddr = true;
}
// non standard output
if (items[i].scriptPubKey && !items[i].scriptPubKey.addresses) {
items[i].scriptPubKey.addresses = ['Unparsed address [' + u++ + ']'];
items[i].notAddr = true;
notAddr = true;
}
// multiple addr at output
if (items[i].scriptPubKey && items[i].scriptPubKey.addresses.length > 1) {
items[i].addr = items[i].scriptPubKey.addresses.join(',');
ret.push(items[i]);
continue;
}
var addr = items[i].addr || (items[i].scriptPubKey && items[i].scriptPubKey.addresses[0]);
if (!tmp[addr]) {
tmp[addr] = {};
tmp[addr].valueSat = 0;
tmp[addr].count = 0;
tmp[addr].addr = addr;
tmp[addr].items = [];
}
tmp[addr].isSpent = items[i].spentTxId;
tmp[addr].doubleSpentTxID = tmp[addr].doubleSpentTxID || items[i].doubleSpentTxID;
tmp[addr].doubleSpentIndex = tmp[addr].doubleSpentIndex || items[i].doubleSpentIndex;
tmp[addr].unconfirmedInput += items[i].unconfirmedInput;
tmp[addr].dbError = tmp[addr].dbError || items[i].dbError;
tmp[addr].valueSat += items[i].value * COIN;
tmp[addr].items.push(items[i]);
tmp[addr].notAddr = notAddr;
tmp[addr].count++;
}
angular.forEach(tmp, function(v) {
v.value = parseInt(v.valueSat) / COIN;
ret.push(v);
});
return ret;
};
var _processTX = function(tx) {
tx.vinSimple = _aggregateItems(tx.vin);
tx.voutSimple = _aggregateItems(tx.vout);
};
var _paginate = function(data) {
$scope.loading = false;
pagesTotal = data.pagesTotal;
pageNum += 1;
data.txs.forEach(function(tx) {
_processTX(tx);
$scope.txs.push(tx);
});
};
var _byBlock = function() {
TransactionsByBlock.get({
block: $routeParams.blockHash,
pageNum: pageNum
}, function(data) {
_paginate(data);
});
};
var _byAddress = function () {
TransactionsByAddress.get({
address: $routeParams.addrStr,
pageNum: pageNum
}, function(data) {
_paginate(data);
});
};
var _findTx = function(txid) {
Transaction.get({
txId: txid
}, function(tx) {
$rootScope.titleDetail = tx.txid.substring(0,7) + '...';
$rootScope.flashMessage = null;
$scope.tx = tx;
_processTX(tx);
$scope.txs.unshift(tx);
}, function(e) {
if (e.status === 400) {
$rootScope.flashMessage = 'Invalid Transaction ID: ' + $routeParams.txId;
}
else if (e.status === 503) {
$rootScope.flashMessage = 'Backend Error. ' + e.data;
}
else {
$rootScope.flashMessage = 'Transaction Not Found';
}
$location.path('/');
});
};
$scope.findThis = function() {
_findTx($routeParams.txId);
};
//Initial load
$scope.load = function(from) {
$scope.loadedBy = from;
$scope.loadMore();
};
//Load more transactions for pagination
$scope.loadMore = function() {
if (pageNum < pagesTotal && !$scope.loading) {
$scope.loading = true;
if ($scope.loadedBy === 'address') {
_byAddress();
}
else {
_byBlock();
}
}
};
//Init without txs
$scope.txs = [];
$scope.$on('tx', function(event, txid) {
_findTx(txid);
});
});
// Source: public/src/js/services/address.js
angular.module('insight.address').factory('Address',
function($resource) {
return $resource('/api/addr/:addrStr', {
addrStr: '@addStr'
}, {
get: {
method: 'GET',
interceptor: {
response: function (res) {
return res.data;
},
responseError: function (res) {
if (res.status === 404) {
return res;
}
}
}
}
});
});
// Source: public/src/js/services/blocks.js
angular.module('insight.blocks')
.factory('Block',
function($resource) {
return $resource('/api/block/:blockHash', {
blockHash: '@blockHash'
}, {
get: {
method: 'GET',
interceptor: {
response: function (res) {
return res.data;
},
responseError: function (res) {
if (res.status === 404) {
return res;
}
}
}
}
});
})
.factory('Blocks',
function($resource) {
return $resource('/api/blocks');
})
.factory('BlockByHeight',
function($resource) {
return $resource('/api/block-index/:blockHeight');
});
// Source: public/src/js/services/currency.js
angular.module('insight.currency').factory('Currency',
function($resource) {
return $resource('/api/currency');
});
// Source: public/src/js/services/global.js
//Global service for global variables
angular.module('insight.system')
.factory('Global',[
function() {
}
])
.factory('Version',
function($resource) {
return $resource('/api/version');
});
// Source: public/src/js/services/socket.js
var ScopedSocket = function(socket, $rootScope) {
this.socket = socket;
this.$rootScope = $rootScope;
this.listeners = [];
};
ScopedSocket.prototype.removeAllListeners = function(opts) {
if (!opts) opts = {};
for (var i = 0; i < this.listeners.length; i++) {
var details = this.listeners[i];
if (opts.skipConnect && details.event === 'connect') {
continue;
}
this.socket.removeListener(details.event, details.fn);
}
this.listeners = [];
};
ScopedSocket.prototype.on = function(event, callback) {
var socket = this.socket;
var $rootScope = this.$rootScope;
var wrapped_callback = function() {
var args = arguments;
$rootScope.$apply(function() {
callback.apply(socket, args);
});
};
socket.on(event, wrapped_callback);
this.listeners.push({
event: event,
fn: wrapped_callback
});
};
ScopedSocket.prototype.emit = function(event, data, callback) {
var socket = this.socket;
var $rootScope = this.$rootScope;
socket.emit(event, data, function() {
var args = arguments;
$rootScope.$apply(function() {
if (callback) {
callback.apply(socket, args);
}
});
});
};
angular.module('insight.socket').factory('getSocket',
function($rootScope) {
var socket = io.connect(null, {
'reconnect': true,
'reconnection delay': 500,
});
return function(scope) {
var scopedSocket = new ScopedSocket(socket, $rootScope);
scope.$on('$destroy', function() {
scopedSocket.removeAllListeners();
});
socket.on('connect', function() {
scopedSocket.removeAllListeners({
skipConnect: true
});
});
return scopedSocket;
};
});
// Source: public/src/js/services/status.js
angular.module('insight.status')
.factory('Status',
function($resource) {
return $resource('/api/status', {
q: '@q'
});
})
.factory('Sync',
function($resource) {
return $resource('/api/sync');
})
.factory('PeerSync',
function($resource) {
return $resource('/api/peer');
});
// Source: public/src/js/services/transactions.js
angular.module('insight.transactions')
.factory('Transaction',
function($resource) {
return $resource('/api/tx/:txId', {
txId: '@txId'
}, {
get: {
method: 'GET',
interceptor: {
response: function (res) {
return res.data;
},
responseError: function (res) {
if (res.status === 404) {
return res;
}
}
}
}
});
})
.factory('TransactionsByBlock',
function($resource) {
return $resource('/api/txs', {
block: '@block'
});
})
.factory('TransactionsByAddress',
function($resource) {
return $resource('/api/txs', {
address: '@address'
});
})
.factory('Transactions',
function($resource) {
return $resource('/api/txs');
});
// Source: public/src/js/directives.js
var ZeroClipboard = window.ZeroClipboard;
angular.module('insight')
.directive('whenScrolled', function($window) {
return {
restric: 'A',
link: function(scope, elm, attr) {
var pageHeight, clientHeight, scrollPos;
$window = angular.element($window);
var handler = function() {
pageHeight = window.document.documentElement.scrollHeight;
clientHeight = window.document.documentElement.clientHeight;
scrollPos = window.pageYOffset;
if (pageHeight - (scrollPos + clientHeight) === 0) {
scope.$apply(attr.whenScrolled);
}
};
$window.on('scroll', handler);
scope.$on('$destroy', function() {
return $window.off('scroll', handler);
});
}
};
})
.directive('clipCopy', function() {
ZeroClipboard.config({
moviePath: '/lib/zeroclipboard/ZeroClipboard.swf',
trustedDomains: ['*'],
allowScriptAccess: 'always',
forceHandCursor: true
});
return {
restric: 'A',
scope: { clipCopy: '=clipCopy' },
template: '<div class="tooltip fade right in"><div class="tooltip-arrow"></div><div class="tooltip-inner">Copied!</div></div>',
link: function(scope, elm) {
var clip = new ZeroClipboard(elm);
clip.on('load', function(client) {
var onMousedown = function(client) {
client.setText(scope.clipCopy);
};
client.on('mousedown', onMousedown);
scope.$on('$destroy', function() {
client.off('mousedown', onMousedown);
});
});
clip.on('noFlash wrongflash', function() {
return elm.remove();
});
}
};
});
// Source: public/src/js/filters.js
angular.module('insight')
.filter('startFrom', function() {
return function(input, start) {
start = +start; //parse to int
return input.slice(start);
}
});
// Source: public/src/js/config.js
//Setting up route
angular.module('insight').config(function($routeProvider) {
$routeProvider.
when('/block/:blockHash', {
templateUrl: '/views/block.html',
title: 'Bitcoin Block '
}).
when('/block-index/:blockHeight', {
controller: 'BlocksController',
templateUrl: '/views/redirect.html'
}).
when('/tx/:txId', {
templateUrl: '/views/transaction.html',
title: 'Bitcoin Transaction '
}).
when('/', {
templateUrl: '/views/index.html',
title: 'Home'
}).
when('/blocks', {
templateUrl: '/views/block_list.html',
title: 'Bitcoin Blocks solved Today'
}).
when('/blocks-date/:blockDate', {
templateUrl: '/views/block_list.html',
title: 'Bitcoin Blocks solved '
}).
when('/address/:addrStr', {
templateUrl: '/views/address.html',
title: 'Bitcoin Address '
}).
when('/status', {
templateUrl: '/views/status.html',
title: 'Status'
})
.otherwise({
templateUrl: '/views/404.html',
title: 'Error'
});
});
//Setting HTML5 Location Mode
angular.module('insight')
.config(function($locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
})
.run(function($rootScope, $route, ngProgress) {
$rootScope.$on('$routeChangeStart', function() {
ngProgress.start();
});
$rootScope.$on('$routeChangeSuccess', function() {
ngProgress.complete();
//Change page title, based on Route information
$rootScope.titleDetail = '';
$rootScope.title = $route.current.title;
$rootScope.isCollapsed = true;
$rootScope.currentAddr = null;
});
});
// Source: public/src/js/init.js
angular.element(document).ready(function() {
// Init the app
// angular.bootstrap(document, ['insight']);
});

2
public/js/main.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1653
public/js/vendors.js Normal file

File diff suppressed because one or more lines are too long

3
public/js/vendors.min.js vendored Normal file

File diff suppressed because one or more lines are too long