Fixing bug 158510, patch number 96466.

git-svn-id: svn://10.0.0.236/trunk@127956 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mikep%oeone.com
2002-08-23 17:14:36 +00:00
parent 1bbadbfbc5
commit e336223fa6
8 changed files with 278 additions and 205 deletions

View File

@@ -410,8 +410,8 @@
</menupopup>
</menulist>
</box>
<tree tooltip="savetip" id="unifinder-search-results-listbox" flex="1" seltype="multiple" enableColumnDrag="false">
<!-- leave the following line as onclick, don't change it to onselect, we take care of our own selection -->
<tree tooltip="savetip" id="unifinder-search-results-listbox" onclick="unifinderOnSelect()" flex="1" enableColumnDrag="false">
<treecols id="unifinder-search-results-tree-cols">
<treecol id="unifinder-search-results-tree-col-title"
persist="hidden ordinal width" flex="1"

View File

@@ -137,7 +137,7 @@ function cutToClipboard( /* calendarEventArray */)
function copyToClipboard( calendarEventArray )
{
if( !calendarEventArray)
var calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;
calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;
if(calendarEventArray.length == 0)
alert("No events selected");
@@ -182,6 +182,7 @@ function copyToClipboard( calendarEventArray )
return true;
}
}
return false;
}
@@ -218,9 +219,9 @@ function pasteFromClipboard()
trans.getAnyTransferData(flavour, data, length);
data = data.value.QueryInterface(Components.interfaces.nsISupportsWString).data;
//DEBUG alert("clipboard type: " + flavour.value);
var calendarEventArray;
switch (flavour.value) {
case "text/calendar":
var calendarEventArray;
calendarEventArray = parseIcalData( data );
//change the date of all the events to now
@@ -237,7 +238,7 @@ function pasteFromClipboard()
addEventsToCalendar( calendarEventArray );
break;
case "text/unicode":
if ( data.indexOf("BEGIN:VEVENT") == -1 )
if ( data.indexOf("BEGIN:VCALENDAR") == -1 )
{
// no iCalendar data, paste clipboard text into description of new event
calendarEvent = createEvent();
@@ -247,7 +248,6 @@ function pasteFromClipboard()
}
else
{
var calendarEventArray;
calendarEventArray = parseIcalData( data );
//change the date of all the events to now
var startDate = gCalendarWindow.currentView.getNewEventDate();

View File

@@ -289,6 +289,15 @@
</menupopup>
</menulist>
</row>
<!-- Cancelled -->
<row align="center">
<spacer />
<checkbox id="cancelled-checkbox" checked="false" label="&newevent.cancelled.label;"/>
</row>
</rows>
</grid>
</tabpanel>

View File

@@ -124,7 +124,7 @@ function loadEventsFromFile()
var buttonPressed =
promptService.confirmEx(window,
"Import", "About to import " + calendarEventArray.length + " event(s). Do you want to open all events to import before importing?",
"Import", "About to import " + calendarEventArray.length + " item(s). Do you want to open all items to import before importing?",
(promptService.BUTTON_TITLE_YES * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_NO * promptService.BUTTON_POS_1) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_2),
@@ -169,29 +169,69 @@ function createUniqueID()
function addEventsToCalendar( calendarEventArray, silent )
{
var defaultServer = gCalendarWindow.calendarManager.calendars[0];
for(var i = 0; i < calendarEventArray.length; i++)
{
calendarEvent = calendarEventArray[i]
if( isEvent( calendarEventArray[i] ) )
{
var calendarEvent = calendarEventArray[i];
// Check if event with same ID already in Calendar. If so, import event with new ID.
if( gICalLib.fetchEvent( calendarEvent.id ) != null ) {
calendarEvent.id = createUniqueID( );
// Check if event with same ID already in Calendar. If so, import event with new ID.
if( gICalLib.fetchEvent( calendarEvent.id ) != null ) {
calendarEvent.id = createUniqueID( );
}
// the start time is in zulu time, need to convert to current time
if(calendarEvent.allDay != true)
convertZuluToLocal( calendarEvent );
// open the event dialog with the event to add
if( silent )
gICalLib.addEvent( calendarEvent, defaultServer.path );
else
editNewEvent( calendarEvent );
}
else if( isToDo( calendarEventArray[i] ) )
{
//
calendarTodo = calendarEventArray[i];
// Check if task with same ID already in Calendar. If so, import task with new ID.
if( gICalLib.fetchTodo( calendarTodo.id ) != null ) {
calendarTodo.id = createUniqueID( );
}
// open the todo dialog with the task to add
if( silent ){alert(defaultServer.path);
gICalLib.addTodo( calendarTodo, defaultServer.path );}
else
gICalLib.addTodo( calendarTodo, defaultServer.path );
// XXX TODO: add support to add todo using dialog
// editToDo( calendarTodo );
}
// the start time is in zulu time, need to convert to current time
if(calendarEvent.allDay != true)
convertZuluToLocal( calendarEvent );
// open the event dialog with the event to add
if( silent )
gICalLib.addEvent( calendarEvent );
else
editNewEvent( calendarEvent );
}
}
const ZULU_OFFSET_MILLIS = new Date().getTimezoneOffset() * 60 * 1000;
function convertToUTC( aLocalTime )
{
if( calendarEvent.start.utc == false )
{
aLocalTime.setTime( aLocalTime.getTime() + ZULU_OFFSET_MILLIS );
aLocalTime.utc = true;
}
}
function convertFromUTC( aUtcTime )
{
if( aUtcTime.utc == true )
{
aUtcTime.setTime( aUtcTime.getTime() - ZULU_OFFSET_MILLIS );
aUtcTime.utc = false;
}
}
function convertZuluToLocal( calendarEvent )
{
if( calendarEvent.start.utc == true )
@@ -278,19 +318,20 @@ function initCalendarEvent( calendarEvent )
* Parses those events and returns an array of calendarEvents.
*/
function parseIcalData( icalStr )
function parseIcalData( icalendarString )
{
var calendarEventArray = new Array();
var i,j;
var icalStr = icalendarString;
while( icalStr.indexOf("BEGIN:VEVENT") != -1 )
{
// try to find the begin and end of an event. ParseIcalString does not support VCALENDAR
i = icalStr.indexOf("BEGIN:VEVENT");
j = icalStr.indexOf("END:VEVENT") + 10;
eventData = icalStr.substring(i, j);
var eventData = icalStr.substring(i, j);
calendarEvent = createEvent();
var calendarEvent = createEvent();
// if parsing import iCalendar failed, add date as description
if ( !calendarEvent.parseIcalString(eventData) )
@@ -306,7 +347,29 @@ function parseIcalData( icalStr )
// remove the parsed VEVENT from the calendar data to parse
icalStr = icalStr.substring(j+1);
}
icalStr = icalendarString;
while( icalStr.indexOf("BEGIN:VTODO") != -1 )
{
// try to find the begin and end of an task. ParseIcalString does not support VCALENDAR
i = icalStr.indexOf("BEGIN:VTODO");
j = icalStr.indexOf("END:VTODO") + 9;
var todoData = icalStr.substring(i, j);
var calendarTodo = createToDo();
// if parsing import iCalendar failed, add date as description
if ( !calendarTodo.parseTodoIcalString(todoData) )
{
// Save the parsed text as description.
calendarTodo.description = icalStr;
}
calendarEventArray[ calendarEventArray.length ] = calendarTodo;
// remove the parsed VTODO from the calendar data to parse
icalStr = icalStr.substring(j+1);
}
return calendarEventArray;
}
@@ -344,18 +407,18 @@ function readDataFromFile( aFilePath, charset )
var scriptableInputStream;
var tmp; // not sure what the use is for this
LocalFileInstance = Components.classes[LOCALFILE_CTRID].createInstance( nsILocalFile );
LocalFileInstance.initWithPath( aFilePath );
localFileInstance = Components.classes[LOCALFILE_CTRID].createInstance( nsILocalFile );
localFileInstance.initWithPath( aFilePath );
inputStream = Components.classes[FILEIN_CTRID].createInstance( nsIFileInputStream );
try
{
inputStream.init( LocalFileInstance, MODE_RDONLY, 0444, tmp );
inputStream.init( localFileInstance, MODE_RDONLY, 0444, tmp );
scriptableInputStream = Components.classes[SCRIPTSTREAM_CTRID].createInstance( nsIScriptableInputStream);
scriptableInputStream.init( inputStream );
aDataStream = scriptableInputStream.read( -1 );
var aDataStream = scriptableInputStream.read( -1 );
scriptableInputStream.close();
inputStream.close();
@@ -473,22 +536,27 @@ function eventArrayToICalString( calendarEventArray, doPatchForExport )
var sTextiCalendar = "";
for( var eventArrayIndex = 0; eventArrayIndex < calendarEventArray.length; ++eventArrayIndex )
{
var calendarEvent = calendarEventArray[ eventArrayIndex ].clone();
var calendarObject = calendarEventArray[ eventArrayIndex ].clone();
// convert time to represent local to produce correct DTSTART and DTEND
if(calendarEvent.allDay != true)
convertLocalToZulu( calendarEvent );
if( isEvent(calendarObject) && calendarObject.allDay != true )
convertLocalToZulu( calendarObject );
// check if all required properties are available
if( calendarEvent.method == 0 )
calendarEvent.method = calendarEvent.ICAL_METHOD_PUBLISH;
if( calendarEvent.stamp.year == 0 )
calendarEvent.stamp.setTime( new Date() );
if( calendarObject.method == 0 )
calendarObject.method = calendarObject.ICAL_METHOD_PUBLISH;
if( calendarObject.stamp.year == 0 )
calendarObject.stamp.setTime( new Date() );
if ( doPatchForExport )
sTextiCalendar += patchICalStringForExport( calendarEvent.getIcalString() );
if ( isEvent(calendarObject) && doPatchForExport )
sTextiCalendar += patchICalStringForExport( calendarObject.getIcalString() );
else
sTextiCalendar += calendarEvent.getIcalString() ;
{
if( isEvent(calendarObject) )
sTextiCalendar += calendarObject.getIcalString();
else
sTextiCalendar += calendarObject.getTodoIcalString();
}
}
return sTextiCalendar;
@@ -525,11 +593,11 @@ function patchICalStringForExport( sTextiCalendar )
function eventArrayToHTML( calendarEventArray )
{
sHTMLHeader =
const sHTMLHeader =
"<html>\n" + "<head>\n" + "<title>Mozilla Calendar</title>\n" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" +
"</head>\n"+ "<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n";
sHTMLFooter =
const sHTMLFooter =
"\n</body>\n</html>\n";
var sHTMLText = sHTMLHeader;
@@ -639,6 +707,7 @@ function eventArrayToXCS( calendarEventArray )
// XXX MAJOR UGLY HACK!! Serializer doesn't insert XML Declaration
// http://bugzilla.mozilla.org/show_bug.cgi?id=63558
// Fixed in Mozilla 1.2
var serialDocument = serializer.serializeToString ( xcsDoc );
if( serialDocument.indexOf( "<?xml" ) == -1 )
@@ -661,11 +730,10 @@ function saveDataToFile(aFilePath, aDataStream, charset)
const nsILocalFile = Components.interfaces.nsILocalFile;
const nsIFileOutputStream = Components.interfaces.nsIFileOutputStream;
var localFileInstance;
var outputStream;
var LocalFileInstance = Components.classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
LocalFileInstance.initWithPath(aFilePath);
var localFileInstance = Components.classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
localFileInstance.initWithPath(aFilePath);
outputStream = Components.classes[FILEOUT_CTRID].createInstance(nsIFileOutputStream);
try
@@ -673,7 +741,7 @@ function saveDataToFile(aFilePath, aDataStream, charset)
if(charset)
aDataStream = convertFromUnicode( charset, aDataStream );
outputStream.init(LocalFileInstance, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, 0664, 0);
outputStream.init(localFileInstance, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, 0664, 0);
outputStream.write(aDataStream, aDataStream.length);
// outputStream.flush();
outputStream.close();
@@ -1028,6 +1096,14 @@ function makeXmlNode( xmlDocument, calendarEvent )
addPropertyNode( xmlDocument, eventNode, "UID", calendarEvent.id );
addPropertyNode( xmlDocument, eventNode, "SUMMARY", checkString( calendarEvent.title ) );
addPropertyNode( xmlDocument, eventNode, "DTSTAMP", checkDate( calendarEvent.stamp ) );
if( isToDo( calendarEvent ) )
{
addPropertyNode( xmlDocument, eventNode, "DUE", checkDate( calendarEvent.due ) );
addPropertyNode( xmlDocument, eventNode, "COMPLETED", checkDate( calendarEvent.completed ) );
addPropertyNode( xmlDocument, eventNode, "PERCENT-COMPLETE", checkBoolean( calendarEvent.percent ) );
}
if( calendarEvent.allDay )
addPropertyNode( xmlDocument, eventNode, "DTSTART", checkDate( calendarEvent.start, true ), "DATE" );
else

View File

@@ -137,7 +137,7 @@ function cutToClipboard( /* calendarEventArray */)
function copyToClipboard( calendarEventArray )
{
if( !calendarEventArray)
var calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;
calendarEventArray = gCalendarWindow.EventSelection.selectedEvents;
if(calendarEventArray.length == 0)
alert("No events selected");
@@ -182,6 +182,7 @@ function copyToClipboard( calendarEventArray )
return true;
}
}
return false;
}
@@ -218,9 +219,9 @@ function pasteFromClipboard()
trans.getAnyTransferData(flavour, data, length);
data = data.value.QueryInterface(Components.interfaces.nsISupportsWString).data;
//DEBUG alert("clipboard type: " + flavour.value);
var calendarEventArray;
switch (flavour.value) {
case "text/calendar":
var calendarEventArray;
calendarEventArray = parseIcalData( data );
//change the date of all the events to now
@@ -237,7 +238,7 @@ function pasteFromClipboard()
addEventsToCalendar( calendarEventArray );
break;
case "text/unicode":
if ( data.indexOf("BEGIN:VEVENT") == -1 )
if ( data.indexOf("BEGIN:VCALENDAR") == -1 )
{
// no iCalendar data, paste clipboard text into description of new event
calendarEvent = createEvent();
@@ -247,7 +248,6 @@ function pasteFromClipboard()
}
else
{
var calendarEventArray;
calendarEventArray = parseIcalData( data );
//change the date of all the events to now
var startDate = gCalendarWindow.currentView.getNewEventDate();

View File

@@ -289,6 +289,15 @@
</menupopup>
</menulist>
</row>
<!-- Cancelled -->
<row align="center">
<spacer />
<checkbox id="cancelled-checkbox" checked="false" label="&newevent.cancelled.label;"/>
</row>
</rows>
</grid>
</tabpanel>

View File

@@ -124,7 +124,7 @@ function loadEventsFromFile()
var buttonPressed =
promptService.confirmEx(window,
"Import", "About to import " + calendarEventArray.length + " event(s). Do you want to open all events to import before importing?",
"Import", "About to import " + calendarEventArray.length + " item(s). Do you want to open all items to import before importing?",
(promptService.BUTTON_TITLE_YES * promptService.BUTTON_POS_0) +
(promptService.BUTTON_TITLE_NO * promptService.BUTTON_POS_1) +
(promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_2),
@@ -169,29 +169,69 @@ function createUniqueID()
function addEventsToCalendar( calendarEventArray, silent )
{
var defaultServer = gCalendarWindow.calendarManager.calendars[0];
for(var i = 0; i < calendarEventArray.length; i++)
{
calendarEvent = calendarEventArray[i]
if( isEvent( calendarEventArray[i] ) )
{
var calendarEvent = calendarEventArray[i];
// Check if event with same ID already in Calendar. If so, import event with new ID.
if( gICalLib.fetchEvent( calendarEvent.id ) != null ) {
calendarEvent.id = createUniqueID( );
// Check if event with same ID already in Calendar. If so, import event with new ID.
if( gICalLib.fetchEvent( calendarEvent.id ) != null ) {
calendarEvent.id = createUniqueID( );
}
// the start time is in zulu time, need to convert to current time
if(calendarEvent.allDay != true)
convertZuluToLocal( calendarEvent );
// open the event dialog with the event to add
if( silent )
gICalLib.addEvent( calendarEvent, defaultServer.path );
else
editNewEvent( calendarEvent );
}
else if( isToDo( calendarEventArray[i] ) )
{
//
calendarTodo = calendarEventArray[i];
// Check if task with same ID already in Calendar. If so, import task with new ID.
if( gICalLib.fetchTodo( calendarTodo.id ) != null ) {
calendarTodo.id = createUniqueID( );
}
// open the todo dialog with the task to add
if( silent ){alert(defaultServer.path);
gICalLib.addTodo( calendarTodo, defaultServer.path );}
else
gICalLib.addTodo( calendarTodo, defaultServer.path );
// XXX TODO: add support to add todo using dialog
// editToDo( calendarTodo );
}
// the start time is in zulu time, need to convert to current time
if(calendarEvent.allDay != true)
convertZuluToLocal( calendarEvent );
// open the event dialog with the event to add
if( silent )
gICalLib.addEvent( calendarEvent );
else
editNewEvent( calendarEvent );
}
}
const ZULU_OFFSET_MILLIS = new Date().getTimezoneOffset() * 60 * 1000;
function convertToUTC( aLocalTime )
{
if( calendarEvent.start.utc == false )
{
aLocalTime.setTime( aLocalTime.getTime() + ZULU_OFFSET_MILLIS );
aLocalTime.utc = true;
}
}
function convertFromUTC( aUtcTime )
{
if( aUtcTime.utc == true )
{
aUtcTime.setTime( aUtcTime.getTime() - ZULU_OFFSET_MILLIS );
aUtcTime.utc = false;
}
}
function convertZuluToLocal( calendarEvent )
{
if( calendarEvent.start.utc == true )
@@ -278,19 +318,20 @@ function initCalendarEvent( calendarEvent )
* Parses those events and returns an array of calendarEvents.
*/
function parseIcalData( icalStr )
function parseIcalData( icalendarString )
{
var calendarEventArray = new Array();
var i,j;
var icalStr = icalendarString;
while( icalStr.indexOf("BEGIN:VEVENT") != -1 )
{
// try to find the begin and end of an event. ParseIcalString does not support VCALENDAR
i = icalStr.indexOf("BEGIN:VEVENT");
j = icalStr.indexOf("END:VEVENT") + 10;
eventData = icalStr.substring(i, j);
var eventData = icalStr.substring(i, j);
calendarEvent = createEvent();
var calendarEvent = createEvent();
// if parsing import iCalendar failed, add date as description
if ( !calendarEvent.parseIcalString(eventData) )
@@ -306,7 +347,29 @@ function parseIcalData( icalStr )
// remove the parsed VEVENT from the calendar data to parse
icalStr = icalStr.substring(j+1);
}
icalStr = icalendarString;
while( icalStr.indexOf("BEGIN:VTODO") != -1 )
{
// try to find the begin and end of an task. ParseIcalString does not support VCALENDAR
i = icalStr.indexOf("BEGIN:VTODO");
j = icalStr.indexOf("END:VTODO") + 9;
var todoData = icalStr.substring(i, j);
var calendarTodo = createToDo();
// if parsing import iCalendar failed, add date as description
if ( !calendarTodo.parseTodoIcalString(todoData) )
{
// Save the parsed text as description.
calendarTodo.description = icalStr;
}
calendarEventArray[ calendarEventArray.length ] = calendarTodo;
// remove the parsed VTODO from the calendar data to parse
icalStr = icalStr.substring(j+1);
}
return calendarEventArray;
}
@@ -344,18 +407,18 @@ function readDataFromFile( aFilePath, charset )
var scriptableInputStream;
var tmp; // not sure what the use is for this
LocalFileInstance = Components.classes[LOCALFILE_CTRID].createInstance( nsILocalFile );
LocalFileInstance.initWithPath( aFilePath );
localFileInstance = Components.classes[LOCALFILE_CTRID].createInstance( nsILocalFile );
localFileInstance.initWithPath( aFilePath );
inputStream = Components.classes[FILEIN_CTRID].createInstance( nsIFileInputStream );
try
{
inputStream.init( LocalFileInstance, MODE_RDONLY, 0444, tmp );
inputStream.init( localFileInstance, MODE_RDONLY, 0444, tmp );
scriptableInputStream = Components.classes[SCRIPTSTREAM_CTRID].createInstance( nsIScriptableInputStream);
scriptableInputStream.init( inputStream );
aDataStream = scriptableInputStream.read( -1 );
var aDataStream = scriptableInputStream.read( -1 );
scriptableInputStream.close();
inputStream.close();
@@ -473,22 +536,27 @@ function eventArrayToICalString( calendarEventArray, doPatchForExport )
var sTextiCalendar = "";
for( var eventArrayIndex = 0; eventArrayIndex < calendarEventArray.length; ++eventArrayIndex )
{
var calendarEvent = calendarEventArray[ eventArrayIndex ].clone();
var calendarObject = calendarEventArray[ eventArrayIndex ].clone();
// convert time to represent local to produce correct DTSTART and DTEND
if(calendarEvent.allDay != true)
convertLocalToZulu( calendarEvent );
if( isEvent(calendarObject) && calendarObject.allDay != true )
convertLocalToZulu( calendarObject );
// check if all required properties are available
if( calendarEvent.method == 0 )
calendarEvent.method = calendarEvent.ICAL_METHOD_PUBLISH;
if( calendarEvent.stamp.year == 0 )
calendarEvent.stamp.setTime( new Date() );
if( calendarObject.method == 0 )
calendarObject.method = calendarObject.ICAL_METHOD_PUBLISH;
if( calendarObject.stamp.year == 0 )
calendarObject.stamp.setTime( new Date() );
if ( doPatchForExport )
sTextiCalendar += patchICalStringForExport( calendarEvent.getIcalString() );
if ( isEvent(calendarObject) && doPatchForExport )
sTextiCalendar += patchICalStringForExport( calendarObject.getIcalString() );
else
sTextiCalendar += calendarEvent.getIcalString() ;
{
if( isEvent(calendarObject) )
sTextiCalendar += calendarObject.getIcalString();
else
sTextiCalendar += calendarObject.getTodoIcalString();
}
}
return sTextiCalendar;
@@ -525,11 +593,11 @@ function patchICalStringForExport( sTextiCalendar )
function eventArrayToHTML( calendarEventArray )
{
sHTMLHeader =
const sHTMLHeader =
"<html>\n" + "<head>\n" + "<title>Mozilla Calendar</title>\n" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" +
"</head>\n"+ "<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n";
sHTMLFooter =
const sHTMLFooter =
"\n</body>\n</html>\n";
var sHTMLText = sHTMLHeader;
@@ -639,6 +707,7 @@ function eventArrayToXCS( calendarEventArray )
// XXX MAJOR UGLY HACK!! Serializer doesn't insert XML Declaration
// http://bugzilla.mozilla.org/show_bug.cgi?id=63558
// Fixed in Mozilla 1.2
var serialDocument = serializer.serializeToString ( xcsDoc );
if( serialDocument.indexOf( "<?xml" ) == -1 )
@@ -661,11 +730,10 @@ function saveDataToFile(aFilePath, aDataStream, charset)
const nsILocalFile = Components.interfaces.nsILocalFile;
const nsIFileOutputStream = Components.interfaces.nsIFileOutputStream;
var localFileInstance;
var outputStream;
var LocalFileInstance = Components.classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
LocalFileInstance.initWithPath(aFilePath);
var localFileInstance = Components.classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
localFileInstance.initWithPath(aFilePath);
outputStream = Components.classes[FILEOUT_CTRID].createInstance(nsIFileOutputStream);
try
@@ -673,7 +741,7 @@ function saveDataToFile(aFilePath, aDataStream, charset)
if(charset)
aDataStream = convertFromUnicode( charset, aDataStream );
outputStream.init(LocalFileInstance, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, 0664, 0);
outputStream.init(localFileInstance, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, 0664, 0);
outputStream.write(aDataStream, aDataStream.length);
// outputStream.flush();
outputStream.close();
@@ -1028,6 +1096,14 @@ function makeXmlNode( xmlDocument, calendarEvent )
addPropertyNode( xmlDocument, eventNode, "UID", calendarEvent.id );
addPropertyNode( xmlDocument, eventNode, "SUMMARY", checkString( calendarEvent.title ) );
addPropertyNode( xmlDocument, eventNode, "DTSTAMP", checkDate( calendarEvent.stamp ) );
if( isToDo( calendarEvent ) )
{
addPropertyNode( xmlDocument, eventNode, "DUE", checkDate( calendarEvent.due ) );
addPropertyNode( xmlDocument, eventNode, "COMPLETED", checkDate( calendarEvent.completed ) );
addPropertyNode( xmlDocument, eventNode, "PERCENT-COMPLETE", checkBoolean( calendarEvent.percent ) );
}
if( calendarEvent.allDay )
addPropertyNode( xmlDocument, eventNode, "DTSTART", checkDate( calendarEvent.start, true ), "DATE" );
else

View File

@@ -61,7 +61,7 @@ function calendarUnifinderInit( )
SearchTree.setAttribute( "suppressonselect", "true" );
SearchTree.treeBoxObject.selection.select( -1 );
SearchTree.treeBoxObject.selection.clearSelection();
if( EventSelectionArray.length > 0 )
{
@@ -75,7 +75,7 @@ function calendarUnifinderInit( )
SearchTree.treeBoxObject.ensureRowIsVisible( Index );
SearchTree.treeBoxObject.selection.select( Index );
SearchTree.treeBoxObject.selection.toggleSelect( Index );
}
}
}
@@ -251,19 +251,25 @@ function getCalendarEventFromEvent( event )
}
}
/**
* This is attached to the onclik attribute of the events shown in the unifinder
*/
function unifinderClickEvent( event )
function unifinderOnSelect( event )
{
// only change checkbox on left mouse-button click
if( event.button != 0)
return;
var tree = document.getElementById( UnifinderTreeName );
var ThisEvent = getCalendarEventFromEvent( event );
var ArrayOfEvents = new Array( ThisEvent );
var start = new Object();
var end = new Object();
var numRanges = tree.view.selection.getRangeCount();
var ArrayOfEvents = new Array( );
for (var t=0; t<numRanges; t++){
tree.view.selection.getRangeAt(t,start,end);
for (var v=start.value; v<=end.value; v++){
var treeitem = tree.treeBoxObject.view.getItemAtIndex( v );
var eventId = treeitem.getAttribute("eventId");
var ThisEvent = gICalLib.fetchEvent( eventId );
if( ThisEvent )
ArrayOfEvents[ ArrayOfEvents.length ] = ThisEvent;
}
}
gCalendarWindow.EventSelection.setArrayToSelection( ArrayOfEvents );
@@ -496,7 +502,7 @@ function setUnifinderEventTreeItem( treeItem, calendarEvent )
treeItem.setAttribute( "eventId", calendarEvent.id );
treeItem.setAttribute( "onmouseover", "changeToolTipTextForEvent( event )" );
treeItem.setAttribute( "ondblclick" , "unifinderDoubleClickEvent(event)" );
treeItem.setAttribute( "onclick" , "unifinderClickEvent(event)" );
//treeItem.setAttribute( "onclick" , "unifinderClickEvent(event)" );
treeItem.setAttribute( "calendarevent", "true" );
treeItem.setAttribute( "id", "search-unifinder-treeitem-"+calendarEvent.id );
@@ -581,109 +587,6 @@ function refreshEventTree( eventArray )
}
}
/* This function is not used */
function refreshEventTreeOld( eventArray )
{
// get the old tree children item and remove it
var oldTreeChildren = document.getElementById( UnifinderTreeName );
while( oldTreeChildren.hasChildNodes() )
oldTreeChildren.removeChild( oldTreeChildren.lastChild );
// 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( "listitem" );
treeItem.setAttribute( "id", "search-unifinder-treeitem-"+calendarEvent.id );
treeItem.event = calendarEvent;
treeItem.setAttribute( "onmouseover", "changeToolTipTextForEvent( event )" );
treeItem.setAttribute( "ondblclick" , "unifinderDoubleClickEvent(" + calendarEvent.id + ")" );
//treeItem.setAttribute( "onclick" , "unifinderClickEvent(" + calendarEvent.id + ")" );
var treeCell = document.createElement( "listcell" );
treeCell.setAttribute( "flex" , "1" );
treeCell.setAttribute( "crop", "right" );
var image = document.createElement( "image" );
image.setAttribute( "class", "unifinder-calendar-event-icon-class" );
if ( calendarEvent.alarm )
{
image.setAttribute( "alarm", "true" );
}
else if( calendarEvent.recur == true )
{
image.setAttribute( "recur", "true" );
}
var treeCellHBox = document.createElement( "hbox" );
treeCellHBox.setAttribute( "flex" , "1" );
treeCellHBox.setAttribute( "class", "unifinder-treecell-box-class" );
treeCellHBox.setAttribute( "crop", "right" );
treeCellHBox.setAttribute( "align", "center" );
var treeCellVBox = document.createElement( "vbox" );
treeCellVBox.setAttribute( "crop", "right" );
treeCellVBox.setAttribute( "flex", "1" );
var text1 = document.createElement( "label" );
text1.setAttribute( "crop", "right" );
var text2 = document.createElement( "label" );
text2.setAttribute( "crop", "right" );
// set up the display and behaviour of the tree items
// set the text of the two text items
text1.setAttribute( "value" , calendarEvent.title );
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 )
{
text2.setAttribute( "value" , "All day on " + startDate + "" );
}
else
{
text2.setAttribute( "value" , startDate + " " + startTime + " - " + endTime );
}
// add the items
if ( calendarEvent.title )
{
treeCellVBox.appendChild( text1 );
}
treeCellVBox.appendChild( text2 );
treeCellHBox.appendChild( image );
treeCellHBox.appendChild( treeCellVBox );
treeCell.appendChild( treeCellHBox );
treeItem.appendChild( treeCell );
oldTreeChildren.appendChild( treeItem );
//you need this for when an event is added.
if( gCalendarWindow.EventSelection.isSelectedEvent( calendarEvent ) )
oldTreeChildren.addItemToSelection( treeItem );
}
}
function unifinderClearSearchCommand()
{