Skip to content

Commit

Permalink
Add Calendar Name (#6)
Browse files Browse the repository at this point in the history
* Add Calendar to Title

Adds an option to include the calendar name in title -- Useful when pulling ical feeds from multiple calendars.

(Pull request here since this seems to be the current fork getting the focus of development.)

* Add cal exists checks

Add check per https://github.com/lbell/GAS-ICS-Sync-CalAPIv3/pull/1#issuecomment-533920898
  • Loading branch information
lbell authored and jonas0b1011001 committed Sep 23, 2019
1 parent 9e8cb3f commit c986f8a
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@

var targetCalendarName = "Full API TEST"; // The name of the Google Calendar you want to add events to
var sourceCalendarURLs = [""
]; // The ics/ical urls that you want to get events from
]; // The ics/ical urls that you want to get events from ["url","url","url"]

var howFrequent = 15; // What interval (minutes) to run this script on to check for new events
var addEventsToCalendar = true; // If you turn this to "false", you can check the log (View > Logs) to make sure your events are being read correctly before turning this on
var modifyExistingEvents = true; // If you turn this to "false", any event in the feed that was modified after being added to the calendar will not update
var removeEventsFromCalendar = true; // If you turn this to "true", any event in the calendar not found in the feed will be removed.
var addAlerts = true; // Whether to add the ics/ical alerts as notifications on the Google Calendar events, this will override the standard reminders specified by the target calendar.
var addOrganizerToTitle = false; // Whether to prefix the event name with the event organiser for further clarity
var addCalToTitle = true; // Whether to add the source calendar to title
var addTasks = false;

var emailWhenAdded = false; // Will email you when an event is added to your calendar
Expand Down Expand Up @@ -125,7 +126,11 @@ function main(){
for each (var tz in vtimezones){
ICAL.TimezoneService.register(tz);
}
vevents = [].concat(component.getAllSubcomponents("vevent"), vevents);

var allevents = component.getAllSubcomponents("vevent");
var calName = component.getFirstPropertyValue("name");
if (calName != null) allevents.forEach(function(event){event.addPropertyWithValue("parentCal", calName); });
vevents = [].concat(allevents, vevents);
}
vevents.forEach(function(event){ icsEventIds.push(event.getFirstPropertyValue('uid').toString()); });

Expand Down Expand Up @@ -221,6 +226,13 @@ function main(){
newEvent.summary = organizer + ": " + vevent.summary;
}

if (addCalToTitle && event.hasProperty('parentCal')){
var calName = event.getFirstPropertyValue('parentCal');

if (calName != null)
newEvent.summary = calName + ": " + vevent.summary;
}

newEvent.iCalUID = vevent.uid;
newEvent.description = vevent.description;
newEvent.location = vevent.location;
Expand Down Expand Up @@ -537,4 +549,4 @@ function eventChanged(event, icsEvent, calEvent){
// return true;

return false;
}
}

0 comments on commit c986f8a

Please sign in to comment.