<commit_before>/*
 * A content script: http://developer.chrome.com/extensions/content_scripts
 * match: ['http://docs.oracle.com/*', 'https://docs.oracle.com/*']
 */

'use strict';

var
  template = window.template,
  server = window.server,
  $ = window.jQuery;

function copy_method ($dest) {
  return function (index) {
    var $m = $('a[href*="' + this + '"]').closest('tr').clone();
    $m.removeClass('altColor rowColor');
    $m.addClass(index % 2 ===  0 ? 'altColor' : 'rowColor');
    $dest.append($m);
  };
}


function render () {
  var
    name = $('.inheritance > li:last').html(), //ex. java.lang.String
    $tpl = $(template);

  //get methods
  server.methods(name, function (methods) {

    //top 5
    methods = methods.slice(0,5);

    //fill template with popular methods
    $.each(methods, copy_method($tpl.find('#popular-methods')));

    //insert in existing dom
    $('.description').before($tpl);

  });

}

/*
 * we are triggered on all frames, so first check that we are on the right one;
 * based on highlighted top navigation element ;-)
 * note: type 'Class' is for classes & interfaces
 */
var type = $('.navBarCell1Rev').html(); // [package,Class]
if (type === 'Class') {
  render();
}

//we can communicate with our background script ;-)
//http://developer.chrome.com/extensions/messaging
<commit_msg>hack because of missing space after comma<commit_after>/*
 * A content script: http://developer.chrome.com/extensions/content_scripts
 * match: ['http://docs.oracle.com/*', 'https://docs.oracle.com/*']
 */

'use strict';

var
  template = window.template,
  server = window.server,
  $ = window.jQuery;

function copy_method ($dest) {
  return function (index) {
    var $m = $('a[href*="' + this + '"]').closest('tr').clone();
    $m.removeClass('altColor rowColor');
    $m.addClass(index % 2 ===  0 ? 'altColor' : 'rowColor');
    $dest.append($m);
  };
}


function render () {
  var
    name = $('.inheritance > li:last').html(), //ex. java.lang.String
    $tpl = $(template);

  //get methods
  server.methods(name, function (methods) {

    if (!methods.length) {
      //do nothing
      return;
    }

    //top 5
    methods = methods.slice(0,5);

    //hack: missing space after comma
    methods = methods.map(function (item){ return item.replace(/,/g, ', ');});

    //fill template with popular methods
    $.each(methods, copy_method($tpl.find('#popular-methods')));

    //insert in existing dom
    $('.description').before($tpl);

  });

}

/*
 * we are triggered on all frames, so first check that we are on the right one;
 * based on highlighted top navigation element ;-)
 * note: type 'Class' is for classes & interfaces
 */
var type = $('.navBarCell1Rev').html(); // [package,Class]
if (type === 'Class') {
  render();
}

//we can communicate with our background script ;-)
//http://developer.chrome.com/extensions/messaging

{'fraction_non_alphanumeric': 0.18591744710371141, 'fraction_numerical': 0.004162330905306972, 'mean_word_length': 3.253687315634218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '718456', 'n_tokens_mistral': 932, 'n_tokens_neox': 897, 'n_words': 243}