<commit_before>var TileMill = TileMill || { settings:{}, page:0, uniq: (new Date().getTime()), customSrs: [], url: '' };
$.fn.reverse = [].reverse;

/**
 * Generate the URL of the current project .mml file.
 */
TileMill.mmlURL = function(options) {
  var url = TileMill.settings.server + 'projects/mml?id=' + TileMill.settings.project_id;
  options = options || { timestamp:1, encode:1 };
  if (options.timestamp) {
    url += '&c=' + TileMill.uniq;
  }
  if (options.encode) {
    url = Base64.encode(url);
  }
  return url;
};

TileMill.addStylesheet = function(options) {
  // If there is no / character, assume this is a single filename.
  if (options.src.split('/').length === 1) {
    var filename = options.src.split('.')[0];
    options.src = TileMill.settings.server + 'projects/mss?id='+ TileMill.settings.project_id +'&filename='+ filename;
  }
  // Otherwise, assume this is a URL.
  else {
    var filename = $.url.setUrl(options.src).param('filename');
  }
  $.get(options.src, function(data) {
    var stylesheet = $('<a class="tab" href="#tab">')
      .text(filename)
      .data('tilemill', options)
      .append($('<input type="hidden">').val(data))
      .append($('<span class="tab-delete">Delete</span>').click(function() {
        if (confirm('Are you sure you want to delete this stylesheet?')) {
          $(this).parents('a.tab').hide('fast', function() {
            $(this).remove();
            // Set the first stylesheet to active.
            TileMill.initCodeEditor($('#tabs a.tab').eq(0), true);
          });
        }
        return false;
      }))
      .click(function() {
        TileMill.initCodeEditor($(this), true);
        return false;
      });
    $('#tabs').append(stylesheet);

    // If a position is defined we are adding stylesheets sequentially. Call
    // the for the addition of the next stylesheet.
    if (typeof options.position !== 'undefined') {
      TileMill.initCodeEditor(stylesheet);
      $('Stylesheet', TileMill.settings.mml).eq(options.position + 1).each(function() {
        if ($(this).attr('src')) {
          TileMill.addStylesheet({src: $(this).attr('src'), position: options.position + 1});
        }
      });
      // If this is the last stylesheet, do final processing.
      if (!$('Stylesheet', mml).eq(options.position + 1).size()) {
      }
    }
  });
};

TileMill.save = function(map) {
  var mml = TileMill.mml();
  $.post('/projects/mml', {
    'id': TileMill.settings.project_id,
    'data': mml,
  });

  // Make sure latest edits to active tab's text have been recorded.
  $('#tabs a.active input').val(TileMill.mirror.getCode());
  $('#tabs a.tab').each(function() {
    var url = $.url.setUrl($(this).data('tilemill')['src']);
    TileMill.mssSave(url.param('filename'), $('input', this).val());
  });

  TileMill.loadInspection();
  TileMill.uniq = (new Date().getTime());
  TileMill.initMap();
}
<commit_msg>Fix for broken reference to global mml.<commit_after>var TileMill = TileMill || { settings:{}, page:0, uniq: (new Date().getTime()), customSrs: [], url: '' };
$.fn.reverse = [].reverse;

/**
 * Generate the URL of the current project .mml file.
 */
TileMill.mmlURL = function(options) {
  var url = TileMill.settings.server + 'projects/mml?id=' + TileMill.settings.project_id;
  options = options || { timestamp:1, encode:1 };
  if (options.timestamp) {
    url += '&c=' + TileMill.uniq;
  }
  if (options.encode) {
    url = Base64.encode(url);
  }
  return url;
};

TileMill.addStylesheet = function(options) {
  // If there is no / character, assume this is a single filename.
  if (options.src.split('/').length === 1) {
    var filename = options.src.split('.')[0];
    options.src = TileMill.settings.server + 'projects/mss?id='+ TileMill.settings.project_id +'&filename='+ filename;
  }
  // Otherwise, assume this is a URL.
  else {
    var filename = $.url.setUrl(options.src).param('filename');
  }
  $.get(options.src, function(data) {
    var stylesheet = $('<a class="tab" href="#tab">')
      .text(filename)
      .data('tilemill', options)
      .append($('<input type="hidden">').val(data))
      .append($('<span class="tab-delete">Delete</span>').click(function() {
        if (confirm('Are you sure you want to delete this stylesheet?')) {
          $(this).parents('a.tab').hide('fast', function() {
            $(this).remove();
            // Set the first stylesheet to active.
            TileMill.initCodeEditor($('#tabs a.tab').eq(0), true);
          });
        }
        return false;
      }))
      .click(function() {
        TileMill.initCodeEditor($(this), true);
        return false;
      });
    $('#tabs').append(stylesheet);

    // If a position is defined we are adding stylesheets sequentially. Call
    // the for the addition of the next stylesheet.
    if (typeof options.position !== 'undefined') {
      TileMill.initCodeEditor(stylesheet);
      $('Stylesheet', TileMill.settings.mml).eq(options.position + 1).each(function() {
        if ($(this).attr('src')) {
          TileMill.addStylesheet({src: $(this).attr('src'), position: options.position + 1});
        }
      });
      // If this is the last stylesheet, do final processing.
      if (!$('Stylesheet', TileMill.settings.mml).eq(options.position + 1).size()) {
      }
    }
  });
};

TileMill.save = function(map) {
  var mml = TileMill.mml();
  $.post('/projects/mml', {
    'id': TileMill.settings.project_id,
    'data': mml,
  });

  // Make sure latest edits to active tab's text have been recorded.
  $('#tabs a.active input').val(TileMill.mirror.getCode());
  $('#tabs a.tab').each(function() {
    var url = $.url.setUrl($(this).data('tilemill')['src']);
    TileMill.mssSave(url.param('filename'), $('input', this).val());
  });

  TileMill.loadInspection();
  TileMill.uniq = (new Date().getTime());
  TileMill.initMap();
}

{'fraction_non_alphanumeric': 0.18950786056049215, 'fraction_numerical': 0.0037593984962406013, 'mean_word_length': 3.0421270718232045, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4645082', 'n_tokens_mistral': 1894, 'n_tokens_neox': 1865, 'n_words': 418}