<commit_before>var modalController = (function () {

  var selectedStateIdx = null;

  var modal = document.getElementById('mainModal');
  var background = document.getElementById('modalBackdrop');

  var hideModal = function () {
    modal.className = 'modal fade';
    background.className = 'modal-backdrop fade';
    selectedStateIdx = null;

    setTimeout(function () {
      modal.style.display = 'none';
    }, 250); //long enough for animation to wrap up

    g.selectAll("path").classed("active", false);
  };

  var populateStateData = function (state) {
    document.getElementById('historical-artifact-image').src = state.historicalArtifactImage;
    document.getElementById('historical-artifact-image').title = state.historicalArtifactImageTitle;
    document.getElementById('historical-artifact-data').innerText = state.historicalArtifactData;
    document.getElementById('pattern-image').src = state.patternImage;
    document.getElementById('pattern-image').title = state.patternImageTitle;
    document.getElementById('pattern-data').innerText = state.patternData;
    document.getElementById('state-title').innerText = state_names[state.stateCode];
  }

  var showState = function (state) {
    selectedStateIdx = state.id;
    modal.style.display = 'block';
    setTimeout(function () {
      modal.className = 'modal fade in';
      background.className = 'modal-backdrop fade in';
    }, 50); //long enough to be at least one animation frame, so that the animation triggers
    populateStateData(state);
  };

  var nextState = function () {
    g.selectAll("path").classed("active", false);

    selectedStateIdx += 1;
    // because state ids are not contiguous
    while(!states_data.hasOwnProperty(selectedStateIdx)){
      selectedStateIdx += 1;
      if (selectedStateIdx >= 57){
        selectedStateIdx = 1;
      }
    }

    g.selectAll("path").filter(function (d, i) { return i === selectedStateIdx;}).classed("active", true)
    var state = states_data[selectedStateIdx];
    state.id = selectedStateIdx;
    populateStateData(state);
  }

  var previousState = function () {
    g.selectAll("path").classed("active", false);


    selectedStateIdx -= 1;
    // because state ids are not contiguous
    while(!states_data.hasOwnProperty(selectedStateIdx)){
      selectedStateIdx -= 1;
      if (selectedStateIdx <= 0){
        selectedStateIdx = 56;
      }
    }

    g.selectAll("path").filter(function (d, i) { return i === selectedStateIdx;}).classed("active", true)
    var state = states_data[selectedStateIdx];
    state.id = selectedStateIdx;
    populateStateData(state);
  }

  return {
    showState: showState,
    hideModal: hideModal,
    nextState: nextState,
    previousState: previousState<commit_msg>fix selector for next and previous coloring<commit_after>var modalController = (function () {

  var selectedStateIdx = null;

  var modal = document.getElementById('mainModal');
  var background = document.getElementById('modalBackdrop');

  var hideModal = function () {
    modal.className = 'modal fade';
    background.className = 'modal-backdrop fade';
    selectedStateIdx = null;

    setTimeout(function () {
      modal.style.display = 'none';
    }, 250); //long enough for animation to wrap up

    g.selectAll("path").classed("active", false);
  };

  var populateStateData = function (state) {
    document.getElementById('historical-artifact-image').src = state.historicalArtifactImage;
    document.getElementById('historical-artifact-image').title = state.historicalArtifactImageTitle;
    document.getElementById('historical-artifact-data').innerText = state.historicalArtifactData;
    document.getElementById('pattern-image').src = state.patternImage;
    document.getElementById('pattern-image').title = state.patternImageTitle;
    document.getElementById('pattern-data').innerText = state.patternData;
    document.getElementById('state-title').innerText = state_names[state.stateCode];
  }

  var showState = function (state) {
    selectedStateIdx = state.id;
    modal.style.display = 'block';
    setTimeout(function () {
      modal.className = 'modal fade in';
      background.className = 'modal-backdrop fade in';
    }, 50); //long enough to be at least one animation frame, so that the animation triggers
    populateStateData(state);
  };

  var nextState = function () {
    g.selectAll("path").classed("active", false);

    selectedStateIdx += 1;
    // because state ids are not contiguous
    while(!states_data.hasOwnProperty(selectedStateIdx)){
      selectedStateIdx += 1;
      if (selectedStateIdx >= 57){
        selectedStateIdx = 1;
      }
    }

    g.selectAll("path").filter(function (d) { return d.id === selectedStateIdx;}).classed("active", true)
    var state = states_data[selectedStateIdx];
    state.id = selectedStateIdx;
    populateStateData(state);
  }

  var previousState = function () {
    g.selectAll("path").classed("active", false);


    selectedStateIdx -= 1;
    // because state ids are not contiguous
    while(!states_data.hasOwnProperty(selectedStateIdx)){
      selectedStateIdx -= 1;
      if (selectedStateIdx <= 0){
        selectedStateIdx = 56;
      }
    }

    g.selectAll("path").filter(function (d) { return d.id === selectedStateIdx;}).classed("active", true)
    var state = states_data[selectedStateIdx];
    state.id = selectedStateIdx;
    populateStateData(state);
  }

  return {
    showState: showState,
    hideModal: hideModal,
    nextState: nextState,
    previousState: previousState
{'fraction_non_alphanumeric': 0.12531599855543518, 'fraction_numerical': 0.005417118093174431, 'mean_word_length': 3.7956709956709958, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5812259', 'n_tokens_mistral': 1592, 'n_tokens_neox': 1508, 'n_words': 331}