' ).text hookname
tdUrl = $( '
' ).attr( 'style', 'width:600px' ).val "#{ hostUrl }/webhooks/#{ hookid }"
img = $( '
![]()
' ).attr( 'class', 'del' )
.attr( 'title', 'Delete Module' ).attr 'src', 'red_cross_small.png'
tr.append( $( '
' ).append img )
tr.append( $( ' | ' ).attr( 'style', 'padding-left:10px' ).append tdName )
tr.append( $( ' | ' ).attr( 'style', 'padding-left:10px' ).append tdUrl )
$( '#table_webhooks' ).append tr
fOnLoad = () ->
document.title = 'Create Webhooks!'
# Load existing Webhooks
fUpdateWebhookList()
# Register button action
$( '#but_submit' ).click ->
$( '#info' ).text ''
hookname = $( '#inp_hookname' ).val()
if hookname is ''
fDisplayError 'Please provide an Event Name for your new Webhook!'
else
# $( '#display_hookurl *' ).remove()
fIssueRequest
body:
command: 'create_webhook'
body: JSON.stringify
hookname: hookname
done: ( data ) ->
oAnsw = JSON.parse data.message
b = $( '' ).text "This is the Webhook Url you can use for your Event '#{ oAnsw.hookname }' : "
$( '#display_hookurl' ).append b
$( '#display_hookurl' ).append $(' ')
inp = $('').attr( 'type', 'text' ).attr( 'style', 'width:600px' )
.val "#{ hostUrl }/webhooks/#{ oAnsw.hookid }"
$( '#display_hookurl' ).append inp
$( '#display_hookurl' ).append $(' ')
div = $( '' )
div.append $( ' ' )
div.append $( ' ' ).html "1. Try it out and push your location to your new webhook
via this page."
div.append $( ' ' )
div.append $( ' ' ).html "2. Then you should setup a Rule for this Event!"
$( '#display_hookurl' ).append div
fUpdateWebhookList()
fail: ( err ) ->
if err.status is 409
fFailedRequest( 'Webhook Event Name already existing!' ) err
else
fFailedRequest( 'Unable to create Webhook! ' + err.message ) err
fUpdateWebhookList()
$( '#table_webhooks' ).on 'click', 'img', () ->
if confirm "Do you really want to delete this webhook?"
url = $( 'input', $( this ).closest( 'tr' ) ).val()
arrUrl = url.split '/'
fIssueRequest
body:
command: 'delete_webhook'
body: JSON.stringify
hookid: arrUrl[ arrUrl.length - 1 ]
done: ( data ) ->
$( '#info' ).text data.message
$( '#info' ).attr 'class', 'success'
fUpdateWebhookList()
fail: ( err ) ->
fFailedRequest( 'Unable to delete Webhook!' ) err
fUpdateWebhookList()
window.addEventListener 'load', fOnLoad, true
|