<commit_before>//= require rails-ujs
//= require turbolinks
//= require_self

const {fire, matches} = Rails;

var views = {};
var binds = {};

function get(options) {
  options.type = 'get';
  ajax(options);
}

function post(options) {
   options.type = 'post';
  ajax(options);
}

function ajax(options) {
  // Rails 5.1.6 hack
  options.beforeSend = ()=>{ return true; };
  options.renameProperty('successHandler', 'success');
  options.renameProperty('errorHandler', 'error');
  if (options.type == 'get' && options.data) {
    options.url += '?';
    let params = [];
    for (let key in options.data) {
      let value = escape(data[key]);
      let param = (key+'='+value);
      params.push(param);
    }
    options.url += params.join('&');
  }
  Rails.ajax(options);
}

Object.prototype.renameProperty = function(oldName, newName) {
  if (oldName != newName && this.hasOwnProperty(oldName)) {
    this[newName] = this[oldName];
    delete this[oldName];
  }
  return this;
}

function render(name, options) {
  let output = views[name];
  for (let key in options) {
    let pattern = ('#{'+key+'}');
    let regex = new RegExp(pattern, 'g');
    let value = options[key];
    output = output.replace(regex, value);
  }
  return output;
}

function getMeta(name) {
  let meta = find(document.head, `meta[name=${name}]`);
  return meta.getAttribute('content');<commit_msg>Fix bug<commit_after>//= require rails-ujs
//= require turbolinks
//= require_self

const {fire, matches} = Rails;

var views = {};
var binds = {};

function get(options) {
  options.type = 'get';
  ajax(options);
}

function post(options) {
   options.type = 'post';
  ajax(options);
}

function ajax(options) {
  // Rails 5.1.6 hack
  options.beforeSend = ()=>{ return true; };
  options.renameProperty('successHandler', 'success');
  options.renameProperty('errorHandler', 'error');
  if (options.type == 'get' && options.data) {
    options.url += '?';
    let params = [];
    for (let key in options.data) {
      let value = escape(options.data[key]);
      let param = (key+'='+value);
      params.push(param);
    }
    options.url += params.join('&');
  }
  Rails.ajax(options);
}

Object.prototype.renameProperty = function(oldName, newName) {
  if (oldName != newName && this.hasOwnProperty(oldName)) {
    this[newName] = this[oldName];
    delete this[oldName];
  }
  return this;
}

function render(name, options) {
  let output = views[name];
  for (let key in options) {
    let pattern = ('#{'+key+'}');
    let regex = new RegExp(pattern, 'g');
    let value = options[key];
    output = output.replace(regex, value);
  }
  return output;
}

function getMeta(name) {
  let meta = find(document.head, `meta[name=${name}]`);
  return meta.getAttribute('content');
{'fraction_non_alphanumeric': 0.17644927536231883, 'fraction_numerical': 0.002173913043478261, 'mean_word_length': 3.624790619765494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3723236', 'n_tokens_mistral': 926, 'n_tokens_neox': 925, 'n_words': 212}