Checked in patch for bug 269250: Make printing use a temp file

This commit is contained in:
mostafah%oeone.com 2004-11-12 15:29:41 +00:00
Родитель b77ec005ec
Коммит 839d1ab472
1 изменённых файлов: 152 добавлений и 125 удалений

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

@ -71,7 +71,10 @@ var startOfWeek;
var gMyTitle; var gMyTitle;
var gShowprivate ; var gShowprivate ;
var gCalendarWindow ; var gCalendarWindow ;
var gHtmlDocument ; var gHtmlDocument;
var gHtmlString;
var gTempFile = null;
var gTempUri;
var gPrintSettingsAreGlobal = true; var gPrintSettingsAreGlobal = true;
var gSavePrintSettings = true; var gSavePrintSettings = true;
@ -157,6 +160,10 @@ function FinishPrintPreview()
var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
if (webBrowserPrint) { if (webBrowserPrint) {
gPrintSettings = GetPrintSettings(); gPrintSettings = GetPrintSettings();
// Don't print the fake title and url
gPrintSettings.docURL=" ";
gPrintSettings.title=" ";
webBrowserPrint.printPreview(gPrintSettings, null, gWebProgress.value); webBrowserPrint.printPreview(gPrintSettings, null, gWebProgress.value);
} }
showPrintPreviewToolbar(); showPrintPreviewToolbar();
@ -189,16 +196,40 @@ function OnLoadPrintEngine(){
prevWeeksInView=gArgs.prevWeeksInView; prevWeeksInView=gArgs.prevWeeksInView;
startOfWeek=gArgs.startOfWeek; startOfWeek=gArgs.startOfWeek;
gHtmlDocument = window.content.document ; gHtmlDocument = window.content.document;
gHtmlString = "";
initHTMLView(); initHTMLView();
eval(HTMLViewFunction)(HTMLFunctionArgs); eval(HTMLViewFunction)(HTMLFunctionArgs);
finishHTMLView() ; finishHTMLView() ;
// Fail-safe check to not init twoce, to prevent leaking files
if (!gTempFile) {
const nsIFile = Components.interfaces.nsIFile;
var dirService = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
gTempFile = dirService.get("TmpD", nsIFile);
gTempFile.append("calendarPrint.html");
gTempFile.createUnique(nsIFile.NORMAL_FILE_TYPE, 0600);
dump("tf: "+gTempFile.path+"\n");
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var gTempUri = ioService.newFileURI(gTempFile);
}
var stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
// 0x2A = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE
stream.init(gTempFile, 0x2A, 0600, 0);
stream.write(gHtmlString, gHtmlString.length);
gHtmlDocument.location.href = gTempUri.spec;
} }
BrowserPrintPreview(); BrowserPrintPreview();
} }
function OnUnloadPrintEngine() function OnUnloadPrintEngine()
{ {
gTempFile.remove(false);
} }
function showPrintPreviewToolbar() function showPrintPreviewToolbar()
@ -220,26 +251,24 @@ function BrowserExitPrintPreview()
function initHTMLView() function initHTMLView()
{ {
//printwindow.document.open(); gHtmlString += "<html><head><title>"+windowTitle+"</title></head><body style='font-size:11px;'>";
gHtmlDocument.write("<html><head><title>"+windowTitle+"</title></head><body style='font-size:11px;'>");
if (gMyTitle.length > 0) if (gMyTitle.length > 0)
{ {
// gHtmlDocument.write("<tr><td colspan=3 align=center style='font-size:26px;font-weight:bold;'>>"); // gHtmlString += "<tr><td colspan=3 align=center style='font-size:26px;font-weight:bold;'>>";
// gHtmlDocument.write("<tr><td colspan=2 align=center style='font-size:26px;font-weight:bold;'>"); // gHtmlString += "<tr><td colspan=2 align=center style='font-size:26px;font-weight:bold;'>";
// gHtmlDocument.write(mytitle); // gHtmlString += mytitle;
// gHtmlDocument.write("</td></tr>"); // gHtmlString += "</td></tr>";
gHtmlDocument.write("<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr><td valign=bottom align=center>"); gHtmlString += "<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr><td valign=bottom align=center>";
gHtmlDocument.write(gMyTitle); gHtmlString += gMyTitle;
gHtmlDocument.write("</td></tr></table>"); gHtmlString += "</td></tr></table>";
} }
return gHtmlDocument; return;
} }
function finishHTMLView() function finishHTMLView()
{ {
gHtmlDocument.write("</body></html>"); gHtmlString += "</body></html>";
gHtmlDocument.close();
} }
function printMultiWeekView(currentDate) function printMultiWeekView(currentDate)
@ -250,17 +279,17 @@ function printMultiWeekView(currentDate)
var weekNumber = DateUtils.getWeekNumber(currentDate) ; var weekNumber = DateUtils.getWeekNumber(currentDate) ;
gHtmlDocument.write("<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr ><td align=center valign=bottom>Week "+weekNumber+"</td></tr></table>"); gHtmlString += "<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr ><td align=center valign=bottom>Week "+weekNumber+"</td></tr></table>";
gHtmlDocument.write("<table style='border:1px solid black;' width=100%>") gHtmlString += "<table style='border:1px solid black;' width=100%>";
gHtmlDocument.write("<tr>"); gHtmlString += "<tr>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[weekStart.getDay()]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[weekStart.getDay()]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+1 >6) ? weekStart.getDay()+1-7:weekStart.getDay()+1]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+1 >6) ? weekStart.getDay()+1-7:weekStart.getDay()+1]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+2 >6) ? weekStart.getDay()+2-7:weekStart.getDay()+2]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+2 >6) ? weekStart.getDay()+2-7:weekStart.getDay()+2]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+3 >6) ? weekStart.getDay()+3-7:weekStart.getDay()+3]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+3 >6) ? weekStart.getDay()+3-7:weekStart.getDay()+3]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+4 >6) ? weekStart.getDay()+4-7:weekStart.getDay()+4]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+4 >6) ? weekStart.getDay()+4-7:weekStart.getDay()+4]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+5 >6) ? weekStart.getDay()+5-7:weekStart.getDay()+5]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+5 >6) ? weekStart.getDay()+5-7:weekStart.getDay()+5]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+6 >6) ? weekStart.getDay()+6-7:weekStart.getDay()+6]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+6 >6) ? weekStart.getDay()+6-7:weekStart.getDay()+6]+"</td>";
gHtmlDocument.write("</tr>"); gHtmlString += "</tr>";
// content here // content here
dayToStart=weekStart.getDate(); dayToStart=weekStart.getDate();
@ -269,16 +298,16 @@ function printMultiWeekView(currentDate)
for (var w=0; w<weeksInView; w++) for (var w=0; w<weeksInView; w++)
{ {
gHtmlDocument.write("<tr>"); gHtmlString += "<tr>";
for (var i=0; i<7; i++) for (var i=0; i<7; i++)
{ {
var thisDaysDate=new Date(yearToStart, monthToStart, dayToStart+i+(w*7)); var thisDaysDate=new Date(yearToStart, monthToStart, dayToStart+i+(w*7));
gHtmlDocument.write("<td style='border:1px solid black;' valign=top width=14%>"); gHtmlString += "<td style='border:1px solid black;' valign=top width=14%>";
gHtmlDocument.write("<table valign=top height=100 width=100% border=0>"); gHtmlString += "<table valign=top height=100 width=100% border=0>";
gHtmlDocument.write("<tr valign=top><td colspan=2 align=center valign=top >"); gHtmlString += "<tr valign=top><td colspan=2 align=center valign=top >";
gHtmlDocument.write(monthNames[thisDaysDate.getMonth()].substring(0,3)+" "+thisDaysDate.getDate()); gHtmlString += monthNames[thisDaysDate.getMonth()].substring(0,3)+" "+thisDaysDate.getDate();
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
gHtmlDocument.write("<tr valign=top><td valign=top width=20%></td><td valign=top width=80%></td></tr>"); gHtmlString += "<tr valign=top><td valign=top width=20%></td><td valign=top width=80%></td></tr>";
var calendarEventDisplay var calendarEventDisplay
// add each calendarEvent // add each calendarEvent
dayEventList = eventSource.getEventsForDay( thisDaysDate ); dayEventList = eventSource.getEventsForDay( thisDaysDate );
@ -301,22 +330,22 @@ function printMultiWeekView(currentDate)
if (calendarEventDisplay.event.allDay) if (calendarEventDisplay.event.allDay)
formattedTime=''; // all day event formattedTime=''; // all day event
if (calendarEventDisplay.event.allDay) if (calendarEventDisplay.event.allDay)
gHtmlDocument.write("<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>"); gHtmlString += "<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>";
else else
gHtmlDocument.write("<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>"+formattedTime+"</td></tr><tr><td></td><td valign=top style='font-size:11px;'>"); gHtmlString += "<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>"+formattedTime+"</td></tr><tr><td></td><td valign=top style='font-size:11px;'>";
gHtmlDocument.write(eventTitle); gHtmlString += eventTitle;
if (calendarEventDisplay.event.location) if (calendarEventDisplay.event.location)
gHtmlDocument.write("</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+locationTag+": "+calendarEventDisplay.event.location); gHtmlString += "</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+locationTag+": "+calendarEventDisplay.event.location;
if (calendarEventDisplay.event.url) if (calendarEventDisplay.event.url)
gHtmlDocument.write("</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+uriTag+": "+calendarEventDisplay.event.url); gHtmlString += "</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+uriTag+": "+calendarEventDisplay.event.url;
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
} }
} }
gHtmlDocument.write("</table>"); gHtmlString += "</table>";
} }
gHtmlDocument.write("</tr>"); gHtmlString += "</tr>";
} // end of all weeks } // end of all weeks
gHtmlDocument.write("</table>") gHtmlString += "</table>";
} }
function printWeekView(currentDate) function printWeekView(currentDate)
@ -326,32 +355,32 @@ function printWeekView(currentDate)
var weekStart=new Date(currentDate.getFullYear(), currentDate.getMonth(), dayStart - dowStart); var weekStart=new Date(currentDate.getFullYear(), currentDate.getMonth(), dayStart - dowStart);
var weekNumber = DateUtils.getWeekNumber(currentDate) ; var weekNumber = DateUtils.getWeekNumber(currentDate) ;
gHtmlDocument.write("<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr ><td align=center valign=bottom>Week "+weekNumber+"</td></tr></table>"); gHtmlString += "<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr ><td align=center valign=bottom>Week "+weekNumber+"</td></tr></table>";
gHtmlDocument.write("<table style='border:1px solid black;' width=100%>") gHtmlString += "<table style='border:1px solid black;' width=100%>";
gHtmlDocument.write("<tr>"); gHtmlString += "<tr>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[weekStart.getDay()]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[weekStart.getDay()]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+1 >6) ? weekStart.getDay()+1-7:weekStart.getDay()+1]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+1 >6) ? weekStart.getDay()+1-7:weekStart.getDay()+1]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+2 >6) ? weekStart.getDay()+2-7:weekStart.getDay()+2]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+2 >6) ? weekStart.getDay()+2-7:weekStart.getDay()+2]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+3 >6) ? weekStart.getDay()+3-7:weekStart.getDay()+3]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+3 >6) ? weekStart.getDay()+3-7:weekStart.getDay()+3]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+4 >6) ? weekStart.getDay()+4-7:weekStart.getDay()+4]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+4 >6) ? weekStart.getDay()+4-7:weekStart.getDay()+4]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+5 >6) ? weekStart.getDay()+5-7:weekStart.getDay()+5]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+5 >6) ? weekStart.getDay()+5-7:weekStart.getDay()+5]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+6 >6) ? weekStart.getDay()+6-7:weekStart.getDay()+6]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+6 >6) ? weekStart.getDay()+6-7:weekStart.getDay()+6]+"</td>";
gHtmlDocument.write("</tr>"); gHtmlString += "</tr>";
// content here // content here
dayToStart=weekStart.getDate(); dayToStart=weekStart.getDate();
monthToStart=weekStart.getMonth(); monthToStart=weekStart.getMonth();
yearToStart=weekStart.getFullYear(); yearToStart=weekStart.getFullYear();
gHtmlDocument.write("<tr>"); gHtmlString += "<tr>";
for (var i=0; i<7; i++) for (var i=0; i<7; i++)
{ {
var thisDaysDate=new Date(yearToStart, monthToStart, dayToStart+i); var thisDaysDate=new Date(yearToStart, monthToStart, dayToStart+i);
gHtmlDocument.write("<td style='border:1px solid black;' valign=top width=14% height=500>"); gHtmlString += "<td style='border:1px solid black;' valign=top width=14% height=500>";
gHtmlDocument.write("<table valign=top width=100 border=0>"); // to force uniform width gHtmlString += "<table valign=top width=100 border=0>"; // to force uniform width
gHtmlDocument.write("<tr valign=top><td valign=top colspan=2 align=center>"); gHtmlString += "<tr valign=top><td valign=top colspan=2 align=center>";
gHtmlDocument.write(monthNames[thisDaysDate.getMonth()].substring(0,3)+" "+thisDaysDate.getDate()); gHtmlString += monthNames[thisDaysDate.getMonth()].substring(0,3)+" "+thisDaysDate.getDate();
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
gHtmlDocument.write("<tr><td width=20%></td><td width=80%></td></tr>"); gHtmlString += "<tr><td width=20%></td><td width=80%></td></tr>";
var calendarEventDisplay var calendarEventDisplay
// add each calendarEvent // add each calendarEvent
dayEventList = eventSource.getEventsForDay( thisDaysDate ); dayEventList = eventSource.getEventsForDay( thisDaysDate );
@ -372,35 +401,35 @@ function printWeekView(currentDate)
var formattedEndTime=returnTime(eventEndTime); var formattedEndTime=returnTime(eventEndTime);
var formattedTime=formattedStartTime+"-"+formattedEndTime; var formattedTime=formattedStartTime+"-"+formattedEndTime;
if (calendarEventDisplay.event.allDay) if (calendarEventDisplay.event.allDay)
gHtmlDocument.write("<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>"); gHtmlString += "<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>";
else else
gHtmlDocument.write("<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>"+formattedTime+"</td></tr><tr><td></td><td valign=top style='font-size:11px;'>"); gHtmlString += "<tr valign=top><td valign=top colspan=2 style='font-size:11px;'>"+formattedTime+"</td></tr><tr><td></td><td valign=top style='font-size:11px;'>";
gHtmlDocument.write(eventTitle); gHtmlString += eventTitle;
if (calendarEventDisplay.event.location) if (calendarEventDisplay.event.location)
gHtmlDocument.write("</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+locationTag+": "+calendarEventDisplay.event.location); gHtmlString += "</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+locationTag+": "+calendarEventDisplay.event.location;
if (calendarEventDisplay.event.url) if (calendarEventDisplay.event.url)
gHtmlDocument.write("</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+uriTag+": "+calendarEventDisplay.event.url); gHtmlString += "</td></tr><tr valign=top><td></td><td valign=top style='font-size:11px;'>"+uriTag+": "+calendarEventDisplay.event.url;
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
} }
} }
gHtmlDocument.write("</table>"); gHtmlString += "</table>";
} }
gHtmlDocument.write("</tr>"); gHtmlString += "</tr>";
gHtmlDocument.write("</table>") gHtmlString += "</table>";
} }
function printDayView(currentDate) { function printDayView(currentDate) {
var dayStart = currentDate.getDate(); var dayStart = currentDate.getDate();
var mydateshow= gCalendarWindow.dateFormater.getLongFormatedDate(currentDate); var mydateshow= gCalendarWindow.dateFormater.getLongFormatedDate(currentDate);
gHtmlDocument.write("<table style='border:1px solid black;' width=100%>"); gHtmlString += "<table style='border:1px solid black;' width=100%>";
gHtmlDocument.write("<tr ><td colspan=2 align=center style='font-size:26px;font-weight:bold;border-bottom:1px solid black;'>"); gHtmlString += "<tr ><td colspan=2 align=center style='font-size:26px;font-weight:bold;border-bottom:1px solid black;'>";
gHtmlDocument.write(mydateshow); gHtmlString += mydateshow;
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
gHtmlDocument.write("<tr><td width=20% style='border-bottom:1px solid black;'>Time</td><td width=80% style='border-bottom:1px solid black;'>Event</td></tr>"); gHtmlString += "<tr><td width=20% style='border-bottom:1px solid black;'>Time</td><td width=80% style='border-bottom:1px solid black;'>Event</td></tr>";
gHtmlDocument.write("<tr style='height=20px;'><td colspan=2 style='border-bottom:1px solid black;'> </td></tr>"); // for entering a new appt gHtmlString += "<tr style='height=20px;'><td colspan=2 style='border-bottom:1px solid black;'> </td></tr>"; // for entering a new appt
var calendarEventDisplay var calendarEventDisplay
// add each calendarEvent // add each calendarEvent
dayEventList = eventSource.getEventsForDay( currentDate ); dayEventList = eventSource.getEventsForDay( currentDate );
@ -415,7 +444,7 @@ function printDayView(currentDate) {
listpriv=false; listpriv=false;
if (listpriv) if (listpriv)
{ {
gHtmlDocument.write("<tr style='height=20px;'><td valign=top style='border-bottom:1px solid black;'>"); gHtmlString += "<tr style='height=20px;'><td valign=top style='border-bottom:1px solid black;'>";
var eventStartTime = new Date( calendarEventDisplay.event.start.getTime() ) ; var eventStartTime = new Date( calendarEventDisplay.event.start.getTime() ) ;
var formattedStartTime=returnTime(eventStartTime); var formattedStartTime=returnTime(eventStartTime);
var eventEndTime = new Date( calendarEventDisplay.event.end.getTime() ) ; var eventEndTime = new Date( calendarEventDisplay.event.end.getTime() ) ;
@ -423,32 +452,32 @@ function printDayView(currentDate) {
var formattedTime=formattedStartTime+"-"+formattedEndTime; var formattedTime=formattedStartTime+"-"+formattedEndTime;
if (calendarEventDisplay.event.allDay) if (calendarEventDisplay.event.allDay)
formattedTime='All Day'; // all day event formattedTime='All Day'; // all day event
gHtmlDocument.write(formattedTime); gHtmlString += formattedTime;
gHtmlDocument.write("</td><td valign=top style='border-bottom:1px solid black;'>"+calendarEventDisplay.event.title); gHtmlString += "</td><td valign=top style='border-bottom:1px solid black;'>"+calendarEventDisplay.event.title;
if (calendarEventDisplay.event.description) if (calendarEventDisplay.event.description)
gHtmlDocument.write("<br><Strong>"+descriptionTag+"</strong>: "+calendarEventDisplay.event.description); gHtmlString += "<br><Strong>"+descriptionTag+"</strong>: "+calendarEventDisplay.event.description;
if (calendarEventDisplay.event.location) if (calendarEventDisplay.event.location)
gHtmlDocument.write("<br><strong>"+locationTag+"</strong>: "+calendarEventDisplay.event.location); gHtmlString += "<br><strong>"+locationTag+"</strong>: "+calendarEventDisplay.event.location;
if (calendarEventDisplay.event.url) if (calendarEventDisplay.event.url)
gHtmlDocument.write("<br><strong>"+uriTag+"</strong>: "+calendarEventDisplay.event.url); gHtmlString += "<br><strong>"+uriTag+"</strong>: "+calendarEventDisplay.event.url;
var mystat='Cancelled'; var mystat='Cancelled';
if (calendarEventDisplay.event.status == 10029) if (calendarEventDisplay.event.status == 10029)
mystat='Tentative'; mystat='Tentative';
if (calendarEventDisplay.event.status == 10030) if (calendarEventDisplay.event.status == 10030)
mystat='Confirmed'; mystat='Confirmed';
gHtmlDocument.write("<br><strong>Status</strong>: "+mystat); gHtmlString += "<br><strong>Status</strong>: "+mystat;
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
gHtmlDocument.write("<tr style='height=20px;'><td colspan=2 style='border-bottom:1px solid black;'> </td></tr>"); // for entering a new appt gHtmlString += "<tr style='height=20px;'><td colspan=2 style='border-bottom:1px solid black;'> </td></tr>"; // for entering a new appt
} }
} }
gHtmlDocument.write("</table>"); gHtmlString += "</table>";
} }
function printEventArray( calendarEventArray) function printEventArray( calendarEventArray)
{ {
gHtmlDocument.write("<table width=100%>"); gHtmlString += "<table width=100%>";
gHtmlDocument.write("<tr><td width=20%>Starts</td><td width=20%>Ends</td><td width=60%>Event</td></tr>"); gHtmlString += "<tr><td width=20%>Starts</td><td width=20%>Ends</td><td width=60%>Event</td></tr>";
for (i in calendarEventArray) for (i in calendarEventArray)
{ {
var calEvent=calendarEventArray[i]; var calEvent=calendarEventArray[i];
@ -459,35 +488,35 @@ function printEventArray( calendarEventArray)
useit=false; useit=false;
if (useit) if (useit)
{ {
gHtmlDocument.write("<tr><td valign=top>"); gHtmlString += "<tr><td valign=top>";
if (calEvent.allDay) if (calEvent.allDay)
{ {
gHtmlDocument.write("All Day"); gHtmlString += "All Day";
gHtmlDocument.write("</td><td>"); gHtmlString += "</td><td>";
} else { } else {
gHtmlDocument.write(calEvent.start); gHtmlString += calEvent.start;
gHtmlDocument.write("</td><td valign=top>"); gHtmlString += "</td><td valign=top>";
gHtmlDocument.write(calEvent.end); gHtmlString += calEvent.end;
} }
gHtmlDocument.write("</td><td valign=top>"); gHtmlString += "</td><td valign=top>";
gHtmlDocument.write(calEvent.title); gHtmlString += calEvent.title;
if (calEvent.description) if (calEvent.description)
gHtmlDocument.write("<br>"+descriptionTag+": "+calEvent.description); gHtmlString += "<br>"+descriptionTag+": "+calEvent.description;
if (calEvent.location) if (calEvent.location)
gHtmlDocument.write("<br>"+locationTag+": "+calEvent.location); gHtmlString += "<br>"+locationTag+": "+calEvent.location;
if (calEvent.url) if (calEvent.url)
gHtmlDocument.write("<br>"+uriTag+": "+calEvent.url); gHtmlString += "<br>"+uriTag+": "+calEvent.url;
var mystat='Cancelled'; var mystat='Cancelled';
if (calEvent.status == 10029) if (calEvent.status == 10029)
mystat='Tentative'; mystat='Tentative';
if (calEvent.status == 10030) if (calEvent.status == 10030)
mystat='Confirmed'; mystat='Confirmed';
gHtmlDocument.write("<br>Status: "+mystat); gHtmlString += "<br>Status: "+mystat;
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
} }
} }
gHtmlDocument.write("</table>"); gHtmlString += "</table>";
} }
function printMonthView(currentDate) { function printMonthView(currentDate) {
@ -500,18 +529,17 @@ function printMonthView(currentDate) {
var endOfMonthDate = new Date(currentDate.getFullYear(), currentDate.getMonth()+1, 0); var endOfMonthDate = new Date(currentDate.getFullYear(), currentDate.getMonth()+1, 0);
var daysInMonth = endOfMonthDate.getDate(); var daysInMonth = endOfMonthDate.getDate();
gHtmlDocument.write("<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr ><td align=center valign=bottom>"+monthNames[currentDate.getMonth()]+" "+currentDate.getFullYear()+"</td></tr></table>"); gHtmlString += "<table border=0 width=100% style='font-size:26px;font-weight:bold;'><tr ><td align=center valign=bottom>"+monthNames[currentDate.getMonth()]+" "+currentDate.getFullYear()+"</td></tr></table>";
gHtmlDocument.write("<table style='border:1px solid black;' width=100%>") gHtmlString += "<table style='border:1px solid black;' width=100%>";
gHtmlDocument.write("<tr>"); gHtmlString += "<tr>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[weekStart.getDay()]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[weekStart.getDay()]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+1 >6) ? weekStart.getDay()+1-7:weekStart.getDay()+1]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+1 >6) ? weekStart.getDay()+1-7:weekStart.getDay()+1]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+2 >6) ? weekStart.getDay()+2-7:weekStart.getDay()+2]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+2 >6) ? weekStart.getDay()+2-7:weekStart.getDay()+2]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+3 >6) ? weekStart.getDay()+3-7:weekStart.getDay()+3]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+3 >6) ? weekStart.getDay()+3-7:weekStart.getDay()+3]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+4 >6) ? weekStart.getDay()+4-7:weekStart.getDay()+4]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+4 >6) ? weekStart.getDay()+4-7:weekStart.getDay()+4]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+5 >6) ? weekStart.getDay()+5-7:weekStart.getDay()+5]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+5 >6) ? weekStart.getDay()+5-7:weekStart.getDay()+5]+"</td>";
gHtmlDocument.write("<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+6 >6) ? weekStart.getDay()+6-7:weekStart.getDay()+6]+"</td>"); gHtmlString += "<td align=center style='border:1px solid black;background-color:#e0e0e0;FONT-SIZE:12px;FONT-WEIGHT: bold'>"+ArrayOfDayNames[(weekStart.getDay()+6 >6) ? weekStart.getDay()+6-7:weekStart.getDay()+6]+"</td>";
gHtmlDocument.write("</tr>"); gHtmlString += "</tr>";
dayToStart=weekStart.getDate(); dayToStart=weekStart.getDate();
monthToStart=weekStart.getMonth(); monthToStart=weekStart.getMonth();
yearToStart=weekStart.getFullYear(); yearToStart=weekStart.getFullYear();
@ -522,14 +550,13 @@ function printMonthView(currentDate) {
{ {
if (inMonth) if (inMonth)
{ {
gHtmlDocument.write("<tr>"); gHtmlString += "<tr>";
for (var i=0; i<7; i++) for (var i=0; i<7; i++)
{ {
gHtmlDocument.write("<td align=left valign=top style='border:1px solid black;vertical-alignment:top;' >"); gHtmlString += "<td align=left valign=top style='border:1px solid black;vertical-alignment:top;' >"; gHtmlString += "<table valign=top height=100 width=100 style='font-size:10px;'><tr valign=top><td valign=top width=20%>";
gHtmlDocument.write("<table valign=top height=100 width=100 style='font-size:10px;'><tr valign=top><td valign=top width=20%>");
if (thisDaysDate.getMonth()==currentDate.getMonth()) if (thisDaysDate.getMonth()==currentDate.getMonth())
gHtmlDocument.write(thisDaysDate.getDate()); gHtmlString += thisDaysDate.getDate();
gHtmlDocument.write("</td><td width=80% valign=top></td></tr>"); gHtmlString += "</td><td width=80% valign=top></td></tr>";
if (thisDaysDate.getMonth()==currentDate.getMonth()) if (thisDaysDate.getMonth()==currentDate.getMonth())
{ {
dayEventList = eventSource.getEventsForDay( thisDaysDate ); dayEventList = eventSource.getEventsForDay( thisDaysDate );
@ -548,27 +575,27 @@ function printMonthView(currentDate) {
var eventStartTime = new Date( calendarEventDisplay.event.start.getTime() ) ; var eventStartTime = new Date( calendarEventDisplay.event.start.getTime() ) ;
var formattedStartTime=returnTime(eventStartTime); var formattedStartTime=returnTime(eventStartTime);
if (calendarEventDisplay.event.allDay) if (calendarEventDisplay.event.allDay)
gHtmlDocument.write("<tr><td valign=top colspan=2 style='font-size:11px;'>"); gHtmlString += "<tr><td valign=top colspan=2 style='font-size:11px;'>";
else else
gHtmlDocument.write("<tr><td valign=top align=right style='font-size:11px;'>"+formattedStartTime+"</td><td valign=top style='font-size:11px;'>"); gHtmlString += "<tr><td valign=top align=right style='font-size:11px;'>"+formattedStartTime+"</td><td valign=top style='font-size:11px;'>";
gHtmlDocument.write(eventTitle); gHtmlString += eventTitle;
gHtmlDocument.write("</td></tr>"); gHtmlString += "</td></tr>";
} }
} //end of events } //end of events
} // if it was in the month } // if it was in the month
gHtmlDocument.write("</table>"); gHtmlString += "</table>";
gHtmlDocument.write("</td>") gHtmlString += "</td>";
//advance to the next day //advance to the next day
thisDaysDate.setDate(thisDaysDate.getDate()+1); thisDaysDate.setDate(thisDaysDate.getDate()+1);
} //end of each day } //end of each day
gHtmlDocument.write("</tr>"); gHtmlString += "</tr>";
} // ok it was in the month } // ok it was in the month
if ( ( thisDaysDate.getMonth() > currentDate.getMonth() ) || if ( ( thisDaysDate.getMonth() > currentDate.getMonth() ) ||
( thisDaysDate.getFullYear() > currentDate.getFullYear() ) ) ( thisDaysDate.getFullYear() > currentDate.getFullYear() ) )
inMonth=false; inMonth=false;
} // end of each week } // end of each week
gHtmlDocument.write("</table>") gHtmlString += "</table>";
} }
function returnTime(timeval) { function returnTime(timeval) {