Browse Source

Bug fixed

release/v0.1
vineetbhargav86 9 years ago
parent
commit
5a62333a20
  1. 6
      iguana/app/startup.js
  2. 10
      iguana/css/bootstrap.css
  3. 2
      iguana/example.js
  4. 19
      iguana/index.html
  5. 4
      iguana/js/api.js
  6. 124
      iguana/js/jquery.tablesort.js
  7. 5
      iguana/js/jquery.tablesorter.min.js
  8. 94
      iguana/js/peerlist.js
  9. 15
      iguana/js/settings.js

6
iguana/app/startup.js

@ -143,6 +143,8 @@ $(function () {
}
else if(e.className && e.className.indexOf('connect_to_peers_from_conf') != -1){
if(peers_pool.peers.length==0)
load_peers_from_conf();
}
@ -154,6 +156,10 @@ $(function () {
save_peersdata_to_conf();
}
else if(e.className && e.className.indexOf('deletePeertabFile_onclick') != -1){
deletePeertabFile_onclick();
}
};

10
iguana/css/bootstrap.css

File diff suppressed because one or more lines are too long

2
iguana/example.js

@ -356,5 +356,7 @@ var change_app_status=function(){
var initialization_commands=function(){
addInitCoins();
load_peers_to_pool();
ListAllExchanges();
};

19
iguana/index.html

@ -259,15 +259,15 @@ data-path="{tc}/{config}">
<span>Peer Management</span>
</h3>
</div>
<div class="panel-body">
<button class="btn btn-xs btn-success btn-raised connect_to_peers_from_conf" >Connect to peers</button>
<div class="panel-body"><div>
<button class="btn btn-xs btn-success btn-raised connect_to_peers_from_conf" >Load peers</button>
<button class="btn btn-xs btn-success btn-raised save_peersdata_to_conf" >Save Peers</button>
<button class="btn btn-xs btn-success btn-raised update_allpeer_status" >Update Peers</button>
<div class="pull-right">
<span class="checkbox"><label><input id="cbShowFavoritePeers" type="checkbox"/> Favorites</label></span>
</div>
<table id="peersTable" class="table table-hover table-bordered">
</div></div><div class="pre-scrollable">
<table id="peersTable" class="table table-hover table-bordered pre-scrollable">
<thead>
<tr>
<th>IP Address</th>
@ -281,7 +281,7 @@ data-path="{tc}/{config}">
</tr>
</thead>
<tbody id="peersTableBody"></tbody>
</table>
</table></div>
</div>
</div>
</div>
@ -332,9 +332,10 @@ data-path="{tc}/{config}">
<div class="panel-heading">
<h3 class="panel-title">Settings</h3>
</div>
<div class="panel-body">
<div class="panel-body" >
<div class="row">
<div class="col-xs-6 col-md-6 col-lg-6">
<div class="pre-scrollable">
<div class="col-xs-6 col-md-6 col-lg-6 ">
<div id="advanced_settings"></div>
</div>
<div class="col-xs-6 col-md-6 col-lg-6">
@ -355,7 +356,7 @@ data-path="{tc}/{config}">
<button>fwrite</button>
</span>
</div>
</div>
</div></div>
</div>
<div class="row">
<div class="col-xs-6 col-md-6 col-lg-6">
@ -544,7 +545,7 @@ data-path="{tc}/{config}">
<script type="text/javascript " src="js/instantdex.js" ></script>
<script type="text/javascript " src="js/tradebot.js" ></script>
<script type="text/javascript " src="js/storage.js" ></script>
<script type="text/javascript " src="js/jquery.tablesorter.min.js" ></script>
<script type="text/javascript " src="js/jquery.tablesort.js" ></script>
</body>
</html>

4
iguana/js/api.js

@ -34,8 +34,8 @@ var SPNAPI = (function(SPNAPI, $, undefined) {
SPNAPI.loadSite(page);
console.log(page);
if(page==="Peers"){
// /peer_resonse=[];
load_peers_to_pool();
}else if(page==="Settings"){
check_files();
//SPNAPI.check_coin_conf_files_present();

124
iguana/js/jquery.tablesort.js

@ -0,0 +1,124 @@
/*
A simple, lightweight jQuery plugin for creating sortable tables.
https://github.com/kylefox/jquery-tablesort
Version 0.0.6
*/
(function($) {
$.tablesort = function ($table, settings) {
var self = this;
this.$table = $table;
this.$thead = this.$table.find('thead');
this.settings = $.extend({}, $.tablesort.defaults, settings);
this.$sortCells = this.$thead.length > 0 ? this.$thead.find('th:not(.no-sort)') : this.$table.find('th:not(.no-sort)');
this.$sortCells.bind('click.tablesort', function() {
self.sort($(this));
});
this.index = null;
this.$th = null;
this.direction = null;
};
$.tablesort.prototype = {
sort: function(th, direction) {
var start = new Date(),
self = this,
table = this.$table,
//body = table.find('tbody').length > 0 ? table.find('tbody') : table,
rows = this.$thead.length > 0 ? table.find('tbody tr') : table.find('tr').has('td'),
cells = table.find('tr td:nth-of-type(' + (th.index() + 1) + ')'),
sortBy = th.data().sortBy,
sortedMap = [];
var unsortedValues = cells.map(function(idx, cell) {
if (sortBy)
return (typeof sortBy === 'function') ? sortBy($(th), $(cell), self) : sortBy;
return ($(this).data().sortValue != null ? $(this).data().sortValue : $(this).text());
});
if (unsortedValues.length === 0) return;
if (direction !== 'asc' && direction !== 'desc')
this.direction = this.direction === 'asc' ? 'desc' : 'asc';
else
this.direction = direction;
direction = this.direction == 'asc' ? 1 : -1;
self.$table.trigger('tablesort:start', [self]);
self.log("Sorting by " + this.index + ' ' + this.direction);
// Try to force a browser redraw
self.$table.css("display");
// Run sorting asynchronously on a timeout to force browser redraw after
// `tablesort:start` callback. Also avoids locking up the browser too much.
setTimeout(function() {
self.$sortCells.removeClass(self.settings.asc + ' ' + self.settings.desc);
for (var i = 0, length = unsortedValues.length; i < length; i++)
{
sortedMap.push({
index: i,
cell: cells[i],
row: rows[i],
value: unsortedValues[i]
});
}
sortedMap.sort(function(a, b) {
if (a.value > b.value) {
return 1 * direction;
} else if (a.value < b.value) {
return -1 * direction;
} else {
return 0;
}
});
$.each(sortedMap, function(i, entry) {
table.append(entry.row);
});
th.addClass(self.settings[self.direction]);
self.log('Sort finished in ' + ((new Date()).getTime() - start.getTime()) + 'ms');
self.$table.trigger('tablesort:complete', [self]);
//Try to force a browser redraw
self.$table.css("display");
}, unsortedValues.length > 2000 ? 200 : 10);
},
log: function(msg) {
if(($.tablesort.DEBUG || this.settings.debug) && console && console.log) {
console.log('[tablesort] ' + msg);
}
},
destroy: function() {
this.$sortCells.unbind('click.tablesort');
this.$table.data('tablesort', null);
return null;
}
};
$.tablesort.DEBUG = false;
$.tablesort.defaults = {
debug: $.tablesort.DEBUG,
asc: 'sorted ascending',
desc: 'sorted descending'
};
$.fn.tablesort = function(settings) {
var table, sortable, previous;
return this.each(function() {
table = $(this);
previous = table.data('tablesort');
if(previous) {
previous.destroy();
}
table.data('tablesort', new $.tablesort(table, settings));
});
};
})(window.Zepto || window.jQuery);

5
iguana/js/jquery.tablesorter.min.js

File diff suppressed because one or more lines are too long

94
iguana/js/peerlist.js

@ -207,7 +207,7 @@ var renderPeersGrid = function () {
}
document.getElementById('peersTableBody').innerHTML = peersTableAllHtml;
$("#peersTable").tablesorter();
};
@ -223,29 +223,57 @@ var startPeerManagement = function () {
};
var peers_pool={"connected":0,peers:[],"saved":false};
var peers_pool={"connected":0,peers:[],"saved":false,"maxpeer":SPNAPI.settings.maxpeers};
var addpeers_from_conf= function(peer_file_as_text, coin_symbol){
var peers=peer_file_as_text.split("\n");
var showConnected=true;
var total_peers=0;
for(var ip in peers){
if(showConnected && ip<SPNAPI.settings.maxpeers){
if(total_peers<SPNAPI.settings.maxpeers){
if(peers[ip]!=="" && peers[ip]!=="\n"){
console.log(peers[ip]);
var peer={"ipaddr":peers[ip],"coin":coin_symbol,"connected":false,"favourite":false,"nodestatus":{"ipaddr":peers[ip],"protover":0,"relay":0,"height":0,"rank":0,"usock":0,"ready":0,"recvblocks":0,"recvtotal":0,"lastcontact":0,"msgcounts":{"version":0,"verack":0,"getaddr":0,"addr":0,"inv":0,"getdata":0,"notfound":0,"getblocks":0,"getheaders":0,"headers":0,"tx":0,"block":0,"mempool":0,"ping":0,"pong":0,"reject":0,"filterload":0,"filteradd":0,"filterclear":0,"merkleblock":0,"alert":0}}};
peers_pool.peers.push(peer);
if(ip<SPNAPI.settings.maxpeers){
connectPeer_from_conf(peers[ip],coin_symbol);}
if(total_peers<SPNAPI.settings.maxpeers){
connectPeer_from_conf(peers[ip],coin_symbol);
}
total_peers=total_peers+1;
}
}
}
peers_pool.maxpeer=SPNAPI.settings.maxpeers;
console.log("total "+total_peers+" peers added in file supporting "+coin_symbol);
};
var sync_peers_to_maxpeers=function(){
//disconnect_all_peers();
peers_pool.peers=[];
load_peers_from_conf();
};
var disconnect_all_peers=function(){
for(var peers in peers_pool.peers){
if(peers_pool.peers[peers].connected){
disconnectPeer(peers_pool.peers[peers].ipaddr,peers_pool.peers[peers].coin,0);
}
}
};
var check_peer_present=function(ip,coin){
for(var peers in peers_pool.peers){
if(peers_pool.peers[peers].ipaddr ===ip && peers_pool.peers[peers].coin===coin){
return true;
}
}
return false;
};
var update_connected=function(coin,ip,id,value){
if(peers_pool.peers[id].ipaddr ===ip && peers_pool.peers[id].coin===coin){
if(peers_pool.peers[id] && peers_pool.peers[id].ipaddr ===ip && peers_pool.peers[id].coin===coin){
peers_pool.peers[id].connected=value;
}else{
for(var peers in peers_pool.peers){
@ -260,7 +288,7 @@ var update_connected=function(coin,ip,id,value){
var update_favourite=function(coin,ip,id,value){
console.log("@update_favourite got values coin:"+coin+" ip:"+ip+" id:"+id+" value:"+value);
if(peers_pool.peers[id].ipaddr ===ip && peers_pool.peers[id].coin===coin){
if(peers_pool.peers[id] && peers_pool.peers[id].ipaddr ===ip && peers_pool.peers[id].coin===coin){
peers_pool.peers[id].favourite=value;
}else{
for(var peers in peers_pool.peers){
@ -297,17 +325,23 @@ var update_allpeer_status=function(){
};
var save_peersdata_to_conf=function(){
if(peers_pool.saved){
delete_file("confs/peer_tab.save");
}
save_contents(JSON.stringify(peers_pool),"confs/peer_tab.save");
peers_pool.saved=true;
save_contents(JSON.stringify(peers_pool),"confs/peer_tab.save");
};
var load_peers_to_pool=function(){
var deletePeertabFile_onclick=function(){
//disconnect_all_peers();
delete_file("confs/peer_tab.save");
peers_pool.peers=[];
renderPeersGrid();
fileSystem.root.getFile("confs/peer_tab.save", {}, function(fileEntry) {
};
var load_peers_to_pool=function(){
//if()
{
fileSystem.root.getFile("confs/peer_tab.save", {}, function(fileEntry) {
//console.log("entered file fu");
// Get a File object representing the file,
// then use FileReader to read its contents.
@ -318,6 +352,8 @@ var load_peers_to_pool=function(){
var peer=this.result;
console.log("reading peerconf file "+this.result);
peers_pool=JSON.parse(peer);
SPNAPI.settings.maxpeers=peers_pool.maxpeer;
resume_connected_peers();
renderPeersGrid();
};
@ -330,8 +366,21 @@ var load_peers_to_pool=function(){
}, function(e){
errorHandler(e);
});
});
}
};
var First_run_peer=true;
var resume_connected_peers=function(){
console.log("resuming peers!");
for(var peers in peers_pool.peers){
if(peers_pool.peers[peers].connected){
connectPeer_from_conf(peers_pool.peers[peers].ipaddr,peers_pool.peers[peers].coin);
}
}
First_run_peer=false;
};
function connectPeer_from_conf(ip,coin){
@ -345,6 +394,9 @@ function connectPeer_from_conf(ip,coin){
console.log('connected to peer ' + ip+" supporting "+coin);
update_connected(coin,ip,0,true);
renderPeersGrid();
}else{
update_connected(coin,ip,0,false);
renderPeersGrid();
}
});
@ -381,3 +433,17 @@ var load_peer_file=function(name,coin){
}, errorHandler);
};
$(document).ready(function () {
// $("#tab").tablesorter();
//$("#peersTable").tablesorter();
$('#peersTable').tablesort();
});
$('table').on('tablesort:start', function(event, tablesort) {
console.log("Starting the sort...");
});
$('table').on('tablesort:complete', function(event, tablesort) {
console.log("Sort finished!");
});

15
iguana/js/settings.js

@ -183,6 +183,20 @@ var SPNAPI = (function(SPNAPI, $,errorHandler,undefined) {
'<div class="row"><div class="pexe_extra_info col-xs-10 col-md-10 col-lg-10">Set number of nodes connected directly per coin type</div></div>'+
'</div>'+
'</div>';
config += '' +
'<div class="panel panel-default">'+
'<div class="panel-body">'+
'<div class="col-xs-6 col-md-6 col-lg-6">Delete peer data</div>'+
'<div class="col-xs-6 col-md-6 col-lg-6" style="text-align: right;">' +
'<div class="checkbox">'+
'<label>'+
'<span><button class="btn btn-xs btn-success btn-raised deletePeertabFile_onclick" > Delete</button></span>'+
'</label>'+
'</div>' +
'</div>' +
'<div class="row"><div class="pexe_extra_info col-xs-10 col-md-10 col-lg-10">Delete peer tab data</div></div>'+
'</div>'+
'</div>';
$("#advanced_settings").html(config);
@ -215,6 +229,7 @@ var SPNAPI = (function(SPNAPI, $,errorHandler,undefined) {
if(SPNAPI.settings.maxpeers!==peers){
SPNAPI.settings.maxpeers=peers;
console.log("maxpeers set to "+SPNAPI.settings.maxpeers);
sync_peers_to_maxpeers();
}
/*var agent_checkbox = $('.agent_checkbox');

Loading…
Cancel
Save