<commit_before>var BlueRidge = BlueRidge || {};

BlueRidge.Browser = {
  require: function(url, options){
    options = options || {};

    var system   = options["system"] || false;
    var callback = options["onload"] || null;

    url = (system) ? this.treatUrlAsRelativeToCurrentFile(url) : this.treatUrlAsRelativeToSpecFile(url);
    this.createScriptTag(url, callback);
  },

  //TODO: holy crap this needs refactoring
  treatUrlAsRelativeToSpecFile: function(url){
    var depth = this.calculateDepth();

    //remove any extra "../" from the start of the URL
    var prefix = "^";
    for(var i=0; i < (depth-1); i++) { prefix += "\.\.\/" }
    url = url.replace(new RegExp(prefix), ""); 
    
    return this.urlCorrection(depth) + url;
  },
  
  treatUrlAsRelativeToCurrentFile: function(url){
    return this.urlCorrection(this.calculateDepth()) + url;
  },
  
  createScriptTag: function(url, onload){
    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement("script");

    script.type = "text/javascript";
    $.ajax({
      url: url,
      async: false,
      success: function(js) {
        script.text = js;
        if (onload) onload();
      }
    });

    head.appendChild(script);
  },
  
  urlCorrection: function(depth){
    var correction = "";
    for(var i=0; i < depth; i++) { correction += "../" }
    return correction;
  },
  
  debug: function(message){
    document.writeln(message + " <br/>");
  },

  currentFile: function(){<commit_msg>Require should avoid caching<commit_after>var BlueRidge = BlueRidge || {};

BlueRidge.Browser = {
  require: function(url, options){
    options = options || {};

    var system   = options["system"] || false;
    var callback = options["onload"] || null;

    url = (system) ? this.treatUrlAsRelativeToCurrentFile(url) : this.treatUrlAsRelativeToSpecFile(url);
    this.createScriptTag(url, callback);
  },

  //TODO: holy crap this needs refactoring
  treatUrlAsRelativeToSpecFile: function(url){
    var depth = this.calculateDepth();

    //remove any extra "../" from the start of the URL
    var prefix = "^";
    for(var i=0; i < (depth-1); i++) { prefix += "\.\.\/" }
    url = url.replace(new RegExp(prefix), ""); 
    
    return this.urlCorrection(depth) + url;
  },
  
  treatUrlAsRelativeToCurrentFile: function(url){
    return this.urlCorrection(this.calculateDepth()) + url;
  },
  
  createScriptTag: function(url, onload){
    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement("script");

    script.type = "text/javascript";
    var url_with_caching_prevention = url + "?" + (new Date()).getTime();
    $.ajax({
      url: url_with_caching_prevention,
      async: false,
      success: function(js) {
        script.text = js;
        if (onload) onload();
      }
    });

    head.appendChild(script);
  },
  
  urlCorrection: function(depth){
    var correction = "";
    for(var i=0; i < depth; i++) { correction += "../" }
    return correction;
  },
  
  debug: function(message){
    document.writeln(message + " <br/>");
  },

  currentFile: function(){
{'fraction_non_alphanumeric': 0.15821371610845295, 'fraction_numerical': 0.002551834130781499, 'mean_word_length': 3.115485564304462, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6048914', 'n_tokens_mistral': 1002, 'n_tokens_neox': 980, 'n_words': 215}