<commit_before>(function (context, factory) {
  if (typeof module === 'object' && typeof module.exports === 'object') {
    module.exports = function (context) {
      var core = require('./core.js');
      return factory(context, core);
    };
  } else {
    factory(context, context._);
  }
}(this, function (context, _) {
  'use strict';

  var window = context.window;
  var document = window.document;
  var $ = context.$ || {};


  function go (path, params, method) {
    // Set method to post by default, if not specified.
    method = method || 'post';
    params = params || {};

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement('form');
    form.method = method;
    form.action = path;

    _.C(params).each(function (value, key) {
        var input = document.createElement('input');
        input.type = 'hidden';
        input.name = key;
        input.value = value;
        form.appendChild(input);
    });

    // HACK create a body if called before DOMContentLoaded
    if (!document.body) {
      document.body = document.createElement('body');
    }
    document.body.appendChild(form);
    form.submit();
  }


  // TODO erase history if possible
  $.openLink = function (to, options) {
    if (!to) {
      _.warn('false URL');
      return;
    }
    options = options || {};
    var withReferer = typeof options.referer === 'undefined' ? true : options.referer;
    var postData = options.post;

    var from = window.location.toString();
    _.info(_.T('{0} -> {1}')(from, to));

    if (postData) {
      go(to, postData, 'post');
      return;
    }

    if (withReferer) {
      go(to, null, 'get');<commit_msg>Fix `$.openLink`.<commit_after>(function (context, factory) {
  if (typeof module === 'object' && typeof module.exports === 'object') {
    module.exports = function (context) {
      var core = require('./core.js');
      return factory(context, core);
    };
  } else {
    factory(context, context._);
  }
}(this, function (context, _) {
  'use strict';

  var window = context.window;
  var document = window.document;
  var $ = context.$ || {};


  function go (path, params, method) {
    // Set method to post by default, if not specified.
    method = method || 'post';
    params = params || {};

    // The rest of this code assumes you are not using a library.
    // It can be made less wordy if you use one.
    var form = document.createElement('form');
    form.method = method;
    form.action = path;

    _.C(params).each(function (value, key) {
        var input = document.createElement('input');
        input.type = 'hidden';
        input.name = key;
        input.value = value;
        form.appendChild(input);
    });

    // HACK create a body if called before DOMContentLoaded
    if (!document.body) {
      document.body = document.createElement('body');
    }
    document.body.appendChild(form);
    form.submit();
  }


  // TODO erase history if possible
  $.openLink = function (to, options) {
    if (typeof to !== 'string' && !to) {
      _.warn('false URL');
      return;
    }
    options = options || {};
    var withReferer = typeof options.referer === 'undefined' ? true : options.referer;
    var postData = options.post;

    var from = window.location.toString();
    _.info(_.T('{0} -> {1}')(from, to));

    if (postData) {
      go(to, postData, 'post');
      return;
    }

    if (withReferer) {
      go(to, null, 'get');
{'fraction_non_alphanumeric': 0.1534963047185901, 'fraction_numerical': 0.0011370096645821489, 'mean_word_length': 2.5295887662988967, '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': '6671343', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1045, 'n_words': 309}