<commit_before>/* global Fae */

'use strict';

Fae.navigation = {
  current_items: [],

  init: function() {
    this.select_current_nav_item();
    this.update_nav_classes();
    this.subnavHighlighter.init();
    this.mobileMenu.init();
    this.utilityNav();
    this.buttonDropdown();
    this.fade_notices();
    this.language.init();
  },

  select_current_nav_item: function() {
    var self = this;
    var current_base_url = window.location.pathname;
    var regex_match = current_base_url.match(/^\/admin\/#?(\w*)?\//);
    $('#main_nav a').each(function(){
      var $this = $(this);
      var link = $this.attr('href');
      if ((regex_match !== null && regex_match.length && link.indexOf(regex_match[1]) > -1) || link === current_base_url) {
        $this.addClass('current');
        self.current_items.push($this);
        return false;
      }
    });
  },

  update_nav_classes: function() {
    var self = this;
    $.each(self.current_items, function(index, $el){
      if ($el.hasClass('main_nav-link')) {
        self.update_first_level($el);
      } else if ($el.hasClass('main_nav-sub-link')) {
        self.update_second_level($el);
      } else if ($el.hasClass('main_nav-third-link')) {
        self.update_third_level($el);
      }
    });<commit_msg>mas better way of setting active with variable path name<commit_after>/* global Fae */

'use strict';

Fae.navigation = {
  current_items: [],

  init: function() {
    this.select_current_nav_item();
    this.update_nav_classes();
    this.subnavHighlighter.init();
    this.mobileMenu.init();
    this.utilityNav();
    this.buttonDropdown();
    this.fade_notices();
    this.language.init();
  },

  select_current_nav_item: function() {
    var self = this;
    var current_base_url = window.location.pathname;
    var regex = new RegExp("^" + Fae.path + "\/#?(\\w*)?\/");
    var regex_match = current_base_url.match(regex);
    $('#main_nav a').each(function(){
      var $this = $(this);
      var link = $this.attr('href');
      if ((regex_match !== null && regex_match.length && link.indexOf(regex_match[1]) > -1) || link === current_base_url) {
        $this.addClass('current');
        self.current_items.push($this);
        return false;
      }
    });
  },

  update_nav_classes: function() {
    var self = this;
    $.each(self.current_items, function(index, $el){
      if ($el.hasClass('main_nav-link')) {
        self.update_first_level($el);
      } else if ($el.hasClass('main_nav-sub-link')) {
        self.update_second_level($el);
      } else if ($el.hasClass('main_nav-third-link')) {
        self.update_third_level($el);
      }
    });
{'fraction_non_alphanumeric': 0.17522658610271905, 'fraction_numerical': 0.0015105740181268882, 'mean_word_length': 2.995475113122172, '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': '6266403', 'n_tokens_mistral': 886, 'n_tokens_neox': 879, 'n_words': 149}