From af21815ed08e61891bc595741d65a4f5e3b31344 Mon Sep 17 00:00:00 2001 From: vineetbhargav86 Date: Tue, 2 Feb 2016 20:39:03 +0545 Subject: [PATCH] changed blockexplorer and deleted setting tab --- iguana/index.html | 30 +++++++----------- iguana/js/api.js | 54 +++++++++++++++++++++++++++----- iguana/js/blockexplorer.js | 63 ++++++++++++++++++++++++++++++++------ 3 files changed, 112 insertions(+), 35 deletions(-) diff --git a/iguana/index.html b/iguana/index.html index 68add5e5b..d00ddcc6d 100644 --- a/iguana/index.html +++ b/iguana/index.html @@ -356,37 +356,29 @@ data-path="{tc}/{config}">
-
+

Block Explorer tab

+
+ +

Set Active coin

-
- -
-
- -
-
- -
-
- -
-
- +
+
- -
- +
+ + + +
-

** Awaiting specific requirements **

diff --git a/iguana/js/api.js b/iguana/js/api.js index 1ed54a6f5..6d111e36e 100755 --- a/iguana/js/api.js +++ b/iguana/js/api.js @@ -11,7 +11,7 @@ function tagGen(len) var SPNAPI = (function(SPNAPI, $, undefined) { SPNAPI.methods = {}; - SPNAPI.pages = ["Settings","Instandex", "Pangea", "Peers","Debug", "Coins", "Blockexplorer"]; + SPNAPI.pages = ["Instandex", "Pangea", "Peers","Debug", "Coins", "Blockexplorer"]; SPNAPI.pageContent = {}; SPNAPI.page = "Blockexplorer"; /* @@ -100,27 +100,67 @@ var SPNAPI = (function(SPNAPI, $, undefined) { }); }else{ request = JSON.parse( request ); - var url=SPNAPI.returnAJAXgetURL(request); + var usepost=SPNAPI.useGETRequest(request); if(url!==false){ /* * Ajax request will be sent if pexe is not loaded or * if usepexe is set to false * (this adds the user the ability to handle how requests are sent) - */ -$.ajax({ + */ + if(!usepost){ + var url=SPNAPI.returnAJAXPostURL(request); + $.ajax({ + type: "POST", + url: url, + crossDomain: true, + dataType: 'json', + data: request, + success: function(response, textStatus, jqXHR) { + console.log('AJAX Response is ' + JSON.stringify(response)); + callback(request, response); + }, + error: function (responseData, textStatus, errorThrown) { + console.log('POST request failed.'); + } + +}); +}else{ + var url=SPNAPI.returnAJAXgetURL(request); + $.ajax({ type: "GET", - url: url - }).done(function( response ) { + url: url, + success:function( response ) { console.log('AJAX Response is ' + response); //if(typeof callback === 'function'){ callback(request, response); //} - }); } +}); +} +} } }; + SPNAPI.useGETRequest=function(request){ + if(request.method && (request.method==='apikeypair' || request.method==='setuserid')){ + return false; + }else{ + return true; + } + }; + + SPNAPI.returnAJAXPostURL=function(request){ + + var url=SPNAPI.domain+":"+SPNAPI.port; + if(request.method === undefined){ + console.log("Invalid request."); + return false; + } + console.log("Post Url for request:"+url); + return url; + }; + SPNAPI.returnAJAXgetURL=function(request){ var url=SPNAPI.domain+":"+SPNAPI.port+"/api/"; diff --git a/iguana/js/blockexplorer.js b/iguana/js/blockexplorer.js index 128e903f2..0c2fa3f18 100644 --- a/iguana/js/blockexplorer.js +++ b/iguana/js/blockexplorer.js @@ -44,7 +44,8 @@ var callBlockEXPRPC=function(coin){ SPNAPI.makeRequest(request, function(request,response){ response=JSON.parse(response); if(response.result && response.result==='set bitcoin RPC coin'){ - document.getElementById('Blockhashbutton').innerHTML=''; + + blockExp_input_table(); } }); }; @@ -57,8 +58,20 @@ var callBlockEXPRPC=function(coin){ * (initially height is set to zero) * */ + +var filterInt = function (value) { + if(/^(\-|\+)?([0-9]+|Infinity)$/.test(value)) + return Number(value); + return "NaN"; +} + var getBlockhash= function(height){ + var height=($('#BlockExp_height').val()); + /* + if (height === "NaN" || height ==='Infinity') { + height=0; + }*/ var request="{\"agent\":\"ramchain\",\"method\":\"getblockhash\",\"height\":\""+height+"\"}"; SPNAPI.makeRequest(request, function(request,response){ @@ -66,8 +79,8 @@ var getBlockhash= function(height){ if(response.result){ BlockHash=response.result; //Blockhashoutput - document.getElementById('Blockhashoutput').innerHTML='Blockhash is: '+BlockHash; - document.getElementById('Blockbutton').innerHTML=''; + document.getElementById('block_output_table').innerHTML=''+'Blockhash is: '+BlockHash+''; + $('#BlockExp_blockhash').val(BlockHash); } }); @@ -83,16 +96,20 @@ var getBlockhash= function(height){ * */ var getBlock= function(hash){ - + var inputhash=$('#BlockExp_blockhash').val(); + if(inputhash!==hash){ + hash=inputhash; + } var request="{\"agent\":\"ramchain\",\"method\":\"getblock\",\"blockhash\":\""+hash+"\",\"remoteonly\":\""+checkExternalBlock+"\"}"; SPNAPI.makeRequest(request, function(request,response){ response=JSON.parse(response); if(response.result){ - document.getElementById('Blockoutput').innerHTML=response.result; + document.getElementById('block_output_table').innerHTML=''+'Block is: '+response.result+''; Block=response.result; - document.getElementById('transactionButton').innerHTML=''; - + }else if(response.error){ + document.getElementById('block_output_table').innerHTML=''+JSON.stringify(response)+''; + } }); @@ -111,8 +128,12 @@ var getBlock= function(hash){ //e7386986f14c994d6c70e8eb60753ea1fe2dc2a58567e6269dc6b04ef5310693 //5f7edfb417855f80b7c12e1a9c040f8b496db23c82c90e4de905b8cff8139f03 var getRawTransaction=function(Hash){ - var request="{\"agent\":\"ramchain\",\"method\":\"getrawtransaction\",\"txid\":\"5f7edfb417855f80b7c12e1a9c040f8b496db23c82c90e4de905b8cff8139f03\",\"verbose\":1}"; + + var inputhash=$('#BlockExp_txid').val(); + var request="{\"agent\":\"ramchain\",\"method\":\"getrawtransaction\",\"txid\":\""+inputhash+"\",\"verbose\":1}"; SPNAPI.makeRequest(request, function(request,response){ + document.getElementById('block_output_table').innerHTML=''+'Output is: '+response+''; + /*response=JSON.parse(response); if(response.result){ document.getElementById('Blockoutput').innerHTML=response.result; @@ -122,6 +143,22 @@ var getRawTransaction=function(Hash){ }); }; +var change_ExternalBlocks=function(){ + + + if(document.getElementById('cbChangeExternalBlocks').checked){ + checkExternalBlock=1; + }else{ + checkExternalBlock=0; + } + console.log("CheckExternalBlock flag change to "+checkExternalBlock); + +}; + +document.getElementById('cbChangeExternalBlocks').onclick = function () { + change_ExternalBlocks(); +}; + /* * * called initially @@ -132,4 +169,12 @@ var startBlockExplorer=function(){ setCoinRadio(); }; - +var blockExp_input_table=function(){ + + var table='Input height:\ +\ +Blockhash:\n\ +Txid:'; + document.getElementById('block_input_table').innerHTML=table; + document.getElementById('block_output_table').innerHTML=""; +};