From 17c808dc4fa98bb36592650d7912fd1491e70ad8 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 17 Sep 2007 22:24:54 -0700 Subject: [PATCH] searching and moving the calendar work --- chrome/content/calendar.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/chrome/content/calendar.js b/chrome/content/calendar.js index 664ba83..d318f28 100644 --- a/chrome/content/calendar.js +++ b/chrome/content/calendar.js @@ -22,6 +22,9 @@ function daysOf(year, month) { function Calendar(container) { var self=this; + self.year = new Date().getFullYear(); // default to current year + self.month = new Date().getMonth(); // default to current month + container.className = 'calendar'; var table = document.createElement('table'); @@ -93,43 +96,39 @@ function Calendar(container) { db.clear(); } - this.finish = function(year, month) { + this.finish = function() { container.removeChild(table); table = document.createElement('table'); container.appendChild(table); - var year = year || new Date().getFullYear(); // default to current year - var month = month || new Date().getMonth(); // default to current month - var days = daysOf(year, month); + var days = daysOf(self.year, self.month); - table.innerHTML = "" + (month+1) + ' / ' + year + '' + + table.innerHTML = "" + (self.month+1) + ' / ' + self.year + '' + "SUNMONTUEWEDTHURFRISAT"; var left = document.getElementById('nav_left'); left.onclick = function() { - var new_month = month - 1; - var new_year = year; - if (new_month < 0) { - new_month = 11; - new_year = year - 1; + self.month--; + if (self.month < 0) { + self.month = 11; + self.year--; } - self.finish(new_year, new_month); + self.finish(); } var right = document.getElementById('nav_right'); right.onclick = function() { - var new_month = month + 1; - var new_year = year; - if (new_month > 11) { - new_month = 0; - new_year = year + 1; + self.month++; + if (self.month > 11) { + self.month = 0; + self.year++; } - self.finish(new_year, new_month); + self.finish(); } var tr = null; for (var date=1; date<=days; date++) { - var curDate = new Date(year, month, date); + var curDate = new Date(self.year, self.month, date); if (!tr) { tr = document.createElement('tr'); @@ -143,7 +142,7 @@ function Calendar(container) { var td = document.createElement('td'); - addTabsToTD(year, month, date, td); + addTabsToTD(self.year, self.month, date, td); tr.appendChild(td); if (curDate.getDay() == 6) { -- 2.11.4.GIT