$.each(examples.tasks, function (name, l) {
  $("#taskselect").append(
    $("<option />").val(name).text(name)
  );
});
$.each(examples.graphs, function (name, l) {
  $("#proofselect").append(
    $("<option />").val(name).text(name)
  );
});

function selectNoTask() {
  $("#taskselect").val("");
  $("#task").hide();
  selectLogic('predicate');
  saveTask();
  task = { };
  task_desc = undefined;
  setupGraph(graph, task);
  processGraph();
}

function selectNamedTask(name) {
  saveTask();
  selectLogic(examples.tasks[name].logic);
  loadTask(examples.tasks[name]);
  task_desc = undefined;
  $("#taskselect").val(name);
}

function selectProof(name) {
  proof = examples.graphs[name];
  proof.loading = true;

  if (proof.task) {
    selectNamedTask(proof.task);
  } else if (proof.logic) {
    selectLogic(proof.logic);
    selectNoTask();
  } else {
    throw new Error("selectProof: Neither task nor logic: " + name);
  }

  graph.fromJSON(proof);
  // This is mostly for backwards compatibility with old stored graphs, and can
  // be removed eventually
  $.each(graph.getElements(), function (i, el) {
    if (el.get('prototypeElement')) {el.remove();}
  });
  // If these have no numbers yet, add them
  $.each(graph.getCells(), function (i, el) {
    if (!el.get('number')) {
      el.set('number', i+1);
    }
  });

  graph.set('loading', false);
}


$(function (){
  $("#taskselect").change(with_graph_loading(function () {
    if (this.value) {
      selectNamedTask(this.value);
    }
  }));
  $("#proofselect").change(with_graph_loading (function () {
    if (this.value) {
      selectProof(this.value);
    }
  }));
  $("#freeproof").click(with_graph_loading (function () { selectNoTask(); }));

  $("#showdialog").click(function(){
    $("#graph").val(JSON.stringify(graph.toJSON(),null,2));
    $("#proof").val(JSON.stringify(buildProof(graph)));
    $("#dialog").toggle();
  });
  $("#closedialog").click(function(){
    $("#dialog").hide();
  });

  $("#showhelp").click(function(){
    $("#help").toggle();
  });
  $("#closehelp").click(function(){
    $("#help").hide();
  });

  $("#reset").click(function(){
    if (window.confirm(i18n.t("confirm-reset"))) {
      $(window).off("unload"); /* Otherwise we’d just save it again */
      localStorage.removeItem("incredible-session");
      window.location.reload(false);
    }
  });

  $("#inferredrule #inferredrulewrapper").draggable({
    appendTo: "body",
    helper: "clone"
    // helper: function ()  { return $("<span>Hi</span>") }
  });
});

@@ -1360,16 +1360,198 @@
 se);%0A%7D%0A%0A
+function reset_everything() %7B%0A  $(window).off(%22unload%22); /* Otherwise we%E2%80%99d just save it again */%0A  localStorage.removeItem(%22incredible-session%22);%0A  window.location.reload(false);%0A%7D%0A%0A
 %0A$(funct
@@ -2375,160 +2375,25 @@
     
-$(window).off(%22unload%22); /* Otherwise we%E2%80%99d just save it again */%0A      localStorage.removeItem(%22incredible-session%22);%0A      window.location.reload(false
+reset_everything(
 );%0A 

Put reset_everything into its own function