' ).append inp )
$( '#tableRules' ).append tr
fFetchRules()
$( '#tableRules' ).on 'click', 'img.del', () ->
ruleName = $( 'div', $( this ).closest( 'tr' )).text()
if confirm "Do you really want to delete the rule '#{ ruleName }'?"
$( '#log_col' ).text ""
data =
command: 'delete_rule'
payload:
id: ruleName
data.payload = JSON.stringify data.payload
$.post( '/usercommand', data )
.done fFetchRules
.fail fErrHandler 'Could not delete rule! '
$( '#tableRules' ).on 'click', 'img.edit', () ->
ruleName = $( 'div', $( this ).closest( 'tr' )).text()
window.location.href = 'forge?page=forge_rule&id=' + encodeURIComponent ruleName
$( '#tableRules' ).on 'click', 'img.log', () ->
ruleName = $( 'div', $( this ).closest( 'tr' )).text()
data =
command: 'get_rule_log'
payload:
id: ruleName
data.payload = JSON.stringify data.payload
$.post( '/usercommand', data )
.done ( data ) ->
log = data.message.replace new RegExp("\n", 'g'), " "
$( '#log_col' ).html "
#{ ruleName } Log:
#{ log }"
.fail fErrHandler 'Could not get rule log! '
# Add parameter list functionality
fChangeInputVisibility = () ->
$( '#tableParams tr' ).each ( id ) ->
if $( this ).is ':last-child' or $( this ).is ':only-child'
$( 'img', this ).hide()
$( 'input[type=checkbox]', this ).hide()
else
$( 'img', this ).show()
$( 'input[type=checkbox]', this ).show()
$( '#tableParams' ).on 'click', 'img', () ->
par = $( this ).closest 'tr'
if not par.is ':last-child'
par.remove()
fChangeInputVisibility()
$( '#tableParams' ).on 'keyup', 'input', ( e ) ->
code = e.keyCode or e.which
if code isnt 9
par = $( this ).closest 'tr'
if par.is ':last-child'
tr = $ '
' ).append inp
par.parent().append tr
fChangeInputVisibility()
else if $( this ).val() is '' and not par.is ':only-child'
par.remove()
fChangeInputVisibility()
window.addEventListener 'load', fOnLoad, true