<commit_before>define([
  'jquery',
  'core/component-manager',
  'core/toolbar',
  'core/socket',
  'core/modal',
  'components',
  'jquery.bootstrap-growl'
], function($, componentManager, toolbar, socket, modal, components) {

  /**
   * @todo Support multiple content areas in publish.
   */
  var $contentAreas = $('.sx-content-area')
    , modals;

  modals = {
    verify_publish : {
      title   : 'Pagina publiceren',
      message : 'Weet je zeker dat je de pagina wilt publiceren? De momenteel gepubliceerde pagina zal overschreven worden.'
    }
  };

  function makeContentObject() {
    var contentObject = {};

    $contentAreas.toArray().forEach(function (element) {
      var $element = $(element);

      contentObject[$element.data('sxArea')] = $element
        .html()
        .replace(/^\s*|\s+$/g, '')
        .replace(/\scontenteditable=".*?"/, '');
    });

    return contentObject;
  }

  /**
   * Call this method when publish was clicked.
   */
  function publish() {
    var $control = $(this);

    $control.prop('disabled', true);

    modal.create(modals.verify_publish, function(result) {
      if (!result) {
        return $control.prop('disabled', false);
      }

      // Remove editable state for publish
      components.setNotEditable();

      return socket.put('/website/publish', {
        body : makeContentObject(),
        page : window.location.pathname
      }, function(data) {
        if (data.error) {
          $.bootstrapGrowl('Er is een fout opgetreden!', { type : 'danger' });
        } else {
          $.bootstrapGrowl('De pagina is gepubliceerd!', {type: 'success'});
        }

        console.log(data);

        // Set back editable state after publish
        components.setEditable();<commit_msg>Removed unused console.log<commit_after>define([
  'jquery',
  'core/component-manager',
  'core/toolbar',
  'core/socket',
  'core/modal',
  'components',
  'jquery.bootstrap-growl'
], function($, componentManager, toolbar, socket, modal, components) {

  /**
   * @todo Support multiple content areas in publish.
   */
  var $contentAreas = $('.sx-content-area')
    , modals;

  modals = {
    verify_publish : {
      title   : 'Pagina publiceren',
      message : 'Weet je zeker dat je de pagina wilt publiceren? De momenteel gepubliceerde pagina zal overschreven worden.'
    }
  };

  function makeContentObject() {
    var contentObject = {};

    $contentAreas.toArray().forEach(function (element) {
      var $element = $(element);

      contentObject[$element.data('sxArea')] = $element
        .html()
        .replace(/^\s*|\s+$/g, '')
        .replace(/\scontenteditable=".*?"/, '');
    });

    return contentObject;
  }

  /**
   * Call this method when publish was clicked.
   */
  function publish() {
    var $control = $(this);

    $control.prop('disabled', true);

    modal.create(modals.verify_publish, function(result) {
      if (!result) {
        return $control.prop('disabled', false);
      }

      // Remove editable state for publish
      components.setNotEditable();

      return socket.put('/website/publish', {
        body : makeContentObject(),
        page : window.location.pathname
      }, function(data) {
        if (data.error) {
          $.bootstrapGrowl('Er is een fout opgetreden!', { type : 'danger' });
        } else {
          $.bootstrapGrowl('De pagina is gepubliceerd!', {type: 'success'});
        }

        // Set back editable state after publish
        components.setEditable();
{'fraction_non_alphanumeric': 0.1502708867978329, 'fraction_numerical': 0.0, 'mean_word_length': 2.605344295991778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2216141', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1053, 'n_words': 242}