<commit_before>$(document).ready(function(){

  // Are we currently trying to load the carousel?
  // 
  var loading = false,
    loaded = false,
    holderId = '#carousel-holder';

  // Function that we'll call when the screen is resized
  // or the page is first loaded.
  // 
  function loadCarousel(){

    // Don't try to load the carousel if we're 
    // already in the process of loading it. Also,
    // don't load it if we've already loaded it.
    // Finally, only try to load the carousel if we're
    // on a screen where it's visible.  In our CSS,
    // we're hiding it on small screens. Finally,
    //
    if (loading === true || loaded === true || $(holderId).is(':visible') === false) {
      return;
    }

    // Try to load the carousel. Notice that we're
    // using jQuery's Promises here (the .done and
    // .always methods, which are chainable).
    //
    loading = true;
    $.get('/carousel')
      .done(function(htmlFragment){
        $(holderId).html(htmlFragment);
        loaded = true;
      })
      .always(function(){loading = false});
  }

  // Try to load the carousel on window resize.
  // 
  $(window).resize(loadCarousel);

  // Try to load the carousel once when the DOM is ready.
  // 
  loadCarousel();<commit_msg>Unbind the callback on window resize to prevent firing after carousel is loaded.<commit_after>$(document).ready(function(){

  // Are we currently trying to load the carousel?
  // 
  var loading = false,
    loaded = false,
    holderId = '#carousel-holder';

  // Function that we'll call when the screen is resized
  // or the page is first loaded.
  // 
  function loadCarousel(){

    // Don't try to load the carousel if we're 
    // already in the process of loading it. Also,
    // don't load it if we've already loaded it.
    // Finally, only try to load the carousel if we're
    // on a screen where it's visible.  In our CSS,
    // we're hiding it on small screens. Finally,
    //
    if (loading === true || loaded === true || $(holderId).is(':visible') === false) {
      return;
    }

    // Try to load the carousel. Notice that we're
    // using jQuery's Promises here (the .done and
    // .always methods, which are chainable).
    //
    loading = true;
    $.get('/carousel')
      .done(function(htmlFragment){

        // Add the carousel to the DOM
        $(holderId).html(htmlFragment);

        // Save that we're loaded
        loaded = true;

        // Unbind the callback so that it never
        // fires again
        $(window).unbind('resize', loadCarousel);

      })
      .always(function(){loading = false});
  }

  // Try to load the carousel on window resize.
  // 
  $(window).bind('resize', loadCarousel);

  // Try to load the carousel once when the DOM is ready.
  // 
  loadCarousel();
{'fraction_non_alphanumeric': 0.12602641913602286, 'fraction_numerical': 0.0, 'mean_word_length': 2.2695449241540255, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7302498', 'n_tokens_mistral': 839, 'n_tokens_neox': 788, 'n_words': 313}