##This file is based on the template from the SimpleWiki source which carries the GPL license

<%inherit file="simplewiki_base.html"/>

<%block name="title"><title>${"Edit " + wiki_title + " - " if wiki_title is not UNDEFINED else ""}MITx 6.002x Wiki</title></%block>

<%block name="wiki_page_title">
<h1>${ wiki_article.title }</h1>
</%block>

<%block name="wiki_head">
<script>
  $(function() {
    //Store the initial contents of #id_contents (the wiki body field) so we can compare for unsaved changes
    $("#id_contents").data('initial_contents', $("#id_contents").val());
    
    window.onbeforeunload = function askConfirm() { //Warn the user before they navigate away
      if ( $("#id_contents").val() != $("#id_contents").data('initial_contents') ) {
        return "You have made changes to the article that have not been saved yet.";
      }
    };
    
    $("#submit_edit").click(function() {
      $("#id_contents").data('initial_contents', $("#id_contents").val());
    });
    
  });
</script>
</%block>


<%block name="wiki_body">
<form method="POST" id="wiki_revision">
  <div style="display:none">
      <input type="hidden" name="csrfmiddlewaretoken" value="${csrf_token}"/>
  </div>
  ${wiki_form}
  <input type="submit" id="submit_edit" name="edit" value="Save Changes" />
  <input type="submit" id="submit_delete" name="delete" value="Delete article" />
</form>

<%include file="simplewiki_instructions.html"/>

</%block>
