@ -84,30 +84,47 @@ TxBrowser.prototype.setState = function (state) {
TxBrowser . prototype . render = function ( ) {
var self = this
let action = yo ` <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> `
var view = yo ` <div class=" ${ css . container } ">
< div class = "${css.txContainer}" >
< div class = "${css.txinputs} p-1 input-group" >
this . state . txNumberInput = yo `
< input
value = "${this.state.txNumber || ''}"
class = "form-control m-0 ${css.txinput}"
id = 'txinput'
onkeyup = $ { function ( ) { self . updateTxN ( arguments [ 0 ] ) } }
type = 'text'
placeholder = $ { 'Transaction hash' }
oninput = $ { this . txInputChanged . bind ( this ) }
placeholder = $ { 'Transaction hash, should start with 0x' }
/ >
`
let txButton = yo `
< 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
< / b u t t o n >
`
var view = yo `
< div class = "${css.container}" >
< div class = "${css.txContainer}" >
< div class = "${css.txinputs} p-1 input-group" >
$ { this . state . txNumberInput }
< / d i v >
< div class = "${css.txbuttons} btn-group p-1" >
$ { action }
$ { txButt on}
< / d i v >
< / d i v >
< span id = 'error' > < / s p a n >
< / d i v > `
< / d i v >
`
if ( this . state . debugging ) {
view . querySelectorAll ( 'input' ) . forEach ( element => { element . setAttribute ( 'disabled' , '' ) } )
}
if ( ! this . state . txNumber ) {
action . setAttribute ( 'disabled' , 'disabled' )
view . querySelector ( "button[id='load']" ) . setAttribute ( 'disabled' , '' )
} else {
this . state . txNumberInput . removeAttribute ( 'diabled' , '' )
}
if ( ! this . view ) {
this . view = view
@ -116,4 +133,15 @@ TxBrowser.prototype.render = function () {
return view
}
TxBrowser . prototype . txInputChanged = function ( event ) {
// todo check validation of txnumber in the input element, use
// required
// oninvalid="setCustomValidity('Please provide a valid transaction number, must start with 0x and have length of 22')"
// pattern="^0[x,X]+[0-9a-fA-F]{22}"
// this.state.txNumberInput.setCustomValidity('')
this . state . txNumber = event . target . value
yo . update ( this . view , this . render ( ) )
}
module . exports = TxBrowser