(function(window,document,exportName,undefined){function DayYearCalendar(){this.daysOfTheWeek=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];this.months=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"];this.date=new Date;this.dateSquares={};this.thresholds={low:0,med:3,high:6,"very-high":9}}DayYearCalendar.prototype={renderHTML:function($container){var $html=$('
S
M
T
W
T
F
S
');$container.append($html);this.setup();$(".day-year-cal-holder .square").mouseover(function(){$(".day-year-cal-holder .info").html($(this).data("date"))})},setup:function(){var todayDayOfWeek=this.daysOfTheWeek[this.date.getDay()];$(".day-year-cal-holder div#"+todayDayOfWeek).children().last().addClass("today");var otherDays=this.daysOfTheWeek.slice(this.date.getDay()+1);for(var i=0;i=365){div.css({"background-color":"white"})}if(daysDate.getDate()==1){var month=this.months[daysDate.getMonth()];$($(".day-year-cal-holder #MonthLabelHolder").children().get(div.index())).html(month)}}},getDivForDaysAgo:function(daysAgo){var dayOfWeekIndex=(this.date.getDay()-daysAgo)%7;if(dayOfWeekIndex<0){dayOfWeekIndex+=7}var dayOfWeek=this.daysOfTheWeek[dayOfWeekIndex];if(daysAgo<=this.date.getDay()){dayOfWeek=this.daysOfTheWeek[this.date.getDay()-daysAgo]}var weeksAgo=0;if(daysAgo>=this.date.getDay()){weeksAgo=Math.floor((daysAgo-(this.date.getDay()+1))/7)+1}console.log(daysAgo+" : "+dayOfWeek+", weeks ago: "+weeksAgo);var remainder=daysAgo%7;var children=$(".day-year-cal-holder #"+dayOfWeek).children();var day=$(children[children.length-1-weeksAgo]);return day},addColorData:function(data){for(var i=0;ithis.thresholds.low){newClass="low"}if(value>this.thresholds.med){newClass="med"}if(value>this.thresholds.high){newClass="high"}if(value>this.thresholds["very-high"]){newClass="very-high"}$(this.dateSquares[data[i].date.getTime()]).addClass(newClass)}}};if(typeof define=="function"&&define.amd){define(function(){return DayYearCalendar})}else if(typeof module!="undefined"&&module.exports){module.exports=DayYearCalendar}else{window[exportName]=DayYearCalendar}})(window,document,"DayYearCalendar");