<commit_before>'use strict';

var missingGithubLinks = {

  packageType: null,

  init: function( type ) {
    if( !type ) {
      return;
    }

    this.packageType = type;

    try {
      this._run();
    } catch(err) {
      console.error(err);
    }
  },

  _run: function() {
    var self = this;
    if(self.packageType === 'npm') {
      self.registryList = npmRegistry.rows;
      chrome.runtime.sendMessage({action: 'init', value: self.packageType});
    }else if(self.packageType === 'bower') {
      self.registryList = bowerRegistry.rows;
      chrome.runtime.sendMessage({action: 'init', value: self.packageType});
    }

    self._updateDom();
  },

  _updateDom: function() {
    var self = this;

    $('.code-body a span').unwrap();

    var types = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
    var list = types.map(function( item ) {
      return self._getPackageNodes(item);
    });

    $.each(list, function( index, item ) {
      self._createLinkTag(item);
    });
  },

  _getPackageNodes: function( selector ) {
    var root = $('.code-body .nt:contains(\'' + selector + '\')');

    if( !root || root.length === 0 ) {
      return [];
    }

    var result = [];
    var el;
    var next = root.parent().next();

    if( next ) {
      while( next.children().length !== 1 ) {
        el = next.children().eq(0);
        result.push({
          el: el,
          pkgName: el.html().replace(/"/g, '')
        });
        next = next.next();
      }
    }
    return result;
  },

  _createLinkTag: function( list ) {
    var self = this;

    $.each(list, function( index, item ) {
      var link = self.registryList[item.pkgName];
      var $link = $('<a>');

      if( !link && self.packageType === 'npm' ) {
        link = 'https://npmjs.org/package/' + item.pkgName;
      }

      if( link ) {
        $link.attr('href', link)
        .on('click', function() {
          var url =  $(this).attr('href');
          chrome.runtime.sendMessage({action: 'forwarding', value: url});
        });
        item.el.wrap($link);
      } else {
        item.el.addClass('tooltipped').attr('original-title', 'Sorry, there is no link for this package available');
      }
    });
  }
};<commit_msg>use arial-label for the tooltips<commit_after>'use strict';

var missingGithubLinks = {

  packageType: null,

  init: function( type ) {
    if( !type ) {
      return;
    }

    this.packageType = type;

    try {
      this._run();
    } catch(err) {
      console.error(err);
    }
  },

  _run: function() {
    var self = this;
    if(self.packageType === 'npm') {
      self.registryList = npmRegistry.rows;
      chrome.runtime.sendMessage({action: 'init', value: self.packageType});
    }else if(self.packageType === 'bower') {
      self.registryList = bowerRegistry.rows;
      chrome.runtime.sendMessage({action: 'init', value: self.packageType});
    }

    self._updateDom();
  },

  _updateDom: function() {
    var self = this;

    $('.code-body a span').unwrap();

    var types = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
    var list = types.map(function( item ) {
      return self._getPackageNodes(item);
    });

    $.each(list, function( index, item ) {
      self._createLinkTag(item);
    });
  },

  _getPackageNodes: function( selector ) {
    var root = $('.code-body .nt:contains(\'' + selector + '\')');

    if( !root || root.length === 0 ) {
      return [];
    }

    var result = [];
    var el;
    var next = root.parent().next();

    if( next ) {
      while( next.children().length !== 1 ) {
        el = next.children().eq(0);
        result.push({
          el: el,
          pkgName: el.html().replace(/"/g, '')
        });
        next = next.next();
      }
    }
    return result;
  },

  _createLinkTag: function( list ) {
    var self = this;

    $.each(list, function( index, item ) {
      var link = self.registryList[item.pkgName];
      var $link = $('<a>');

      if( !link && self.packageType === 'npm' ) {
        link = 'https://npmjs.org/package/' + item.pkgName;
      }

      if( link ) {
        $link.attr('href', link)
        .on('click', function() {
          var url =  $(this).attr('href');
          chrome.runtime.sendMessage({action: 'forwarding', value: url});
        });
        item.el.wrap($link);
      } else {
        item.el.addClass('tooltipped tooltipped-e').attr('aria-label', 'Sorry, there is no link for this package available');
      }
    });
  }
};
{'fraction_non_alphanumeric': 0.1771705597179374, 'fraction_numerical': 0.0013221683561040105, 'mean_word_length': 2.2560975609756095, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4011371', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1414, 'n_words': 305}