<commit_before>/* 
  Event Handlers
*/
$('document').ready(function() {

  /*
    Planbook initialization
  */
  $.ajax({
    type: "GET",
    url: "/settings?json=true", 
    data: {
      'settings': ref.settings
    },
    statusCode: { 
      500: function() {
        alert("There's been a server error. Contact NLTL for assistance.");
      }
    },
    success: function(data) {
      $('li#username').children('a').text(data.name);
      ref.settings = data.settings;

      if (typeof(ref.settings.rows[0]) != "object") { // if it's the old settings format
        for (var i = 0; i < ref.settings.rows.length; i++)
          ref.settings.rows[i] = [ref.settings.rows[i], i+1];
        setSettings(ref.settings, function() {});
      }
      renderRows(ref.settings.rows);
    }
  });


  /* 
    Navigation Buttons
  */
  $('#save').click(function() {
    saveWeek(getAssignmentValues());
  });
  $('#back').click(function() {

    if (!ref.turnInProgress) {
      ref.turnInProgress = true;
      // animation
      saveWeek(getAssignmentValues()); // save the current state
      ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() - 7); // decrement by 1 week
      getWeek(function(o) {
        $('#sidebar').slide($(window).width(), 200);
        $("#planner").slide($(window).width(), 200, function() {
          setAssignmentValues(o);
          ref.turnInProgress = false;
        });
      });
    }
  });
  $('#next').click(function() {
    if (!ref.turnInProgress) {
      ref.turnInProgress = true;
      saveWeek(getAssignmentValues());
      ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() + 7);

      getWeek(function(o) {
        $('#sidebar').slide(-$(window).width(), 200);
        $("#planner").slide(-$(window).width(), 200, function() {
          setAssignmentValues(o);
          ref.turnInProgress = false;
        });
      });
    }
  });

  $(document).bind('keydown', 'meta+s', function(e) {
    e.preventDefault();
    saveWeek(getAssignmentValues());
  });

  $(document).bind('keydown', 'meta+right', function(e) {
    e.preventDefault();
    $('#next').click();
  });
  $(document).bind('keydown', 'meta+left', function(e) {
    e.preventDefault();
    $('#back').click();
  });

  // Mobile navigation buttons
  $('#msave').click(function() {
    saveWeek(getAssignmentValues());
  });
  $('#mback').click(function() {
    // animation
    saveWeek(getAssignmentValues()); // save the current state
    ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() - 7); // decrement by 1 week
    getWeek(setAssignmentValues);
    drawDates()  
  });
  $('#mnext').click(function() {
    saveWeek(getAssignmentValues());
    ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() + 7);
    getWeek(setAssignmentValues);
    drawDates();
  });
  $('#mdays').change(function() {
    $('#' + ref.visibleDay).hide();
    $('#' + $("select option:selected").text()).show();
    ref.visibleDay = $( "select option:selected" ).text();
  });

  // add subject
  $('button#add').click(function() {
    // save
    var id = 0;
    for (var i = 0; i < ref.settings.rows.length; i++) {
      if (ref.settings.rows[i][1] >= id) {
        id = parseInt(ref.settings.rows[i][1])+1
      }
    }
    ref.settings.rows.push(["Class", id]);
    setSettings(ref.settings, function(data) {
      renderRows(ref.settings.rows);
      $('.subj#'+id).children('.subjectspan').trigger('dblclick');
    });
  });
  taListen();
  subjectListen();
});

