<commit_before>$ ->
  loadAjaxTab = (li) ->
    link = $("a", li)
    content_id = link.attr("href").substring(1, 999)
    content = $(".bb-tabs-container #" + content_id + " .bb-tab-container")

    li.data("ajax-loaded", true)
    content.fadeOut 0, ->
      $.get li.data("ajax-url"), (data) ->
        content.html(data)
        content.fadeIn "fast"

  $("body").on "click", ".bb-tabs-container .nav li", ->
    li = $(this)

    if li.data("specific-id-given")
      urlb = new UrlBuilder(window.location.href)
      urlb.queryParameters["bb_selected_tab"] = $(this).data("tab-container-id")

      window.history.pushState("bb-tab-change", "", urlb.pathWithQueryParameters())

    if li.data("ajax-url") && !li.data("ajax-loaded")
      loadAjaxTab(li)

  active_tab = $(".bb-tabs-container .nav li.active[data-ajax-url]")
  loadAjaxTab(active_tab) if active_tab.length > 0<commit_msg>Added functionality to change tab on back and forward events<commit_after>$ ->
  # Used to load dynamic content of a tab
  loadAjaxTab = (li) ->
    link = $("a", li)
    content_id = link.attr("href").substring(1, 999)
    content = $(".bb-tabs-container #" + content_id + " .bb-tab-container")

    li.data("ajax-loaded", true)
    content.fadeOut 0, ->
      $.get li.data("ajax-url"), (data) ->
        content.html(data)
        content.fadeIn "fast"

  # Loads the dynamic content of a tab when activated and sets the URL to the tab ID
  $("body").on "click", ".bb-tabs-container .nav li", ->
    li = $(this)

    if li.data("ignore-next-history-push")
      li.data("ignore-next-history-push", null)
    else if li.data("specific-id-given")
      urlb = new UrlBuilder(window.location.href)
      urlb.queryParameters["bb_selected_tab"] = $(this).data("tab-container-id")

      window.history.pushState("bb-tab-change", "", urlb.pathWithQueryParameters())

    if li.data("ajax-url") && !li.data("ajax-loaded")
      loadAjaxTab(li)

  # Changes the tab on 'back' and 'forward' events
  $(window).bind "popstate", ->
    urlb = new UrlBuilder(window.location.href)
    selected_tab = urlb.queryParameters["bb_selected_tab"]

    li = $("li[data-tab-container-id='" + selected_tab + "']")

    unless li.hasClass("active")
      console.log("Click on LI")
      li.data("ignore-next-history-push", true)
      $("a", li).click()

  # Makes sure the correct tab is loaded on page load
  active_tab = $(".bb-tabs-container .nav li.active[data-ajax-url]")
  loadAjaxTab(active_tab) if active_tab.length > 0
{'fraction_non_alphanumeric': 0.1769876148621654, 'fraction_numerical': 0.004794246903715541, 'mean_word_length': 3.2013422818791946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '1689375', 'n_tokens_mistral': 872, 'n_tokens_neox': 835, 'n_words': 177}