Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-23-2010, 01:30 AM
Member
 
Posts: 11
Default zimlet developing

hay,
i have developed a zimlet which desplay calendar... but it shows more than 31 days per month and the next , prev buttons not working.. can some one check the error with this code..???

Code:
com_zimbra_calendar.prototype._displayDialog = 
function() {
	if (this._dialog) { //if zimlet dialog already exists...
		this._dialog.popup(); // simply popup the dialog
		return;
	}
		
	var view = new DwtComposite(this.getShell()); // creates an empty div as a child of main shell div
	view.setSize("600", "500"); // set width and height
	view.getHtmlElement().style.overflow = "auto"; // adds scrollbar
	view.getHtmlElement().innerHTML = this._createCalendar();// insert my calendat view
	
	// pass the title and view information to create dialog box
	this._dialog = new ZmDialog( { title:"Holiday Calendar Generator", view:view, parent:this.getShell(), standardButtons:[DwtDialog.OK_BUTTON,DwtDialog.CANCEL_BUTTON] } );

	//show the dialog
	this._dialog.popup();
};
Code:
com_zimbra_calendar.prototype._createCalendar =
function(){

	var daycounter = 0;
//var i=0;
	calendarString = '';
	//var daycounter = 0;
	calendarString += '<table width="312" border="1" cellpadding="0" cellspacing="1">';
	calendarString += '<tr>';
	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" id=\"prevyr\" onMouseOver=\"document.PrevYr.src=\'images\/PrevYrOn40x40\.jpg\';\" onMouseOut=\"document.PrevYr.src=\'images\/PrevYrOff40x40\.jpg\';\" onClick=\"this._changedate()\"><img name=\"PrevYr\" src=\"images\/PrevYrOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Prev Yr\"\/><\/a><\/td>';
	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" id=\"prevmo\" onMouseOver=\"document.PrevMo.src=\'images\/PrevMoOn40x40\.jpg\';\" onMouseOut=\"document.PrevMo.src=\'images\/PrevMoOff40x40\.jpg\';\" onClick=\"this._changedate(\'prevmo\')\"><img name=\"PrevMo\" src=\"images\/PrevMoOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Prev Mo\"\/><\/a><\/td>';
	calendarString += '<td bgcolor=\"#C8C896\" align=\"center\" valign=\"center\" width=\"128\" height=\"40\" colspan=\"3\"><b>' + wordMonth[monthNum-1] + '&nbsp;&nbsp;' + yearNum + '<\/b><\/td>';
	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" id=\"nextyr\" onMouseOver=\"document.NextMo.src=\'images\/NextMoOn40x40\.jpg\';\" onMouseOut=\"document.NextMo.src=\'images\/NextMoOff40x40\.jpg\';\" onClick=\"this._changedate(\'nextmo\')\"><img name=\"NextMo\" src=\"images\/NextMoOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Next Mo\"\/><\/a><\/td>';
	calendarString += '<td align=\"center\" valign=\"center\" width=\"40\" height=\"40\"><a href=\"#\" id=\"nextmo\" onMouseOver=\"document.NextYr.src=\'images\/NextYrOn40x40\.jpg\';\" onMouseOut=\"document.NextYr.src=\'images\/NextYrOff40x40\.jpg\';\" onClick=\"this._changedate(\'nextyr\')\"><img name=\"NextYr\" src=\"images\/NextYrOff40x40\.jpg\" width=\"40\" height=\"40\" border=\"0\" alt=\"Next Yr\"\/><\/a><\/td>';
	calendarString += '<\/tr>';
	calendarString += '<tr>';
	calendarString += '<td bgcolor=\"#4A62FF\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Sun<\/td>';
	calendarString += '<td bgcolor=\"#4A62FF\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Mon<\/td>';
	calendarString += '<td bgcolor=\"#4A62FF\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Tue<\/td>';
	calendarString += '<td bgcolor=\"#4A62FF\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Wed<\/td>';
	calendarString += '<td bgcolor=\"#4A62FF\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Thu<\/td>';
	calendarString += '<td bgcolor=\"#4A62FF\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Fri<\/td>';
	calendarString += '<td bgcolor=\"#4A62FF\" align=\"center\" valign=\"center\" width=\"40\" height=\"22\">Sat<\/td>';
	calendarString += '<\/tr>';
	//calendarString +=	this.month;

	if(thisDate == 1){

	for (var i = 1; i <= 6; i++) {
		calendarString += '<tr>';
		for (var x = 1; x <= 7; x++) {
			daycounter = (thisDate - firstDay)+1;
			thisDate++;
			if ((daycounter > numbDays) || (daycounter < 1)) {
				calendarString += '<td align=\"center\" bgcolor=\"#888888\" height=\"30\" width=\"40\">&nbsp;<\/td>';
			} else {
				if (this.checkevents(daycounter,monthNum,yearNum,i,x) || ((todaysDay == x) && (todaysDate == daycounter) && (todaysMonth == monthNum))){
					if ((todaysDay == x) && (todaysDate == daycounter) && (todaysMonth == monthNum)) {
						calendarString += '<td align=\"center\" bgcolor=\"#FFF8C6\" height=\"30\" width=\"40\"><a href=\"javascript:this.showevents(' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ')\" onClick=reset>'  + daycounter + '<\/a><\/td>';
					}
 					else	calendarString += '<td align=\"center\" bgcolor=\"#FAAFBE\" height=\"30\" width=\"40\"><a href=\"javascript:this.showevents(' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ')\" onClick=reset>'  + daycounter + '<\/a><\/td>';
				} else {
					calendarString += '<td align=\"center\" bgcolor=\"#DDFFFF\" height=\"30\" width=\"40\"><a href=\"javascript:this.showevents(' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ')\" onClick=reset>'  + daycounter + '<\/a><\/td>';
				}
			}
		}
	
		calendarString += '<\/tr>';
	}
}	
return calendarString;
	thisDate = 1;
	
};
the next prev buttons run with this code... but when the click happen this function not going to execute..
Code:
com_zimbra_calendar.prototype._changedate=
function(buttonpressed) {

	var butn=buttonpressed;
	
if (prevYr) yearNum--;
	else if (butn == "nextyr") yearNum++;
	else if (butn == "prevmo") monthNum--;
	else if (butn == "nextmo") monthNum++;
	else  if (butn == "return") { 
		monthNum = todaysMonth;
		yearNum = todaysYear;
	}

	if (monthNum == 0) {
		monthNum = 12;
		yearNum--;
	}
	else if (monthNum == 13) {
		monthNum = 1;
		yearNum++
	}

	lastDate = new Date(String(monthNum+1)+"/0/"+String(yearNum));
	numbDays = lastDate.getDate();
	firstDate = new Date(String(monthNum)+"/1/"+String(yearNum));
	firstDay = firstDate.getDay() + 1;
	this._createCalendar();
	return;
};
can some one please tell me why this is not going to work with click happend...

thank...
Reply With Quote
  #2 (permalink)  
Old 12-23-2010, 01:39 AM
Member
 
Posts: 11
Default

I mistakenly publish the code in _changedate function:
Quote:
if (prevYr) yearNum--;
should be

if (butn=="prevyr") yearNum--;
and
in the second code fragment
Quote:
onClick=\"this._changedate()\" in the 10th line should be onClick=\"this._changedate(\'prevyr\')\"
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.