|
|
|
User Guide
Table Of Contents
Standard Iframe Installation
The standard iframe installation is the recommended implementation of the calendar. The iframe allows you keep the code changes to your page limited to a single tag. It provides an excellent way to separate the calendar from your html.
The iframe installation of the calendar requires just 4 steps.
Step #1
The zip file of the software with the demo or full versions contains the following directory structure.
- sccomponents
- scimages
- scthemes
You must preserve this exact folder structure, both when extracting files from the zip and when you upload files to the webserver. To extract the folder structure from the zip, use the "extract" command rather than drag and drop. This will create the correct folder structure. When uploading files to the webserver, you must create the right folders and upload the appropiate files for that folder. FTP software makes it easy to transfer entire folder structures with appropiate files.
Your HTML page where you want the calendar to appear is the starting point. The folder where your HTML page resides will be called the root folder. You should upload the scriptcalendar folders into the same location as your HTML page.
Step #2
Your HTML page requires only the a single "iframe" tag to display the calendar. Simply place this tag in your HTML...
<!-- scriptcalendar iframe tag -->
<iframe id="scIFrame" name="[license key]" src="scthemes/standard/scrptcal.htm" scrolling="no" frameborder="0" width="800" height="700" ></iframe>
Step #3
You may change the "src" attribute of the iframe to point to the theme files of your choice. The "src" attribute of the "iframe" tag specifies what HTML will display within the "iframe". This is where you put the virtual path to the theme you want. The "scthemes" directory should be a subfolder of your root folder, so the virtual path should be the same. In the example relative path below, the standard theme is used.
/scthemes/standard/scrptcal.htm
Step #4
Cut and paste your license key(s) into the "name" attribute of the iframe tag. The "name" attribute of the "iframe" tag provides the license key for the software. The key attribute contains license key text. It may be a single key, for example name="abc". The attribute may multiple keys in a comma delimited string, for example name="abc,xyz". Without the the proper license key, the calendar will only show events in the first ten days of the month. The behavior is called the demo version. The addition of the proper license key to the demo version makes it the full version.
There will be more information on the the license key later in this guide.
Here is an example HTML page with the scriptcalendar iframe tag. You'll notice that other HTML elements can be before and after the calendar. This allows you to integrate the calendar within you page layout.
<html>
<head>
<title>my page</title>
</head>
<body>
<p>
This is text or HTML elements that preceed the calendar
</p>
<!-- scriptcalendar iframe tag -->
<iframe id="scIFrame" name="[license key]" src="scthemes/standard/scrptcal.htm"
scrolling="no" frameborder="0" width="800" height="700" ></iframe>
<p>
This is text or HTML elements that follow the calendar
</p>
</body>
</html>
You have now completed the standard iframe installation of the calendar.
No Iframe Installation
There may be a reason you do not wish to use the iframe installation. Instead, you may wish to render the calendar directly within your HTML page. This method merges the scriptcalendar code with your HTML, so you lose the separation achieved by the iframe. But, you gain the advantage of not having the iframe.
In the no iframe installation, you must merge the code typically seen in the scrptcal.htm file of your choosen theme into your HTML page. The following is an example HTML page showing that merge.
<html>
<head>
<title>my page</title>
</head>
<body>
<p>
This is text or HTML elements that preceed the calendar
</p>
<div id="scParent">
<!-- ********* ********* ********* ********* ********* -->
<!-- BEGIN SCRIPTCALENDAR CODE -->
<!-- ********* ********* ********* ********* ********* -->
<!-- JAVASCRIPT COMPONENTS -->
<!-- do not edit unless you have moved the component javascript files -->
<style type="text/css" media="screen"> <!-- @import "scthemes/outlook/scrptcal.css"; --></style>
<style type="text/css" media="print"> <!-- @import "scthemes/outlook/scprint.css"; --></style>
<script type="text/javascript" src="sccomponents/scrptcal.js"></script>
<script type="text/javascript" src="sccomponents/overlib.js"></script>
<script type="text/javascript" src="sccomponents/scevent.js"></script>
<script type="text/javascript" src="sccomponents/scspcevt.js"></script>
<script type="text/javascript" src="scthemes/outlook/schandlr.js"></script>
<!-- SCRIPTCALENDAR OBJECT -->
<!-- edit the properties as you see fit -->
<script type="text/javascript">
var objCal = new scriptcalendar();
objCal.license = new Array("[insert license key here]");
objCal.deadCellBehavior = 0; // dead date cell behavior
objCal.dateSelector = 1+2+4+8; // date selectors
objCal.prevHtml = "«"; // PREV month link text
objCal.nextHtml = "»"; // NEXT month link text
objCal.dateRangeStart = 2007; // start year range
objCal.dateRangeEnd = 2010; // end year range
objCal.cellWidth = 100; // width of date cell
objCal.cellHeight = 100; // height of date cells
objCal.padding = "2"; // table cellpadding
objCal.spacing = "1"; // table cellspacing
objCal.initialize();
</script>
<!-- ********* ********* ********* ********* ********* -->
<!-- END SCRIPTCALENDAR CODE -->
<!-- ********* ********* ********* ********* ********* -->
</div>
<p>
This is text or HTML elements that follow the calendar
</p>
</body>
</html>
You must still upload the contents of the scriptcalendar zip to your web server. Again, make sure you preserve the folder structure. Also, upload the folders to the same location as the HTML page where you want the calendar to appear. This location is the root folder.
Please note the css and javascript includes. These lines of code import the scriptcalendar engine, events, special events, css and more. Assuming you preserved the correct folder structure, the relative paths of these files should not need to change.
Next, the calendar is a javascript object. You create an instance of the scriptcalendar object, set the various properties, and call the initialize method.
Finally, note that the license key is implemented using the "license" property. You must place the proper license key here or the calendar will behave in demo mode.
The License Key
The license key is stored in the "name" attribute of "iframe" tag of your HTML page. Setting the value of the "name" attribute establishes your license key. The "name" attribute may contain a single license key in the form of a text string. Additionally, it may contain several license keys in the form of a comma delimited string. Please see the examples below.
Single license key example
<!-- scriptcalendar iframe tag -->
<iframe id="scIFrame" name="abc" src="scthemes/standard/scrptcal.htm" scrolling="no" frameborder="0" width="800" height="700" ></iframe>
Multiple license key example
<!-- scriptcalendar iframe tag -->
<iframe id="scIFrame" name="abc,def,xyz" src="scthemes/standard/scrptcal.htm" scrolling="no" frameborder="0" width="800" height="700" ></iframe>
It is important that the "id" attribute of the "iframe" tag is the value
"scIFrame". Don't change the value of the "id" attribute.
If no events beyond the 10th day of the month will appear your license key is mistyped or invalid. This behavior is known as demo mode. Please check your domain and your license key. To check your domain, open your HTML page with your browser and examine the URL in the Address bar. The domain portion of the URL starts after the "http://" and ends at the first forward slash "/".
Please note that it is possible for your browser to cache the HTML file. That means even if you edit the license key, the browser may continue to display events only up to the tenth. That is because the browser is using the cached version of the page without your edit. To clear the cache, use the browsers refresh button. So, every time you change the license key, make sure you use the refresh button on the browser.
The license key checking is done in javascript when the calendar loads. It is internal to the scriptcalendar engine. The license key check doesn't reference or make a call to this website or any other website.
The only difference between the demo version and the full version is the license key. Adding the correct license key to the demo version of the software instantly upgrades it to the full version. You will be granted a license key during the purchase process by this website. You can immediately insert the license key into the demo version and it becomes the full version. Therefore, you can test and develope the demo version and only when you are satisfied do you need to come back for the license key.
Scriptcalendar Files
This section describes the various folder and files that comprise the Scriptcalendar software.
The sccomponents directory is where the various javascript files for the scriptcalendar are kept. The javascript component files are...
| file |
required |
editable |
description |
| overlib.js |
required |
no |
Third party javascript library used for creating DIV tooltips |
| scedit.htm |
optional |
no |
The HTML event editor page. This is provided to help you create and maintain events in either format. |
| scevent.js |
optional |
yes |
The script containing your custom events. You may use XML event data instead. |
| scevent.xml |
optional |
yes |
The xml data file containing the events. You may use scevent.js file instead. |
| scevent.xsd |
optional |
no |
The xml schema describing the structure of the scevent.xml |
| schandlr.js |
required |
yes |
The script containing the onMouseOver handling functions. |
| scrptcal.js |
required |
NO |
The scriptcalendar engine that renders the calendar. |
| scrptcal.xsl |
optional |
yes |
The XSLT transform file used if you choose XML data events. |
| scspcevt.js |
required |
yes |
The script containing special, recurring or holiday events. |
The scimages directory is where the common graphics files for the demo and full versions
of the script calendar are stored. Graphics used exclusively by a theme are stored in the
theme directory. You will probably have a similiar folder on your website, and you'll probably
use those images in your calendar. Therefore, you can choose to omit this entire folder.
Just make sure that when placing your graphic file in an event that the virtual path is
correct.
The scthemes directory is where the various theme files for the scriptcalendar
are kept. The theme files are...
| file |
required |
editable |
description |
| schandlr.js |
required |
yes |
The script containing onMouseOver and onMouseOut handling functions. |
| scprint.css |
required |
yes |
The CSS file used for printing the calendar. |
| scrptcal.css |
required |
yes |
The CSS file used for displaying the calendar layout and colors. |
| scrptcal.htm |
required |
yes |
The file od the src attribute in the IFrame. This file includes the CSS file, the javascsript components and calls the calendar. |
There may also be various graphics files used by a theme stored in the theme folder.
Within the Theme folder, you'll find a "scrptcal.htm" file which is the source HTML for the
IFrame. Inside the scrptcal.htm file you are able to set the various object oriented
properties of the calendar. Those properites are covered in the configuration section.
Themes and the scrptcal.htm file
As you have seen in the installation instructions, the Scriptcalendar iframe loads the scrptcal.htm from one of the theme folders. The theme folder houses a unique theme. Themes are a set of calendar properties and css classes working in unison to present the calendar. In order to begin configuring the calendar, you must select a theme.
The scrptcal.htm file is the most important file of the theme. The calendar functions by placing the "/themes/(theme name)/scrptcal.htm" HTML within the in-line frame tag you place on your HTML page. This integrates the calendar within your page layout. The HTML for the scrptcal.htm performs several functions.
- Imports the "scrptcal.css" file, which is the CSS for the theme
- Imports the "scprint.css" file, which is the printing CSS for the theme
- Includes the "../../components/scrptcal.js" file containing the Scriptcalendar engine
- Includes the "../../components/overlib.js" file containing 3rd party software for tooltips
- Includes the "../../components/scevent.js" file containing the standard events
- Includes the "../../components/scspcevt.js" file containing the special events
- Includes the "schandlr.js" file containing the onMouseOver handling functions
- Creates an instance of the scriptcalendar object and stores the reference in the variable "objCal".
- Sets the various properties using the "objCal" variable.
- Renders the calendar by calling the "initialize" method of the "objCal" variable.
Below is an example of a typical scrptcal.htm file. Notice how it performs all of the described duties.
<!--
SCRIPTCALENDAR
An incredible javascript calendar
copyright 2005
http://www.scriptcalendar.com
-->
<html>
<head>
<title>http://www.scriptcalendar.com</title>
</head>
<body>
<!-- JAVASCRIPT COMPONENTS -->
<!-- do not edit unless you have moved the component javascript files -->
<style type="text/css" media="screen"> <!-- @import "scrptcal.css"; --></style>
<style type="text/css" media="print"> <!-- @import "scprint.css"; --></style>
<script type="text/javascript" src="../../sccomponents/scrptcal.js"></script>
<script type="text/javascript" src="../../sccomponents/overlib.js"></script>
<script type="text/javascript" src="../../sccomponents/scevent.js"></script>
<script type="text/javascript" src="../../sccomponents/scspcevt.js"></script>
<script type="text/javascript" src="schandlr.js"></script>
<!-- SCRIPTCALENDAR OBJECT -->
<!-- edit the properties as you see fit -->
<script type="text/javascript">
var objCal = new scriptcalendar();
objCal.deadCellBehavior = 0; // dead date cell
objCal.dateSelector = 1+2+4+8; // date selectors
objCal.prevHtml = "«"; // PREV month link text
objCal.nextHtml = "»"; // NEXT month link text
objCal.dateRangeStart = 2004; // start year range
objCal.dateRangeEnd = 2010; // end year range
objCal.cellWidth = 100; // width of date cell
objCal.cellHeight = 100; // height of date cells
objCal.padding = "0"; // table cellpadding
objCal.spacing = "2"; // table cellspacing
objCal.beginMonday = false; // begin week on Monday
objCal.displayWeekNumber = false; // display Week Number
objCal.showFutureEvents = true; // show future events
objCal.showPastEvents = true; // show future events
objCal.expandEventStyle = true; // allow event style to grow
objCal.enableHandlers = true; // add event handlers
objCal.initialize();
</script>
</body>
</html>
Calendar Properties
You've seen how the scrptcal.htm loads within the iframe. You know the scrptcal.htm is responsible for importing the javascript files and CSS files. But the scrptcal.htm also creates the scriptcalendar object.
The Scriptcalendar object is a javascript object. Basically, that means you can control the various settings of the calendar through properties. The properties exposed by the calendar are listed below.
| property |
description |
data type |
default value |
| beginMonday |
This boolean flag controls which day begins the weeks the calendar displays. Set this property to "true" to begin the week on Monday. Omit this property or set it "false" to begin the week with Sunday. Please note that you must also change the "longDays" property if you set this to "true" |
boolean |
FALSE |
| cellHeight |
This numeric property controls the height of the date cells within the calendar, and therefore the horizontal size of the entire calendar. If the event text is too large to fit in the cell, the text will be truncated. |
integer |
100 |
| cellWidth |
This numeric property controls the width of the date cells within the calendar, and therefore the vertical size of the entire calendar. |
integer |
100 |
| dateRangeEnd |
Sets the last available year in the year dropdown data selector. The year selector will display numbers between dateRangeStart and dateRangeEnd |
integer |
current year + 3 years |
| dateRangeStart |
Sets the first available year in the year dropdown data selector. The year selector will display numbers between dateRangeStart and dateRangeEnd |
integer |
current year - 3 years |
| dateSelector |
Defines which of the date selectors will be displayed in the calendar header. This is property is manipulated by bitwise operators.
a value of 1 = month selector is visible
a value of 2 = year selector is visible
a value of 4 = prev month link is visible
a value of 8 = next month link is visible
a value of 16 = month is displayed as text
a value of 32 = year is displayed as text
Values may be combined to create various looks. For example 4+8 means only the prev and next are visible while the month and year are hidden.
|
integer |
1+2+4+8 |
| deadCellBehavior |
Defines what will display in the cells belonging to the previous or next month. This is property is manipulated by bitwise operators. Cells belonging in the previous or next month are called ""dead"" cells. There are three types of behavior. One, display the date number. Two, show display dead events. Three, display event from the previous and next month.
a value of 1 = date number is visible
a value of 2 = dead events are visible. (A dead event is an event for a non-existant date. For example, the date 2/0/2005 would put an event in on the February 2005 calendar in the last day of January. The event would only be visible in February, not January.
a value of 4 = events from the previous and next month are visible
Values may be combined to create various looks. For example 1+2 means only the date number and dead events are visible.
|
integer |
0 |
| displayWeekNumber |
This boolean flag controls if the calendar the week number of the year is shown along the left hand side of the calendar. The style is set by the class "scWeekNumber". |
boolean |
FALSE |
| enableHandlers |
Instructs the calendar to call the onmouseover functions in the scHandlr.js |
boolean |
FALSE |
| expandCellHeight |
This boolean allows the date cell expand to include all the events and event text. The normal behavior is to truncate the events at the height set in the cellHeight property. If the you set this property to true, the cellHeight acts like a "min-height" and if needed will expand to include all events. Please note that some browsers may render this slightly differently. |
boolean |
FALSE |
| expandEventStyle |
This boolean allows the event class of one event expand to include other events that have no class. The origin of this property is from calendar that use background colors. If you a "red" background event and a recurring event with no class (i.e. black text), you might want the red background to expand and cover both events, thus the entire date cell will be red and not just half of it. |
boolean |
TRUE |
| filter |
Flag to turn on filters |
boolean |
FALSE |
| filterNames |
This string allows you to create keywords to filter events. The string is simply a comma delimited list of keywords. If this property is something other than empty string, a table of checkboxes appears at the bottom of the calendar. |
string |
empty string |
| initialDate |
This date value controls the month and year displayed when the calendar is first accessed. By default, it uses the current date. However, you can set it to any valid date value. |
date |
current date |
| initialDate |
This date value controls the month and year displayed when the calendar is first accessed. By default, it uses the current date. However, you can set it to any valid date value. |
data |
current date |
| license |
An array of license keys. This property is used with the noiframe installation |
string array |
null |
| longDays |
This array supplies the weekday headers for the calendar. The defaults are Sun, Mon, Tues... but you could change the array to Sunday, Monday, Tuesday... Also, this permits weekday headers in alternative languages. |
string array |
new Array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ); |
| longMonths |
This array supplies the months header for the calendar. |
string array |
new Array( "January", "February", "March", "April","May", "June", "July", "August", "September", "October", "November", "December" ); |
| nextHtml |
This string supplies the HTML to be used for the next month link in the calendar header. You may use an image tag to use a graphic for the link. The style for the link is the class "scSelector". |
string |
» |
| overrideSpecialEvent |
This boolean, when set to true will suppress any special event in a date cell that has regular event. |
boolean |
FALSE |
| padding |
This numeric property controls the amount of padding in pixels between the edge of the date cell and the event text. |
integer |
3 |
| popupAddParam |
This boolean property controls appending the "scDate" QueryString parameter on the URL of the popup window. The parameter will contain the date value of the event. |
boolean |
TRUE |
| popupProperities |
This string property is the equivalent of the window.open properties string. It allows you to set the size, scrollbars, etc... of the windows that popup (assuming you've defined a few events with the popuplink parameter). |
string |
width=600, height=400, scrollbars=yes, resizable=yes, titlebar=yes, toolbar=yes, menubar=yes, location=yes, status=yes. |
| popupType |
This numeric property controls how the pages specified in the PopupLink parameter of the fscEvent call are displayed.
a value of 1 = popup, new browser window
a value of 2 = a DIV tag on top of the calendar (defeats popup blocking software).
a value of 3 = as a hyperlink in the main window. |
integer |
1 |
| prevHtml |
This string supplies the HTML to be used for the previous month link in the calendar header. You may use an image tag to use a graphic for the link. The style for the link is the class "scSelector". |
string |
« |
| showFutureEvents |
This boolean property can hide future events coded in the dcevent.js if the value is set to false. Thus, only todays and past events are displayed. |
boolean |
TRUE |
| showPastEvents |
This boolean property can hide past events coded in the dcevent.js if the value is set to false. Thus, only todays and future events are displayed. |
boolean |
TRUE |
| spacing |
This numeric property controls the amount of transparent space in pixels appears between date cells. Either the background color of the calendar (set in calendarStyle) or your HTML page will show through. |
integer |
2 |
| specialEventsFirst |
Flag to place special before or after regular events |
boolean |
FALSE |
| tooltipType |
This numeric property controls the type of tooltip
a value of 1 = standard tooltip using "title" attribute
a value of 2 = overlib.js DIV tooltip
|
integer |
2 |
| tooltipUseEventText |
Flag to put eventText into the empty tooltips |
boolean |
true |
| xmlFile |
Specify the virtual path to the xml events file |
string |
null |
| xslFile |
Specify the virtual path to the XSLT file for the xml |
string |
null |
Cascading Style Sheet
The scrptcal.css is the display CSS file of a theme. It controls the forecolor, background color, header and border of the calendar. below is a list of the various CSS classes found in the scrptcal.css.
| class name |
element type |
description |
| standard classnames |
| body |
body |
The standard CSS body tag |
| A:link |
hyperlink |
The standard CSS A:link tag. |
| A:visited |
hyperlink |
The standard CSS A:visited tag. |
| A:hover |
hyperlink |
The standard CSS A:hover tag. |
| A:active |
hyperlink |
The standard CSS A:active tag. |
| main calendar classnames |
| .scCalendar |
div |
Applied to the main element of calendar. |
| .scHeader |
div |
Applied to the selectors and weekday header elements. |
| .scMonthDropdown |
combobox |
Applied to the month dropdown, used to control the width. |
| .scYearDropdown |
combobox |
Applied to the year dropdown, used to control the width. |
| .scSelector |
span |
Applied to the previous and next month hyperlink elements. |
| .scWeekNumber |
div |
Applied to the week numbers on the left side of the calendar. |
| .scWeekday |
div |
Applied to every date cell element of the calendar. |
| .scEvent |
div |
Applied to every event element of the calendar. |
| .scToday |
div |
Applied to "today" event defined in the scSpcEvt.js |
| past, present and future date classnames |
| .scDateDead |
div |
Applied to the dead cells of the calendar. |
| .scDatePast |
div |
Applied to the past cells of the calendar. |
| .scDateCurrent |
div |
Applied to the current cell of the calendar. |
| .scDateFuture |
div |
Applied to the future cells of the calendar. |
| event classnames |
| .scEventRed |
div |
Applied to event elements. Use in the scevent.js |
| .scEventOrange |
div |
Applied to event elements. Use in the scevent.js |
| .scEventYellow |
div |
Applied to event elements. Use in the scevent.js |
| .scEventGreen |
div |
Applied to event elements. Use in the scevent.js |
| .scEventBlue |
div |
Applied to event elements. Use in the scevent.js |
| .scEventPurple |
div |
Applied to event elements. Use in the scevent.js |
| .scEventBlack |
div |
Applied to event elements. Use in the scevent.js |
| day of the month classnames |
| .scNumber |
div |
Additional style applied to day of the month text. |
| event handler classnames |
| .scOnMouseOver |
div |
Applied to date cells of the calendar on the mouse over. |
| Popup DIV classnames |
| .scPopupContainer |
div |
Applied to the DIV that contains the DHTML popup iframe. |
| .scPopupIFrame |
iframe |
Applied to the IFrame of the DHTML popup. |
| Filter classnames |
| .scFilterContainer |
div |
Applied to the DIV that contains the DHTML popup iframe. |
| .scFilterItem |
span |
Applied to a span around the checkbox. |
| DIV tooltip classnames |
| .scDivTooltipBackground |
table |
Applied to the outer table of the DIV tooltip. |
| .scDivTooltipFont |
div |
Applied to the DIV of the DIV tooltip. Put most tooltip styles here. |
| .scDivTooltipForeground |
table |
Applied to the inner table of the DIV tooltip. |
You may modify any of these classes in any of the themes to satisfy your needs. If you are not familiar with CSS, then you should stick with a supplied theme and do not alter it.
Armed with this CSS knowledge, you may decide to create your own theme. Perhaps none of the themes supplied work and you want something that integrates better with your website. Please feel free to create themes of your own to meet your needs.
CSS Applied when Printing
There are two CSS files in each theme folder. The "scrptcal.css" provides the styles for displaying the calendar in the browser. The "scprint.css" provides styles for printing the calendar. The classnames inside both style sheets are the same since they both refer to the same elements.
The scprint.css is included on the scrptcal.htm file with the attribute media="print". The scrptcal.css has media="sreen". This makes the scprint.css applicable when printing.
The "scprint.css" that is included in the zip displays most elements with a white background and black text. It also places a border around each weekday element. Please edit the file to print the calendar as you see fit.
Customizing Your Calendar
You have looked at installing the calendar. You have selected a theme, and learned how the calendar properties and the CSS control various features of the calendar.
The next sections will describe how to accomplish some common customization of the calendar.
Changing the Calendar Size
When using the iframe design of the calendar, the height or width must be changed in two places. First, set the height and width in the cellHeight and cellWidth properties of the "scrptcal.htm" file. Second, adjust the height and width attributes of the "iframe" tag in your HTML.
The cellHeight and cellWidth determine the size of the table cells representing individual dates. These properties are the number of pixels tall and wide the date table cells will be. There are 7 days in a week, which means there are 7 columns. There are 4 to 6 weeks in a month, so 4 to 6 rows. Changing the size date table cells affects the overal size of the calendar.
You must comprise between the amount of event text and how big your calendar can be to fit on screen. Date table cell heights of 80 pixels and widths of 80 pixels produce a compact calendar. 100 pixels by 100 pixels produces a larger calendar, while still fitting to a single page.
One tip is to use a small amount of event text to summarize your event, and then having a link or a popup to more detailed information. There is more on adding hyperlinks and popups to events when events themselves are discussed.
The second adjustments is the iframe. Now that you have changed the size of the calendar, you must adjust the iframe. The iframe height and width control how much real estate on your page you will give to the calendar. A larger calendar must be accounted for within height and width of the iframe. Otherwise the iframe will truncate portions of the calendar.
Determining the correct value of the iframe height attribute is done through trial and error. A good starting point is for a cellHeight of 100, set the iframe height to 800. For a cellHeight of 150 set the iframe height to 1050.
Also note that the calendar may have six weeks and not just five. Check a month and year that will give you the six weeks display. A good example and good date to test is January 2005.
The iframe height will need to be larger than most months of the calendar, considering some months can have 6 weeks. The calendar itself will adjust depending on the month, but the iframe height is fixed.
You can blend the calendar with your page by setting the "body" class of the scrptcal.css to the same background as you page. The "body" class is the body of the scrptcal.htm file (which is loaded in the iframe). You can still have a border around the calendar using the "scCalendar" class in the same CSS. This is a class for a DIV tag that wraps the calendar. It will grow and shrink with the calendar height.
Automatically Expanding Cell Height
The recommended solution to display all events and event text is to adjust the cellHeight or cellWidth. This was covered in a previous section.
The "expandCellHeight" property is alternative to this method. Setting this boolean property to True allows the date cell to expand as needed to include all the events. The online demo shows off this property if you check the "standard" and "original" themes.
There are some variations in the way browsers render the calendar with the property set to True. MSIE and Firefox render the calendar properly as expected. Opera and Netscape browsers may not expand the last event style to cover the entire cell. Please be aware of this variation if you use this property.
It is recommended that if you use expandCellHeight that you turn off "expandEventStyle". With expandEventStyle set to false, the calendar will not attempt to expand the events, and you should get a consitent look across all browsers.
Note: The expandCellHeight property will not work in MSIE with a DocType declaration tag. DocType declaration tags are used to indicate if the browser should render strict/ w3c compliant css, or if it should render in the browsers own particular flavor of css. The expandCellHeight only works in MSIE in loose CSS mode, and when not rendered as xhtml. So, the only DocType tag that will work is DocType tag that is equivalent to not having a DocType tag at all. That tag is below.
Changing the Weekday Names or Month Names
You change the weekday names that appear above each column in the calendar table. The names are stored in the "longDays" property. This property is an array of strings. Below is the default value of the longDays property.
objCal.longDays = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
You could easily change this to be full names instead of abbreviations. Simply set the property equal to a new array of string values.
objCal.longDays = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
Similarly, the month names are stored the property "longMonths". Below is the default value of the longMonths property.
objCal.longMonths = new Array( "January", "February", "March", "April","May", "June", "July", "August", "September", "October", "November", "December" );
Using the Calendar in other Languages
The scriptcalendar can support any language you choose. There are only three places where text is displayed, and you change choose the language of that text.
The first place is the month names. As you have seen in the previous section, you can control this text using the "longMonths" property.
The second place is the weekday names. Just like the month names, you can control this text using the "longDays" property.
The final place is the event text. You control the event text in the scevent.js or scspcevt.js files. You create the events, and you decide what language the text of these events will be. Actually adding the events is covered later.
Start the Week on Monday
In some countries the week begins on Sunday. In other countries the week begins on Monday.
The Scriptcalendar allows you to control which day the week begins with using the "beginMonday" flag. This property accepts a boolean value. If the value is false, the week begins with Sunday. If it is true, the week begins on Monday. The property is false by default, meaning the week begins on Sunday.
Now, if you change the beginMonday property to true, you also need to adjust the weekday names to match. As you've seen, the weekday names are set in the "longDays" property. TO make the change to start the week on Monday, use this code.
objCal.beginMonday = true;
objCal.longDays = new Array( "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" );
Changing the Month and Year Selection
The "dateSelector" property controls the display of the month and year dropdowns as well as the previous and next month links. The property is a numeric value designed for bitwise operations. The values are list below.
| value |
description |
| 1 |
The month drop-down is displayed. |
| 2 |
The month drop-down is displayed. |
| 4 |
The previous month link is displayed. |
| 8 |
The next month link is displayed. |
| 16 |
The month is displayed as text only. |
| 32 |
The year is displayed as text only. |
By default all selectors are displayed, with the month and year as dropdowns. The default is equivalent to the code below.
objCal.dateSelector = 1+2+4+8;
You can choose to display only the month drop-down by setting the property to the value of 1. You can combine these values to create combinations. You can choose to display both dropdowns by using the value 1+2 or 3. You can choose to display only the previous and next month links by using the value 4+8 or 12. If you'd like the month and year displayed as text, use the value 16+32.
The "dateRangeStart" and "dateRangeEnd" control the minimum and maximum values of the year drop-down. These properties accept an integer value. You can set these properties to control what dates a user can see.
objCal.dateRangeStart = 2008;
objCal.dateRangeEnd = 2015;
The "prevHtml" and "nextHtml" properties control what text is displayed in the previous and next month links. These properties accept string values. You may use HTML with the string, so you can use images tags as well as text. By default the values equivalent to the code below.
objCal.prevHtml = "«";
objCal.nextHtml = "»";
The previous and next month link style is controlled by the CSS file "scSelector" class. The HTML element for the links is a span. If you edit this class, you can change the font or colors of these links.
Control the Initial Date
There are two ways to set the initial date of the calendar
The first is to the use the "initialDate" property. This property controls what date is displayed when the calendar first comes up. The default value is the current date. But you can set it to any valid date value. You would set the property like the code below, using a vaild javascript date value.
objCal.initialDate = new Date(2009, 10, 1);
The second way is using the scDate querystring parameter. You've already toched on how to do it, and you've asked me for a specific example...
<!-- scriptcalendar iframe tag -->
<iframe id="scIFrame" name="[license key]" src="scthemes/standard/scrptcal.htm?scDate=10/1/2009" scrolling="no" frameborder="0" width="800" height="700" >
</iframe>
But, the forward slash should really be URL encoded, so use this instead...
<!-- scriptcalendar iframe tag -->
<iframe id="scIFrame" name="[license key]" src="scthemes/standard/scrptcal.htm?scDate=10%2F1%2F2009" scrolling="no" frameborder="0" width="800" height="700" >
</iframe>
Using Event Filters
The concept of the filter is to allow you or your users to display subsets of the events on the calendar. First you define a set of keywords, and these keywords appear as checkboxes along the top of the calendar. When you or a user checks a keyword, the calendar is refreshed and the events corresponding to that keyword are displayed. Conversely, when a keyword is unchecked the events are removed. This is accomplished by using a QueryString parameter "scFilter".
To use the filter on your calendar, you must follow a few steps. One, use the filterNames properties to define keywords as a comma delimited string. For example, the line below creates three keywords.
objCal.filterNames = "weekends,holidays,special";
Two, you must add the keywords to individual events. Each event may only have one keyword. You add a keyword by using the 9th parameter of the fscEvent function. If you do not add a filter keyword to an event, that event will always appear regardless of the filters selected.
Three, you will probably want to have some filtered events showing when the page first displays. Since the filter is accomplished through the QueryString parameter "scFilter", you must edit the iframe url to accomplish the default. Now, the "scFilter" parameter is comma delimited string. Keywords contained with string will display events, those omitted will hide events. Let's look at an example url for the iframe tag (using the keywords above).
scthemes/standard/scrptcal.htm?scFilter=weekends%2Cholidays
This url will have the "weekends" and "holidays" filter events appearing, and the "special" filter events will not appear. You'll note that url must be encoded. When a url is encoded, a comma character is translated into "%2C". Therefore, you when you create the default url, you want to use "%2C" to delimit keywords.
Bear in mind that a space also gets encoded. It is recommended that you choose keywords without spaces or simply remove the spaces from your keywords. This will make it easier to create the url to default the filters.
You can control the style of the filter checkboxes in the CSS. The CSS Section covers the classnames in the CSS and describes what classes control the filter display.
The Date Displayed
You may find it necessary to know what date the user has selected and the calendar is displaying. This is particularly useful when you are using server side scripting to return data to the calendar.
Every time the user selects a new month or new year, the calendar refreshes within the IFrame with a parameter named "scDate". This parameter is a date representing the month and year displayed. The date is in a forward slash notation, for example "10/01/2005" (URL encoded of course, but that is transparent to you). The date always uses the first of the month, since the user can't select a day of the month.
You may add code to the "scrptcal.htm" file (in your choosen theme folder) to react to the "scDate" parameter. For example, you could use this date to only pull back the event data required for that month.
You may also use this to establish an initial date for the calendar. If the Scriptcalendar IFrame tag "src" attribute contains a URL that includes the "scDate" parameter, the calendar will display that date. You can use the "scDate" parameter to display a specific month and year. Please note that the parameter should be URL Encoded.
Reacting to OnMouseOver
The schandlr.js give you a method to have "onmouseover" and "onmouseout" and other scripts execute. The schandlr.js is a file within your selected them folder. It provides functions the following functions.
| function |
calendar object |
javascript event |
| fscCellOnMouseDown
| entire date cell
| on mouse down
|
| fscCellOnMouseOver
| entire date cell
| on mouse over
|
| fscCellOnMouseOut
| entire date cell
| on mouse out
|
| fscCellOnMouseUp
| entire date cell
| on mouse up
|
| fscNumberOnMouseDown
| date number
| on mouse down
|
| fscNumberOnMouseOver
| date number
| on mouse over
|
| fscNumberOnMouseOut
| date number
| on mouse out
|
| fscNumberOnMouseUp
| date number
| on mouse up
|
| fscEventOnMouseDown
| calendar event
| on mouse down
|
| fscEventOnMouseOver
| calendar event
| on mouse over
|
| fscEventOnMouseOut
| calendar event
| on mouse out
|
| fscEventOnMouseUp
| calendar event
| on mouse up
|
Each function has the following arguments.
| argument |
data type |
description |
| e |
javascript event |
othe event triggering the call (onmouseover, onmouseout, etc...) |
| obj |
DIV object |
reference to the DIV wrapping the calendar element |
| m |
integer |
the month portion of the date of the object |
| d |
integer |
the day portion of the date of the object |
| y |
integer |
the year portion of the date of the object |
| dte |
date |
a date varible constructed from m,d and y inside the function |
Imagine you want to react to a mouse moving over, and then away from a date number. First, you need to instruct the calendar to use the schandlr.js code. You do this by setting the "enableHandlers" property of the calendar in the scrptal.htm of your selected theme. For example...
objCal.enableHandlers = true;
You could add the following code to the schandlr.js functions to change the text color of the date number to red. We have reference to the DIV containing the text, so we adjust the style.
function fscNumberOnMouseOver(e, obj, y, m, d) {
var dte = new Date(y, m, d);
obj.style.color = "#ff0000";
};
And when the mouse moves away, the color goes to black.
function fscNumberOnMouseOver(e, obj, y, m, d) {
var dte = new Date(y, m, d);
obj.style.color = "#000000";
};
You could do the same for an event, just using the fscEventOnMouseOver and fscEventOnMouseOut functions instead.
You could choose to react only to certain dates as well.
Managing your Events
The scriptcalendar software is 100% javascript. Javascript has the built in limitation where it cannot read or write files on the server. This includes databases. There is no way to manage your events online with a javascript solution.
The scriptcalendar works by including the scevent.js and spspcevt.js files that conatin event data from the scrptcal.htm file. The main calendar engine scrptcal.js is also included. The scevent.js is a list of function calls. The function called is contained within the main engine. The scspcevt.js is itself a function, and it is called my the main engine.
The point is that these files containing the event data must exist on the server when the calendar is loaded. There is no way for the javascript solution to read data from a database or any other format.
You must manage your events somewhere else, probably in a text editor on your local machine. When you are ready to post updated events, you upload these files to the web server.
The event editor assists you with writing events. But it is still an offline tool. You manage your events, save them to a file, and then upload the file to server.
If you use the XML event format, the xml is loaded through an ajax-like process. But the xml event file must also exist before the calendar is loaded.
If you have server side scripting, like .NET or Java or PHP, you can generate the event data files from a database. A method of doing would be to change the include of the scevent.js to point to a page like scevent.aspx, scevent.jsp or scevent.php and have the events generated.
There is a example on the Scriptcalendar website of such a page in C#. The example uses the method above to generate the event file on demand by using scevent.aspx. There is also a page allowing you to manage the events online. You are free to download this code, study it and adapt to your needs. However, there is no method included with calendar to manage events online.
Standard Events
You add standard events to the calendar using the scevent.js file. A standard event is and event that occurs on a specific date. You simply want that event to appear in the calendar on that day.
The primary way of adding events is using the scevent.js file. This file is
nothing more that a list of calls to a function of the Scriptcalendar engine. The function is the "fscEvent" function. To create an event in the calendar, you simply make a call the fscEvent function. In order to call the function, you must know what parameters to use. Please see the table of the parameters below.
| parameter |
type |
required |
description |
| month |
number |
no |
The numeric month (1-12) of the date of the event. |
| day |
number |
yes |
The numeric day (1-31) of the date of the event. |
| year |
number |
no |
The 4 digit numeric year of the date of the event. |
| text |
string |
no |
The text you want to appear in a date cell. It may include HTML. |
| popuplink |
string |
no |
An url you want to popup in a new window when the event text is clicked. |
| style |
string |
no |
A class name of a CSS class that you want applied to the event. |
| tooltip |
string |
no |
A message that appears when the mouse hovers over an event. |
| script |
string |
no |
Javascript to be executed during "onMouseDown" in the date cell. |
| filter |
string |
no |
Keyword to allow users to filter events. |
To add a new event to the file, you first need to open it for editing. Windows notepad is an simple text editor and works well. You can use whatever editor you like.
Simply add a new call to the fscEvent function to the file. The call must be correct javascript code. For example, to a new event for January 1st 2010, add this code.
fscEvent( 1, 1, 2006, "January 1st 2010" );
You'll note that some of the parameters are missing. Since all the parameters after the EventText parameter were NULL, we just omitted them. This would be same as the call below.
fscEvent( 1, 1, 2006, "January 1st 2006", null, null, null, null, null );
To edit an event, locate it the file and change the fscEvent call as necessary.
To remove an event, locate it the file and delete the code for it.
When you are finished editing the scevent.js, you must upload it to your web server. Save the changes on your local machine, and then FTP it to the proper folder on your web server.
Again, the scevent.js file must be comprised of valid javascript code. It will cause a javacript error if the syntax is incorrect. There is an event editor tool described later on in this guide that will assist you constructing valid javascript.
Here is a example of an entire, short scevent.js file. It only has events in January 2010.
// ********* ********* ********* ********* ********* ********* ********* ********* *********
// Define Events
// call the fscEvent function
//
// # PARMS DATA TYPE DESCRIPTION
// 1 m number 2 digit month (1=jan, 2=feb, 3=mar,... 12=dec)
// 2 d number 2 digit day
// 3 y number 4 digit year
// 4 text string HTML event text
// 5 link string URL for popup window
// 6 style string CSS class for the event (in-line style is invalid)
// 7 tooltip string text for hover over tooltip
// 8 script string javascript to execute during onMouseDown
// 9 filter string keyword to allow users to filter events
// ********* ********* ********* ********* ********* ********* ********* ********* *********
fscEvent( 1, 19, 2010, "Custom color event example", null, "scEventRed", null, null );
fscEvent( 1, 20, 2010, "Custom color event example", null, "scEventOrange", null, null );
fscEvent( 1, 28, 2010, "multiple events", null, "scEventRed", null, null );
fscEvent( 1, 28, 2010, "multiple events", null, "scEventOrange", null, null );
fscEvent( 1, 28, 2010, "multiple events", null, "scEventYellow", null, null );
fscEvent( 1, 28, 2010, "multiple events", null, "scEventGreen", null, null );
fscEvent( 1, 28, 2010, "multiple events", null, "scEventBlue", null, null );
fscEvent( 1, 28, 2010, "multiple events", null, "scEventPurple", null, null );
Multiple Events in a Single Day
You may define more that one event for a specific date. The calendar will display the events as they are ordered in the scevent.js file. For example...
fscEvent( 1, 1, 2010, "event 1" );
fscEvent( 1, 1, 2010, "event 2" );
fscEvent( 1, 1, 2010, "event 3" );
Will place three events in the January 1st 2010 date. They will appear in the order above.
Please note that if you have many events defined in a single day, the calendar may truncate the display based on the cellHeight and expandCellHeight properties.
If your events are being cut off, you need more space to display them. In that case, increase the cellWidth and cellHeight properties to enlarge the individual date cells. Please see the section on control the calendar size for more details.
Alternatively, you can set the expandCellHeight which allows the date cell to grow to show all the events. This property is covered in depth in a later section.
Multiple Day Events
You may demonstrate an event spaning several days by coding an event for each day. Using a color to unify the event helps identify it as spanning multiple days.
For example, the code creates an event on each day between 1/1/2010 and 1/3/2010. the style parameter and the scEventRed class name are used to provide a unifying color.
fscEvent( 1, 1, 2010, "3 day long event", null, "scEventRed" );
fscEvent( 1, 2, 2010, "3 day long event", null, "scEventRed" );
fscEvent( 1, 3, 2010, "3 day long event", null, "scEventRed" );
Monthly and Yearly Events
Monthly events are events that occur on the same day each month. Yearly events are events that occur on the same day each year. Events that occur on these regular schedules can be represented in the scevent.js file
A good example of a yearly event is Christmas day. It occurs on December 25th each year. Other examples are New Years day, the Fourth of July and your birthday.
You can write an event to occur year by passing the year parameter of the fscEvent call as null. For example, the event below occurs every Christmas.
fscEvent( 12, 25, null, "Christmas day");
An event that occurs every month can also be represented by passing the month parameter as null. For example, imagine you have a business where the end of the month processing occurs the 3rd day of each new month. You could write an event like the code below.
fscEvent( null, 3, null, "End of Month Processing");
Many times it is better to write holidays and reocurring event as special events, which are discussed later. The reason is you can't use this method to represent Thanksgiving, which changes each year.
Events in the Dead Dates
The dead date cells are the cells of the calendar belonging to previous or next
month. By default, nothing is displayed in these cells. In many of the themes provided, the cells themselves are not even displayed. In order to see the dead cells, please examine the "original" theme.
What displays in the "dead" cells is determined by the deadCellType property. The property is a numeric value designed for bitwise operations. That means that are three basic types of behavior for the dead cells that you can use and combine. The basic values are below.
| value |
description |
| 1 |
The Date Number is displayed. |
| 2 |
The special, non-standard event dates are displayed. |
| 4 |
The events for the previous and next month are displayed. |
You can combine these values to create combinations. For instance, if you set the property to the value of 1+2 or 3, then the Date Number and the non-standard event dates are displayed. A value of 1+2+4 or 7 will display all three things.
A non-standard event date is an event in the scEvent.js that is not a valid date. In the scEvent.js you could have the following event.
fscEvent( 1, 0, 2010, "One day until January 1st.");
Which is not a valid date since 1/0/2010 is not valid. The calendar will interpret this as "one day before before the first of January 2010". If a dead cell is available, this event will display in the date 12/31/2009 for the month of January. It will not appear in December. Thus, a dead date cell in January can display information meant only for the month of January. The
day value of "-1" will correspond to the date 12/30/2009 and so on. Dates beyond the last day of the month behave the same way, so a day value of "32" for January 2010 will display in the February 1st dead cell for the January month only.
Adding color to an Event
The 6th parameter of the fscEvent function is an optional string containing a CSS Class Name. This parameter is called the style parameter. If the argument does in fact contain as string (not NULL), then the event is display using the corresponding style from the CSS file stylesheet. For example, see the event below.
fscEvent( 1, 1, 2006, "event with style", null, "scEventRed");
Will display an event on January 1st 2006 with the scEventRed class. This class name is present in the CSS file and contain attributes for controlling the colors of the background and text. Some knowledge of CSS is required to edit the CSS file, so if you don't want to edit the CSS file, you can use the class names provided.
In-line styles are not supported. All styles must referenced by class name and should be placed in the CSS file.
Follow these steps to add new event with custom colors.
(1) In appropiate scrptcal.css file, create new
classnames and styles that you desire.
.CustomColor1 { background-color: #fc9c9c; color: #ffffff; }
(2) Use the new classnames in the 6th parameter of the
fscEvent call.
fscEvent( 1, 1, 2010, "my event", null, "CustomColor1" );
Adding a HTML to an Event
The 4th parameter of the fscEvent function is a string of text to appear in the specific date cell. This is called the EventText parameter. The string value may contain HTML tags.
For example, to place an image in the date cell for January 1st 2010, use the following code.
fscEvent( 1, 1, 2010, "preceeding text <img src='myimage.gif'>");
Please note that the linked file must be enclosed with single quotes. Double quotes are already used to enclose the text string itself.
Any HTML tags can be used. For example, to place a hyperlink in the date cell for January 1st, 2010, use the following code.
fscEvent( 1, 1, 2010, "the <a href='http://www.yahoo.com'>hyperlink</a>.");
Adding a Popup Window to an Event
The 5th parameter of the fscEvent function the popupLink parameter. It is an optional string containing a URL. If the argument does in fact contain as string (not NULL), the event text will be displayed as a hyperlink and destination will be the URL specified. Clicking the link will open the destination URL.
fscEvent( 1, 1, 2010, "my event", null, "http://www.yahoo.com" );
How the destination URL is opened is set by the popupType property. This property is a numeric property. It's value can be 1, 2 or 3. Setting this property controls the popup type of all the events, so you can't mix the behavior.
| value |
description |
| 1 |
The URL is opened in a popup, new browser window. |
| 2 |
The URL is opened in a DIV element, circumventing popup blocking software. |
| 3 |
The URL is opened as a regular hyperlink in the main browser. |
The value of 1 is the default. This opens the destination URL in a new browser window as a popup. Some aggresive popup blocking software may interpret the popup as an advertisement an prevent it from displaying. The attributes of the popup window are set in the popupProperties property.
To circumvent popup block software, use the value of two to display the destination URL in a DIV tag. The style of the DIV tag is controlled in the CSS file.
Alternatively, you can write javascript in the "text" or "script" parameters of the fscEvent function to do custom popups.
Event Tooltips
Adding a tooltip is great way way to display extra information to your visitors. It's also a good way to make an event stand out against a busy calendar.
There are two types of tooltips. Type one is the standard "title" attribute tooltip of a div tag. This is a very plain tooltip. You cannot control the colors, font sizes, use html or determine how long it is visible.
The second type is a div tooltip. This is a tooltip added by the third party javascript library overlib.js. With this type of tooltip, you control the colors and fonts in the scrptcal.css. You can use html. The tooltip is visible as long as the mouse hovers over the event.
The type is controlled by the tooltipType property. The default type is type two, the overlib.js tooltip.
You can specify exactly what you want to appear in the tooltip of every event by using the 7th argument of the fscEvent call. This is the tooltip argument. If you use type 2 tooltips, you can put html in the text argument and it will be used on the tooltips. If you use type 1, use only plain text in the arugment.
When you use type 2 tooltips, you can configure the events to reuse the event text in the tooltip when the tooltip argument is empty. Every event will have a tooltip. Events with a tooltip argument will use the tooltip argument html. Events without tooltip arguments will use the the event text for the tooltip. You can control this the property tooltipUseEventText which is a boolean value.
You can control the fonts and colors of the type 2 tooltip in the scrptcal.css. There are classes beginning with "scTooltip" that are used to configure the tooltip div. The .scDivTooltipBackground and .scDivTooltipForeground are table elements. The .scDivTooltipFont is the inner div of the tooltip. This class is where you should put most of your styles.
The overLIB is a JavaScript library created to enhance websites with small popup information boxes (like tooltips) to help visitors around your website. It can be used to provide the user with information about what will happen when they click on a link as well as navigational help. Not to mention that it looks cool, is stable, and has an active developer community to boot!
The overlib.js homepage http://www.bosrup.com/web/overlib/
The Event Editor
The event editor is an HTML page included along with the ScriptCalendar software. It provides an easy way to add, modify and delete events. The editor constructs the proper javascript syntax for the scevent.js file. When you use the editor, you will always have valid javascript for your events.
The page is located in the "components" folder and is named "scEdit.htm". The page must reside in the same folder as the scEvent.js. This is necessary because it reads the events from the scEvent.js. To begin using the editor, simply open the scEdit.htm page.
The event editor may be used with MSIE 6+ and Firefox browsers. It may work in other browsers as well, but it is only certified in those two browser.
Please note that the editor cannot be used online. Javascript has a built in limitation that it cannot read or write from the server. So, the editor cannot update your scevent.js on the server. Instead, it displays the appropiate scevent.js file on screen. Then, you must manually...
- copy the formatted output from the page,
- paste the new code into the scevent.js file,
- save the new file to your harddrive, and
- upload it to you webserver. This makes the editor an offline tool.
To have calendar that you can have users add, update and delete events from you must...
- have server-side scripting software such as asp, java or php and
- you must code a page to interact with the scevent.js or scevent.xml.
There is a Interactive Example page written in C#.
Insert an Event
- Locate the blue form containing data inputs at the bottom right of the page.
- Enter the date, text and other data for your event. You may leave some fields blank.
- Click the Insert Record button. The new event is added to the table of events.
Update an Event
- Click on the appropiate event in the table of events.
- Locate the blue form containing data inputs at the bottom right of the page.
- Edit the date, text and other data for your event. You may leave some fields blank.
- Click the Update Record button. The event changes in the table of events.
Delete an Event
- Click on the appropiate event in the table of events.
- Locate the blue form containing data inputs at the bottom right of the page.
- Click the Delete Record button. The event is removed table of events.
Get the scevent.js output
- Locate the blue form containing data inputs at the bottom right of the page.
- Click the View Output button.
- Copy Output textarea with the formatted output to the clipboard.
- Paste the output from the clipboard into your scevent.js file.
Unfortunately, javascript has a built in security limitation that prevents it from writing to a file. Therefore, it will be necessary for you to copy the output of the editor from the page and paste it into your scevent.js or xml file.
Special Events
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.
Holidays
Thanksgiving, Memorial day and Easter are difficult to code in the scevent.js file. These holidays don't happen on the same day every year like Christmas. The best way to handle these holidays in the spspcevt.js file.
Thanksgiving occurs on the 4th Thursday in November. In order to represent it, we must check for three things.
- The month is November
- It is the 4th week of the month
- The weekday is Thursday
You perform all of these checks using the code below. The code relies on the variables provided within the spspcevt.js that are based on the date being rendered.
// Thanksgiving Day, fourth Thursday in November.
if (m==11 && intWeekday==4 && intWeekOfMonth==4) {
objEvent = new EventObj(m,d,y, "Thanksgiving", null, "scEventRed");
arrEvents[arrEvents.length] = objEvent;
};
Memorial Day is the last Monday in May. You can perform a similar check for it. Below is the code for a Memorial day event.
// Memorial Day, Last Monday in May.
if (m==5 && intWeekday==1 && blnLast==true) {
objEvent = new EventObj(m,d,y, "Memorial Day", null, "scEventRed");
arrEvents[arrEvents.length] = objEvent;
};
A much trickier holiday is the Easter holiday. To make it easier, the Scriptcalendar will provide the Easter holiday date in the variable dteEaster with the spspcevt.js. The variable gets the data from the calendar engine in a function named fscEaster. The year is passed into this function.
When you know the Easter holiday, you can also determine a date for Mardi Gras and Ash Wednesday.
// Easter Sunday
if (dte.equalsTo(dteEaster)) {
objEvent = new EventObj(m,d,y, "Easter Sunday", null, "scEventRed");
arrEvents[arrEvents.length] = objEvent;
};
// Mardi Gras (47 days before Easter Sunday)
if (dte.equalsTo(dteMardiGras)) {
objEvent = new EventObj(m,d,y, "Mardi Gras", null, "scEventRed");
arrEvents[arrEvents.length] = objEvent;
};
Reoccuring Events
Another use for the scspcevt.js is to code reoccuring events. For example, you could have an event that happens the 2nd Monday of every month. The following is an example of how to write such an event.
// 2nd Monday of every month
if (intWeekday==1 && intWeekOfMonth==2) {
objEvent = new EventObj(m,d,y, "2nd Monday", null, "scEventRed");
arrEvents[arrEvents.length] = objEvent;
};
The code relies on the variables with the scspcevt.js function that are based on the date being rendered.
Another example is an event that occurs on the 1st and 3rd Sunday of each month.
// first and third Sunday
if (intWeekday==0 && (intWeekOfMonth==1 || intWeekOfMonth==3) ) {
objEvent = new EventObj(m,d,y, "1st & 3rd Sunday", null, "scEventRed");
arrEvents[arrEvents.length] = objEvent;
};
Events across a Range of Days
You may have a need to write an event that spans two months or several months. The reoccuring code already presented is inadequate for such events.
Instead, you need to turn to a concept called a "ymd" date. Ymd stands for year-month-day. It means that instead of writing a date like 01/01/2010, you write it year first, follwed by the month and finally the day. The same date becomes 2010-01-01. Last, we can remove the dashes to have the number 20100101.
When you write dates in this ymd format, you can do numeric comparisons. Like
12/31/2008 is less than 01/01/2009 ( 20081231 < 20090101) or 5/1/2009
is less than 9/20/2009 (20090501 < 20090920).
You change the date being rendered to the ymd numeric date in the spspcevt.js. The date passed to the scspcevt.js is the "dte" variable. To translate this javascript date into a ymd numeric value, you can call a method on date values. This method is added by the Scriptcalendar engine. Please see the the code below.
var numericDate = dte.format("yymmdd");
Now you can use this ymd numeric to your advantage. Imagine you need an event from 5/1/2009 through 9/20/2009. We can translate these values in ymd numeric values. They become 20090501 and 20090920 respectively. To check if we are in the range, we just compare the numeric values.
// lunch event between 5/1/09 and 9/20/09
var numericDate = dte.format("yymmdd");
if (numericDate >= 20090501 && numericDate <= 20090920)
{
objEvent = new EventObj(m,d,y, "Lunch", null, "scEventBlue");
arrEvents[arrEvents.length] = objEvent;
}
A word about DocTypes
DocType declaration tags are used to indicate if the browser should render strict/ w3c compliant css, or if it should render in the browsers own particular flavor of css. The scriptcalendar will often run only when there is no DocType at all. Please use the loose DocType if you must have one.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|