<commit_before>(function( $ ) {
  
  /*
   * Configuration.
   */
  var key = ''; // TODO add your API key
  var datasource = function (products, callback) {
    // TODO add your data call
    $.getJSON(your_url, url_params, callback);
  };


  
  /**************************************************************************/
  

  
  /*
   * Main invocation method.
   */
  $.fn.thesocialdigits = function(api, args, template) {
    var elm = this;
    
    callAPI(api, args, function(data) {
      if('result' in data) {
        datasource(data.result, function(products) {
          buildHTML(elm, data.result, template, products);
        });
      }
    });
  };

  /*
   * Build HTML from template.
   */
  function buildHTML(elm, ids, template, _products) { 
    // ensure the correct sorting of product data
    products = [];
    
    for (var i in ids) {
      var id = ids[i];
      
      for(var j in _products) {
        if(_products[j]['id'] == id) {
          products[i] = _products[j];
          break;
        }
      }
    }
                 
    // generate the html from the template
    elm.append(renderTemplate($(template).html(), products));
    
    // add click logging
    for (var i in ids) {
      var id = ids[i];
      
      $('a[rel="__tsd-' + id + '"]').click({'id': id}, function(event) {
        var href = $(this).attr('href');
        setTimeout('window.location.href = "' + href + '";', 1000); // always go
        
        callAPI('__log_click', {'product': event.data.id}, function() {
          window.location.href = href; // go on success
        });
        
        return false; // don't go yet
      });
    }
  }

  /*
   * Primitive template rendering.
   */
  function renderTemplate(template, products) {
    var output = '';
    
    for (var i in products) {
      var product = products[i];
      var tmp = template.replace('<a', '<a rel="__tsd-' + product['id'] + '"');
      <commit_msg>Now all links are also replaced.<commit_after>(function( $ ) {
  
  /*
   * Configuration.
   */
  var key = ''; // TODO add your API key
  var datasource = function (products, callback) {
    // TODO add your data call
    $.getJSON(your_url, url_params, callback);
  };


  
  /**************************************************************************/
  

  
  /*
   * Main invocation method.
   */
  $.fn.thesocialdigits = function(api, args, template) {
    var elm = this;
    
    callAPI(api, args, function(data) {
      if('result' in data) {
        datasource(data.result, function(products) {
          buildHTML(elm, data.result, template, products);
        });
      }
    });
  };

  /*
   * Build HTML from template.
   */
  function buildHTML(elm, ids, template, _products) { 
    // ensure the correct sorting of product data
    products = [];
    
    for (var i in ids) {
      var id = ids[i];
      
      for(var j in _products) {
        if(_products[j]['id'] == id) {
          products[i] = _products[j];
          break;
        }
      }
    }
                 
    // generate the html from the template
    elm.append(renderTemplate($(template).html(), products));
    
    // add click logging
    for (var i in ids) {
      var id = ids[i];
      
      $('a[rel="__tsd-' + id + '"]').click({'id': id}, function(event) {
        var href = $(this).attr('href');
        setTimeout('window.location.href = "' + href + '";', 1000); // always go
        
        callAPI('__log_click', {'product': event.data.id}, function() {
          window.location.href = href; // go on success
        });
        
        return false; // don't go yet
      });
    }
  }

  /*
   * Primitive template rendering.
   */
  function renderTemplate(template, products) {
    var output = '';
    
    for (var i in products) {
      var product = products[i];
      var tmp = template.replace(new RegExp('<a', 'g'), '<a rel="__tsd-' + product['id'] + '"');
      
{'fraction_non_alphanumeric': 0.18839103869653767, 'fraction_numerical': 0.002036659877800407, 'mean_word_length': 1.9969488939740656, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5737777', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1166, 'n_words': 299}