<commit_before>onLoad(function() {  
  // Grabs the server time to use as a timestamp. More comments on server-side.
  $.getJSON("tickets/get_sys_time", function(json) {
    window.sysTime = json.time; // Attach the timestamp to the window object to make it globally accessible
  });       
        
  // Allows the user to try to get the client.
  $(".addTicket").click(function(caller) {
    $.getJSON("tickets/getClient.json?clientID=" + caller.target.id, function(json) {
      if (json.Success != null) { // if successful
        $('#' + caller.target.id).addClass("autoHide").hide();
        selector =  $('#' + json.ticketPriority + "PriorityCount");        
        updateCounters(selector);
        $("#userMessage").hide().html(json.Success).fadeIn(1000);
      }
      else
        $("#userMessage").hide().html(json.userMessage).fadeIn(1000);
    });
  });

  $(window).scroll(function(e) {
    var scroller_anchor;
    scroller_anchor = $(".scroller_anchor").offset().top;
    if ($(this).scrollTop() >= scroller_anchor - 50 && $(".scroller").css("position") !== "fixed") {
      $(".scroller").css({
        position: "fixed",
        top: "50px"
      });
      $(".scroller_anchor").css({
        height: $(".scroller").css("height")
      });
    } else if ($(this).scrollTop() < scroller_anchor - 50 && $(".scroller").css("position") !== "relative") {
      $(".scroller_anchor").css({
        height: 0
      });
      $(".scroller").css({  
        position: "relative",
        top: 0
      });
    }
  });
  
  function updateClients() {
    $.getJSON("tickets/updates?&timestamp=" + window.sysTime, function(json) {
      var i, len = json.length - 1; // compensating for system time appended to the end of JSON object
      for (i = 0; i < len; i++) {      	
        if (json[i].user_id == 0 || json[i].user_id == null)
             updateClient(json[i], "show");
        else updateClient(json[i], "hide");
      }
      window.sysTime = json[i]; // Update the timestamp to send to the server
      console.log("Updated at " + window.sysTime);
    });
    setTimeout(updateClients, 2000);
  }  
  
  function updateClient(c, action) {
  	if (action == 'show') {
  	  $('#' + c.id).show();
      $('#' + c.id).removeClass("autoHide");
      $('#' + c.id + '_span').html("");
     }
  	else {
      $('#' + c.id).hide();
      $('#' + c.id).addClass("autoHide");
      $('#' + c.id + '_span').html(c.first_name + " " + c.last_name+ "<br />(" + c.school_id + ")");
  	}  	
  }
  
  
  function updateCounters(selector) {
    highSelector   = $('#highPriorityCount');
    mediumSelector = $('#mediumPriorityCount');
    lowSelector    = $('#lowPriorityCount');
    
    if (selector.html() > 0)
      mm(selector);      
      
    // Check for the existence of totalLeft  
    if (typeof $('#clientsRemaining') !== 'undefined') { 
      var totalLeft  = parseInt($('#clientsRemaining').html());
      
      // Update the total counter 
      if (totalLeft > 0) {
        $('#clientsRemaining').html(totalLeft - 1);
        totalLeft--;        
      }
      
      // Check all the counters to make sure they are not greater than the total
      if (parseInt(highSelector.html()) > totalLeft){
        highSelector.html(totalLeft);
      }
      if (mediumSelector.html() > totalLeft)
        mediumSelector.html(totalLeft);
      if (lowSelector.html() > totalLeft)
        lowSelector.html(totalLeft);
    }        
  }
    
  // This function is similar to a -- on a variable except it accepts the element that has a number in it
  function mm(selector) {selector.html(selector.html() - 1);}

  // Recursive function that pings the server to check for updates
  setTimeout(updateClients, 1000);  
  
  // Initialized the datatable with the bootstrap tooltip feature added
  var table =  $('.ticket_table').dataTable({
        "aoColumns" : [{"sWidth": "12%"}, {"sType": "priority", "sWidth": "8%" }, { "sWidth": "26%" }, {"sWidth": "26%"}, {"sWidth": "18%"}, {"sWidth": "10%"}],
        "bPaginate" : false,
        "iCookieDuration": 60,
        "bStateSave": false,
        "bAutoWidth": false,
        "bProcessing": true,
        "bRetrieve": true,
        "bJQueryUI": true,
        "fnPreDrawCallback": $(".autoHide").hide()
         }, 
         $(".defaultTooltip").tooltip({
        'selector': '',
        'placement': 'left',
        'container': 'body'
    }));
<commit_msg>tickets index now does not ping if teacher assigns clients<commit_after>//*********************************************************************************************************************/
// Tickets.js - Everything must be wrapped in the onLoad function to handle Turbolinks
//*********************************************************************************************************************/

onLoad(function() {  
	
  // Initializes the page for pinging the server and grabs the server time to use as a timestamp. More comments on server-side.
  $.getJSON("tickets/get_sys_time", function(json) {
    window.sysTime = json.time; // Attach the timestamp to the window object to make it globally accessible
    
    if (json.time != "assign") {
      
      $.getJSON('tickets/left', function(json) {
      	setCounters(json.Total, json.High, json.Medium, json.Low);
      });
      
      setTimeout(updateClients, 1000);      
    }
  });       
        
  // Allows the user to try to get the client.
  $(".addTicket").click(function(caller) {
    $.getJSON("tickets/getClient.json?clientID=" + caller.target.id, function(json) {
      if (json.Success != null) { // if successful
        $('#' + caller.target.id).addClass("autoHide").hide();
        selector =  $('#' + json.ticketPriority + "PriorityCount");        
        updateCounters(selector);
        $("#userMessage").hide().html(json.Success).fadeIn(1000);
      }
      else
        $("#userMessage").hide().html(json.userMessage).fadeIn(1000);
    });
  });

  $(window).scroll(function(e) {
    var scroller_anchor;
    scroller_anchor = $(".scroller_anchor").offset().top;
    if ($(this).scrollTop() >= scroller_anchor - 50 && $(".scroller").css("position") !== "fixed") {
      $(".scroller").css({
        position: "fixed",
        top: "50px"
      });
      $(".scroller_anchor").css({
        height: $(".scroller").css("height")
      });
    } else if ($(this).scrollTop() < scroller_anchor - 50 && $(".scroller").css("position") !== "relative") {
      $(".scroller_anchor").css({
        height: 0
      });
      $(".scroller").css({  
        position: "relative",
        top: 0
      });
    }
  });
  
  function updateClients() {
    $.getJSON("tickets/updates?&timestamp=" + window.sysTime, function(json) {
      var i, len = json.length - 1; // compensating for system time appended to the end of JSON object
      for (i = 0; i < len; i++) {      	
        if (json[i].user_id == 0 || json[i].user_id == null)
             updateClient(json[i], "show");
        else updateClient(json[i], "hide");
      }
      window.sysTime = json[i]; // Update the timestamp to send to the server
      console.log("Updated at " + window.sysTime);
    });
    setTimeout(updateClients, 2000);
  }  
  
  function updateClient(c, action) {
  	if (action == 'show') {
  	  $('#' + c.id).show();
      $('#' + c.id).removeClass("autoHide");
      $('#' + c.id + '_span').html("");
     }
  	else {
      $('#' + c.id).hide();
      $('#' + c.id).addClass("autoHide");
      $('#' + c.id + '_span').html(c.first_name + " " + c.last_name+ "<br />(" + c.school_id + ")");
  	}  	
  }
  
  function setCounters(total, high, medium, low) {
  	$('#clientsRemaining').html(total);
  	$('#highPriorityCount').html(high);
  	$('#mediumPriorityCount').html(medium);
  	$('#lowPriorityCount').html(low);
  }
  
  function updateCounters(selector) {
    highSelector   = $('#highPriorityCount');
    mediumSelector = $('#mediumPriorityCount');
    lowSelector    = $('#lowPriorityCount');
    
    if (selector.html() > 0)
      mm(selector);      
      
    // Check for the existence of totalLeft  
    if (typeof $('#clientsRemaining') !== 'undefined') { 
      var totalLeft  = parseInt($('#clientsRemaining').html());
      
      // Update the total counter 
      if (totalLeft > 0) {
        $('#clientsRemaining').html(totalLeft - 1);
        totalLeft--;        
      }
      
      // Check all the counters to make sure they are not greater than the total
      if (parseInt(highSelector.html()) > totalLeft){
        highSelector.html(totalLeft);
      }
      if (mediumSelector.html() > totalLeft)
        mediumSelector.html(totalLeft);
      if (lowSelector.html() > totalLeft)
        lowSelector.html(totalLeft);
    }        
  }
    
  // This function is similar to a -- on a variable except it accepts the element that has a number in it
  function mm(selector) {selector.html(selector.html() - 1);}

  // Recursive function that pings the server to check for updates
  //setTimeout(updateClients, 1000);

  
  // Initialized the datatable with the bootstrap tooltip feature added
  var table =  $('.ticket_table').dataTable({
        "aoColumns" : [{"sWidth": "12%"}, {"sType": "priority", "sWidth": "8%" }, { "sWidth": "26%" }, {"sWidth": "26%"}, {"sWidth": "18%"}, {"sWidth": "10%"}],
        "bPaginate" : false,
        "iCookieDuration": 60,
        "bStateSave": false,
        "bAutoWidth": false,
        "bProcessing": true,
        "bRetrieve": true,
        "bJQueryUI": true,
        "fnPreDrawCallback": $(".autoHide").hide()
         }, 
         $(".defaultTooltip").tooltip({
        'selector': '',
        'placement': 'left',
        'container': 'body'
    }));

{'fraction_non_alphanumeric': 0.19966979671860488, 'fraction_numerical': 0.00949334434010938, 'mean_word_length': 2.5869726128793484, 'pattern_counts': {'":': 28, '<': 9, '<?xml version=': 0, '>': 17, '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': '4929220', 'n_tokens_mistral': 2990, 'n_tokens_neox': 2912, 'n_words': 662}