The Pug Automatic

Adapting the iCal Events widget for iCalTV

Written July 27, 2006. Tagged JavaScript, OS X, Dashboard widgets.

iCal Events widget

I realized it'd be nice to have a widget that displays the upcoming favorite TV shows entered into iCal by iCalTV.

The easiest solution was to use the iCal Events widget, setting it to only display events from the "TV" calendar.

I made two small adjustments to the widget to fit iCalTV better.

For one, I made it not display newlines and anything trailing them, in event titles. Having the description as part of the title looks great in reminders, but not so good in a listing such as this one.

Also, if an event (a show, in this case) spans two days, it would appear once under the heading for each day, without the starting time on the second day. I changed it so it only appears on the day the show starts.

The changes follow as a unidiff (man diff, man patch):

--- iCalEvents.js.old	2006-07-27 20:27:58.000000000 +0200
+++ iCalEvents.js 2006-07-27 20:39:07.000000000 +0200
@@ -262,7 +262,7 @@
currentDayEnd_getTime > startDate_getTime))
displayTime = true;
else
- displayTime = false;
+ continue;

if (currentDayStart_getTime >= endDate_getTime) {
// TODO: optimization here using firstEventConsidered.
@@ -311,7 +311,7 @@

paperHTML += ">";
if (summary)
- paperHTML += summary;
+ paperHTML += summary.replace(/\n.+/, "");
paperHTML += "</td></tr>";

} else {

Download.

Apply it with e.g.

patch ~/Library/Widgets/iCal\ Events.wdgt/iCalEvents.js < icalevents.diff