2002-04-08 19:32:23 +04:00
|
|
|
/* ***** 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>
|
|
|
|
* Chris Charabaruk <coldacid@meldstar.com>
|
|
|
|
* Colin Phillips <colinp@oeone.com>
|
2002-07-31 19:02:35 +04:00
|
|
|
* ArentJan Banck <ajbanck@planet.nl>
|
2002-04-08 19:32:23 +04:00
|
|
|
*
|
|
|
|
* 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 ***** */
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
* U N I F I N D E R
|
|
|
|
*
|
|
|
|
* This is a hacked in interface to the unifinder. We will need to
|
|
|
|
* improve this to make it usable in general.
|
|
|
|
*/
|
2002-06-19 19:00:38 +04:00
|
|
|
const UnifinderTreeName = "unifinder-search-results-listbox";
|
|
|
|
|
2002-05-06 23:11:19 +04:00
|
|
|
function calendarUnifinderInit( )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
|
|
|
var unifinderEventSelectionObserver =
|
|
|
|
{
|
|
|
|
onSelectionChanged : function( EventSelectionArray )
|
|
|
|
{
|
2002-08-26 19:20:53 +04:00
|
|
|
var SearchTree = document.getElementById( "unifinder-search-results-listbox" );
|
2002-08-28 00:06:09 +04:00
|
|
|
|
2002-08-26 19:20:53 +04:00
|
|
|
SearchTree.setAttribute( "suppressonselect", "true" );
|
|
|
|
|
|
|
|
SearchTree.treeBoxObject.selection.select( -1 );
|
|
|
|
|
|
|
|
if( EventSelectionArray.length > 0 )
|
|
|
|
{
|
|
|
|
for( i = 0; i < EventSelectionArray.length; i++ )
|
|
|
|
{
|
|
|
|
var SearchTreeItem = document.getElementById( "search-unifinder-treeitem-"+EventSelectionArray[i].id );
|
|
|
|
|
|
|
|
if( SearchTreeItem )
|
|
|
|
{
|
|
|
|
var Index = SearchTree.contentView.getIndexOfItem( SearchTreeItem );
|
|
|
|
|
|
|
|
SearchTree.treeBoxObject.ensureRowIsVisible( Index );
|
|
|
|
|
|
|
|
SearchTree.treeBoxObject.selection.select( Index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gCalendarWindow.EventSelection.addObserver( unifinderEventSelectionObserver );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Observer for the calendar event data source. This keeps the unifinder
|
|
|
|
* display up to date when the calendar event data is changed
|
|
|
|
*/
|
|
|
|
|
|
|
|
var unifinderEventDataSourceObserver =
|
|
|
|
{
|
|
|
|
onLoad : function()
|
|
|
|
{
|
2002-05-06 23:11:19 +04:00
|
|
|
if( !gICalLib.batchMode )
|
|
|
|
{
|
2002-08-27 16:34:47 +04:00
|
|
|
unifinderRefresh();
|
2002-05-06 23:11:19 +04:00
|
|
|
}
|
2002-04-08 19:32:23 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onStartBatch : function()
|
|
|
|
{
|
|
|
|
},
|
|
|
|
|
|
|
|
onEndBatch : function()
|
|
|
|
{
|
2002-08-27 16:34:47 +04:00
|
|
|
unifinderRefresh();
|
2002-04-08 19:32:23 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onAddItem : function( calendarEvent )
|
|
|
|
{
|
2002-05-06 23:11:19 +04:00
|
|
|
if( !gICalLib.batchMode )
|
|
|
|
{
|
|
|
|
if( calendarEvent )
|
|
|
|
{
|
2002-08-27 16:34:47 +04:00
|
|
|
unifinderRefresh();
|
2002-05-06 23:11:19 +04:00
|
|
|
}
|
|
|
|
}
|
2002-04-08 19:32:23 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onModifyItem : function( calendarEvent, originalEvent )
|
|
|
|
{
|
2002-05-06 23:11:19 +04:00
|
|
|
if( !gICalLib.batchMode )
|
|
|
|
{
|
2002-08-27 16:34:47 +04:00
|
|
|
unifinderRefresh();
|
2002-05-06 23:11:19 +04:00
|
|
|
}
|
2002-04-08 19:32:23 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onDeleteItem : function( calendarEvent )
|
|
|
|
{
|
2002-05-06 23:11:19 +04:00
|
|
|
if( !gICalLib.batchMode )
|
|
|
|
{
|
2002-08-27 16:34:47 +04:00
|
|
|
unifinderRefresh();
|
2002-05-06 23:11:19 +04:00
|
|
|
}
|
2002-04-08 19:32:23 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onAlarm : function( calendarEvent )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-08-23 22:13:04 +04:00
|
|
|
|
2002-04-08 19:32:23 +04:00
|
|
|
/**
|
|
|
|
* Called when the calendar is loaded
|
|
|
|
*/
|
|
|
|
|
2002-05-06 23:11:19 +04:00
|
|
|
function prepareCalendarUnifinder( )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
|
|
|
// tell the unifinder to get ready
|
2002-05-06 23:11:19 +04:00
|
|
|
calendarUnifinderInit( );
|
2002-04-08 19:32:23 +04:00
|
|
|
// set up our calendar event observer
|
|
|
|
|
|
|
|
gICalLib.addObserver( unifinderEventDataSourceObserver );
|
|
|
|
}
|
|
|
|
|
2002-05-06 23:35:15 +04:00
|
|
|
/**
|
|
|
|
* Called when the calendar is unloaded
|
|
|
|
*/
|
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
function finishCalendarUnifinder( )
|
2002-05-06 23:35:15 +04:00
|
|
|
{
|
|
|
|
gICalLib.removeObserver( unifinderEventDataSourceObserver );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-08 19:32:23 +04:00
|
|
|
/**
|
|
|
|
* Helper function to display event dates in the unifinder
|
|
|
|
*/
|
|
|
|
|
|
|
|
function formatUnifinderEventDate( date )
|
|
|
|
{
|
2002-04-09 00:41:42 +04:00
|
|
|
return( gCalendarWindow.dateFormater.getFormatedDate( date ) );
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to display event times in the unifinder
|
|
|
|
*/
|
|
|
|
|
|
|
|
function formatUnifinderEventTime( time )
|
|
|
|
{
|
2002-06-19 19:00:38 +04:00
|
|
|
return( gCalendarWindow.dateFormater.getFormatedTime( time ) );
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by event observers to update the display
|
|
|
|
*/
|
|
|
|
|
2002-08-27 16:34:47 +04:00
|
|
|
function unifinderRefresh()
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-08-23 00:15:15 +04:00
|
|
|
//gEventSource.onlyFutureEvents = (document.getElementById( 'unifinder-future-events' ).getAttribute( "checked" ) == "true" );
|
|
|
|
eventTable = gEventSource.getCurrentEvents();
|
|
|
|
|
|
|
|
gEventSource.onlyFutureEvents = false;
|
2002-05-21 21:13:16 +04:00
|
|
|
|
2002-04-08 19:32:23 +04:00
|
|
|
unifinderSearchKeyPress( document.getElementById( 'unifinder-search-field' ), null );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is attached to the ondblclik attribute of the events shown in the unifinder
|
|
|
|
*/
|
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
function unifinderDoubleClickEvent( event )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
|
|
|
// find event by id
|
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
var calendarEvent = getCalendarEventFromEvent( event );
|
2002-04-08 19:32:23 +04:00
|
|
|
|
|
|
|
if( calendarEvent != null )
|
|
|
|
{
|
|
|
|
// go to day view, of the day of the event, select the event
|
|
|
|
|
|
|
|
editEvent( calendarEvent );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
function getCalendarEventFromEvent( event )
|
|
|
|
{
|
|
|
|
var tree = document.getElementById( UnifinderTreeName );
|
|
|
|
var row = new Object();
|
|
|
|
|
|
|
|
tree.treeBoxObject.getCellAt( event.clientX, event.clientY, row, {}, {} );
|
|
|
|
|
|
|
|
if( row.value != -1 && row.value < tree.view.rowCount )
|
|
|
|
{
|
|
|
|
var treeitem = tree.treeBoxObject.view.getItemAtIndex( row.value );
|
|
|
|
var eventId = treeitem.getAttribute("eventId");
|
|
|
|
return gICalLib.fetchEvent( eventId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:20:53 +04:00
|
|
|
/**
|
|
|
|
* This is attached to the onclik attribute of the events shown in the unifinder
|
|
|
|
*/
|
|
|
|
|
|
|
|
function unifinderClickEvent( event )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-08-23 00:15:15 +04:00
|
|
|
var tree = document.getElementById( UnifinderTreeName );
|
2002-08-26 19:20:53 +04:00
|
|
|
var ThisEvent = getCalendarEventFromEvent( event );
|
|
|
|
var ArrayOfEvents = new Array( ThisEvent );
|
2002-04-08 19:32:23 +04:00
|
|
|
|
|
|
|
gCalendarWindow.EventSelection.setArrayToSelection( ArrayOfEvents );
|
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
if( ArrayOfEvents.length == 1 )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-06-19 19:00:38 +04:00
|
|
|
/*start date is either the next or last occurence, or the start date of the event */
|
2002-08-23 00:15:15 +04:00
|
|
|
var eventStartDate = getNextOrPreviousRecurrence( ThisEvent );
|
2002-05-13 23:25:20 +04:00
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
/* you need this in case the current day is not visible. */
|
2002-05-13 23:25:20 +04:00
|
|
|
gCalendarWindow.currentView.goToDay( eventStartDate, true);
|
2002-06-19 19:00:38 +04:00
|
|
|
}
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2002-04-09 00:29:01 +04:00
|
|
|
* This is called from the unifinder's edit command
|
2002-04-08 19:32:23 +04:00
|
|
|
*/
|
|
|
|
|
2002-04-09 00:29:01 +04:00
|
|
|
function unifinderEditCommand()
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-08-23 00:15:15 +04:00
|
|
|
if( gCalendarWindow.EventSelection.selectedEvents.length == 1 )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-08-23 00:15:15 +04:00
|
|
|
var calendarEvent = gCalendarWindow.EventSelection.selectedEvents[0];
|
2002-04-08 19:32:23 +04:00
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
if( calendarEvent != null )
|
|
|
|
{
|
|
|
|
editEvent( calendarEvent );
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-04-09 00:29:01 +04:00
|
|
|
* This is called from the unifinder's delete command
|
2002-04-08 19:32:23 +04:00
|
|
|
*/
|
|
|
|
|
2002-04-09 00:29:01 +04:00
|
|
|
function unifinderDeleteCommand( DoNotConfirm )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-07-31 19:02:35 +04:00
|
|
|
if( unifinderToDoHasFocus() )
|
|
|
|
{
|
|
|
|
unifinderDeleteToDoCommand( DoNotConfirm );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-08 19:32:23 +04:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gICalLib.deleteEvent( calendarEvent.id );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !DoNotConfirm ) {
|
|
|
|
if ( confirm( confirmDeleteUntitledEvent ) ) {
|
|
|
|
gICalLib.deleteEvent( calendarEvent.id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gICalLib.deleteEvent( calendarEvent.id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( SelectedItems.length > 1 )
|
|
|
|
{
|
|
|
|
if( !DoNotConfirm )
|
|
|
|
{
|
|
|
|
if( confirm( "Are you sure you want to delete everything?" ) )
|
|
|
|
{
|
|
|
|
while( SelectedItems.length )
|
|
|
|
{
|
|
|
|
var ThisItem = SelectedItems.pop();
|
|
|
|
|
|
|
|
gICalLib.deleteEvent( ThisItem.id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while( SelectedItems.length )
|
|
|
|
{
|
|
|
|
var ThisItem = SelectedItems.pop();
|
|
|
|
|
|
|
|
gICalLib.deleteEvent( ThisItem.id );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called from the unifinder when a key is pressed in the search field
|
|
|
|
*/
|
2002-07-09 17:55:30 +04:00
|
|
|
var gSearchTimeout = null;
|
2002-04-08 19:32:23 +04:00
|
|
|
|
|
|
|
function unifinderSearchKeyPress( searchTextItem, event )
|
2002-07-09 17:55:30 +04:00
|
|
|
{
|
2002-07-11 18:00:37 +04:00
|
|
|
// 13 == return
|
|
|
|
if (event && event.keyCode == 13)
|
|
|
|
{
|
|
|
|
clearSearchTimer();
|
|
|
|
doSearch();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// always clear the old one first
|
2002-07-09 17:55:30 +04:00
|
|
|
|
|
|
|
clearSearchTimer();
|
|
|
|
|
|
|
|
// make a new timer
|
|
|
|
|
|
|
|
gSearchTimeout = setTimeout( "doSearch()", 400 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearSearchTimer( )
|
|
|
|
{
|
|
|
|
if( gSearchTimeout )
|
|
|
|
{
|
|
|
|
clearTimeout( gSearchTimeout );
|
|
|
|
gSearchTimeout = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function doSearch( )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-06-19 19:00:38 +04:00
|
|
|
var eventTable = new Array();
|
|
|
|
|
2002-07-09 17:55:30 +04:00
|
|
|
var searchText = document.getElementById( "unifinder-search-field" ).value;
|
2002-04-08 19:32:23 +04:00
|
|
|
|
2002-07-09 17:55:30 +04:00
|
|
|
if ( searchText == '' )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-06-19 19:00:38 +04:00
|
|
|
eventTable = gEventSource.getCurrentEvents();
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
2002-07-09 17:55:30 +04:00
|
|
|
else if ( searchText == " " )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
2002-07-24 17:19:34 +04:00
|
|
|
searchText = "";
|
|
|
|
document.getElementById( "unifinder-search-field" ).value = '';
|
2002-08-20 18:24:17 +04:00
|
|
|
return;
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-20 18:24:17 +04:00
|
|
|
var FieldsToSearch = new Array( "title", "description", "location", "categories" );
|
2002-06-19 19:00:38 +04:00
|
|
|
eventTable = gEventSource.search( searchText, FieldsToSearch );
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
2002-05-13 23:25:20 +04:00
|
|
|
|
2002-07-02 21:07:38 +04:00
|
|
|
if( document.getElementById( "erase_command" ) )
|
2002-05-13 23:25:20 +04:00
|
|
|
{
|
|
|
|
if( searchText.length <= 0 )
|
2002-07-02 21:07:38 +04:00
|
|
|
document.getElementById( "erase_command" ).setAttribute( "disabled", "true" );
|
2002-05-13 23:25:20 +04:00
|
|
|
else
|
2002-07-02 21:07:38 +04:00
|
|
|
document.getElementById( "erase_command" ).removeAttribute( "disabled" );
|
2002-05-13 23:25:20 +04:00
|
|
|
}
|
2002-06-19 19:00:38 +04:00
|
|
|
refreshEventTree( eventTable );
|
2002-04-08 19:32:23 +04:00
|
|
|
}
|
|
|
|
|
2002-04-12 19:38:39 +04:00
|
|
|
|
|
|
|
function unifinderShowEventsWithAlarmsOnly()
|
|
|
|
{
|
2002-06-19 19:00:38 +04:00
|
|
|
var eventTable = gEventSource.getEventsWithAlarms();
|
2002-04-12 19:38:39 +04:00
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
refreshEventTree( eventTable );
|
2002-04-12 19:38:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function unifinderShowFutureEventsOnly( event )
|
|
|
|
{
|
2002-08-23 00:15:15 +04:00
|
|
|
var Today = new Date();
|
|
|
|
//do this to allow all day events to show up all day long
|
|
|
|
var StartDate = new Date( Today.getFullYear(), Today.getMonth(), Today.getDate(), 0, 0, 0 );
|
|
|
|
|
|
|
|
switch( event.currentTarget.parentNode.selectedItem.value )
|
|
|
|
{
|
|
|
|
case "all":
|
|
|
|
gEventSource.onlyFutureEvents = false;
|
|
|
|
eventTable = gEventSource.getCurrentEvents();
|
|
|
|
break;
|
2002-04-12 19:38:39 +04:00
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
case "today":
|
|
|
|
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 ) - 1 );
|
|
|
|
eventTable = gEventSource.getEventsForRange( StartDate, EndDate );
|
|
|
|
break;
|
|
|
|
case "week":
|
|
|
|
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 8 ) );
|
|
|
|
eventTable = gEventSource.getEventsForRange( StartDate, EndDate );
|
|
|
|
break;
|
|
|
|
case "2weeks":
|
|
|
|
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 15 ) );
|
|
|
|
eventTable = gEventSource.getEventsForRange( StartDate, EndDate );
|
|
|
|
break;
|
|
|
|
case "month":
|
|
|
|
var EndDate = new Date( StartDate.getTime() + ( 1000 * 60 * 60 * 24 * 32 ) );
|
|
|
|
eventTable = gEventSource.getEventsForRange( StartDate, EndDate );
|
|
|
|
break;
|
|
|
|
case "future":
|
|
|
|
gEventSource.onlyFutureEvents = true;
|
|
|
|
eventTable = gEventSource.getCurrentEvents();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
alert( "there's no case for ".event.currentTarget.selectedItem.value );
|
|
|
|
break;
|
|
|
|
}
|
2002-04-12 19:38:39 +04:00
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
refreshEventTree( eventTable );
|
|
|
|
|
2002-07-31 19:02:35 +04:00
|
|
|
/* The following isn't exactly right. It should actually reload after the next event happens. */
|
2002-05-13 23:25:20 +04:00
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
setTimeout( "refreshEventTree( eventTable )", milliSecsTillTomorrow );
|
2002-04-12 19:38:39 +04:00
|
|
|
}
|
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
/**
|
|
|
|
* Attach the calendarToDo event to the treeitem
|
|
|
|
*/
|
|
|
|
|
|
|
|
function setUnifinderEventTreeItem( treeItem, calendarEvent )
|
|
|
|
{
|
|
|
|
treeItem.calendarEvent = calendarEvent;
|
|
|
|
treeItem.setAttribute( "eventId", calendarEvent.id );
|
|
|
|
treeItem.setAttribute( "onmouseover", "changeToolTipTextForEvent( event )" );
|
|
|
|
treeItem.setAttribute( "ondblclick" , "unifinderDoubleClickEvent(event)" );
|
2002-08-26 19:20:53 +04:00
|
|
|
treeItem.setAttribute( "onclick" , "unifinderClickEvent(event)" );
|
2002-08-23 00:15:15 +04:00
|
|
|
treeItem.setAttribute( "calendarevent", "true" );
|
|
|
|
treeItem.setAttribute( "id", "search-unifinder-treeitem-"+calendarEvent.id );
|
|
|
|
|
|
|
|
var treeRow = document.createElement( "treerow" );
|
|
|
|
var treeCellTitle = document.createElement( "treecell" );
|
|
|
|
var treeCellStartdate = document.createElement( "treecell" );
|
|
|
|
var treeCellEnddate = document.createElement( "treecell" );
|
|
|
|
var treeCellCategories = document.createElement( "treecell" );
|
|
|
|
|
|
|
|
var now = new Date();
|
|
|
|
|
|
|
|
var thisMorning = new Date( now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0 );
|
|
|
|
|
|
|
|
if(treeItem.getElementsByTagName( "treerow" )[0])
|
|
|
|
treeItem.removeChild( treeItem.getElementsByTagName( "treerow" )[0] );
|
|
|
|
|
|
|
|
if( calendarEvent.title == "" )
|
|
|
|
var titleText = "Untitled";
|
|
|
|
else
|
|
|
|
var titleText = calendarEvent.title;
|
|
|
|
|
|
|
|
treeCellTitle.setAttribute( "label", titleText );
|
|
|
|
|
|
|
|
var eventStartDate = getNextOrPreviousRecurrence( calendarEvent );
|
|
|
|
var eventEndDate = new Date( calendarEvent.end.getTime() );
|
|
|
|
var startDate = formatUnifinderEventDate( eventStartDate );
|
|
|
|
var startTime = formatUnifinderEventTime( eventStartDate );
|
|
|
|
var endTime = formatUnifinderEventTime( eventEndDate );
|
|
|
|
|
|
|
|
if( calendarEvent.allDay )
|
|
|
|
{
|
|
|
|
startText = "All day " + startDate;
|
|
|
|
endText = "All day " + startDate;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
startText = startDate + " " + startTime;
|
|
|
|
endText = startDate + " " + endTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
treeCellStartdate.setAttribute( "label", startText );
|
|
|
|
treeCellEnddate.setAttribute( "label", endText );
|
|
|
|
treeCellCategories.setAttribute( "label", calendarEvent.categories );
|
|
|
|
|
|
|
|
treeRow.appendChild( treeCellTitle );
|
|
|
|
treeRow.appendChild( treeCellStartdate );
|
|
|
|
treeRow.appendChild( treeCellEnddate );
|
|
|
|
treeRow.appendChild( treeCellCategories );
|
|
|
|
treeItem.appendChild( treeRow );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-08 19:32:23 +04:00
|
|
|
/**
|
|
|
|
* Redraw the categories unifinder tree
|
|
|
|
*/
|
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
function refreshEventTree( eventArray )
|
2002-04-08 19:32:23 +04:00
|
|
|
{
|
|
|
|
// get the old tree children item and remove it
|
2002-05-13 23:25:20 +04:00
|
|
|
|
2002-08-23 00:15:15 +04:00
|
|
|
var tree = document.getElementById( UnifinderTreeName );
|
|
|
|
|
|
|
|
var elementsToRemove = document.getElementsByAttribute( "calendarevent", "true" );
|
|
|
|
|
|
|
|
for( var i = 0; i < elementsToRemove.length; i++ )
|
|
|
|
{
|
|
|
|
elementsToRemove[i].parentNode.removeChild( elementsToRemove[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// add: tree item, row, cell, box and text items for every event
|
|
|
|
for( var index = 0; index < eventArray.length; ++index )
|
|
|
|
{
|
|
|
|
var calendarEvent = eventArray[ index ];
|
|
|
|
|
|
|
|
// make the items
|
|
|
|
|
|
|
|
var treeItem = document.createElement( "treeitem" );
|
|
|
|
|
|
|
|
setUnifinderEventTreeItem( treeItem, calendarEvent );
|
|
|
|
|
|
|
|
tree.getElementsByTagName( "treechildren" )[0]. appendChild( treeItem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-13 23:25:20 +04:00
|
|
|
function unifinderClearSearchCommand()
|
|
|
|
{
|
|
|
|
document.getElementById( "unifinder-search-field" ).value = "";
|
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
var eventTable = gEventSource.getCurrentEvents();
|
2002-05-13 23:25:20 +04:00
|
|
|
|
2002-06-19 19:00:38 +04:00
|
|
|
refreshEventTree( eventTable );
|
2002-05-13 23:25:20 +04:00
|
|
|
}
|
|
|
|
|
2002-08-16 21:41:09 +04:00
|
|
|
function focusFirstItemIfNoSelection()
|
|
|
|
{
|
|
|
|
if( gCalendarWindow.EventSelection.selectedEvents.length == 0 )
|
|
|
|
{
|
|
|
|
//select the first event in the list.
|
|
|
|
var ListBox = document.getElementById( "unifinder-search-results-listbox" );
|
|
|
|
|
|
|
|
if( ListBox.childNodes.length > 0 )
|
|
|
|
{
|
|
|
|
var SelectedEvent = ListBox.childNodes[0].event;
|
|
|
|
|
|
|
|
var ArrayOfEvents = new Array();
|
|
|
|
|
|
|
|
ArrayOfEvents[ ArrayOfEvents.length ] = SelectedEvent;
|
|
|
|
|
|
|
|
gCalendarWindow.EventSelection.setArrayToSelection( ArrayOfEvents );
|
|
|
|
|
|
|
|
/*start date is either the next or last occurence, or the start date of the event */
|
|
|
|
var eventStartDate = getNextOrPreviousRecurrence( SelectedEvent );
|
|
|
|
|
|
|
|
/* you need this in case the current day is not visible. */
|
|
|
|
gCalendarWindow.currentView.goToDay( eventStartDate, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-13 23:25:20 +04:00
|
|
|
|
|
|
|
function getNextOrPreviousRecurrence( calendarEvent )
|
|
|
|
{
|
|
|
|
if( calendarEvent.recur )
|
|
|
|
{
|
|
|
|
var now = new Date();
|
|
|
|
|
|
|
|
var result = new Object();
|
|
|
|
|
|
|
|
var isValid = calendarEvent.getNextRecurrence( now.getTime(), result );
|
|
|
|
|
|
|
|
if( isValid )
|
|
|
|
{
|
|
|
|
var eventStartDate = new Date( result.value );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
isValid = calendarEvent.getPreviousOccurrence( now.getTime(), result );
|
|
|
|
|
|
|
|
var eventStartDate = new Date( result.value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !isValid || !calendarEvent.recur )
|
|
|
|
{
|
|
|
|
var eventStartDate = new Date( calendarEvent.start.getTime() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return eventStartDate;
|
|
|
|
}
|
2002-08-28 00:06:09 +04:00
|
|
|
|
|
|
|
|
|
|
|
function changeToolTipTextForEvent( event )
|
|
|
|
{
|
|
|
|
var thisEvent = getCalendarEventFromEvent( event );
|
|
|
|
|
|
|
|
var Html = document.getElementById( "savetip" );
|
|
|
|
|
|
|
|
while( Html.hasChildNodes() )
|
|
|
|
{
|
|
|
|
Html.removeChild( Html.firstChild );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !thisEvent )
|
|
|
|
{
|
|
|
|
showTooltip = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
showTooltip = true;
|
|
|
|
|
|
|
|
var HolderBox = getPreviewText( thisEvent );
|
|
|
|
|
|
|
|
Html.appendChild( HolderBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPreviewText( calendarEvent )
|
|
|
|
{
|
|
|
|
var HolderBox = document.createElement( "vbox" );
|
|
|
|
|
|
|
|
if (calendarEvent.title)
|
|
|
|
{
|
|
|
|
var TitleHtml = document.createElement( "description" );
|
|
|
|
var TitleText = document.createTextNode( "Title: "+calendarEvent.title );
|
|
|
|
TitleHtml.appendChild( TitleText );
|
|
|
|
HolderBox.appendChild( TitleHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
var DateHtml = document.createElement( "description" );
|
|
|
|
var startDate = new Date( calendarEvent.start.getTime() );
|
|
|
|
var DateText = document.createTextNode( "Start: "+gCalendarWindow.dateFormater.getFormatedDate( startDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( startDate ) );
|
|
|
|
DateHtml.appendChild( DateText );
|
|
|
|
HolderBox.appendChild( DateHtml );
|
|
|
|
|
|
|
|
DateHtml = document.createElement( "description" );
|
|
|
|
var endDate = new Date( calendarEvent.end.getTime() );
|
|
|
|
DateText = document.createTextNode( "End: "+gCalendarWindow.dateFormater.getFormatedDate( endDate )+" "+gCalendarWindow.dateFormater.getFormatedTime( endDate ) );
|
|
|
|
DateHtml.appendChild( DateText );
|
|
|
|
HolderBox.appendChild( DateHtml );
|
|
|
|
|
|
|
|
if (calendarEvent.description)
|
|
|
|
{
|
|
|
|
var DescriptionHtml = document.createElement( "description" );
|
|
|
|
var DescriptionText = document.createTextNode( "Description: "+calendarEvent.description );
|
|
|
|
DescriptionHtml.appendChild( DescriptionText );
|
|
|
|
HolderBox.appendChild( DescriptionHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ( HolderBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
|