Skip to content
Open

Ac #3

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: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"rpcUrl": "http://78.47.64.48/api"
"rpcUrl": "https://explorer.affilcoin.net/api"
}
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@
<a class="navbar-brand" href="https://affilcoin.com">
<img src="https://affilcoin.com/static/img/logo.de4fc5a8.svg" alt="affilcoin" style="height: 40px" />
</a>
<!--
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
-->
<button class="navbar-toggler" type="button" id="button_open_menu">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">
<li class="nav-divider"></li>
Expand Down Expand Up @@ -112,6 +118,11 @@ <h4 class="modal-title">Allow Access to Geth and Refresh the Page</h4>
</div>
<script>
$("#modaltext").text( 'geth --rpc --rpccorsdomain "'+ window.location.protocol + '//' + window.location.host + '"' );
$(document).ready(function(){
$('#button_open_menu').click(function(){
$('#navbarNav').toggle();
});
});
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion scripts/controllers/addressInfoController.js

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

48 changes: 30 additions & 18 deletions scripts/controllers/blockInfosController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ angular.module('ethExplorer.block', ['ngRoute','ui.bootstrap'])
.controller('blockInfosCtrl', function ($rootScope, $scope, $location, $routeParams,$q) {

var web3 = $rootScope.web3;


$scope.init = function()
{
$rootScope.loading = true;
$scope.blockId = $routeParams.blockId;


var number = 0;
if($scope.blockId!==undefined) {


web3.eth.getBlockNumber().then(res => {
number = res;
}, err => console.log(err));

getBlockInfos()
.then(function(result){
.then( function(result){

var number = web3.eth.blockNumber;
$rootScope.loading = false;
$scope.result = result;

Expand All @@ -30,24 +36,28 @@ angular.module('ethExplorer.block', ['ngRoute','ui.bootstrap'])
$scope.miner ='pending';
}
$scope.gasLimit = result.gasLimit;
$scope.gasUsed = result.gasUsed;
$scope.nonce = result.nonce;
$scope.gasUsed = (result.gasUsed !== null ? result.gasUsed : 0);
$scope.nonce = (result.nonce === null ? 'null' : result.nonce);
$scope.difficulty = ("" + result.difficulty).replace(/['"]+/g, '');
$scope.gasLimit = result.gasLimit; // that's a string
$scope.nonce = result.nonce;
$scope.number = result.number;
$scope.parentHash = result.parentHash;
$scope.blockNumber = result.number;
$scope.timestamp = result.timestamp;
$scope.extraData = result.extraData;
$scope.extraData = (result.extraData === null ? 'null' : result.extraData);
$scope.dataFromHex = hex2a(result.extraData);
$scope.size = result.size;
if($scope.blockNumber!==undefined){
$scope.conf = number - $scope.blockNumber + " Confirmations";
if($scope.conf===0 + " Confirmations"){
$scope.conf='Unconfirmed';
}
}

if(result.number!==undefined){
$scope.conf = number - result.number + " Confirmations";
if($scope.conf===0 + " Confirmations"){
$scope.conf='Unconfirmed';
}
if ( (number - result.number) <= 0) {
$scope.conf='Unconfirmed';
}
}

if($scope.blockNumber!==undefined){
var info = web3.eth.getBlock($scope.blockNumber);
if(info!==undefined){
Expand All @@ -57,8 +67,6 @@ angular.module('ethExplorer.block', ['ngRoute','ui.bootstrap'])
}
}



});

} else {
Expand Down Expand Up @@ -87,9 +95,10 @@ angular.module('ethExplorer.block', ['ngRoute','ui.bootstrap'])
// parse transactions
$scope.transactions = []
web3.eth.getBlockTransactionCount($scope.blockId, function(error, result){
var txCount = result

var txCount = result;
for (var blockIdx = 0; blockIdx < txCount; blockIdx++) {

web3.eth.getTransactionFromBlock($scope.blockId, blockIdx, function(error, result) {

var transaction = {
Expand All @@ -110,6 +119,9 @@ angular.module('ethExplorer.block', ['ngRoute','ui.bootstrap'])


function hex2a(hexx) {
if (hexx === null) {
return 'null';
}
var hex = hexx.toString();//force conversion
var str = '';
for (var i = 0; i < hex.length; i += 2)
Expand Down
38 changes: 36 additions & 2 deletions scripts/controllers/mainController.js

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

24 changes: 17 additions & 7 deletions scripts/controllers/transactionInfosController.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
angular.module('ethExplorer.tx', ['ngRoute','ui.bootstrap'])
.controller('transactionInfosCtrl', function ($rootScope, $scope, $location, $routeParams,$q) {

var web3 = $rootScope.web3;

var web3 = $rootScope.web3;

$scope.init=function()
{
$scope.txId=$routeParams.transactionId;

web3.eth.getTransactionReceipt($scope.txId).then((res)=>{
console.log('res: '+res);
}, (err) => {
console.log('err: '+err);
});

if($scope.txId!==undefined) { // add a test to check if it match tx paterns to avoid useless API call, clients are not obliged to come from the search form...
$rootScope.loading = true;
getTransactionInfos()
.then(function(result){
.then(function(result){
if (result == null) {
$rootScope.loading = false;
alert('Невозможно отобразить данные о транзакции');
return console.log('getTransactionInfos err: '+result);
}
//TODO Refactor this logic, asynchron calls + services....
var number = web3.eth.blockNumber;
$rootScope.loading = false;
$scope.result = result;

if(result.blockHash!==undefined){
$scope.blockHash = result.blockHash;
}
Expand Down Expand Up @@ -52,7 +62,7 @@ angular.module('ethExplorer.tx', ['ngRoute','ui.bootstrap'])
}
}

});
}, err => console.log(err));

}

Expand All @@ -64,6 +74,7 @@ angular.module('ethExplorer.tx', ['ngRoute','ui.bootstrap'])


function getTransactionInfos(){

var deferred = $q.defer();

web3.eth.getTransaction($scope.txId,function(error, result) {
Expand All @@ -82,6 +93,5 @@ angular.module('ethExplorer.tx', ['ngRoute','ui.bootstrap'])

};
$scope.init();
console.log($scope.result);

});
8 changes: 8 additions & 0 deletions styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ input.form-control {
width: 400px !important;
}

@media screen and (max-width: 990px) {
input.form-control {
width: 0 !important;
}
.collapse {
margin-bottom: 30px;
}
}

.navbar-brand {
padding-left: 0;
Expand Down