function taListen() {
  $("textarea").unbind();
  $("textarea").bind('keydown', 'meta+s', function(e) {
    e.preventDefault();
    saveWeek(getAssignmentValues());
  });
  /*
    Keypress listener, for parsing and using inputs to different textareas.
    Will get quite large as features such as lab requests are added.
  */
  $("textarea").blur(function() {
    saveWeek(getAssignmentValues());
  });
  $("textarea").keydown(function(e) {
    if ($(this).val().indexOf('snake') >= 0) {
      $('#snakebtn').show();
    }
    // If it's been more than 30 seconds since you've updated from this device
    var taID = this.id;
    if (new Date().getTime() - ref.lastUpdate.getTime() > 30000) {
      getWeek(function(assignments) {<commit_msg>made the easter egg happen on keyup so that you don't have to type a space after snake for it to work<commit_after>/* 
  Event Handlers
*/
$('document').ready(function() {

  /*
    Planbook initialization
  */
  $.ajax({
    type: "GET",
    url: "/settings?json=true", 
    data: {
      'settings': ref.settings
    },
    statusCode: { 
      500: function() {
        alert("There's been a server error. Contact NLTL for assistance.");
      }
    },
    success: function(data) {
      $('li#username').children('a').text(data.name);
      ref.settings = data.settings;

      if (typeof(ref.settings.rows[0]) != "object") { // if it's the old settings format
        for (var i = 0; i < ref.settings.rows.length; i++)
          ref.settings.rows[i] = [ref.settings.rows[i], i+1];
        setSettings(ref.settings, function() {});
      }
      renderRows(ref.settings.rows);
    }
  });


  /* 
    Navigation Buttons
  */
  $('#save').click(function() {
    saveWeek(getAssignmentValues());
  });
  $('#back').click(function() {

    if (!ref.turnInProgress) {
      ref.turnInProgress = true;
      // animation
      saveWeek(getAssignmentValues()); // save the current state
      ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() - 7); // decrement by 1 week
      getWeek(function(o) {
        $('#sidebar').slide($(window).width(), 200);
        $("#planner").slide($(window).width(), 200, function() {
          setAssignmentValues(o);
          ref.turnInProgress = false;
        });
      });
    }
  });
  $('#next').click(function() {
    if (!ref.turnInProgress) {
      ref.turnInProgress = true;
      saveWeek(getAssignmentValues());
      ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() + 7);

      getWeek(function(o) {
        $('#sidebar').slide(-$(window).width(), 200);
        $("#planner").slide(-$(window).width(), 200, function() {
          setAssignmentValues(o);
          ref.turnInProgress = false;
        });
      });
    }
  });

  $(document).bind('keydown', 'meta+s', function(e) {
    e.preventDefault();
    saveWeek(getAssignmentValues());
  });

  $(document).bind('keydown', 'meta+right', function(e) {
    e.preventDefault();
    $('#next').click();
  });
  $(document).bind('keydown', 'meta+left', function(e) {
    e.preventDefault();
    $('#back').click();
  });

  // Mobile navigation buttons
  $('#msave').click(function() {
    saveWeek(getAssignmentValues());
  });
  $('#mback').click(function() {
    // animation
    saveWeek(getAssignmentValues()); // save the current state
    ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() - 7); // decrement by 1 week
    getWeek(setAssignmentValues);
    drawDates()  
  });
  $('#mnext').click(function() {
    saveWeek(getAssignmentValues());
    ref.monday = new Date(ref.monday.getFullYear(), ref.monday.getMonth(), ref.monday.getDate() + 7);
    getWeek(setAssignmentValues);
    drawDates();
  });
  $('#mdays').change(function() {
    $('#' + ref.visibleDay).hide();
    $('#' + $("select option:selected").text()).show();
    ref.visibleDay = $( "select option:selected" ).text();
  });

  // add subject
  $('button#add').click(function() {
    // save
    var id = 0;
    for (var i = 0; i < ref.settings.rows.length; i++) {
      if (ref.settings.rows[i][1] >= id) {
        id = parseInt(ref.settings.rows[i][1])+1
      }
    }
    ref.settings.rows.push(["Class", id]);
    setSettings(ref.settings, function(data) {
      renderRows(ref.settings.rows);
      $('.subj#'+id).children('.subjectspan').trigger('dblclick');
    });
  });
  taListen();
  subjectListen();
});

function taListen() {
  $("textarea").unbind();
  $("textarea").bind('keydown', 'meta+s', function(e) {
    e.preventDefault();
    saveWeek(getAssignmentValues());
  });
  /*
    Keypress listener, for parsing and using inputs to different textareas.
    Will get quite large as features such as lab requests are added.
  */
  $("textarea").blur(function() {
    saveWeek(getAssignmentValues());
  });

  $("textarea").keyup(function(e) {
    if ($(this).val().indexOf('snake') >= 0) {
      $('#snakebtn').show();
    }
  });

  $("textarea").keydown(function(e) {
    // If it's been more than 30 seconds since you've updated from this device
    var taID = this.id;
    if (new Date().getTime() - ref.lastUpdate.getTime() > 30000) {
      getWeek(function(assignments) {
{'fraction_non_alphanumeric': 0.19981937231880786, 'fraction_numerical': 0.0083540302551366, 'mean_word_length': 2.9690860215053765, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '5412060', 'n_tokens_mistral': 2882, 'n_tokens_neox': 2833, 'n_words': 524}