From cdb92801120036232684788a3343a17c02a05625 Mon Sep 17 00:00:00 2001 From: vineetbhargav86 Date: Mon, 1 Feb 2016 20:47:06 +0545 Subject: [PATCH] Updated coin mgt block exp pangea instantdex --- iguana/app/coin_mgmt.js | 132 +++++++++++-- iguana/app/startup.js | 67 ++++++- iguana/index.html | 97 ++++++++-- iguana/js/api.js | 16 +- iguana/js/blockexplorer.js | 135 +++++++++++++ iguana/js/instantdex.js | 385 +++++++++++++++++++++++++++++++++++++ iguana/js/pangea.js | 120 ++++++++++++ iguana/js/sites.js | 2 +- 8 files changed, 923 insertions(+), 31 deletions(-) create mode 100644 iguana/js/blockexplorer.js create mode 100644 iguana/js/instantdex.js create mode 100644 iguana/js/pangea.js diff --git a/iguana/app/coin_mgmt.js b/iguana/app/coin_mgmt.js index b4d1cb273..7d00e718a 100644 --- a/iguana/app/coin_mgmt.js +++ b/iguana/app/coin_mgmt.js @@ -30,13 +30,13 @@ coinManagement.CoinStatuses = [ coinManagement.Initialize = function () { coinManagement.Coins = [ - new coinManagement.Coin(6, 'USD', 'US Dollar', 1), - new coinManagement.Coin(2, 'EUR', 'EURO', 2), - new coinManagement.Coin(3, 'GBP', 'British Pound', 3), - new coinManagement.Coin(4, 'INR', 'Indian Rupee', 4), - new coinManagement.Coin(5, 'YEN', 'Japanese Yen', 3) + new coinManagement.Coin(1, 'BTC', 'Bitcoin', 1), + new coinManagement.Coin(2, 'BTCD', 'Bitcoin Dark', 1), + //new coinManagement.Coin(3, 'GBP', 'British Pound', 3), + //new coinManagement.Coin(4, 'INR', 'Indian Rupee', 4), + //new coinManagement.Coin(5, 'YEN', 'Japanese Yen', 3) ]; -} +}; coinManagement.GetCoinIndex = function (id) { @@ -52,6 +52,20 @@ coinManagement.GetCoinIndex = function (id) { } }; +coinManagement.GetCoinIndexBySymbol = function (id) { + + if (coinManagement.Coins == null || coinManagement.Coins == undefined) { + return -1; + } + + for (var index = 0; index < coinManagement.Coins.length; index++) { + if (coinManagement.Coins[index].Symbol == id) { + console.log('# coin symbol:' + id.toString() + 'is @' + index); + return index; + } + } +}; + coinManagement.Post = function (coin) { if (coin === null || coin === undefined) { @@ -228,15 +242,35 @@ var GetStatusNameHtml = function (id) { }; -var getActionButton = function (id) { - return ''; +var getActionButton = function (objCoin) { + if(objCoin.StatusId===3){ + return getStopActionButton(objCoin.Id); + }else if(objCoin.StatusId===2 || objCoin.StatusId===4){ + return getStartActionButton(objCoin.Id); + }else if(objCoin.StatusId===1){ + return getAddActionButton(objCoin.Id); + } +}; + +var getAddActionButton = function (id) { + return ''; +}; + +var getStopActionButton = function (id) { +// return ''; + return ''; +}; + +var getStartActionButton = function (id) { +// return ''; + return ''; }; var objToHtml = function (objCoin) { if (objCoin == null || objCoin == undefined) { return ''; } - return '' + objCoin.Symbol + '' + objCoin.Description + '' + GetStatusNameHtml(objCoin.StatusId) + '' + getActionButton(objCoin.Id) + ''; + return '' + objCoin.Symbol + '' + objCoin.Description + '' + GetStatusNameHtml(objCoin.StatusId) + '' + getActionButton(objCoin) + ''; }; var addCoin = function (e) { @@ -244,7 +278,7 @@ var addCoin = function (e) { console.log('# add coin called'); e.target.removeAttribute('data-dismiss'); - if (coinEditFormIsValid() == false) { + if (coinEditFormIsValid() === false) { console.log('# add coin form is invalid'); return; } @@ -283,11 +317,85 @@ var deleteCoin = function (id) { renderGrid(); }; +var pauseCoin = function (id) { + console.log('# coin pause called'); + var index = coinManagement.GetCoinIndex(id); + var coin=coinManagement.Coins[index].Symbol; + console.log("clicked on coin "+coin); + var request="{\"agent\":\"iguana\",\"method\":\"pausecoin\",\"coin\":\""+coin+"\"}"; + + SPNAPI.makeRequest(request, function(request,response){ + response=JSON.parse(response); + if(response.result && response.result ==="coin paused"){ + var indx=coinManagement.GetCoinIndexBySymbol(request.coin); + coinManagement.Coins[indx].StatusId=4; + console.log("coins status changed "+coinManagement.Coins[indx].StatusId); + renderGrid(); + } + }); + +}; + +var startCoin = function (id) { + console.log('# coin start called'); + //coinManagement.Delete(id); + var index = coinManagement.GetCoinIndex(id); + var coin=coinManagement.Coins[index].Symbol; + console.log("clicked on coin "+coin); + var request="{\"agent\":\"iguana\",\"method\":\"startcoin\",\"coin\":\""+coin+"\"}"; + + SPNAPI.makeRequest(request, function(request,response){ + response=JSON.parse(response); + if(response.result && response.result ==="coin started"){ + var indx=coinManagement.GetCoinIndexBySymbol(request.coin); + coinManagement.Coins[indx].StatusId=3; + console.log("coins status changed "+coinManagement.Coins[indx].StatusId); + renderGrid(); + } + }); + +}; + +var addExistingCoin = function (id) { + + var isactive=0; + var maxpeers=16; + var services=128; + var index = coinManagement.GetCoinIndex(id); + console.log('# coin add called '+index); + var coin=coinManagement.Coins[index].Symbol; + console.log("clicked on coin "+coin); + var request="{\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\""+coin+"\",\"active\":"+isactive+",\"maxpeers\":"+maxpeers+",\"services\":"+services+"}"; + + SPNAPI.makeRequest(request, function(request,response){ + response=JSON.parse(response); + if(response.result && (response.result ==="coin added" || response.result ==="coin already there")){ + var indx=coinManagement.GetCoinIndexBySymbol(request.newcoin); + coinManagement.Coins[indx].StatusId=2; + console.log("coins status changed "+coinManagement.Coins[indx].StatusId); + renderGrid(); + } + }); + +}; + +var initCoinsAdded=false; + +var addInitCoins= function(){ + + if(!initCoinsAdded){ + for (var index = 0; index < coinManagement.Coins.length; index++) { + addExistingCoin(coinManagement.Coins[index].Id); + } + initCoinsAdded=true; + } +}; + var coinEditFormReset = function () { document.getElementById('txtSymbol').value = ''; document.getElementById('txtDescription').value = ''; document.getElementById('ddStatus').value = 1; -} +}; // Event Handlers var startCoinManagement = function () { @@ -302,4 +410,4 @@ var startCoinManagement = function () { renderGrid(); populateCoinStatusDropDown(); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/iguana/app/startup.js b/iguana/app/startup.js index 302c3d481..b561b64da 100644 --- a/iguana/app/startup.js +++ b/iguana/app/startup.js @@ -4,6 +4,7 @@ $(function () { $(".select ").dropdown({ "autoinit ": ".select " }); startCoinManagement(); + startBlockExplorer(); //startPeerManagement(); // Event Handlers @@ -11,8 +12,12 @@ $(function () { // $('.coinMgmtActionButton').click equivelant w/o jQuery document.body.onclick = function (e) { e = window.event ? event.srcElement : e.target; - if (e.className && e.className.indexOf('coinMgmtActionButton') != -1) { - deleteCoin(e.getAttribute('data-id')); + if (e.className && e.className.indexOf('coinMgmtStartActionButton') != -1) { + startCoin(e.getAttribute('data-id')); + } else if (e.className && e.className.indexOf('coinMgmtAddActionButton') != -1) { + addExistingCoin(e.getAttribute('data-id')); + } else if (e.className && e.className.indexOf('coinMgmtStopActionButton') != -1) { + pauseCoin(e.getAttribute('data-id')); } else if (e.className && e.className.indexOf('addPeerToFav') != -1) { addPeerToFav(e.getAttribute('data-id'),e.getAttribute('data-coin')); @@ -25,6 +30,64 @@ $(function () { }else if(e.className && e.className.indexOf('connectPeer') != -1){ connectPeer(e.getAttribute('data-ip'),e.getAttribute('data-coin')); + }else if(e.className && e.className.indexOf('coinRPCactive') != -1){ + callBlockEXPRPC(e.getAttribute('data-value')); + }else if(e.className && e.className.indexOf('getBlockHashActionButton') != -1){ + getBlockhash(e.getAttribute('data-height')); + }else if(e.className && e.className.indexOf('getBlockActionButton') != -1){ + getBlock(e.getAttribute('data-hash')); + }else if(e.className && e.className.indexOf('getTrancationActionButton') != -1){ + getRawTransaction(e.getAttribute('data-hash')); } + else if(e.className && e.className.indexOf('host_pangea_request') != -1){ + hostPangea(); + } + else if(e.className && e.className.indexOf('list_pangea_request') != -1){ + lobbyPangea(); + } + else if(e.className && e.className.indexOf('join_pangea_game') != -1){ + joinPangea(e.getAttribute("data-tablehash")); + } + else if(e.className && e.className.indexOf('instantdex_set_keypair') != -1){ + setUeseridandAPIkeyPair(); + } + else if(e.className && e.className.indexOf('instantdex_orderbook') != -1){ + orderbook(); + } + else if(e.className && e.className.indexOf('instantdex_set_method_table') != -1){ + instantdex_set_method_table(e.getAttribute("data-method")); + } + else if(e.className && e.className.indexOf('instantdex_sell') != -1){ + InstantDEXSell(); + } + else if(e.className && e.className.indexOf('instantdex_buy') != -1){ + InstantDEXBuy(); + } + else if(e.className && e.className.indexOf('instantdex_balance') != -1){ + InstantDEX_balance(); + } + else if(e.className && e.className.indexOf('instantdex_support') != -1){ + InstantDEX_supports(); + } + else if(e.className && e.className.indexOf('instantdex_withdraw') != -1){ + InstantDEXWithdaw(); + } + else if(e.className && e.className.indexOf('instantdex_order_status') != -1){ + InstantDEX_orderstatus(); + } + else if(e.className && e.className.indexOf('instantdex_open_orders') != -1){ + InstantDEX_openorders(); + } + else if(e.className && e.className.indexOf('instantdex_trade_history') != -1){ + InstantDEX_tradehistory(); + } + else if(e.className && e.className.indexOf('instantdex_order_cancel') != -1){ + InstantDEX_cancelorder(); + } + else if(e.className && e.className.indexOf('instantdex_pollgap') != -1){ + InstantDEX_pollgap(); + } + ///instantdex_pollgap + }; }); \ No newline at end of file diff --git a/iguana/index.html b/iguana/index.html index 640944e44..68add5e5b 100644 --- a/iguana/index.html +++ b/iguana/index.html @@ -52,7 +52,7 @@ data-path="{tc}/{config}">