Fixing the ability to import events, when using the wizard.

This commit is contained in:
mikep%oeone.com 2002-11-01 20:46:46 +00:00
Родитель c1aa011ff3
Коммит fd469b21f0
10 изменённых файлов: 226 добавлений и 53 удалений

Просмотреть файл

@ -160,8 +160,8 @@ function calendarInit()
} }
//a bit of a hack since the menulist doesn't remember the selected value //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' ).setAttribute( "label", document.getElementById( 'event-filter-menulist' ).selectedItem.getAttribute( 'label' ) ); 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 // Set the date and time on the clock and set up a timeout to refresh the clock when the

Просмотреть файл

@ -174,7 +174,7 @@ function createUniqueID()
* Takes an array of events and adds the evens one by one to the calendar * Takes an array of events and adds the evens one by one to the calendar
*/ */
function addEventsToCalendar( calendarEventArray, silent ) function addEventsToCalendar( calendarEventArray, silent, ServerName )
{ {
gICalLib.batchMode = true; gICalLib.batchMode = true;
@ -194,8 +194,10 @@ function addEventsToCalendar( calendarEventArray, silent )
// open the event dialog with the event to add // open the event dialog with the event to add
if( silent ) if( silent )
{ {
var DefaultServer = gCalendarWindow.calendarManager.getDefaultServer(); if( ServerName == null || ServerName == "" || ServerName == false )
gICalLib.addEvent( calendarEvent, DefaultServer ); var ServerName = gCalendarWindow.calendarManager.getDefaultServer();
gICalLib.addEvent( calendarEvent, ServerName );
} }
else else
editNewEvent( calendarEvent ); editNewEvent( calendarEvent );

Просмотреть файл

@ -44,6 +44,37 @@ function checkInitialPage()
} }
function onPageShow( PageId )
{
switch( PageId )
{
case "import":
if( document.getElementById( "import-path-textbox" ).value.length == 0 )
{
document.getElementById( "calendar-wizard" ).canAdvance = false;
}
else
{
document.getElementById( "calendar-wizard" ).canAdvance = true;
}
break;
case "import-2":
buildCalendarsListbox( 'import-calendar-radiogroup' );
if( document.getElementById( "import-calendar-radiogroup" ).selectedItem == null )
{
document.getElementById( "calendar-wizard" ).canAdvance = false;
}
else
{
document.getElementById( "calendar-wizard" ).canAdvance = true;
}
document.getElementById( "import-calendar-radiogroup" ).childNodes[0].setAttribute( "selected", "true" );
break;
}
}
function buildCalendarsListbox( ListBoxId ) function buildCalendarsListbox( ListBoxId )
{ {
document.getElementById( ListBoxId ).database.AddDataSource( opener.gCalendarWindow.calendarManager.rdf.getDatasource() ); document.getElementById( ListBoxId ).database.AddDataSource( opener.gCalendarWindow.calendarManager.rdf.getDatasource() );
@ -53,10 +84,12 @@ function buildCalendarsListbox( ListBoxId )
function doWizardFinish( ) function doWizardFinish( )
{ {
window.setCursor( "wait" );
switch( gWizardType ) switch( gWizardType )
{ {
case "import": case "import":
return doWizardImport(); return true;
break; break;
case "export": case "export":
@ -76,34 +109,68 @@ function doWizardFinish( )
function doWizardImport() function doWizardImport()
{ {
window.setCursor( "wait" );
var calendarEventArray; var calendarEventArray;
var fileName = document.getElementById( "import-path-textbox" ).value; var fileName = document.getElementById( "import-path-textbox" ).value;
var aDataStream = readDataFromFile( fileName, "UTF-8" ); var aDataStream = readDataFromFile( fileName, "UTF-8" );
if( fileName.indexOf( ".ics" ) == -1 ) if( fileName.indexOf( ".ics" ) != -1 )
{ calendarEventArray = parseIcalData( aDataStream );
calendarEventArray = parseIcalData( aDataStream ); else if( fileName.indexOf( ".xcs" ) != -1 )
}
else if( fileName.indexOf( ".xcs" ) == -1 )
{
calendarEventArray = parseXCSData( aDataStream ); calendarEventArray = parseXCSData( aDataStream );
}
if( document.getElementById( "import-2-radiogroup" ).selectedItem.value == "silent" ) if( document.getElementById( "import-2-radiogroup" ).selectedItem.value == "silent" )
{ {
addEventsToCalendar( calendarEventArray, true ); var ServerName = document.getElementById( "import-calendar-radiogroup" ).selectedItem.value;
doAddEventsToCalendar( calendarEventArray, true, ServerName );
} }
else else
{ {
addEventsToCalendar( calendarEventArray, true ); doAddEventsToCalendar( calendarEventArray, true, null );
} }
return( false ); //true will close the window
} }
function doAddEventsToCalendar( calendarEventArray, silent, ServerName )
{
gICalLib.batchMode = true;
for(var i = 0; i < calendarEventArray.length; i++)
{
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( );
}
// 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 )
{
if( ServerName == null || ServerName == "" || ServerName == false )
var ServerName = gCalendarWindow.calendarManager.getDefaultServer();
gICalLib.addEvent( calendarEvent, ServerName );
document.getElementById( "import-progress-meter" ).setAttribute( "value", ( (i/calendarEventArray.length)*100 )+"%" );
}
else
editNewEvent( calendarEvent );
}
gICalLib.batchMode = false;
window.setCursor( "default" );
document.getElementById( "importing-box" ).setAttribute( "collapsed", "true" );
document.getElementById( "done-importing-box" ).removeAttribute( "collapsed" );
}
function doWizardExport() function doWizardExport()
{ {
@ -199,5 +266,7 @@ function launchFilePicker( Mode, ElementToGiveValueTo )
filePath += extension; filePath += extension;
*/ */
document.getElementById( ElementToGiveValueTo ).value = fp.file.path; document.getElementById( ElementToGiveValueTo ).value = fp.file.path;
document.getElementById( "calendar-wizard" ).canAdvance = true;
} }
} }

Просмотреть файл

@ -61,8 +61,10 @@
title="Mozilla Calendar Wizard" title="Mozilla Calendar Wizard"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onwizardfinish="return doWizardFinish();" onwizardfinish="return doWizardFinish();"
persist="screenX screenY"
> >
<script type="application/x-javascript" src="chrome://calendar/content/calendar.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarWizard.js"/> <script type="application/x-javascript" src="chrome://calendar/content/calendarWizard.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarImportExport.js"/> <script type="application/x-javascript" src="chrome://calendar/content/calendarImportExport.js"/>
@ -75,7 +77,7 @@
</radiogroup> </radiogroup>
</wizardpage> </wizardpage>
<wizardpage pageid="import" label="Import Events" description="Choose the events you want to import." onpagehide="" onpageshow="" next="import-2"> <wizardpage pageid="import" label="Import Events" description="Choose the events you want to import." onpagehide="" onpageshow="onPageShow( 'import' );" next="import-2">
<textbox id="import-path-textbox"/> <textbox id="import-path-textbox"/>
<button oncommand="launchFilePicker( 'open', 'import-path-textbox' )" label="Find a File"/> <button oncommand="launchFilePicker( 'open', 'import-path-textbox' )" label="Find a File"/>
<description> <description>
@ -85,17 +87,17 @@
</wizardpage> </wizardpage>
<wizardpage pageid="import-2" label="Select Calendar" description="Choose the file to import into." onpagehide="" onpageshow="buildCalendarsListbox( 'import-calendar-radiogroup' )" next="import-3"> <wizardpage pageid="import-2" label="Select Calendar" description="Choose the file to import into." onpagehide="" onpageshow="onPageShow( 'import-2' );" next="import-3">
<radiogroup id="import-calendar-radiogroup" datasources="rdf:null" ref="urn:calendarcontainer"> <radiogroup id="import-calendar-radiogroup" datasources="rdf:null" ref="urn:calendarcontainer">
<template> <template>
<rule> <rule>
<radio uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#name"/> <radio oncommand="document.getElementById( 'calendar-wizard' ).canAdvance = true;" uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#name" value="rdf:http://home.netscape.com/NC-rdf#path"/>
</rule> </rule>
</template> </template>
</radiogroup> </radiogroup>
</wizardpage> </wizardpage>
<wizardpage pageid="import-3" onpagehide="" onpageshow=""> <wizardpage pageid="import-3" onpagehide="" onpageshow="" next="import-4">
<description>Should I open each event before importing it?</description> <description>Should I open each event before importing it?</description>
<radiogroup id="import-2-radiogroup"> <radiogroup id="import-2-radiogroup">
<radio id="import-2-no" value="silent" label="No, just import the events." selected="true"/> <radio id="import-2-no" value="silent" label="No, just import the events." selected="true"/>
@ -103,6 +105,16 @@
</radiogroup> </radiogroup>
</wizardpage> </wizardpage>
<wizardpage pageid="import-4" onpagehide="" onpageshow="setTimeout( 'doWizardImport()', 1000 );">
<box id="importing-box">
<description>Importing...</description>
<progressmeter id="import-progress-meter" mode="determined" flex="1"/>
</box>
<box id="done-importing-box" collapsed="true">
<description>All your events have been imported. Click finish to close the wizard.</description>
</box>
</wizardpage>
<wizardpage pageid="export" label="Export Events" onpagehide="" onpageshow="buildCalendarsListbox( 'export-calendars-listbox' )" next="export-2"> <wizardpage pageid="export" label="Export Events" onpagehide="" onpageshow="buildCalendarsListbox( 'export-calendars-listbox' )" next="export-2">
<radiogroup> <radiogroup>
<radio id="export-calendars" label="Export Entire Calendar" selected="true"/> <radio id="export-calendars" label="Export Entire Calendar" selected="true"/>

Просмотреть файл

@ -102,6 +102,11 @@ calendar {
color: #ffffff; color: #ffffff;
} }
.cal-day[busy="true"]
{
font-weight : bold;
}
.cal-day:hover { .cal-day:hover {
color: #ff0000; color: #ff0000;
border: 1px solid #d2d2d2; border: 1px solid #d2d2d2;

Просмотреть файл

@ -174,7 +174,7 @@ function createUniqueID()
* Takes an array of events and adds the evens one by one to the calendar * Takes an array of events and adds the evens one by one to the calendar
*/ */
function addEventsToCalendar( calendarEventArray, silent ) function addEventsToCalendar( calendarEventArray, silent, ServerName )
{ {
gICalLib.batchMode = true; gICalLib.batchMode = true;
@ -194,8 +194,10 @@ function addEventsToCalendar( calendarEventArray, silent )
// open the event dialog with the event to add // open the event dialog with the event to add
if( silent ) if( silent )
{ {
var DefaultServer = gCalendarWindow.calendarManager.getDefaultServer(); if( ServerName == null || ServerName == "" || ServerName == false )
gICalLib.addEvent( calendarEvent, DefaultServer ); var ServerName = gCalendarWindow.calendarManager.getDefaultServer();
gICalLib.addEvent( calendarEvent, ServerName );
} }
else else
editNewEvent( calendarEvent ); editNewEvent( calendarEvent );

Просмотреть файл

@ -475,6 +475,7 @@ var treeView =
getImageSrc : function(){return false;}, getImageSrc : function(){return false;},
cycleHeader : function( ColId, element ) cycleHeader : function( ColId, element )
{ {
//dump( "\nin cycle header" );
var sortActive; var sortActive;
var treeCols; var treeCols;
@ -507,7 +508,9 @@ var treeView =
} }
element.setAttribute("sortActive", sortActive); element.setAttribute("sortActive", sortActive);
element.setAttribute("sortDirection", this.sortDirection); element.setAttribute("sortDirection", this.sortDirection);
//dump( "\nabout to sort events "+gEventArray.length );
gEventArray.sort( sortEvents ); gEventArray.sort( sortEvents );
//dump( "\nSORTED!");
document.getElementById( UnifinderTreeName ).view = this; document.getElementById( UnifinderTreeName ).view = this;
}, },
setTree : function( tree ){this.tree = tree;}, setTree : function( tree ){this.tree = tree;},
@ -527,11 +530,7 @@ var treeView =
switch( column ) switch( column )
{ {
case "unifinder-search-results-tree-col-title": case "unifinder-search-results-tree-col-title":
if( calendarEvent.title == "" ) return( calendarEvent.title );
var titleText = "Untitled";
else
var titleText = calendarEvent.title;
return( titleText );
case "unifinder-search-results-tree-col-startdate": case "unifinder-search-results-tree-col-startdate":
var eventStartDate = getNextOrPreviousRecurrence( calendarEvent ); var eventStartDate = getNextOrPreviousRecurrence( calendarEvent );
@ -588,11 +587,14 @@ function sortEvents( EventA, EventB )
{ {
modifier = -1; modifier = -1;
} }
//dump( "\nswitch on treeview.SelectedColumn which is "+treeView.selectedColumn );
switch(treeView.selectedColumn) switch(treeView.selectedColumn)
{ {
case "unifinder-search-results-tree-col-title": case "unifinder-search-results-tree-col-title":
{
//dump( "\nreturning "+EventA.title +" > "+EventB.title );
return( ((EventA.title > EventB.title) ? 1 : -1) * modifier ); return( ((EventA.title > EventB.title) ? 1 : -1) * modifier );
}
case "unifinder-search-results-tree-col-startdate": case "unifinder-search-results-tree-col-startdate":
return( ((EventA.start.getTime() > EventB.start.getTime()) ? 1 : -1) * modifier ); return( ((EventA.start.getTime() > EventB.start.getTime()) ? 1 : -1) * modifier );

Просмотреть файл

@ -394,7 +394,7 @@ var toDoTreeView =
} }
element.setAttribute("sortActive", sortActive); element.setAttribute("sortActive", sortActive);
element.setAttribute("sortDirection", this.sortDirection); element.setAttribute("sortDirection", this.sortDirection);
gTaskArray.sort( sortEvents ); gTaskArray.sort( sortTasks );
document.getElementById( ToDoUnifinderTreeName ).view = this; document.getElementById( ToDoUnifinderTreeName ).view = this;
}, },
setTree : function( tree ){this.tree = tree;}, setTree : function( tree ){this.tree = tree;},
@ -406,7 +406,7 @@ var toDoTreeView =
{ {
this.selectedColumn = column; this.selectedColumn = column;
this.sortDirection = columnElement.getAttribute("sortDirection"); this.sortDirection = columnElement.getAttribute("sortDirection");
gTaskArray.sort(sortEvents); gTaskArray.sort(sortTasks);
} }
calendarToDo = gTaskArray[row]; calendarToDo = gTaskArray[row];
@ -441,7 +441,7 @@ var toDoTreeView =
} }
} }
function sortEvents( TaskA, TaskB ) function sortTasks( TaskA, TaskB )
{ {
var modifier = 1; var modifier = 1;
if (toDoTreeView.sortDirection == "descending") if (toDoTreeView.sortDirection == "descending")

Просмотреть файл

@ -44,6 +44,37 @@ function checkInitialPage()
} }
function onPageShow( PageId )
{
switch( PageId )
{
case "import":
if( document.getElementById( "import-path-textbox" ).value.length == 0 )
{
document.getElementById( "calendar-wizard" ).canAdvance = false;
}
else
{
document.getElementById( "calendar-wizard" ).canAdvance = true;
}
break;
case "import-2":
buildCalendarsListbox( 'import-calendar-radiogroup' );
if( document.getElementById( "import-calendar-radiogroup" ).selectedItem == null )
{
document.getElementById( "calendar-wizard" ).canAdvance = false;
}
else
{
document.getElementById( "calendar-wizard" ).canAdvance = true;
}
document.getElementById( "import-calendar-radiogroup" ).childNodes[0].setAttribute( "selected", "true" );
break;
}
}
function buildCalendarsListbox( ListBoxId ) function buildCalendarsListbox( ListBoxId )
{ {
document.getElementById( ListBoxId ).database.AddDataSource( opener.gCalendarWindow.calendarManager.rdf.getDatasource() ); document.getElementById( ListBoxId ).database.AddDataSource( opener.gCalendarWindow.calendarManager.rdf.getDatasource() );
@ -53,10 +84,12 @@ function buildCalendarsListbox( ListBoxId )
function doWizardFinish( ) function doWizardFinish( )
{ {
window.setCursor( "wait" );
switch( gWizardType ) switch( gWizardType )
{ {
case "import": case "import":
return doWizardImport(); return true;
break; break;
case "export": case "export":
@ -76,34 +109,68 @@ function doWizardFinish( )
function doWizardImport() function doWizardImport()
{ {
window.setCursor( "wait" );
var calendarEventArray; var calendarEventArray;
var fileName = document.getElementById( "import-path-textbox" ).value; var fileName = document.getElementById( "import-path-textbox" ).value;
var aDataStream = readDataFromFile( fileName, "UTF-8" ); var aDataStream = readDataFromFile( fileName, "UTF-8" );
if( fileName.indexOf( ".ics" ) == -1 ) if( fileName.indexOf( ".ics" ) != -1 )
{ calendarEventArray = parseIcalData( aDataStream );
calendarEventArray = parseIcalData( aDataStream ); else if( fileName.indexOf( ".xcs" ) != -1 )
}
else if( fileName.indexOf( ".xcs" ) == -1 )
{
calendarEventArray = parseXCSData( aDataStream ); calendarEventArray = parseXCSData( aDataStream );
}
if( document.getElementById( "import-2-radiogroup" ).selectedItem.value == "silent" ) if( document.getElementById( "import-2-radiogroup" ).selectedItem.value == "silent" )
{ {
addEventsToCalendar( calendarEventArray, true ); var ServerName = document.getElementById( "import-calendar-radiogroup" ).selectedItem.value;
doAddEventsToCalendar( calendarEventArray, true, ServerName );
} }
else else
{ {
addEventsToCalendar( calendarEventArray, true ); doAddEventsToCalendar( calendarEventArray, true, null );
} }
return( false ); //true will close the window
} }
function doAddEventsToCalendar( calendarEventArray, silent, ServerName )
{
gICalLib.batchMode = true;
for(var i = 0; i < calendarEventArray.length; i++)
{
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( );
}
// 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 )
{
if( ServerName == null || ServerName == "" || ServerName == false )
var ServerName = gCalendarWindow.calendarManager.getDefaultServer();
gICalLib.addEvent( calendarEvent, ServerName );
document.getElementById( "import-progress-meter" ).setAttribute( "value", ( (i/calendarEventArray.length)*100 )+"%" );
}
else
editNewEvent( calendarEvent );
}
gICalLib.batchMode = false;
window.setCursor( "default" );
document.getElementById( "importing-box" ).setAttribute( "collapsed", "true" );
document.getElementById( "done-importing-box" ).removeAttribute( "collapsed" );
}
function doWizardExport() function doWizardExport()
{ {
@ -199,5 +266,7 @@ function launchFilePicker( Mode, ElementToGiveValueTo )
filePath += extension; filePath += extension;
*/ */
document.getElementById( ElementToGiveValueTo ).value = fp.file.path; document.getElementById( ElementToGiveValueTo ).value = fp.file.path;
document.getElementById( "calendar-wizard" ).canAdvance = true;
} }
} }

Просмотреть файл

@ -61,8 +61,10 @@
title="Mozilla Calendar Wizard" title="Mozilla Calendar Wizard"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onwizardfinish="return doWizardFinish();" onwizardfinish="return doWizardFinish();"
persist="screenX screenY"
> >
<script type="application/x-javascript" src="chrome://calendar/content/calendar.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarWizard.js"/> <script type="application/x-javascript" src="chrome://calendar/content/calendarWizard.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarImportExport.js"/> <script type="application/x-javascript" src="chrome://calendar/content/calendarImportExport.js"/>
@ -75,7 +77,7 @@
</radiogroup> </radiogroup>
</wizardpage> </wizardpage>
<wizardpage pageid="import" label="Import Events" description="Choose the events you want to import." onpagehide="" onpageshow="" next="import-2"> <wizardpage pageid="import" label="Import Events" description="Choose the events you want to import." onpagehide="" onpageshow="onPageShow( 'import' );" next="import-2">
<textbox id="import-path-textbox"/> <textbox id="import-path-textbox"/>
<button oncommand="launchFilePicker( 'open', 'import-path-textbox' )" label="Find a File"/> <button oncommand="launchFilePicker( 'open', 'import-path-textbox' )" label="Find a File"/>
<description> <description>
@ -85,17 +87,17 @@
</wizardpage> </wizardpage>
<wizardpage pageid="import-2" label="Select Calendar" description="Choose the file to import into." onpagehide="" onpageshow="buildCalendarsListbox( 'import-calendar-radiogroup' )" next="import-3"> <wizardpage pageid="import-2" label="Select Calendar" description="Choose the file to import into." onpagehide="" onpageshow="onPageShow( 'import-2' );" next="import-3">
<radiogroup id="import-calendar-radiogroup" datasources="rdf:null" ref="urn:calendarcontainer"> <radiogroup id="import-calendar-radiogroup" datasources="rdf:null" ref="urn:calendarcontainer">
<template> <template>
<rule> <rule>
<radio uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#name"/> <radio oncommand="document.getElementById( 'calendar-wizard' ).canAdvance = true;" uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#name" value="rdf:http://home.netscape.com/NC-rdf#path"/>
</rule> </rule>
</template> </template>
</radiogroup> </radiogroup>
</wizardpage> </wizardpage>
<wizardpage pageid="import-3" onpagehide="" onpageshow=""> <wizardpage pageid="import-3" onpagehide="" onpageshow="" next="import-4">
<description>Should I open each event before importing it?</description> <description>Should I open each event before importing it?</description>
<radiogroup id="import-2-radiogroup"> <radiogroup id="import-2-radiogroup">
<radio id="import-2-no" value="silent" label="No, just import the events." selected="true"/> <radio id="import-2-no" value="silent" label="No, just import the events." selected="true"/>
@ -103,6 +105,16 @@
</radiogroup> </radiogroup>
</wizardpage> </wizardpage>
<wizardpage pageid="import-4" onpagehide="" onpageshow="setTimeout( 'doWizardImport()', 1000 );">
<box id="importing-box">
<description>Importing...</description>
<progressmeter id="import-progress-meter" mode="determined" flex="1"/>
</box>
<box id="done-importing-box" collapsed="true">
<description>All your events have been imported. Click finish to close the wizard.</description>
</box>
</wizardpage>
<wizardpage pageid="export" label="Export Events" onpagehide="" onpageshow="buildCalendarsListbox( 'export-calendars-listbox' )" next="export-2"> <wizardpage pageid="export" label="Export Events" onpagehide="" onpageshow="buildCalendarsListbox( 'export-calendars-listbox' )" next="export-2">
<radiogroup> <radiogroup>
<radio id="export-calendars" label="Export Entire Calendar" selected="true"/> <radio id="export-calendars" label="Export Entire Calendar" selected="true"/>