From 7d3e2d12c81b6c4f278dbdb3625c6b02a23648d3 Mon Sep 17 00:00:00 2001 From: vineetbhargav86 Date: Sat, 6 Feb 2016 21:43:47 +0545 Subject: [PATCH] instantdex modifications and new tradebot tab --- iguana/app/startup.js | 52 +++++- iguana/example.js | 45 +++++ iguana/index.html | 71 ++++++-- iguana/js/api.js | 11 +- iguana/js/common.js | 6 + iguana/js/instantdex.js | 117 +++++++++---- iguana/js/tradebot.js | 289 +++++++++++++++++++++++++++++++ iguana/pnacl/Release/iguana.nmf | 12 -- iguana/pnacl/Release/iguana.pexe | Bin 2758976 -> 0 bytes 9 files changed, 534 insertions(+), 69 deletions(-) create mode 100644 iguana/js/tradebot.js delete mode 100644 iguana/pnacl/Release/iguana.nmf delete mode 100644 iguana/pnacl/Release/iguana.pexe diff --git a/iguana/app/startup.js b/iguana/app/startup.js index bf289a88d..fe252ba32 100644 --- a/iguana/app/startup.js +++ b/iguana/app/startup.js @@ -94,7 +94,57 @@ $(function () { else if(e.className && e.className.indexOf('clear-response-coin') != -1){ $(".coin_result").text("JSON response"); } - ///clear-response-coin + else if(e.className && e.className.indexOf('instantdex_set_userid') != -1){ + InstantDEX_setuserid(); + } + else if(e.className && e.className.indexOf('Tradebot_set_method_table') != -1){ + tradebot_set_method_table(e.getAttribute("data-method")); + } + else if(e.className && e.className.indexOf('Tradebot_monitorall') != -1){ + Tradebot_monitorall_api(); + } + else if(e.className && e.className.indexOf('Tradebot_monitor') != -1){ + Tradebot_monitor_api(); + } + else if(e.className && e.className.indexOf('Tradebot_unmonitor_api') != -1){ + Tradebot_unmonitor_api(); + } + else if(e.className && e.className.indexOf('Tradebot_accumulate') != -1){ + Tradebot_accumulate_api(); + } + else if(e.className && e.className.indexOf('Tradebot_divest') != -1){ + Tradebot_divest_api(); + } + + else if(e.className && e.className.indexOf('Tradebot_activebots') != -1){ + Tradebot_activebots_api(); + } + else if(e.className && e.className.indexOf('Tradebot_status') != -1){ + Tradebot_status_api(); + } + + else if(e.className && e.className.indexOf('Tradebot_pause') != -1){ + Tradebot_pause_api(); + } + else if(e.className && e.className.indexOf('Tradebot_stop') != -1){ + Tradebot_stop_api(); + } + else if(e.className && e.className.indexOf('Tradebot_resume') != -1){ + Tradebot_resume_api(); + } + else if(e.className && e.className.indexOf('instantdex_allpairs') != -1){ + InstantDEX_allpairs(); + + } + // }; + + $("div .btn-primary").on("click",function(){ + $("div .btn-primary").each(function(){ + $(this).removeClass('btn-raised'); + }); + $(this).addClass("btn-raised"); + }); + }); \ No newline at end of file diff --git a/iguana/example.js b/iguana/example.js index 3cac5ee50..1556f9cc5 100755 --- a/iguana/example.js +++ b/iguana/example.js @@ -244,6 +244,7 @@ function ArrayBufferToString(buf) { return String.fromCharCode.apply(null, new U function handleMessage(message_event) { var data = message_event.data; if ((typeof(data) === 'string' || data instanceof String)) { + check_if_pexe_7778_working(data); common.logMessage(data); } else if (data instanceof Object) @@ -279,3 +280,47 @@ function handleMessage(message_event) { common.logMessage('Error: Unknow message `' + data + '` received from NaCl module.'); } } + +var APPLICATION={pexe:"not loaded",port7778:"Not binded"}; + + +var check_if_pexe_7778_working=function(string){ + var if_changed=0; +if(string.indexOf("iguana_rpcloop")>-1 && string.indexOf("bind sock")>-1 ){ + + APPLICATION.port7778="successfully binded"; + if_changed=1; +}else if(string.indexOf("finished DidCreate iguana")>-1){ + APPLICATION.pexe="Loaded"; + if_changed=1; +}else if(string.indexOf("ERROR BINDING PORT.7778")>-1){ + //APPLICATION.state="Loading.."; + APPLICATION.port7778="Retrying"; + /*if(APPLICATION.pexe.indexOf("not loaded")>-1 || APPLICATION.pexe.indexOf("crashed")>-1){ + APPLICATION.state="not working"; + }*/ + if_changed=1; +}else if(string.indexOf("NaCl module crashed")>-1){ + APPLICATION.pexe="crashed"; + if_changed=1; +}else if(string.indexOf("try again: Address already in use")>-1){ + APPLICATION.port7778="bind failed"; + if_changed=1; +} +if(if_changed){change_app_status();} +//finished DidCreate iguana +// ERROR BINDING PORT.7778. will exit. wait up to a minute and try again. dont worry, this is normal +// NativeClient: NaCl module crashed +//string.indexOf(substring) > -1 +//bind(127.0.0.1) port.7778 try again: Address already in use sock.4. errno.98 + + +}; + +var change_app_status=function(){ + var html="ParameterStatus"; + //html=html+"Application state:"+APPLICATION.state+""; + html=html+"Pexe state:"+APPLICATION.pexe+""; + html=html+"Port 7778 state:"+APPLICATION.port7778+""; + $("#appstatus").html(html); +}; diff --git a/iguana/index.html b/iguana/index.html index 3c48d1335..58fe10620 100644 --- a/iguana/index.html +++ b/iguana/index.html @@ -47,7 +47,7 @@ data-path="{tc}/{config}"> - Iguana + Iguana + +
+
+
+
+

+ Tradebot +

+
+
+ + + + + + + + + + + + + + +
+
+ + + + +
+ + + +
+
+
+
+
@@ -402,9 +441,10 @@ data-path="{tc}/{config}">
-

- ** Awaiting specific requirements ** -

+ + + +