<commit_before>/* global $, pushStateTree, demoPath, navbarAdd */

(function($, pushStateTree){
  'use strict';

  var rule = pushStateTree.createRule({
    id: 'servers',
    rule: /^servers\/(.*)/
  });
  var scrollSpyRule = pushStateTree.createRule({
    id: 'server-scrollspy',
    parentGroup: 1,
    rule: /[^/]+/
  });

  $(rule)
    .append(scrollSpyRule)
    .appendTo(pushStateTree);
  
  // Add menu option in the first load
  navbarAdd('Servers', '/servers/', 3);

  var $template;
  var $body = $('body');
  var $window = $(window);
  var $sidebar;
  
  // Load template
  var ready = $.ajax(demoPath + 'servers.html').done(function (template){
    $template = $(template);
  }).promise();

  var onScroll = trottle(function (){
    if (!$sidebar) return;
    if ($sidebar.parent().offset().top >= $body.scrollTop()) {
      if($sidebar.hasClass('affix-top')) return;
      $sidebar.toggleClass('affix-top', true).toggleClass('affix', false);
    } else {
      if($sidebar.hasClass('affix')) return;
      $sidebar.toggleClass('affix-top', false).toggleClass('affix', true);
    }
  }, 50);

  $(rule).on('enter', function(){
    ready.done(function (){
      $('#content').append($template);
      $sidebar = $template.find('.bs-docs-sidebar');
    });

    // Listen for scroll event
    $window.on('scroll', onScroll);
  }).on('leave', function(){
    // Stop listening for scroll event
    $window.off('scroll', onScroll);

    $template.remove && $template.remove();
  });

  $(scrollSpyRule).on('update', function(event){
    // on match any scroll spy rule, animate the scroll to the element with the corresponding ID on DOM if it exists

    var oEvent = event.originalEvent;
    var section = oEvent.detail.match[0];

    ready.done(function () {
      var $focusDocElement = $('#' + section);
      $body.animate({
        scrollTop: $focusDocElement.offset().top
      }, 300, function(){
        $focusDocElement.css({
          backgroundColor: '#ffffcc'
        });
        setTimeout(function(){
          $focusDocElement.css({
            backgroundColor: ''
          });
        }, 1e3);
      });
      $sidebar.find('.active').removeClass('active');
      $sidebar.find('[href="' + section + '"]').parents('li').addClass('active');
    });
  });

})($, pushStateTree);<commit_msg>Fixed match event on server docs<commit_after>/* global $, pushStateTree, demoPath, navbarAdd */

(function($, pushStateTree){
  'use strict';

  var rule = pushStateTree.createRule({
    id: 'servers',
    rule: /^servers\/(.*)/
  });
  var scrollSpyRule = pushStateTree.createRule({
    id: 'server-scrollspy',
    parentGroup: 1,
    rule: /[^/]+/
  });

  $(rule)
    .append(scrollSpyRule)
    .appendTo(pushStateTree);
  
  // Add menu option in the first load
  navbarAdd('Servers', '/servers/', 3);

  var $template;
  var $body = $('body');
  var $window = $(window);
  var $sidebar;
  
  // Load template
  var ready = $.ajax(demoPath + 'servers.html').done(function (template){
    $template = $(template);
  }).promise();

  var onScroll = trottle(function (){
    if (!$sidebar) return;
    if ($sidebar.parent().offset().top >= $body.scrollTop()) {
      if($sidebar.hasClass('affix-top')) return;
      $sidebar.toggleClass('affix-top', true).toggleClass('affix', false);
    } else {
      if($sidebar.hasClass('affix')) return;
      $sidebar.toggleClass('affix-top', false).toggleClass('affix', true);
    }
  }, 50);

  $(rule).on('enter', function(){
    ready.done(function (){
      $('#content').append($template);
      $sidebar = $template.find('.bs-docs-sidebar');
    });

    // Listen for scroll event
    $window.on('scroll', onScroll);
  }).on('leave', function(){
    // Stop listening for scroll event
    $window.off('scroll', onScroll);

    $template.remove && $template.remove();
  });

  $(scrollSpyRule).on('match', function(event){
    // on match any scroll spy rule, animate the scroll to the element with the corresponding ID on DOM if it exists

    var oEvent = event.originalEvent;
    var section = oEvent.detail.match[0];

    ready.done(function () {
      var $focusDocElement = $('#' + section);
      $body.animate({
        scrollTop: $focusDocElement.offset().top
      }, 300, function(){
        $focusDocElement.css({
          backgroundColor: '#ffffcc'
        });
        setTimeout(function(){
          $focusDocElement.css({
            backgroundColor: ''
          });
        }, 1e3);
      });
      $sidebar.find('.active').removeClass('active');
      $sidebar.find('[href="' + section + '"]').parents('li').addClass('active');
    });
  });

})($, pushStateTree);
{'fraction_non_alphanumeric': 0.18803786574870912, 'fraction_numerical': 0.004302925989672977, 'mean_word_length': 2.9735042735042736, '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': '5237502', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1423, 'n_words': 306}