Teacher Calendar

v2.0

by Turner

HTML

<!DOCTYPE html>
<html>

  <head>
    <title>Mr. Turner's Calendar</title>
    <link type="text/css" rel="stylesheet" href="stylesheet.css">
  </head>

  <body>
    <div id="loginPanel">
      <h3>Login to Submit Work</h3>
      <table id="loginTable">
      </table>
    </div>
    <div class="results"></div>

    <div id="selectCalendars">
      <h3>Select Calendars to Display</h3>
      <form action="">
        <input type="checkbox" name="class1" value="Trig">Trigonometry/Pre-Calculus
        <br>
        <input type="checkbox" name="class2" value="IM3">Integrated Mathematics 3
        <br>
        <input type="checkbox" name="class3" value="APCSA">AP Computer Science A
      </form>
    </div>
    
    <div id="tableHolder">
      <table id="calTable">
      </table>
    </div>


  </body>

</html>

CSS

#tableTitle{
  font-family:sans-serif;
  font-size:35pt;
}

#monthYear{
  font-family:sans-serif;
  font-size:20pt;
}

#daysOfWeek {
  font-family:sans-serif;
  font-size:15pt;
}

.hoverCell{
    border: solid #FF9900;
    font-weight: bold;
}

#tableHolder{
  display: table;
  width: 100%;
}

.cell{
  display: table-cell;
  width: 100px;
  height: 100px;
}

#calTable {
  text-align: center;
  background-color: #cceeff;
  border-collapse: collapse;
  border: 5px solid black;
}

td{
    border: 2px solid black;
    text-align: left;
    vertical-align: top;
    font-size: 25px;
}

#selectCalendars, #loginPanel {
  display: inline-block;
}

JavaScript

$(document).ready(function(){
  $('#selectCalendars').hide(0);
  $('#loginPanel').hide(0);
  var toDate = new Date();
  var firstDate = new Date(toDate.getFullYear(), toDate.getMonth(), 1);
  var lastDate = new Date(toDate.getFullYear(), toDate.getMonth()+1, 0);
  makeCal(toDate, firstDate, lastDate);
  $('.cell').hover(
  		function(){
  			$(this).addClass('hoverCell');
    	},
    	function(){
        $(this).removeClass('hoverCell');
    	}
    );
   $('.cell').click(
   		function(){
				$(this).animate({width: "100%", fontSize: "20pt"}, 500, function(){
      		$(this).animate({}, 500);
      	});
      });
});

function makeCal(focusDate, startDate, endDate){
    var startWeek = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()-(6-startDate.getDay()));
    var endWeek = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()+(6-startDate.getDay()));
    if (endDate.getDay() != 6){
    	endDate.setDate(endDate.getDate()+(6-endDate.getDay()));
    };
    
    $('#calTable').append("<thead><tr><th id='tableTitle' colspan='7'>Mr. Turner's Calendar</th></tr><tr id='monthYear'><th></th><th></th><th colspan='3'>" + month[startDate.getMonth()] + "  " + startDate.getFullYear() + "</th><th></th><th></th></tr><tr id='daysOfWeek'><th>SUN</th><th>MON</th><th>TUE</th><th>WED</th><th>THU</th><th>FRI</th><th>SAT</th></tr></thead>");
    do{
    	$('#calTable').append(makeWeek(startWeek, endWeek));
      startWeek.setDate(endWeek.getDate()+1);
      endWeek.setDate(endWeek.getDate()+7);
    } while(endWeek.getDate() != endDate.getDate());
$('#calTable').append(makeWeek(startWeek, endWeek));
}

function makeWeek(startDate, endDate){
	var week = "<tr class='row'>";
  for (var day = 0; day < 7; day++){	
    week += ("<td class='cell'>" + startDate.getDate() + "</td>");
    startDate.setDate(startDate.getDate()+1);
  }
  week += "</tr>";
  return week;
}

var month = new Array();
month[0] = "January";
month[1] =...