Monday, March 12, 2012

jQuery Efficiency

Over the summer I started working on a data table project, and in the end got it working entirely. But the code was bulky. Over the past 6 months I've learned a lot more about jQuery though, and so have been going back to old code and trying to rewrite it.

This particular code controls the hiding and showing of rows depending on what checkboxes a user clicks. About a month go I changed part of the code and reduced it's original 35KB down to 7KB. Now though I've gotten the rest updated, and it's 1.5KB. It's also much more flexible, because it can handle changes in the data without needing changes itself.

So just to show off, I present here the original, and the newest version.

New
Original

$(document).ready(function() {

  var course;

  $(":checkbox").click(function(event){

    course = "." + $(this).attr("id");

    if ( $(this).prop("checked") ) {

      $(course).css("display", "block");

      $(':checkbox:not(:checked)').each(function(){ $('div.'+ $(this).attr("id")).hide(); });

    }

    else {
      $(course).css("display", "none");

    }

  });

  $(':checkbox:not(:checked)').each(function(){ $('div.'+ $(this).attr("id")).hide(); });

});
$(document).ready(function()

{

  if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
  if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
  if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
  if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

  if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
  if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
  if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
  if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
  if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
  if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
  if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
  if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
  if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
  if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

  if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
  if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
  if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
  if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
  if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
  if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
  if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

  $("#sem_spring2009").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".aspring2009").css("display", "block");

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".aspring2009").css("display", "none");

    }

  });

  $("#sem_fall2010").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".bfall2010").css("display", "block");

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".bfall2010").css("display", "none");

    }

  });

  $("#sem_spring2011").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".cspring2011").css("display", "block");

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".cspring2011").css("display", "none");

    }

  });

  $("#sem_fall2011").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".dfall2011").css("display", "block");

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".dfall2011").css("display", "none");

    }

  });

/*************************************************************************************************/

/************************************* The class checkboxes **************************************/

/*************************************************************************************************/

  $("#class_CE331").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE331").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE331").css("display", "none");

    }

  });

  $("#class_MA266").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".MA266").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".MA266").css("display", "none");

    }

  });

  $("#class_CE203").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE203").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE203").css("display", "none");

    }

  });

  $("#class_CE340").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE340").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE340").css("display", "none");

    }

  });

  $("#class_CGT164").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CGT164").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CGT164").css("display", "none");

    }

  });

  $("#class_CE343").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE343").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE343").css("display", "none");

    }

  });

  $("#class_CE361").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE361").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE361").css("display", "none");

    }

  });

  $("#class_CE398").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE398").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE398").css("display", "none");

    }

  });

  $("#class_CE399").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE399").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE399").css("display", "none");

    }

  });

  $("#class_CE383").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".CE383").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#type_spreadsheet").prop("checked")) )  {$(".spreadsheet").css("display", "none");}
      if ( !($("#type_worddoc").prop("checked")) )      {$(".worddoc").css("display", "none");}
      if ( !($("#type_presentation").prop("checked")) ) {$(".presentation").css("display", "none");}
      if ( !($("#type_photoshop").prop("checked")) )    {$(".photoshop").css("display", "none");}
      if ( !($("#type_image").prop("checked")) )        {$(".image").css("display", "none");}
      if ( !($("#type_adobedoc").prop("checked")) )     {$(".adobedoc").css("display", "none");}
      if ( !($("#type_autocad").prop("checked")) )      {$(".autocad").css("display", "none");}

    }

    else {

      $(".CE383").css("display", "none");

    }

  });

/*************************************************************************************************/

/************************************ The file type checkboxes ***********************************/

