From b170fe921e327d8d1be9768d30305ba953ccae9f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 16 Sep 2014 14:20:26 +0100 Subject: Added a section on bing words if you enable desktop notifications. --- webclient/settings/settings-controller.js | 11 ++++++++++- webclient/settings/settings.html | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'webclient/settings') diff --git a/webclient/settings/settings-controller.js b/webclient/settings/settings-controller.js index 8c877a24e9..9cdace704a 100644 --- a/webclient/settings/settings-controller.js +++ b/webclient/settings/settings-controller.js @@ -194,7 +194,16 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu /*** Desktop notifications section ***/ $scope.settings = { - notifications: undefined + notifications: undefined, + bingWords: matrixService.config().bingWords + }; + + $scope.saveBingWords = function() { + console.log("Saving words: "+JSON.stringify($scope.settings.bingWords)); + var config = matrixService.config(); + config.bingWords = $scope.settings.bingWords; + matrixService.setConfig(config); + matrixService.saveConfig(); }; // If the browser supports it, check the desktop notification state diff --git a/webclient/settings/settings.html b/webclient/settings/settings.html index c358a6e9d8..3b3dd3dadd 100644 --- a/webclient/settings/settings.html +++ b/webclient/settings/settings.html @@ -52,6 +52,14 @@
Notifications are enabled. +
+

Words to alert on:

+ +
    +
  • {{word}}
  • +
+
You have denied permission for notifications.
-- cgit 1.4.1 From a402e0c5e6e432a175b48279c972bc9ae7e944bc Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 16 Sep 2014 15:15:19 +0100 Subject: Added bing detection logic. Persist the display name of the user in localstorage for use when binging. --- .../components/matrix/event-handler-service.js | 37 ++++++++++++++++++++-- webclient/home/home-controller.js | 4 +++ webclient/room/room-controller.js | 4 +-- webclient/settings/settings.html | 6 ++-- 4 files changed, 44 insertions(+), 7 deletions(-) (limited to 'webclient/settings') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 8783b9b1e0..16d5763ed2 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -140,8 +140,41 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { } if (window.Notification) { - // Show notification when the window is hidden, or the user is idle - if (document.hidden || matrixService.presence.unavailable === mPresence.getState()) { + var bingWords = matrixService.config().bingWords; + var content = event.content.body; + var shouldBing = false; + + // case-insensitive name check for user_id OR display_name if they exist + var myUserId = matrixService.config().user_id; + if (myUserId) { + myUserId = myUserId.toLocaleLowerCase(); + } + var myDisplayName = matrixService.config().display_name; + if (myDisplayName) { + myDisplayName = myDisplayName.toLocaleLowerCase(); + } + if ( (myDisplayName && content.toLocaleLowerCase().indexOf(myDisplayName) != -1) || + (myUserId && content.toLocaleLowerCase().indexOf(myUserId) != -1) ) { + shouldBing = true; + } + + // bing word list check + if (bingWords && !shouldBing) { + for (var i=0; iDesktop notifications
- Notifications are enabled. + Notifications are enabled. You will be alerted when a message contains your user ID or display name.
-

Words to alert on:

- Additional words to alert on: +
  • {{word}}
  • -- cgit 1.4.1 From 3395a3305f9477e950849b18c2caacfef70c118b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 16 Sep 2014 15:47:29 +0100 Subject: Bing on all the things if there are 0 bing words. --- webclient/components/matrix/event-handler-service.js | 6 ++++++ webclient/settings/settings.html | 1 + 2 files changed, 7 insertions(+) (limited to 'webclient/settings') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index d61a150463..72859eae3e 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -189,6 +189,12 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { // notifications when currently viewing the chat screen though, but that is preferable to the alternative imo. var isIdle = (document.hidden || matrixService.presence.unavailable === mPresence.getState()); + // always bing if there are 0 bing words... apparently. + var bingWords = matrixService.config().bingWords; + if (bingWords && bingWords.length === 0) { + shouldBing = true; + } + if (shouldBing) { console.log("Displaying notification for "+JSON.stringify(event)); var notification = new window.Notification( diff --git a/webclient/settings/settings.html b/webclient/settings/settings.html index 1a42ae435a..b251cce569 100644 --- a/webclient/settings/settings.html +++ b/webclient/settings/settings.html @@ -54,6 +54,7 @@ Notifications are enabled. You will be alerted when a message contains your user ID or display name.

    Additional words to alert on:

    +

    Leave blank to alert on all messages.

      -- cgit 1.4.1 From d7b206cc9325e4cc7b460bf5bfc218ad2b304fc1 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 16 Sep 2014 16:01:38 +0100 Subject: Added basic RegExp support. --- webclient/components/matrix/event-handler-service.js | 6 ++---- webclient/settings/settings.html | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'webclient/settings') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 72859eae3e..0c7c0d1696 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -74,10 +74,8 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { // bing word list check if (bingWords && !shouldBing) { for (var i=0; i

      Additional words to alert on:

      Leave blank to alert on all messages.

      -
      • {{word}}
      • -- cgit 1.4.1