gecko-dev/calendar/resources/content/calendar.js

1087 строки
28 KiB
JavaScript

/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is OEone Calendar Code, released October 31st, 2001.
*
* The Initial Developer of the Original Code is
* OEone Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Garth Smedley <garths@oeone.com>
* Mike Potter <mikep@oeone.com>
* Colin Phillips <colinp@oeone.com>
* Karl Guertin <grayrest@grayrest.com>
* Mike Norton <xor@ivwnet.com>
* ArentJan Banck <ajbanck@planet.nl>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/***** calendar
* AUTHOR
* Garth Smedley
*
* REQUIRED INCLUDES
* <script type="application/x-javascript" src="chrome://global/content/strres.js"/>
* <script type="application/x-javascript" src="chrome://calendar/content/calendarEvent.js"/>
*
* NOTES
* Code for the oe-calendar.
*
* What is in this file:
* - Global variables and functions - Called directly from the XUL
* - Several classes:
* CalendarWindow - Owns the 3 subviews, keeps track of the selection etc.
* CalendarView - Super class for three views
* MonthView
* WeekView
* DayView
* - Unifinder functions - fill in content of the unifinder.
*
* IMPLEMENTATION NOTES
*
* WARNING - We currently use CalendarEvent objects in what will be an unsafe way
* when the datasource changes. We assume that there is exactly one instance of CalendarEvent for
* each unique event. We will probably have to switch to using the calendar event id
* property instead of the object. G.S. April 2001.
**********
*/
/*-----------------------------------------------------------------
* G L O B A L V A R I A B L E S
*/
//the next line needs XX-DATE-XY but last X instead of Y
var gDateMade = "2002052213-cal"
// turn on debuging
var gDebugCalendar = false;
// ICal Library
var gICalLib = null;
// calendar event data source see penCalendarEvent.js
var gEventSource = null;
// single global instance of CalendarWindow
var gCalendarWindow;
//an array of indexes to boxes for the week view
var gHeaderDateItemArray = null;
var gClockId;
// Show event details on mouseover
var showTooltip = true;
// DAY VIEW VARIABLES
var kDayViewHourLeftStart = 105;
var kWeekViewHourHeight = 50;
var kWeekViewHourWidth = 78;
var kWeekViewItemWidth = 20;
var kWeekViewHourLeftStart = 97;
var kWeekViewHourHeightDifference = 2;
var kDaysInWeek = 7;
const kMAX_NUMBER_OF_DOTS_IN_MONTH_VIEW = "8"; //the maximum number of dots that fit in the month view
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var rootPrefNode = prefService.getBranch(null); // preferences root node
/*-----------------------------------------------------------------
* G L O B A L C A L E N D A R F U N C T I O N S
*/
/**
* Called from calendar.xul window onload.
*/
function calendarInit()
{
// get the calendar event data source
gEventSource = new CalendarEventDataSource();
// get the Ical Library
gICalLib = gEventSource.getICalLib();
// set up the CalendarWindow instance
gCalendarWindow = new CalendarWindow( gEventSource );
//when you switch to a view, it takes care of refreshing the events, so that call is not needed.
gCalendarWindow.currentView.switchTo( gCalendarWindow.currentView );
// set up the unifinder
prepareCalendarUnifinder();
prepareCalendarToDoUnifinder();
update_date();
checkForMailNews();
if( window.arguments && window.arguments[0].channel )
{
gCalendarWindow.calendarManager.checkCalendarURL( window.arguments[0].channel );
}
//a bit of a hack since the menulist doesn't remember the selected value
var value = document.getElementById( 'event-filter-menulist' ).value;
document.getElementById( 'event-filter-menulist' ).selectedItem = document.getElementById( 'event-filter-'+value );
}
// Set the date and time on the clock and set up a timeout to refresh the clock when the
// next minute ticks over
function update_date()
{
// get the current time
var now = new Date();
var tomorrow = new Date( now.getFullYear(), now.getMonth(), ( now.getDate() + 1 ) );
var milliSecsTillTomorrow = tomorrow.getTime() - now.getTime();
gCalendarWindow.currentView.hiliteTodaysDate();
gClockId = setTimeout( "update_date()", milliSecsTillTomorrow );
}
/**
* Called from calendar.xul window onunload.
*/
function calendarFinish()
{
finishCalendarUnifinder();
finishCalendarToDoUnifinder();
gCalendarWindow.close();
}
function launchPreferences()
{
goPreferences( "calendarPanel", "chrome://calendar/content/pref/calendarPref.xul", "calendar" );
}
/**
* Called to set up the date picker from the go to day button
*/
function prepareChooseDate()
{
// the value attribute of the datePickerPopup is the initial date shown
var datePickerPopup = document.getElementById( "oe-date-picker-popup" );
datePickerPopup.setAttribute( "value", gCalendarWindow.getSelectedDate() );
}
/**
* Called on single click in the day view, select an event
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function dayEventItemClick( eventBox, event )
{
//do this check, otherwise on double click you get into an infinite loop
if( event.detail == 1 )
gCalendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
if ( event )
{
event.stopPropagation();
}
}
/**
* Called on double click in the day view, edit an existing event
* or create a new one.
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function dayEventItemDoubleClick( eventBox, event )
{
editEvent( eventBox.calendarEventDisplay.event );
if ( event )
{
event.stopPropagation();
}
}
/**
* Called on single click in the hour area in the day view
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function dayViewHourClick( event )
{
if( event.detail == 1 )
gCalendarWindow.setSelectedHour( event.target.getAttribute( "hour" ) );
}
/**
* Called on single click in the hour area in the day view
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function dayViewHourContextClick( event )
{
var dayIndex = event.target.getAttribute( "day" );
gNewDateVariable = gCalendarWindow.getSelectedDate();
gNewDateVariable.setHours( event.target.getAttribute( "hour" ) );
gNewDateVariable.setMinutes( 0 );
}
/**
* Called on double click of an hour box.
*/
function dayViewHourDoubleClick( event )
{
var startDate = gCalendarWindow.dayView.getNewEventDate();
newEvent( startDate );
}
/**
* Called on single click in the day view, select an event
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function weekEventItemClick( eventBox, event )
{
//do this check, otherwise on double click you get into an infinite loop
if( event.detail == 1 )
{
gCalendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
var newDate = gCalendarWindow.getSelectedDate();
newDate.setDate( eventBox.calendarEventDisplay.event.start.day );
gCalendarWindow.setSelectedDate( newDate );
}
if ( event )
{
event.stopPropagation();
}
}
/**
* Called on double click in the day view, edit an existing event
* or create a new one.
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function weekEventItemDoubleClick( eventBox, event )
{
editEvent( eventBox.calendarEventDisplay.event );
if ( event )
{
event.stopPropagation();
}
}
/** ( event )
* Called on single click in the hour area in the day view
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function weekViewHourClick( event )
{
if( event.detail == 1 )
{
var dayIndex = event.target.getAttribute( "day" );
newDate = new Date( gHeaderDateItemArray[dayIndex].getAttribute( "date" ) );
newDate.setHours( event.target.getAttribute( "hour" ) );
gCalendarWindow.setSelectedDate( newDate );
}
}
/** ( event )
* Called on single click in the hour area in the day view
*
* PARAMETERS
* hourNumber - 0-23 hard-coded in the XUL
* event - the click event, Not used yet
*/
function weekViewContextClick( event )
{
var dayIndex = event.target.getAttribute( "day" );
gNewDateVariable = new Date( gHeaderDateItemArray[dayIndex].getAttribute( "date" ) );
gNewDateVariable.setHours( event.target.getAttribute( "hour" ) );
}
/**
* Called on double click of an hour box.
*/
function weekViewHourDoubleClick( event )
{
var startDate = gCalendarWindow.weekView.getNewEventDate();
newEvent( startDate );
}
/**
* Called on single click on an event box in the month view
*
* PARAMETERS
* eventBox - The XUL box clicked on
* event - the click event
*/
function monthEventBoxClickEvent( eventBox, event )
{
//do this check, otherwise on double click you get into an infinite loop
if( event.detail == 1 )
{
gCalendarWindow.EventSelection.replaceSelection( eventBox.calendarEventDisplay.event );
var newDate = gCalendarWindow.getSelectedDate();
newDate.setDate( eventBox.calendarEventDisplay.event.start.day );
gCalendarWindow.setSelectedDate( newDate );
}
if ( event )
{
event.stopPropagation();
}
}
/**
* Called on double click on an event box in the month view,
* launches the edit dialog on the event
*
* PARAMETERS
* eventBox - The XUL box clicked on
*/
function monthEventBoxDoubleClickEvent( eventBox, event )
{
gCalendarWindow.monthView.clearSelectedDate();
editEvent( eventBox.calendarEventDisplay.event );
if ( event )
{
event.stopPropagation();
}
}
/**
* Called when the new event button is clicked
*/
var gNewDateVariable = null;
function newEventCommand( event )
{
if( gNewDateVariable != null )
{
var startDate = gNewDateVariable;
}
else
var startDate = gCalendarWindow.currentView.getNewEventDate();
var Minutes = Math.ceil( startDate.getMinutes() / 5 ) * 5 ;
startDate = new Date( startDate.getFullYear(),
startDate.getMonth(),
startDate.getDate(),
startDate.getHours(),
Minutes,
0);
newEvent( startDate );
}
/**
* Called when the new event button is clicked
*/
function newToDoCommand()
{
var calendarToDo = createToDo();
var dueDate = gCalendarWindow.currentView.getNewEventDate();
var Minutes = Math.ceil( dueDate.getMinutes() / 5 ) * 5 ;
dueDate = new Date( dueDate.getFullYear(),
dueDate.getMonth(),
dueDate.getDate(),
dueDate.getHours(),
Minutes,
0);
calendarToDo.due.setTime( dueDate );
calendarToDo.start.setTime( dueDate );
var args = new Object();
args.mode = "new";
args.onOk = self.addToDoDialogResponse;
args.calendarToDo = calendarToDo;
window.setCursor( "wait" );
// open the dialog modally
openDialog("chrome://calendar/content/calendarToDoDialog.xul", "caEditEvent", "chrome,modal", args );
}
function createEvent ()
{
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
var iCalEvent = iCalEventComponent.QueryInterface(Components.interfaces.oeIICalEvent);
return iCalEvent;
}
function createToDo ()
{
var iCalToDoComponent = Components.classes["@mozilla.org/icaltodo;1"].createInstance();
var iCalToDo = iCalToDoComponent.QueryInterface(Components.interfaces.oeIICalTodo);
return iCalToDo;
}
function isEvent ( aObject )
{
return aObject instanceof Components.interfaces.oeIICalEvent;
}
function isToDo ( aObject )
{
return aObject instanceof Components.interfaces.oeIICalTodo;
}
/**
* Helper function to launch the event composer to create a new event.
* When the user clicks OK "addEventDialogResponse" is called
*/
function newEvent( startDate, endDate )
{
// create a new event to be edited and added
var calendarEvent = createEvent();
calendarEvent.start.setTime( startDate );
if( !endDate )
{
var MinutesToAddOn = getIntPref(gCalendarWindow.calendarPreferences.calendarPref, "event.defaultlength", 60 );
var endDateTime = startDate.getTime() + ( 1000 * 60 * MinutesToAddOn );
calendarEvent.end.setTime( endDateTime );
}
else
{
calendarEvent.end.setTime( endDate.getTime() );
}
//get the selected calendar
var selectedCalendarItem = document.getElementById( "list-calendars-listbox" ).selectedItem;
var server = null;
if( selectedCalendarItem )
{
server = selectedCalendarItem.calendarPath;
}
editNewEvent( calendarEvent, server );
}
/**
* Helper function to launch the event composer to edit a new event.
* When the user clicks OK "addEventDialogResponse" is called
*/
function editNewEvent( calendarEvent, server )
{
// set up a bunch of args to pass to the dialog
var args = new Object();
args.mode = "new";
args.onOk = self.addEventDialogResponse;
args.calendarEvent = calendarEvent;
if( server )
args.server = server;
window.setCursor( "wait" );
// open the dialog modally
openDialog("chrome://calendar/content/calendarEventDialog.xul", "caEditEvent", "chrome,modal", args );
}
/**
* Called when the user clicks OK in the new event dialog
*
* Update the data source, the unifinder views and the calendar views will be
* notified of the change through their respective observers
*/
function addEventDialogResponse( calendarEvent, Server )
{
gICalLib.addEvent( calendarEvent, Server );
}
/**
* Called when the user clicks OK in the new to do item dialog
*
*/
function addToDoDialogResponse( calendarToDo, Server )
{
gICalLib.addTodo( calendarToDo, Server );
}
/**
* Helper function to launch the event composer to edit an event.
* When the user clicks OK "modifyEventDialogResponse" is called
*/
function editEvent( calendarEvent )
{
// set up a bunch of args to pass to the dialog
var args = new Object();
args.mode = "edit";
args.onOk = self.modifyEventDialogResponse;
args.calendarEvent = calendarEvent;
// open the dialog modally
window.setCursor( "wait" );
openDialog("chrome://calendar/content/calendarEventDialog.xul", "caEditEvent", "chrome,modal", args );
}
/**
* Helper function to launch the event composer to edit an event.
* When the user clicks OK "modifyEventDialogResponse" is called
*/
function editToDo( calendarToDo )
{
// set up a bunch of args to pass to the dialog
var args = new Object();
args.mode = "edit";
args.onOk = self.modifyToDoDialogResponse;
args.calendarToDo = calendarToDo;
window.setCursor( "wait" );
// open the dialog modally
openDialog("chrome://calendar/content/calendarToDoDialog.xul", "caEditToDo", "chrome,modal", args );
}
/**
* Called when the user clicks OK in the edit event dialog
*
* Update the data source, the unifinder views and the calendar views will be
* notified of the change through their respective observers
*/
function modifyEventDialogResponse( calendarEvent, Server )
{
gICalLib.modifyEvent( calendarEvent, Server );
}
/**
* Called when the user clicks OK in the edit event dialog
*
* Update the data source, the unifinder views and the calendar views will be
* notified of the change through their respective observers
*/
function modifyToDoDialogResponse( calendarToDo, Server )
{
gICalLib.modifyTodo( calendarToDo, Server );
}
/**
* This is called from the unifinder's edit command
*/
function editEventCommand()
{
if( gCalendarWindow.EventSelection.selectedEvents.length == 1 )
{
var calendarEvent = gCalendarWindow.EventSelection.selectedEvents[0];
if( calendarEvent != null )
{
editEvent( calendarEvent );
}
}
}
/**
* This is called from the unifinder's delete command
*/
function deleteEventCommand( DoNotConfirm )
{
if( unifinderToDoHasFocus() )
{
deleteToDoCommand( DoNotConfirm );
return;
}
var SelectedItems = gCalendarWindow.EventSelection.selectedEvents;
if( SelectedItems.length == 1 )
{
var calendarEvent = SelectedItems[0];
if ( calendarEvent.title != "" ) {
if( !DoNotConfirm ) {
if ( confirm( confirmDeleteEvent+" "+calendarEvent.title+"?" ) ) {
gICalLib.deleteEvent( calendarEvent.id );
gCalendarWindow.clearSelectedEvent( calendarEvent );
}
}
else
{
gICalLib.deleteEvent( calendarEvent.id );
gCalendarWindow.clearSelectedEvent( calendarEvent );
}
}
else
{
if( !DoNotConfirm ) {
if ( confirm( confirmDeleteUntitledEvent ) ) {
gICalLib.deleteEvent( calendarEvent.id );
gCalendarWindow.clearSelectedEvent( calendarEvent );
}
}
else
{
gICalLib.deleteEvent( calendarEvent.id );
gCalendarWindow.clearSelectedEvent( calendarEvent );
}
}
}
else if( SelectedItems.length > 1 )
{
var NumberOfEventsToDelete = SelectedItems.length;
gICalLib.batchMode = true;
if( !DoNotConfirm )
{
if( confirm( "Are you sure you want to delete all selected events?" ) )
{
gCalendarWindow.clearSelectedEvent( calendarEvent );
while( SelectedItems.length )
{
var ThisItem = SelectedItems.pop();
gICalLib.deleteEvent( ThisItem.id );
}
}
}
else
{
gCalendarWindow.clearSelectedEvent( calendarEvent );
while( SelectedItems.length )
{
var ThisItem = SelectedItems.pop();
gICalLib.deleteEvent( ThisItem.id );
}
}
gICalLib.batchMode = false;
/*
var NumberOfTotalEvents = gCalendarWindow.calendarEvent.getAllEvents().length;
if( NumberOfTotalEvents = NumberOfEventsToDelete )
{
//highlight today's date
gCalendarWindow.currentView.hiliteTodaysDate();
}
*/
}
}
function goFindNewCalendars()
{
//launch the browser to http://www.apple.com/ical/library/
var browserService = penapplication.getService( "org.penzilla.browser" );
if(browserService)
{
browserService.setUrl("http://www.icalshare.com/");
browserService.focusBrowser();
}
}
function displayCalendarVersion()
{
window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", 'chrome://calendar/content/about.html' );
}
function playSound( ThisURL )
{
ThisURL = "chrome://calendar/content/sound.wav";
var url = Components.classes["@mozilla.org/network/standard-url;1"].createInstance();
url = url.QueryInterface(Components.interfaces.nsIURL);
url.spec = ThisURL;
var sample = Components.classes["@mozilla.org/sound;1"].createInstance();
sample = sample.QueryInterface(Components.interfaces.nsISound);
sample.play( url );
}
var gSelectAll = false;
function selectAllEvents()
{
gSelectAll = true;
gCalendarWindow.EventSelection.setArrayToSelection( gCalendarWindow.eventSource.currentEvents );
}
function closeCalendar()
{
self.close();
}
function launchWizard()
{
var args = new Object();
openDialog("chrome://calendar/content/calendarWizard.xul", "caWizard", "chrome,modal", args );
}
/**
* Called when a user hovers over an element and the text for the mouse over is changed.
*/
function getPreviewTextForRepeatingEvent( calendarEventDisplay )
{
showTooltip = true;
var HolderBox = document.createElement( "vbox" );
if (calendarEventDisplay.event.title)
{
var TitleHtml = document.createElement( "description" );
var TitleText = "Title: "+calendarEventDisplay.event.title;
/*
if( calendarEventDisplay.event.recurUnits == "years" )
{
//count the number of years to figure out
TitleText = TitleText+" "+getNumberOfRepeatTimes( calendarEventDisplay.event, false );
}*/
var TitleTextNode = document.createTextNode( TitleText );
TitleHtml.appendChild( TitleTextNode );
HolderBox.appendChild( TitleHtml );
}
var DateHtml = document.createElement( "description" );
var startDate = new Date( calendarEventDisplay.displayDate );
var DateText = document.createTextNode( "Start: "+gCalendarWindow.dateFormater.getFormatedDate( startDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( startDate ) );
DateHtml.appendChild( DateText );
HolderBox.appendChild( DateHtml );
if( calendarEventDisplay.recur == true )
{
var DateHtml = document.createElement( "description" );
var DateText = document.createTextNode( "This is a repeating event." );
DateHtml.appendChild( DateText );
HolderBox.appendChild( DateHtml );
}
else
{
var DateHtml = document.createElement( "description" );
var startDate = new Date( calendarEventDisplay.event.end.getTime() );
var DateText = document.createTextNode( "End: "+gCalendarWindow.dateFormater.getFormatedDate( startDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( startDate ) );
DateHtml.appendChild( DateText );
HolderBox.appendChild( DateHtml );
}
if (calendarEventDisplay.event.description)
{
var DescriptionHtml = document.createElement( "description" );
var DescriptionText = document.createTextNode( "Description: "+calendarEventDisplay.event.description );
DescriptionHtml.appendChild( DescriptionText );
HolderBox.appendChild( DescriptionHtml );
}
return ( HolderBox );
}
function getNumberOfRepeatTimes( Event, DateToCompare )
{
if( !DateToCompare )
{
DateToCompare = new Date();
}
var startDate = new Date( Event.start.getTime() );
//get the difference in the number of years from now.
var NumberOfYears = DateToCompare.getFullYear() - startDate.getFullYear();
//find out if the event has happened this year or not.
//add on the proper extension.
return( NumberOfYears );
}
function reloadApplication()
{
gCalendarWindow.eventSource.calendarManager.refreshAllRemoteCalendars();
}
/** PUBLIC
*
* Print events using a stylesheet.
* Mostly Hack to get going, Should probably be rewritten later when stylesheets are available
*/
function printEventArray( calendarEventArray, stylesheetName )
{
var xslProcessor = new XSLTProcessor();
var domParser = new DOMParser;
var xcsDocument = getXcsDocument( calendarEventArray );
printWindow = window.open( "", "CalendarPrintWindow");
if( printWindow )
{
// if only passsed a filename, assume it is a file in the default directory
if( stylesheetName.indexOf( ":" ) == -1 )
stylesheetName = convertersDirectory + stylesheetName;
var stylesheetUrl = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
stylesheetUrl.spec = convertersDirectory;
domParser.baseURI = stylesheetUrl;
var xslContent = loadFile( stylesheetName );
var xslDocument = domParser.parseFromString(xslContent, 'text/xml');
// hack, might be cleaner to assing xml document directly to printWindow.document
// var elementNode = xcsDocument.documentElement;
// result.appendChild(elementNode); // doesn't work
xslProcessor.transformDocument(xcsDocument, xslDocument, printWindow.document, null);
printWindow.locationbar.visible = false;
printWindow.personalbar.visible = false;
printWindow.statusbar.visible = false;
printWindow.toolbar.visible = false;
printWindow.print();
printWindow.close();
}
}
function print()
{
printEventArray( gCalendarWindow.EventSelection.selectedEvents, "chrome://calendar/content/converters/sortEvents.xsl" );
}
function publishCalendarData()
{
var args = new Object();
args.onOk = self.publishCalendarDataDialogResponse;
openDialog("chrome://calendar/content/calendarPublishDialog.xul", "caPublishEvents", "chrome,modal", args );
}
function publishCalendarDataDialogResponse( CalendarPublishObject )
{
var calendarString = eventArrayToICalString( gCalendarWindow.EventSelection.selectedEvents );
calendarPublish(calendarString, CalendarPublishObject.url, CalendarPublishObject.remotePath, CalendarPublishObject.username, CalendarPublishObject.password, "text/calendar");
}
/*
** A little function to see if we can show the tooltip
*/
function checkTooltip( event )
{
//returns true if you can show the tooltip
//or false if the tooltip should not be shown
return( showTooltip );
}
function getCharPref (prefObj, prefName, defaultValue)
{
try
{
return prefObj.getCharPref (prefName);
}
catch (e)
{
prefObj.setCharPref( prefName, defaultValue );
return defaultValue;
}
}
function getIntPref (prefObj, prefName, defaultValue)
{
try
{
return prefObj.getIntPref (prefName);
}
catch (e)
{
prefObj.setIntPref( prefName, defaultValue );
return defaultValue;
}
}
function getBoolPref (prefObj, prefName, defaultValue)
{
try
{
return prefObj.getBoolPref (prefName);
}
catch (e)
{
prefObj.setBoolPref( prefName, defaultValue );
return defaultValue;
}
}
function GetUnicharPref(prefObj, prefName, defaultValue)
{
try {
return prefObj.getComplexValue(prefName, Components.interfaces.nsISupportsString).data;
}
catch(e)
{
return defaultValue;
}
}
function SetUnicharPref(aPrefObj, aPrefName, aPrefValue)
{
try {
var str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
str.data = aPrefValue;
aPrefObj.setComplexValue(aPrefName, Components.interfaces.nsISupportsString, str);
}
catch(e) {}
}