Advertisement

Found bug?

Moderators: Calcifer, slothy

Found bug?

Postby kai » Wed May 31, 2006 5:02 pm

Hi,

maybe i found a bug in your calendar script. The weekday of 01.06.2006 is wrong. It should be Thursday and not Saturday. I've checked the script and changed the first lines of the function "writeCalendarContent()". The changes are listed below. Anyway a nice script.

Thank you and greetings from Germany

Kai Gaberle




function writeCalendarContent()
{
var calendarContentDivExists = true;
if(!calendarContentDiv){
calendarContentDiv = document.createElement('DIV');
calendarDiv.appendChild(calendarContentDiv);
calendarContentDivExists = false;
}

// ********* BEGIN CHANGES ********

var lastMonth;
var lastMonthYear;

if(currentMonth == 0) {
lastMonth = 11;
lastMonthYear = currentYear -1;
}
else {
lastMonth = currentMonth -1;
lastMonthYear = currentYear;
}

var d = new Date();
d.setFullYear(lastMonthYear, lastMonth, daysInMonthArray[lastMonth]);

// ********* END CHANGES ********


document.getElementById('calendar_year_txt').innerHTML = currentYear;
document.getElementById('calendar_month_txt').innerHTML = monthArray[currentMonth];

var existingTable = calendarContentDiv.getElementsByTagName('TABLE');
if(existingTable.length>0){
calendarContentDiv.removeChild(existingTable[0]);
}

var calTable = document.createElement('TABLE');
calTable.cellSpacing = '0';
calendarContentDiv.appendChild(calTable);
var calTBody = document.createElement('TBODY');
calTable.appendChild(calTBody);
var row = calTBody.insertRow(-1);
var cell = row.insertCell(-1);
cell.innerHTML = weekString;
cell.style.backgroundColor = selectBoxRolloverBgColor;

for(var no=0;no<dayArray.length;no++){
var cell = row.insertCell(-1);
cell.innerHTML = dayArray[no];
}

var row = calTBody.insertRow(-1);
var cell = row.insertCell(-1);
cell.style.backgroundColor = selectBoxRolloverBgColor;
var week = getWeek(currentYear,currentMonth,1);
cell.innerHTML = week; // Week
for(var no=0;no<d.getDay();no++){
var cell = row.insertCell(-1);
cell.innerHTML = '&nbsp;';
}

var colCounter = d.getDay();
var daysInMonth = daysInMonthArray[currentMonth];
if(daysInMonth==28){
if(isLeapYear(currentYear))daysInMonth=29;
}

for(var no=1;no<=daysInMonth;no++){
d.setDate(no-1);
if(colCounter>0 && colCounter%7==0){
var row = calTBody.insertRow(-1);
var cell = row.insertCell(-1);
var week = getWeek(currentYear,currentMonth,no);
cell.innerHTML = week; // Week
cell.style.backgroundColor = selectBoxRolloverBgColor;
}
var cell = row.insertCell(-1);
if(currentYear==inputYear && currentMonth == inputMonth && no==inputDay){
cell.style.color = '#FF0000';
}
cell.innerHTML = no;
cell.onclick = pickDate;
colCounter++;
}


if(!document.all){
if(calendarContentDiv.offsetHeight)
document.getElementById('topBar').style.top = calendarContentDiv.offsetHeight + document.getElementById('topBar').offsetHeight -1 + 'px';
else{
document.getElementById('topBar').style.top = '';
document.getElementById('topBar').style.bottom = '0px';
}

}

if(iframeObj){
if(!calendarContentDivExists)setTimeout('resizeIframe()',350);else setTimeout('resizeIframe()',10);
}


}
kai
 
Posts: 1
Joined: Wed May 31, 2006 4:54 pm

Return to Calendar script questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron