<commit_before>jQuery(function($) {
  var $form = $('.js-dataview-edit')
    ;

  $form.submit(onFormSubmit);
});

function onFormSubmit(e) {
  e.preventDefault();
  var $submit = $('.js-submit')
    ;

  // if form is good to go let's submit it
  if (e.target.checkValidity()) {
    $submit.html('<i class="icon-spinner icon-spin icon-large"></i> Updating - this should only take a moment ...');
    doDataViewUpdate(function(err, url) {
      if (err) {
        alert('Error on saving: ' + err.responseText);
      } else {
        $submit.html('Updated Successfully!').removeClass('btn-primary').addClass('btn-success'); 
        setTimeout(function() {
          // restore original message
          $submit.html('Update &raquo;').removeClass('btn-success').addClass('btn-primary'); 
        }, 2000);
      }
    });
  }
}

var doDataViewUpdate = function(cb) {
  var $form = $('.js-dataview-edit')
    ;
  var formData = _.object(_.map($form.serializeArray(), function(item) {
    return [ item.name, item.value ];
  }));
  function getFormAttr(attr) {
    return formData[attr];
  }
  // defined in main template - passed in from backend
  // dataViewData
  var dataview = _.extend(dataViewData, {
    title: getFormAttr('title'),
    resources: _.extend(dataViewData.resources, {
      resources: [{
        backend: 'gdocs',
        url: getFormAttr('url')
      }]
    }),
    tmconfig: _.extend({}, dataViewData.tmconfig, {
      dayfirst: Boolean(formData.dayfirst)
    })
  });
  $.ajax({
    url: '/api/v1/dataview/' + dataview.owner + '/' + dataview.name,<commit_msg>[#57][xs]: bugfix for editing dataview source data url.<commit_after>jQuery(function($) {
  var $form = $('.js-dataview-edit')
    ;

  $form.submit(onFormSubmit);
});

function onFormSubmit(e) {
  e.preventDefault();
  var $submit = $('.js-submit')
    ;

  // if form is good to go let's submit it
  if (e.target.checkValidity()) {
    $submit.html('<i class="icon-spinner icon-spin icon-large"></i> Updating - this should only take a moment ...');
    doDataViewUpdate(function(err, url) {
      if (err) {
        alert('Error on saving: ' + err.responseText);
      } else {
        $submit.html('Updated Successfully!').removeClass('btn-primary').addClass('btn-success'); 
        setTimeout(function() {
          // restore original message
          $submit.html('Update &raquo;').removeClass('btn-success').addClass('btn-primary'); 
        }, 2000);
      }
    });
  }
}

var doDataViewUpdate = function(cb) {
  var $form = $('.js-dataview-edit')
    ;
  var formData = _.object(_.map($form.serializeArray(), function(item) {
    return [ item.name, item.value ];
  }));
  function getFormAttr(attr) {
    return formData[attr];
  }
  // defined in main template - passed in from backend
  // dataViewData
  var dataview = _.extend(dataViewData, {
    title: getFormAttr('title'),
    resources: [
      _.extend({}, dataViewData.resources[0], {
        backend: 'gdocs',
        url: getFormAttr('url')
      })
    ],
    tmconfig: _.extend({}, dataViewData.tmconfig, {
      dayfirst: Boolean(formData.dayfirst)
    })
  });
  $.ajax({
    url: '/api/v1/dataview/' + dataview.owner + '/' + dataview.name,
{'fraction_non_alphanumeric': 0.17332916926920675, 'fraction_numerical': 0.004059962523422861, 'mean_word_length': 2.8730350665054414, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6465350', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1025, 'n_words': 204}