Skip to content

Commit

Permalink
Merge pull request #78 from corollari/infinite-params
Browse files Browse the repository at this point in the history
Enable parameter addition (unlimited parameters)
  • Loading branch information
corollari committed Dec 29, 2019
2 parents fbdd947 + a538797 commit 6887b25
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
53 changes: 22 additions & 31 deletions public/js/eco-scripts/abi_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,17 @@ function updateInvokeParamsJs() {

if (invokefunc != "")
pushParams(neonJSParams, "String", invokefunc);

if ($("#invokeparamjsbox1")[0].value != "None") {
if ($("#cbx_inarray_js1")[0].checked)
pushParams(arrayparam, $("#invokeparamjsbox1")[0].value, $("#invokeparamsjs1")[0].value);
else
pushParams(neonJSParams, $("#invokeparamjsbox1")[0].value, $("#invokeparamsjs1")[0].value);
}
if ($("#invokeparamjsbox2")[0].value != "None") {
if ($("#cbx_inarray_js2")[0].checked)
pushParams(arrayparam, $("#invokeparamjsbox2")[0].value, $("#invokeparamsjs2")[0].value);
else
pushParams(neonJSParams, $("#invokeparamjsbox2")[0].value, $("#invokeparamsjs2")[0].value);
}
if ($("#invokeparamjsbox3")[0].value != "None") {
if ($("#cbx_inarray_js3")[0].checked)
pushParams(arrayparam, $("#invokeparamjsbox3")[0].value, $("#invokeparamsjs3")[0].value);
else
pushParams(neonJSParams, $("#invokeparamjsbox3")[0].value, $("#invokeparamsjs3")[0].value);
}

var i = 1;
while($("#invokeparamjsbox"+i).length > 0){
if ($("#invokeparamjsbox"+i)[0].value != "None") {
if ($("#cbx_inarray_js"+i)[0].checked)
pushParams(arrayparam, $("#invokeparamjsbox"+i)[0].value, $("#invokeparamsjs"+i)[0].value);
else
pushParams(neonJSParams, $("#invokeparamjsbox"+i)[0].value, $("#invokeparamsjs"+i)[0].value);
}
i++;
}

if ($("#cbx_usearray_js")[0].checked)
pushParams(neonJSParams, 'Array', arrayparam);
Expand All @@ -165,20 +157,19 @@ function updateInvokeParamsJs() {

// block and unblock array checkboxes
function updateArrayInvokeParamsJs() {
var paramId = 1;
if ($("#cbx_usearray_js")[0].checked) {
$("#cbx_inarray_js1")[0].checked = true;
$("#cbx_inarray_js1")[0].disabled = false;
$("#cbx_inarray_js2")[0].checked = true;
$("#cbx_inarray_js2")[0].disabled = false;
$("#cbx_inarray_js3")[0].checked = true;
$("#cbx_inarray_js3")[0].disabled = false;
while($("#cbx_inarray_js"+paramId).length>0){
$("#cbx_inarray_js"+paramId)[0].checked = true;
$("#cbx_inarray_js"+paramId)[0].disabled = false;
paramId++;
}
} else {
$("#cbx_inarray_js1")[0].checked = false;
$("#cbx_inarray_js1")[0].disabled = true;
$("#cbx_inarray_js2")[0].checked = false;
$("#cbx_inarray_js2")[0].disabled = true;
$("#cbx_inarray_js3")[0].checked = false;
$("#cbx_inarray_js3")[0].disabled = true;
while($("#cbx_inarray_js"+paramId).length>0){
$("#cbx_inarray_js"+paramId)[0].checked = false;
$("#cbx_inarray_js"+paramId)[0].disabled = true;
paramId++;
}
}
updateInvokeParamsJs();
}
Expand Down
14 changes: 13 additions & 1 deletion public/partials/ecolab.html
Original file line number Diff line number Diff line change
Expand Up @@ -1347,9 +1347,12 @@ <h4>ABI:</h4>
</div>
</div>
<div class="row">
<div class="col-md-2">
<div class="col-md-1">
<button type="submit" id="invokebtn" class="btn btn-success btn-sm" data-toggle="modal"><i class="fas fa-fire"></i> Invoke</button>
</div>
<div class="col-md-2">
<span id="addparamsbtn" class="btn btn-success btn-sm" data-toggle="modal"><i class="fas fa-plus"></i> Add params</button>
</div>
<div class="col-md-2">
<div class="form-group">
<span type="checkbox" class="label label-success">Advancing signing</span>
Expand Down Expand Up @@ -2934,6 +2937,15 @@ <h4>ABI:</h4>
}); //End of invoke function
//===============================================================


$("#addparamsbtn").click(()=>{
var lastParam = 1;
while($("#invokeparamsjs"+lastParam).length>0){
lastParam++;
}
$($("#forminvokejs>.row")[1]).append($([lastParam, lastParam+1, lastParam+2, lastParam+3].map(id=>`<div class="col-md-1"><div class="form-group"><label>Type</label><select id="invokeparamjsbox${id}" class="custom-select form-control" onchange="updateInvokeParamsJs()"><option value="None">None</option><option value="String">String</option><option value="Address">Address</option><option value="Hex">Hex</option><option value="Integer">Integer</option><option value="DecFixed8">DecFixed8</option></select></div></div><div class="col-md-2"><div class="form-group"><label>Param ${id}: </label> <input type="checkbox" id="cbx_inarray_js${id}" checked="" onchange="updateInvokeParamsJs()"> in array<br><input id="invokeparamsjs${id}" class="form-control" value="" placeholder="Script Param ${id}" oninput="updateInvokeParamsJs()"></div></div>`).join('')))
});

//===============================================================
//Deploy JS
$("#formdeployjs").submit(function(e) {
Expand Down

0 comments on commit 6887b25

Please sign in to comment.