An Incredible Javascript Event Calendar

User Guide

»  Table Of Contents

Special Events

Section 3.4.0

You may have events that reoccur every week. You may also have holiday events that don't fall on a specific date, like Easter or Thanksgiving. For these events, you would want to use the special event file, the spspcevt.js

The spspcevt.js is a javascript function that gets called when a date is rendered in the calendar. This gives you a chance to programmaticly add events as the calendar renders. You can harness the full power of javascript to create reoccuring or holiday events.

To write code to insert an event, you are going to need to know which date is being rendered. The main calendar engine passes in the date as each date is rendered. The function then constructs several local variables to assist you writing events. Those variables are below.

variable type description
y number the 4-digit year (ex. 2006)
m number the month (1=jan, 2=feb,... 12=dec)
d number the day
dte date the specific javascript date variable
intWeekday number day of the week (0=sun; 1=mon; 2=tue, ..., 6=sat)
intWeekOfYear number week number of the year
intWeekOfMonth number week number of month (1st Sunday, 2nd Sunday, ...)
blnLast boolean is this the last weekday of the month?
dteEaster date javascript date variable for Easter of the year
dteMardiGras date javascript date variable for Mardi Gras of the year
dteAshWednesday date javascript date variable for Ash Wednesday of the year
dteGoodFriday date javascript date variable for Good Friday of the year

Now that you have the information on what date is being rendered, you can construct events. Below is an example of a single event being rendered in a single date. Normally, you would do a simple event like this in the scevent.js, so this is illustrative only. More complex examples will follow.

// event on 1/1/2010
if (m==1 && d==1 && y==2010 ) {
    objEvent = new EventObj(m,d,y, "jan 1st 2010");
    arrEvents[arrEvents.length] = objEvent;

When adding events with the scSpcEvt.js file, the parameters for the "EventObj" are exactly the same as those used in a scEvent.js "fscEvent" call. There is just a difference in making the call itself.

»  Table Of Contents