/*************************************************************************************************/

  $("#type_spreadsheet").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".spreadsheet").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

    }

    else {

      $(".spreadsheet").css("display", "none");

    }

  });

  $("#type_worddoc").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".worddoc").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

    }

    else {

      $(".worddoc").css("display", "none");

    }

  });

  $("#type_presentation").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".presentation").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

    }

    else {

      $(".presentation").css("display", "none");

    }

  });

  $("#type_photoshop").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".photoshop").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

    }

    else {

      $(".photoshop").css("display", "none");

    }

  });

  $("#type_image").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".image").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}
    }

    else {

      $(".image").css("display", "none");

    }

  });

  $("#type_adobedoc").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".adobedoc").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

    }

    else {

      $(".adobedoc").css("display", "none");

    }

  });

  $("#type_autocad").click(function(event){

    if ( $(this).prop("checked") ) {

      $(".autocad").css("display", "block");

      if ( !($("#sem_spring2009").prop("checked")) ) {$(".aspring2009").css("display", "none");}
      if ( !($("#sem_fall2010").prop("checked")) )   {$(".bfall2010").css("display", "none");}
      if ( !($("#sem_spring2011").prop("checked")) ) {$(".cspring2011").css("display", "none");}
      if ( !($("#sem_fall2011").prop("checked")) )   {$(".dfall2011").css("display", "none");}

      if ( !($("#class_CE331").prop("checked")) )  {$(".CE331").css("display", "none");}
      if ( !($("#class_MA266").prop("checked")) )  {$(".MA266").css("display", "none");}
      if ( !($("#class_CE203").prop("checked")) )  {$(".CE203").css("display", "none");}
      if ( !($("#class_CE340").prop("checked")) )  {$(".CE340").css("display", "none");}
      if ( !($("#class_CGT164").prop("checked")) ) {$(".CGT164").css("display", "none");}
      if ( !($("#class_CE343").prop("checked")) )  {$(".CE343").css("display", "none");}
      if ( !($("#class_CE361").prop("checked")) )  {$(".CE361").css("display", "none");}
      if ( !($("#class_CE398").prop("checked")) )  {$(".CE398").css("display", "none");}
      if ( !($("#class_CE399").prop("checked")) )  {$(".CE399").css("display", "none");}
      if ( !($("#class_CE383").prop("checked")) )  {$(".CE383").css("display", "none");}

    }

    else {

      $(".autocad").css("display", "none");

    }

  });

});

The way that this was achieved is in two ways. The first is by making everything not dependent on clicking certain checkboxes. Instead of saying, when the user clicks checkbox A, hide row A, I say when the user clicks any checkbox, check the name of that checkbox, and hide that row. Then only one statement is needed instead of one for every checkbox.

Additionally, there is a line that hides all rows who's checkboxes aren't checked. This is useful if the user refreshes the page. But originally it was an if/then statement for every single checkbox, and now is a single line. I had to get help for that one, but the results are beautiful.

Thoughts? Comments? Could it be even BETTER? Let me know in the comments.
 

Tuesday, March 6, 2012

Dancing Violin

A friend shared this on Facebook, and I'm digging it. This lady can not only play great violin, but can dance while doing it. (She also does Cosplay in one of her videos O.O) Check it out!


 

Weekend Roadtrip

Last weekend I went down to Bloomington, IN, for a road trip. I have a friend who goes to IU, we stayed at her apartment.

We left Purdue Friday afternoon, and picked up one person from Indy on the way down. Got to IU in the evening, then went out to the bars until pretty late.

On Saturday, we explored the town and campus, including getting up on the roof of the tallest tower of the student union. And unlike Purdue's student union, this tower wasn't 3 stories tall, it was 9. We ended Saturday by going bowling. Pictures below!










 

Thursday, March 1, 2012

And Life Goes On

I had a strange afternoon yesterday, with nothing to do. I'd had a geotech exam in class, which canceled my geotech homework for this week. In Surveying, I was assigned a paper this week, which canceled any regular homework that that that. Bowling never has homework, and I'd just turned on the every-two-weeks homework for Construction. So, nothing to do.

Plus it was super warm out, but my bicycle still isn't working. Sort of like the world was teasing me with warm weather I couldn't use.

I ended up sitting down with a good (well, decent) book, and relaxed for the rest of the afternoon, before coming home and fiddling with Mass Effect, trying to get it working on my computer. It did work for a bit, but then overheated my computer. On the lowest settings.

It's okay though, because I'm tomorrow I'm gettin' out of this town. Going on a weekend vacation down to Bloomington, IN, to see some friends. In 4 years of college, this is the first weekend road trip I've ever taken, so I'm looking forward to it.
 

Wednesday, February 29, 2012

Hello Out There

When I started this blog, I figured that the cloak of anonymity would hide me pretty well. How many people are going to look at it, even on the internet. And for the first several years it was true, I'd average 20 or 30 hits a month, probably half of them being me.

Over the past year though, the numbers have been going up. In fact this month I almost doubled the past highest, from 417 to just over 700. While still nothing huge, this is far beyond me or my friends, so some of you out there must be people I don't know. It's to you that I send this greeting! Thank you for stopping by and spending some of your time here with me. I hope that what I post entertains or educates you.
 

Tuesday, February 28, 2012

Michigan Primary

With 65% of the vote in, Romney is leading Santorum 40% to 36%, which makes me breath a sigh of relief. As the results started coming in, Santorum seemed to be winning for the first hour, but things turned around as the urban counties started reporting in more heavily.

It's bad news for Obama, who'd love to face off against Santorum. Santorum who has said that the separation of church and state makes him want to throw up, that the idea of everyone going to college is elitist snobbery, and that Satan is attacking the US.

Romney though, is not really all that different from Obama, so he'll have a better change with independents. I still am predicting an Obama win though, even against Romney. That's for next fall however. For now, onward to Super Tuesday!
 

Monday, February 27, 2012

Saving Energy

It would be much easier to get people to save energy if things like this were more common.