Teacher Calendar

v2.4

by Turner

HTML

<!DOCTYPE html>
<html>

  <head>
    <title>Mr. Turner's Calendar</title>
    <link type="text/css" rel="stylesheet" href="stylesheet.css">
    <script language="JavaScript">
<!--
function resize_iframe()
{

	var height=window.innerWidth;//Firefox
	if (document.body.clientHeight)
	{
		height=document.body.clientHeight;//IE
	}
	//resize the iframe according to the size of the
	//window (all these should be on the same line)
	document.getElementById("glu").style.height=parseInt(height-
	document.getElementById("glu").offsetTop-8)+"px";
}

// this will resize the iframe every
// time you change the size of the window.
window.onresize=resize_iframe; 

//Instead of using this you can use: 
//	<BODY onresize="resize_iframe()">


//-->
</script>
  </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%;
}

.otherMonth{
  background-color: #b3b3cc;
}

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

#today{
  color: #00ff00;
  font-weight: bold;
}

#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');
    	}
    );
});

function makeCal(focusDate, startDate, endDate){
    
    if (startDate.getDay() != 0){
      startDate.setDate(startDate.getDate() - startDate.getDay(0))
    };
    if (endDate.getDay() != 6){
    	endDate.setDate(endDate.getDate()+(6-endDate.getDay()));
    };
    var startWeek = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
    var endWeek = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()+(6-startDate.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, focusDate.getMonth(), focusDate));
      startWeek.setDate(endWeek.getDate()+1);
      endWeek.setDate(endWeek.getDate()+7);
    } while(endWeek.getDate() != endDate.getDate());
$('#calTable').append(makeWeek(startWeek, endWeek));
}

function makeWeek(startDate, endDate, thisMonth, today){
	var week = "<tr class='row'>";
  while (startDate.getTime() <= endDate.getTime()){
  	if (startDate.getMonth() != thisMonth){
    	week += ("<td class='cell otherMonth'>" + startDate.getDate() + "</td>");
    }
    else if(startDate == today){
    	week += ("<td class='cell' id='today'>" + startDate.getDate() + "</td>");
 ...