Browse Source

js code updated to not use async false

ca333-dev
Satinder Grewal 8 years ago
parent
commit
2c1f8eeab1
  1. 19
      gui/index.html
  2. 156
      gui/loading.js

19
gui/index.html

@ -34,14 +34,17 @@
var portcheck; var portcheck;
function sartcheck() { function sartcheck() {
portcheck = setInterval(function(){ portcheck = setInterval(function(){
var check = Iguana_activehandle(); Iguana_activehandle().then(function(result){
console.log(check[0]) console.log(result)
if (check[0] !== 'error') { if (result !== 'error') {
stopcheck(); stopcheck();
$('#loading_status_text').text('Connecting to Basilisk Network...') $('#loading_status_text').text('Connecting to Basilisk Network...')
EDEX_DEXgetinfoAll() EDEX_DEXgetinfoAll()
//window.close(); //window.close();
} }
})
//var check = Iguana_activehandle();
//console.log(check[0])
},2000); },2000);
} }

156
gui/loading.js

@ -1,39 +1,48 @@
function Iguana_activehandle() { function IguanaAJAX(url,ajax_data) {
var result = [];
//comment return $.ajax({
var ajax_data = {"agent":"SuperNET","method":"activehandle"};
//console.log(ajax_data);
$.ajax({
async: false,
type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:7778', url: url,
//dataType: 'text', type: 'POST',
success: function(data, textStatus, jqXHR) { dataType: 'json',
var AjaxOutputData = JSON.parse(data); //beforeSend: showLoadingImgFn
//console.log('== ActiveHandle Data OutPut =='); })
.fail(function(xhr, textStatus, error) {
// handle request failures
});
}
function Iguana_activehandle(callback) {
return new Promise((resolve) =>{
var ajax_data = {"agent":"SuperNET","method":"activehandle"};
var AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData); //console.log(AjaxOutputData);
result.push(AjaxOutputData); resolve(AjaxOutputData);
}, }).fail(function(xhr, textStatus, error) {
error: function(xhr, textStatus, error) { // handle request failures
console.log(xhr.statusText); console.log(xhr.statusText);
if ( xhr.readyState == 0 ) { if ( xhr.readyState == 0 ) {
//Iguana_ServiceUnavailable();
result.push('error')
} }
console.log(textStatus); console.log(textStatus);
console.log(error); console.log(error);
} })
}); })
//return 'Executed Iguana_activehandle. Check Iguana_activehandle_output var value.';
return result;
} }
//Iguana_activehandle().then(function(result){
//console.log(result)
//})
function StartIguana() { function StartIguana() {
var ajax_data = {"herd":"iguana"}; var ajax_data = {"herd":"iguana"};
console.log(ajax_data); console.log(ajax_data);
$.ajax({ $.ajax({
async: false, //async: false,
type: 'POST', type: 'POST',
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:17777/shepherd/herd', url: 'http://127.0.0.1:17777/shepherd/herd',
@ -55,82 +64,63 @@ function StartIguana() {
} }
function EDEX_DEXnotarychains() { function EDEX_DEXnotarychains() {
var result = []; return new Promise((resolve) =>{
var ajax_data = {"agent":"dpow","method":"notarychains"}
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); var AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dpow","method":"notarychains"} //console.log(AjaxOutputData.responseText);
console.log(ajax_data); AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
$.ajax({
async: false,
type: 'POST',
data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:7778',
//dataType: 'text',
success: function(data, textStatus, jqXHR) {
var AjaxOutputData = JSON.parse(data);
//console.log('== EDEX_DEXnotarychains Data OutPut ==');
//console.log(AjaxOutputData); //console.log(AjaxOutputData);
result.push(AjaxOutputData); resolve(AjaxOutputData);
}, }).fail(function(xhr, textStatus, error) {
error: function(xhr, textStatus, error) { // handle request failures
console.log(xhr.statusText); console.log(xhr.statusText);
if ( xhr.readyState == 0 ) { if ( xhr.readyState == 0 ) {
Iguana_ServiceUnavailable();
} }
console.log(textStatus); console.log(textStatus);
console.log(error); console.log(error);
} })
}); });
//console.log(result);
return result[0];
} }
function EDEX_DEXgetinfoAll() { function EDEX_DEXgetinfoAll() {
var result = [];
var ajax_data = '';
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth'); var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth');
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dpow","method":"notarychains"}
var get_dex_notarychains = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
//console.log(get_dex_notarychains.responseText);
get_dex_notarychains = JSON.parse(get_dex_notarychains.responseText)
//console.log(get_dex_notarychains)
var get_dex_notarychains = EDEX_DEXnotarychains(); $.each(get_dex_notarychains, function( coin_index, coin_value ) {
console.log(get_dex_notarychains.length) console.log(coin_index + ': ' + coin_value);
var tmpIguanaRPCAuth = 'tmpIgRPCUser@'+sessionStorage.getItem('IguanaRPCAuth');
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"getinfo","symbol":coin_value}
console.log(ajax_data);
$.each(get_dex_notarychains, function( coin_index, coin_value ) { if (coin_value !== 'MESH') {
console.log(coin_index + ': ' + coin_value); var getinfo_each_chain = IguanaAJAX('http://127.0.0.1:7778',ajax_data).done(function(data) {
var ajax_data = {'userpass':tmpIguanaRPCAuth,"agent":"dex","method":"getinfo","symbol":coin_value} getinfo_each_chain = JSON.parse(getinfo_each_chain.responseText)
console.log('==> ajax_data') console.log(getinfo_each_chain)
console.log(ajax_data); var tmp_index = parseInt(coin_index) + 1
$.ajax({ $('#loading_sub_status_text').text('Connection status... ' + tmp_index + '/' + get_dex_notarychains.length + ': ' + coin_value)
//async: false, if (getinfo_each_chain.error === 'less than required responses') {
type: 'POST', $('#loading_sub_status_output_text').text('Output: ' + getinfo_each_chain.error)
data: JSON.stringify(ajax_data), } else {
url: 'http://127.0.0.1:7778', $('#loading_sub_status_output_text').text('Output: Connected')
//dataType: 'text', }
success: function(data, textStatus, jqXHR) { if ( tmp_index == 10 ) {
var AjaxOutputData = JSON.parse(data); //Ajax output gets the whole list of unspent coin with addresses window.close();
//console.log('== EDEX_DEXgetinfoAll Data OutPut =='); }
console.log(AjaxOutputData); }).fail(function(xhr, textStatus, error) {
result.push(AjaxOutputData); // handle request failures
var tmp_index = parseInt(coin_index) + 1 console.log(xhr.statusText);
$('#loading_sub_status_text').text('Connection status... ' + tmp_index + '/' + get_dex_notarychains.length + ': ' + coin_value) if ( xhr.readyState == 0 ) {
if (AjaxOutputData.error === 'less than required responses') { }
$('#loading_sub_status_output_text').text('Output: ' + AjaxOutputData.error) console.log(textStatus);
} else { console.log(error);
$('#loading_sub_status_output_text').text('Output: Connected') })
}
if ( tmp_index == 50 ) {
window.close();
}
},
error: function(xhr, textStatus, error) {
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
} }
}); });
}); });
//console.log(result);
return result[0];
} }
Loading…
Cancel
Save