<!DOCTYPE HTML>
<html>
  <head>
    <title>Invoke an event</title>
    {{{head_requires}}}
  </head>
  <body>
    {{{div_menubar}}}
		<div id="mainbody">
	    <div id="pagetitle">Hi {{user.username}}, invoke your own Event!</div>
	    <p>
	    	<textarea id="textarea_event" rows="20" cols="50">
{
	"event": "mail",
	"eventid": "mail_0",
	"payload": {
		"subject": "hello"
	}
}
	    	</textarea>
	    </p>
    	<p>
    		<button id="but_submit">invoke</button>
    	</p>
    </div>
    <div id="info"></div>
    
    <script>
      $('#but_submit').click(function() {
        $.post('/event', JSON.parse($('#textarea_event').val()))
        .done(function(data) {
        	alert(data);
        })
        .fail(function(err) {
          alert('Posting of event failed: ' + err.responseText);
        });
      });
    </script>
  </body>
</html>