|
|
@ -20,16 +20,75 @@ class MultiParamManager { |
|
|
|
this.clickCallBack = clickCallBack |
|
|
|
this.clickCallBack = clickCallBack |
|
|
|
this.inputs = inputs |
|
|
|
this.inputs = inputs |
|
|
|
this.title = title |
|
|
|
this.title = title |
|
|
|
|
|
|
|
this.basicInputField |
|
|
|
|
|
|
|
this.multiFields |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switchMethodViewOn () { |
|
|
|
switchMethodViewOn () { |
|
|
|
this.contractActionsContainerSingle.style.display = 'none' |
|
|
|
this.contractActionsContainerSingle.style.display = 'none' |
|
|
|
this.contractActionsContainerMulti.style.display = 'flex' |
|
|
|
this.contractActionsContainerMulti.style.display = 'flex' |
|
|
|
|
|
|
|
this.makeMultiVal() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switchMethodViewOff () { |
|
|
|
switchMethodViewOff () { |
|
|
|
this.contractActionsContainerSingle.style.display = 'flex' |
|
|
|
this.contractActionsContainerSingle.style.display = 'flex' |
|
|
|
this.contractActionsContainerMulti.style.display = 'none' |
|
|
|
this.contractActionsContainerMulti.style.display = 'none' |
|
|
|
|
|
|
|
var multiValString = this.getMultiValsString() |
|
|
|
|
|
|
|
if (multiValString) this.basicInputField.value = multiValString |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getValue (item, index) { |
|
|
|
|
|
|
|
var valStr = item.value.join('') |
|
|
|
|
|
|
|
return valStr |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getMultiValsString () { |
|
|
|
|
|
|
|
var valArray = this.multiFields.querySelectorAll('input') |
|
|
|
|
|
|
|
var ret = '' |
|
|
|
|
|
|
|
var valArrayTest = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < valArray.length; j++) { |
|
|
|
|
|
|
|
if (ret !== '') ret += ',' |
|
|
|
|
|
|
|
var elVal = valArray[j].value |
|
|
|
|
|
|
|
valArrayTest.push(elVal) |
|
|
|
|
|
|
|
elVal = elVal.replace(/(^|,\s+|,)(\d+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted number by quoted number
|
|
|
|
|
|
|
|
elVal = elVal.replace(/(^|,\s+|,)(0[xX][0-9a-fA-F]+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted hex string by quoted hex string
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
JSON.parse(elVal) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
elVal = '"' + elVal + '"' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ret += elVal |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var valStringTest = valArrayTest.join('') |
|
|
|
|
|
|
|
if (valStringTest) { |
|
|
|
|
|
|
|
return ret |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emptyInputs () { |
|
|
|
|
|
|
|
var valArray = this.multiFields.querySelectorAll('input') |
|
|
|
|
|
|
|
for (var k = 0; k < valArray.length; k++) { |
|
|
|
|
|
|
|
valArray[k].value = '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.basicInputField.value = '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
makeMultiVal () { |
|
|
|
|
|
|
|
var inputString = this.basicInputField.value |
|
|
|
|
|
|
|
if (inputString) { |
|
|
|
|
|
|
|
inputString = inputString.replace(/(^|,\s+|,)(\d+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted number by quoted number
|
|
|
|
|
|
|
|
inputString = inputString.replace(/(^|,\s+|,)(0[xX][0-9a-fA-F]+)(\s+,|,|$)/g, '$1"$2"$3') // replace non quoted hex string by quoted hex string
|
|
|
|
|
|
|
|
var inputJSON = JSON.parse('[' + inputString + ']') |
|
|
|
|
|
|
|
var multiInputs = this.multiFields.querySelectorAll('input') |
|
|
|
|
|
|
|
for (var k = 0; k < multiInputs.length; k++) { |
|
|
|
|
|
|
|
if (inputJSON[k]) { |
|
|
|
|
|
|
|
multiInputs[k].value = JSON.stringify(inputJSON[k]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
createMultiFields () { |
|
|
|
createMultiFields () { |
|
|
@ -52,28 +111,29 @@ class MultiParamManager { |
|
|
|
title = '(fallback)' |
|
|
|
title = '(fallback)' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var basicInputField = yo`<input></input>` |
|
|
|
this.basicInputField = yo`<input></input>` |
|
|
|
basicInputField.setAttribute('placeholder', this.inputs) |
|
|
|
this.basicInputField.setAttribute('placeholder', this.inputs) |
|
|
|
basicInputField.setAttribute('title', this.inputs) |
|
|
|
this.basicInputField.setAttribute('title', this.inputs) |
|
|
|
|
|
|
|
|
|
|
|
var onClick = (domEl) => { |
|
|
|
var onClick = (domEl) => { |
|
|
|
this.clickCallBack(this.funABI.inputs, basicInputField.value) |
|
|
|
this.clickCallBack(this.funABI.inputs, this.basicInputField.value) |
|
|
|
|
|
|
|
this.emptyInputs() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.contractActionsContainerSingle = yo`<div class="${css.contractActionsContainerSingle}" >
|
|
|
|
this.contractActionsContainerSingle = yo`<div class="${css.contractActionsContainerSingle}" >
|
|
|
|
<button onclick=${() => { onClick() }} class="${css.instanceButton}">${title}</button>${basicInputField}<i class="fa fa-angle-down ${css.methCaret}" onclick=${() => { this.switchMethodViewOn() }} title=${title} ></i> |
|
|
|
<button onclick=${() => { onClick() }} class="${css.instanceButton}">${title}</button>${this.basicInputField}<i class="fa fa-angle-down ${css.methCaret}" onclick=${() => { this.switchMethodViewOn() }} title=${title} ></i> |
|
|
|
</div>` |
|
|
|
</div>` |
|
|
|
|
|
|
|
|
|
|
|
var multiFields = this.createMultiFields() |
|
|
|
this.multiFields = this.createMultiFields() |
|
|
|
|
|
|
|
|
|
|
|
var multiOnClick = () => { |
|
|
|
var multiOnClick = () => { |
|
|
|
var valArray = multiFields.querySelectorAll('input') |
|
|
|
var valsString = this.getMultiValsString() |
|
|
|
var ret = '' |
|
|
|
if (valsString) { |
|
|
|
for (var k = 0; k < valArray.length; k++) { |
|
|
|
this.clickCallBack(this.funABI.inputs, valsString) |
|
|
|
var el = valArray[k] |
|
|
|
} else { |
|
|
|
if (ret !== '') ret += ',' |
|
|
|
this.clickCallBack(this.funABI.inputs, '') |
|
|
|
ret += el.value |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
this.clickCallBack(this.funABI.inputs, ret) |
|
|
|
this.emptyInputs() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var button = yo`<button onclick=${() => { multiOnClick() }} class="${css.instanceButton}"></button>` |
|
|
|
var button = yo`<button onclick=${() => { multiOnClick() }} class="${css.instanceButton}"></button>` |
|
|
@ -84,7 +144,7 @@ class MultiParamManager { |
|
|
|
<div class="${css.multiTitle}">${title}</div> |
|
|
|
<div class="${css.multiTitle}">${title}</div> |
|
|
|
<i class='fa fa-angle-up ${css.methCaret}'></i> |
|
|
|
<i class='fa fa-angle-up ${css.methCaret}'></i> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
${multiFields} |
|
|
|
${this.multiFields} |
|
|
|
<div class="${css.group} ${css.multiArg}" > |
|
|
|
<div class="${css.group} ${css.multiArg}" > |
|
|
|
${button} |
|
|
|
${button} |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -106,7 +166,7 @@ class MultiParamManager { |
|
|
|
contractProperty.classList.add(css.hasArgs) |
|
|
|
contractProperty.classList.add(css.hasArgs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden' |
|
|
|
this.contractActionsContainerSingle.querySelector('i').style.visibility = 'hidden' |
|
|
|
basicInputField.style.display = 'none' |
|
|
|
this.basicInputField.style.display = 'none' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.funABI.payable === true) { |
|
|
|
if (this.funABI.payable === true) { |
|
|
|