From 5df818a19c43f4d6237bff3402e665881c4f4d99 Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Sun, 12 Mar 2017 11:36:40 -0500 Subject: [PATCH 1/3] Add in support to hide and exclude events based on a filter --- modules/default/calendar/README.md | 1 + modules/default/calendar/calendar.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/default/calendar/README.md b/modules/default/calendar/README.md index bc2e9771..81981243 100644 --- a/modules/default/calendar/README.md +++ b/modules/default/calendar/README.md @@ -44,6 +44,7 @@ The following properties can be configured: | `urgency` | When using a timeFormat of `absolute`, the `urgency` setting allows you to display events within a specific time frame as `relative`. This allows events within a certain time frame to be displayed as relative (in xx days) while others are displayed as absolute dates

**Possible values:** a positive integer representing the number of days for which you want a relative date, for example `7` (for 7 days)

**Default value:** `7` | `broadcastEvents` | If this property is set to true, the calendar will broadcast all the events to all other modules with the notification message: `CALENDAR_EVENTS`. The event objects are stored in an array and contain the following fields: `title`, `startDate`, `endDate`, `fullDayEvent`, `location` and `geo`.

**Possible values:** `true`, `false`

**Default value:** `true` | `hidePrivate` | Hides private calendar events.

**Possible values:** `true` or `false`
**Default value:** `false` +| `excludedEvents` | An array of words / phrases from event titles that will be excluded from being shown.

**Example:** `['Birthday', 'Hide This Event']`
**Default value:** `[""]` ### Calendar configuration diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 644fc1f6..7c075d1c 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -38,7 +38,10 @@ Module.register("calendar", { "De verjaardag van ": "", "'s birthday": "" }, - broadcastEvents: true + broadcastEvents: true, + excludedEvents: [ + "" + ] }, // Define required scripts. @@ -120,6 +123,19 @@ Module.register("calendar", { for (var e in events) { var event = events[e]; + var excluded = false; + for (var f in this.config.excludedEvents) { + var filter = this.config.excludedEvents[f]; + if (event.title.toLowerCase().includes(filter.toLowerCase())) { + excluded = true; + break; + } + } + + if (excluded) { + continue; + } + var eventWrapper = document.createElement("tr"); if (this.config.colored) { From 873125abe10bb39895f97460f169c97518df3ae5 Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Sun, 12 Mar 2017 11:39:05 -0500 Subject: [PATCH 2/3] Add changes to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 564564cb..4b209397 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Korean Translation. - Added console warning on startup when deprecated config options are used - Added `DAYAFTERTOMORROW`, `UPDATE_NOTIFICATION`, `UPDATE_NOTIFICATION_MODULE`, `UPDATE_INFO` to Norwegian translations (`nn` and `nb`). +- Added in the ability to hide events in the calendar module based on simple string filters. ### Fixed - Update .gitignore to not ignore default modules folder. From 5466e1b733682282fc287b026d8185197c9aefa2 Mon Sep 17 00:00:00 2001 From: Andrew McOlash Date: Sun, 12 Mar 2017 20:22:40 -0500 Subject: [PATCH 3/3] Remove unnecessary string from excluded array --- modules/default/calendar/README.md | 2 +- modules/default/calendar/calendar.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/default/calendar/README.md b/modules/default/calendar/README.md index 81981243..713b7940 100644 --- a/modules/default/calendar/README.md +++ b/modules/default/calendar/README.md @@ -44,7 +44,7 @@ The following properties can be configured: | `urgency` | When using a timeFormat of `absolute`, the `urgency` setting allows you to display events within a specific time frame as `relative`. This allows events within a certain time frame to be displayed as relative (in xx days) while others are displayed as absolute dates

**Possible values:** a positive integer representing the number of days for which you want a relative date, for example `7` (for 7 days)

**Default value:** `7` | `broadcastEvents` | If this property is set to true, the calendar will broadcast all the events to all other modules with the notification message: `CALENDAR_EVENTS`. The event objects are stored in an array and contain the following fields: `title`, `startDate`, `endDate`, `fullDayEvent`, `location` and `geo`.

**Possible values:** `true`, `false`

**Default value:** `true` | `hidePrivate` | Hides private calendar events.

**Possible values:** `true` or `false`
**Default value:** `false` -| `excludedEvents` | An array of words / phrases from event titles that will be excluded from being shown.

**Example:** `['Birthday', 'Hide This Event']`
**Default value:** `[""]` +| `excludedEvents` | An array of words / phrases from event titles that will be excluded from being shown.

**Example:** `['Birthday', 'Hide This Event']`
**Default value:** `[]` ### Calendar configuration diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 7c075d1c..f13345fb 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -39,9 +39,7 @@ Module.register("calendar", { "'s birthday": "" }, broadcastEvents: true, - excludedEvents: [ - "" - ] + excludedEvents: [] }, // Define required scripts. @@ -135,7 +133,7 @@ Module.register("calendar", { if (excluded) { continue; } - + var eventWrapper = document.createElement("tr"); if (this.config.colored) {