<commit_before>// dependencies: module.js, search.js, display.js, resizable.js, navbar.js

// initialization
$(document).ready(function() {

  init_load();
  init_panes();
  init_searchpane();
  init_search();
  init_globals();
  init_favorites();
  init_feedback();
  init_display();
  init_evals();
  init_logout();
  init_about();

})

// loads course from url
var init_load = function () {
  // Parse and display search parameters, if any exist
  parseSearchParameters()

  // Parse course from the URL to determine which course (if any) to display on pageload
  var pathnameMatch = /^\/course\/(\d+)$/.exec(window.location.pathname)
  if (pathnameMatch !== null && pathnameMatch.length === 2) {
    // Load the course
    courseId = parseInt(pathnameMatch[1])
    if (!isNaN(courseId)) displayCourseDetails(courseId)
  }
}

// Handle displaying a course after pushing the back/forward button in the browser
window.onpopstate = function (event) {
  if (event.state && event.state.courseID) {
    displayCourseDetails(event.state.courseID)
  }
  parseSearchParameters()
}

// Parse the URL to check for whether the app should be showing a course and displaying any search terms
var parseSearchParameters = function () {
  // Parse search terms
  var unparsedParameters = window.location.search.replace('?', '').split('&')
  var parameters = {}
  for (var parametersIndex in unparsedParameters) {
    var keyValue = unparsedParameters[parametersIndex].split('=')
    if (keyValue.length === 2) {
      parameters[keyValue[0]] = decodeURIComponent(keyValue[1])
    }
  }
  if (parameters.hasOwnProperty('search')) {
    $('#searchbox').val(parameters.search)
  }
  if (parameters.hasOwnProperty('semester')) {
    $('#semester').data('query', parameters.semester).val(parameters.semester)
  }
  if (parameters.hasOwnProperty('sort')) {
    $('#sort').val(parameters.sort)
  }
  if (parameters !== {}) {
    searchForCourses()
  }
}

// to initialize draggability
var init_panes = function() {
  $('#search-pane').resizable({
    handleSelector: "#search-resizer",
    resizeHeight: false
  })

  $('#info-pane').resizable({
    handleSelector: "#info-resizer",
    resizeHeight: false,
    resizeWidthFrom: 'left'
  })
}

// to initalize search pane section collapsing
var init_searchpane = function() {
  $('#favorite-courses').css('max-height', '30%')

    // toggle display of favorite things
  var toggleFavDisplay = function() {
    var isVisible = $('#favorite-courses').css('display') !== 'none'

    var icon = $('#fav-display-toggle')
    icon.removeClass(isVisible ? 'fa-minus' : 'fa-plus')
    icon.addClass(isVisible ? 'fa-plus' : 'fa-minus')
    $('#favorite-courses').slideToggle()
  }
  $('#fav-display-toggle').click(toggleFavDisplay)<commit_msg>Fixed issue with favorites in Safari<commit_after>// dependencies: module.js, search.js, display.js, resizable.js, navbar.js

// initialization
$(document).ready(function() {

  init_load();
  init_panes();
  init_searchpane();
  init_search();
  init_globals();
  init_favorites();
  init_feedback();
  init_display();
  init_evals();
  init_logout();
  init_about();

})

// loads course from url
var init_load = function () {
  // Parse and display search parameters, if any exist
  parseSearchParameters()

  // Parse course from the URL to determine which course (if any) to display on pageload
  var pathnameMatch = /^\/course\/(\d+)$/.exec(window.location.pathname)
  if (pathnameMatch !== null && pathnameMatch.length === 2) {
    // Load the course
    courseId = parseInt(pathnameMatch[1])
    if (!isNaN(courseId)) displayCourseDetails(courseId)
  }
}

// Handle displaying a course after pushing the back/forward button in the browser
window.onpopstate = function (event) {
  if (event.state && event.state.courseID) {
    displayCourseDetails(event.state.courseID)
  }
  parseSearchParameters()
}

// Parse the URL to check for whether the app should be showing a course and displaying any search terms
var parseSearchParameters = function () {
  // Parse search terms
  var unparsedParameters = window.location.search.replace('?', '').split('&')
  var parameters = {}
  for (var parametersIndex in unparsedParameters) {
    var keyValue = unparsedParameters[parametersIndex].split('=')
    if (keyValue.length === 2) {
      parameters[keyValue[0]] = decodeURIComponent(keyValue[1])
    }
  }
  if (parameters.hasOwnProperty('search')) {
    $('#searchbox').val(parameters.search)
  }
  if (parameters.hasOwnProperty('semester')) {
    $('#semester').data('query', parameters.semester).val(parameters.semester)
  }
  if (parameters.hasOwnProperty('sort')) {
    $('#sort').val(parameters.sort)
  }
  if (parameters !== {}) {
    searchForCourses()
  }
}

// to initialize draggability
var init_panes = function() {
  $('#search-pane').resizable({
    handleSelector: "#search-resizer",
    resizeHeight: false
  })

  $('#info-pane').resizable({
    handleSelector: "#info-resizer",
    resizeHeight: false,
    resizeWidthFrom: 'left'
  })
}

// to initalize search pane section collapsing
var init_searchpane = function() {
  $('#favorite-courses').css('max-height', '30vh')

    // toggle display of favorite things
  var toggleFavDisplay = function() {
    var isVisible = $('#favorite-courses').css('display') !== 'none'

    var icon = $('#fav-display-toggle')
    icon.removeClass(isVisible ? 'fa-minus' : 'fa-plus')
    icon.addClass(isVisible ? 'fa-plus' : 'fa-minus')
    $('#favorite-courses').slideToggle()
  }
  $('#fav-display-toggle').click(toggleFavDisplay)
{'fraction_non_alphanumeric': 0.15441441441441442, 'fraction_numerical': 0.0025225225225225223, 'mean_word_length': 4.083333333333333, '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': '3475362', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1708, 'n_words': 396}