Commit 665491a0 authored by yann300's avatar yann300

keep only "tx hash" input

parent 90a27495
...@@ -40,31 +40,28 @@ var css = csjs` ...@@ -40,31 +40,28 @@ var css = csjs`
function TxBrowser () { function TxBrowser () {
this.event = new EventManager() this.event = new EventManager()
this.blockNumber this.state = {
this.txNumber txNumber: undefined,
debugging: false
}
this.view this.view
this.debugging = false
} }
TxBrowser.prototype.submit = function () { TxBrowser.prototype.submit = function () {
if (this.debugging) { if (this.state.debugging) {
this.unload() this.unload()
} else { } else {
this.event.trigger('requestDebug', [this.blockNumber, this.txNumber]) this.event.trigger('requestDebug', [undefined, this.state.txNumber])
} }
yo.update(this.view, this.render()) yo.update(this.view, this.render())
} }
TxBrowser.prototype.updateBlockN = function (ev) {
this.blockNumber = ev.target.value
}
TxBrowser.prototype.updateTxN = function (ev) { TxBrowser.prototype.updateTxN = function (ev) {
this.txNumber = ev.target.value this.state.txNumber = ev.target.value
} }
TxBrowser.prototype.load = function (txHash, tx) { TxBrowser.prototype.load = function (txHash, tx) {
this.txNumber = txHash this.state.txNumber = txHash
} }
TxBrowser.prototype.unload = function () { TxBrowser.prototype.unload = function () {
...@@ -72,9 +69,7 @@ TxBrowser.prototype.unload = function () { ...@@ -72,9 +69,7 @@ TxBrowser.prototype.unload = function () {
} }
TxBrowser.prototype.setState = function (state) { TxBrowser.prototype.setState = function (state) {
if (state.debugging !== undefined) this.debugging = state.debugging this.state = {...this.state, ...state}
if (state.blockNumber !== undefined) this.blockNumber = state.blockNumber
if (state.txNumber !== undefined) this.txNumber = state.txNumber
if (this.view) { if (this.view) {
yo.update(this.view, this.render()) yo.update(this.view, this.render())
} }
...@@ -85,16 +80,15 @@ TxBrowser.prototype.render = function () { ...@@ -85,16 +80,15 @@ TxBrowser.prototype.render = function () {
var view = yo`<div class="${css.container}"> var view = yo`<div class="${css.container}">
<div class="${css.txContainer}"> <div class="${css.txContainer}">
<div class="${css.txinputs} p-1 input-group"> <div class="${css.txinputs} p-1 input-group">
<input value="${this.blockNumber || ''}" class="form-control ${css.txinput}" onkeyup=${function () { self.updateBlockN(arguments[0]) }} type='text' placeholder=${'Block number'} /> <input value="${this.state.txNumber || ''}" class="form-control ${css.txinput}" id='txinput' onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' placeholder=${'Transaction hash'} />
<input value="${this.txNumber || ''}" class="form-control ${css.txinput}" id='txinput' onkeyup=${function () { self.updateTxN(arguments[0]) }} type='text' placeholder=${'Transaction index or hash'} />
</div> </div>
<div class="${css.txbuttons} btn-group p-1"> <div class="${css.txbuttons} btn-group p-1">
<button class='btn btn-primary btn-sm ${css.txbutton}' id='load' title='${this.debugging ? 'Stop' : 'Start'} debugging' onclick=${function () { self.submit() }}>${this.debugging ? 'Stop' : 'Start'} debugging</button> <button class='btn btn-primary btn-sm ${css.txbutton}' id='load' title='${this.state.debugging ? 'Stop' : 'Start'} debugging' onclick=${function () { self.submit() }}>${this.state.debugging ? 'Stop' : 'Start'} debugging</button>
</div> </div>
</div> </div>
<span id='error'></span> <span id='error'></span>
</div>` </div>`
if (this.debugging) { if (this.state.debugging) {
view.querySelectorAll('input').forEach(element => { element.setAttribute('disabled', '') }) view.querySelectorAll('input').forEach(element => { element.setAttribute('disabled', '') })
} }
if (!this.view) { if (!this.view) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment