var PageApp = new Backbone.Marionette.Application();
PageApp.commands.setHandler("postContents", function(formData){
  $.ajax({
    url: $("#contents").attr("action"),
    type: "POST",
    data: formData,
    processData: false,
    contentType: false
  });
});

$("#pagenameform").submit(function(e){
  var ce = $("<pre />").html($("#content").html());
  if($.browser.webkit)
    ce.find("div").replaceWith(function() { return "\n" + this.innerHTML; });
  if($.browser.msie)
    ce.find("p").replaceWith(function() { return this.innerHTML + "<br>"; });
  if($.browser.mozilla || $.browser.opera ||$.browser.msie )
    ce.find("br").replaceWith("\n");

  var fd = new FormData();
  fd.append("content", ce.text());
  fd.append("pagename", $("#pagenameinput").val());
  PageApp.execute("postContents", fd);
  $("#pagename").text($("#pagenameinput").val());
  $("#pagename").show();
  $("#pagenameform").hide();
  return false;
});

$("#contents").submit(function(e){
  var ce = $("<pre />").html($("#content").html());
  if($.browser.webkit)
    ce.find("div").replaceWith(function() { return "\n" + this.innerHTML; });
  if($.browser.msie)
    ce.find("p").replaceWith(function() { return this.innerHTML + "<br>"; });
  if($.browser.mozilla || $.browser.opera ||$.browser.msie )
    ce.find("br").replaceWith("\n");

  var fd = new FormData();
  fd.append("content", ce.text());
  fd.append("pagename", $("#pagenameinput").val());
  PageApp.execute("postContents", fd);
  return false;
});

var PageNameView = Marionette.ItemView.extend({
  el: '#pagename',

  template: false,

  events: {
    'click': 'showPageForm'
  },

  showPageForm: function() {
    this.$el.hide();
    $("#pagenameform").show();
  }
});


$(function (){
  $("#content").focus();

  var pageNameView = new PageNameView();
});

@@ -58,15 +58,13 @@
 App.
-command
+reqre
 s.se
@@ -78,215 +78,30 @@
 r(%22p
-ost
+arse
 Content
-s%22, function(formData)%7B%0A  $.ajax(%7B%0A    url: $(%22#contents%22).attr(%22action%22),%0A    type: %22POST%22,%0A    data: formData,%0A    processData: false,%0A    contentType: false%0A  %7D);%0A%7D);%0A%0A$(%22#pagenameform%22).submit(
+Editable%22, 
 func
@@ -97,33 +97,36 @@
 able%22, function(
-e
+html
 )%7B%0A  var ce = $(
@@ -141,36 +141,20 @@
 %22).html(
-$(%22#content%22).
 html
-()
 );%0A  if(
@@ -450,673 +450,736 @@
 %22);%0A
-%0A  var fd = new FormData();%0A  fd.append(%22content%22, ce.text());%0A  fd.append(%22pagename%22, $(%22#pagenameinput%22).val());%0A  PageApp.execute(%22postContents%22, fd);%0A  $(%22#pagename%22).text($(%22#pagenameinput%22).val());%0A  $(%22#pagename%22).show();%0A  $(%22#pagenameform%22).hide();%0A  return false;%0A%7D);%0A%0A$(%22#contents%22).submit(function(e)%7B%0A  var ce = $(%22%3Cpre /%3E%22).html($(%22#content%22).html());%0A  if($.browser.webkit)%0A    ce.find(%22div%22).replaceWith(function() %7B return %22%5Cn%22 + this.innerHTML; %7D);%0A  if($.browser.msie)%0A    ce.find(%22p%22).replaceWith(function() %7B return this.innerHTML + %22%3Cbr%3E%22; %7D);%0A  if($.browser.mozilla %7C%7C $.browser.opera %7C%7C$.browser.msie )%0A    ce.find(%22br%22).replaceWith(%22%5Cn%22
+  return ce;%0A%7D);%0APageApp.commands.setHandler(%22postContents%22, function(formData)%7B%0A  $.ajax(%7B%0A    url: $(%22#contents%22).attr(%22action%22),%0A    type: %22POST%22,%0A    data: formData,%0A    processData: false,%0A    contentType: false%0A  %7D);%0A%7D);%0A%0A$(%22#pagenameform%22).submit(function(e)%7B%0A  var ce = PageApp.request(%22parseContentEditable%22, $(%22#content%22).html());%0A  var fd = new FormData();%0A  fd.append(%22content%22, ce.text());%0A  fd.append(%22pagename%22, $(%22#pagenameinput%22).val());%0A  PageApp.execute(%22postContents%22, fd);%0A  $(%22#pagename%22).text($(%22#pagenameinput%22).val());%0A  $(%22#pagename%22).show();%0A  $(%22#pagenameform%22).hide();%0A  return false;%0A%7D);%0A%0A$(%22#contents%22).submit(function(e)%7B%0A  var ce = PageApp.request(%22parseContentEditable%22, $(%22#content%22).html()
 );%0A
-%0A
   va

define parsing contenteditable as Request Response