<commit_before>$(window).bind("editorloaded", function() {
  var MY_URL = $('<a href="."></a>')[0].href
  var BASE_URL = "http://webpagemakerapi.vcap.mozillalabs.com/";
  var dlg = $("#publish-dialog");

  function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
      var pair = vars[i].split("=");
      if (pair[0] == variable) {
        return unescape(pair[1]);
      }
    }
  }

  if (getQueryVariable('p')) {
    editor.setValue('');
    jQuery.ajax({
      type: 'GET',
      url: BASE_URL + getQueryVariable('p'),
      crossDomain: true,
      dataType: 'text',
      success: function(data) {
        editor.setValue(data);
      }
    });
  }

  $(".close", dlg).click(function() {
    dlg.hide();
    return false;
  });
  $("#publish").click(function() {
    dlg.show();
    $(".done", dlg).hide();
    $.ajax({
      type: 'POST',
      url: BASE_URL + 'page',
      crossDomain: true,
      data: editor.getValue(),
      error: function() {
        console.log("ERROR");
      },
      success: function(data) {
        console.log("SUCCESS");
      },
      complete: function(data) {
        var viewURL = BASE_URL + data.responseText;
        var remixURL = MY_URL + '?p=' + escape(data.responseText);
        $(".done", dlg).fadeIn();
        $('a.view', dlg).attr('href', viewURL).text(viewURL);
        $('a.remix', dlg).attr('href', remixURL).text(remixURL);
      },
      dataType: 'text'
    });
  });
});
<commit_msg>added very rudimentary error messaging when publishing in editor.<commit_after>$(window).bind("editorloaded", function() {
  var MY_URL = $('<a href="."></a>')[0].href
  var BASE_URL = "http://webpagemakerapi.vcap.mozillalabs.com/";
  var dlg = $("#publish-dialog");

  function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
      var pair = vars[i].split("=");
      if (pair[0] == variable) {
        return unescape(pair[1]);
      }
    }
  }

  if (getQueryVariable('p')) {
    editor.setValue('');
    jQuery.ajax({
      type: 'GET',
      url: BASE_URL + getQueryVariable('p'),
      crossDomain: true,
      dataType: 'text',
      error: function() {
        alert('Sorry, an error occurred while trying to get the page. :(');
      },
      success: function(data) {
        editor.setValue(data);
      }
    });
  }

  $(".close", dlg).click(function() {
    dlg.hide();
    return false;
  });
  $("#publish").click(function() {
    dlg.show();
    $(".done", dlg).hide();
    $.ajax({
      type: 'POST',
      url: BASE_URL + 'page',
      crossDomain: true,
      data: editor.getValue(),
      error: function() {
        alert("Sorry, an error occurred while trying to publish. :(");
        dlg.hide();
      },
      success: function(data) {
        var viewURL = BASE_URL + data;
        var remixURL = MY_URL + '?p=' + escape(data);
        $(".done", dlg).fadeIn();
        $('a.view', dlg).attr('href', viewURL).text(viewURL);
        $('a.remix', dlg).attr('href', remixURL).text(remixURL);
      },
      dataType: 'text'
    });
  });
});

{'fraction_non_alphanumeric': 0.19981470043236566, 'fraction_numerical': 0.0030883261272390363, 'mean_word_length': 2.4827956989247313, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7020655', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1089, 'n_words': 219}