diff --git a/src/_locales/en_US/messages.json b/src/_locales/en_US/messages.json
index 24445d4..cfb2a4a 100644
--- a/src/_locales/en_US/messages.json
+++ b/src/_locales/en_US/messages.json
@@ -85,5 +85,11 @@
},
"playMessageSounds":{
"message": "Play sound messages"
+ },
+ "highlightPostIfPersonSaysSomething":{
+ "message": "Highlight posts with these words"
+ },
+ "highlightPostIfPersonSaysSomethingDescription":{
+ "message": "Put a word or phrase on each line:"
}
}
diff --git a/src/manifest.json b/src/manifest.json
index daad661..7d24913 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -53,6 +53,7 @@
"scripts/kindling.emoji.js",
"scripts/kindling.sounds.js",
"scripts/kindling.highlight.js",
+ "scripts/kindling.highlightpostifpersonsayssomething.js",
"scripts/kindling.messagefilter.js",
"scripts/kindling.avatars.js",
"scripts/kindling.notificationpublisher.js",
diff --git a/src/options.html b/src/options.html
index c4f6fc9..6bdb761 100644
--- a/src/options.html
+++ b/src/options.html
@@ -97,6 +97,15 @@
+
+
+
+
+
+
+
{highlightPostIfPersonSaysSomethingDescription}
+
+
diff --git a/src/scripts/kindling.background.js b/src/scripts/kindling.background.js
index 2344c26..8ed5dbf 100644
--- a/src/scripts/kindling.background.js
+++ b/src/scripts/kindling.background.js
@@ -95,6 +95,7 @@ kindling.module(function () {
initOption('useLargeAvatars', 'false');
initOption('minimalInterface', 'false');
initOption('expandAbbreviations', 'true');
+ initOption('highlightPostIfPersonSaysSomething', 'false');
initOption('htmlNotifications', 'true');
initOption('playMessageSounds', 'true');
initOption('showAvatarsInNotifications', localStorage.showAvatars === 'false' ? 'false' : 'true');
diff --git a/src/scripts/kindling.highlightpostifpersonsayssomething.js b/src/scripts/kindling.highlightpostifpersonsayssomething.js
new file mode 100644
index 0000000..a5bc3d3
--- /dev/null
+++ b/src/scripts/kindling.highlightpostifpersonsayssomething.js
@@ -0,0 +1,40 @@
+kindling.module(function () {
+ 'use strict';
+
+ function resetPostBorders(){
+ $('#chat-wrapper div').css("border", "");
+ }
+
+ function changePostsBorder(wordList, borderStyle){
+ if(wordList == "") return;
+
+ var words = wordList.split('\n');
+ for(var i = 0; i < words.length; i++){
+ $('#chat-wrapper div:contains(' + words[i] + ')').css("border", borderStyle);
+ }
+ }
+
+ function highlightPostIfPersonSaysSomething(e, options, username) {
+
+ if(options.highlightPostIfPersonSaysSomething === 'true'){
+ changePostsBorder(options.highlightPostWordList, "9px solid red");
+ }
+
+ }
+
+ function onOptionsChanged(e, options) {
+
+ resetPostBorders();
+
+ if(options.highlightPostIfPersonSaysSomething === 'true'){
+ changePostsBorder(options.highlightPostWordList, "9px solid red")
+ }
+ }
+
+ return {
+ init: function () {
+ $.subscribe('newMessage', highlightPostIfPersonSaysSomething);
+ $.subscribe('optionsChanged', onOptionsChanged);
+ }
+ };
+}());
diff --git a/src/scripts/kindling.options.js b/src/scripts/kindling.options.js
index b8e8f02..d8669f8 100644
--- a/src/scripts/kindling.options.js
+++ b/src/scripts/kindling.options.js
@@ -17,7 +17,8 @@ kindling.module(function () {
'showAvatarsInChat',
'useLargeAvatars',
'playMessageSounds',
- 'useDifferentTheme'
+ 'useDifferentTheme',
+ 'highlightPostIfPersonSaysSomething'
];
function getMessages() {
@@ -73,6 +74,22 @@ kindling.module(function () {
onOptionChanged();
}
+ function onHighlightPostWordListChanged() {
+ var wordList = $('#highlightPostWordList textarea').val().split("\n");
+ wordList = removeEmptiesFromWordList(wordList);
+ localStorage.highlightPostWordList = wordList.join("\n");
+ onOptionChanged();
+ }
+
+ function removeEmptiesFromWordList(originalArray){
+ var i = 0;
+
+ while(i < originalArray.length)
+ originalArray[i] === "" ? originalArray.splice( i, 1 ) : i++;
+
+ return originalArray;
+ }
+
function onToggle(e) {
var option = $(e.currentTarget).attr('for');
var value = localStorage[option];
@@ -94,6 +111,8 @@ kindling.module(function () {
$('#themeColor input[title=' + localStorage.themeColor + ']').attr('checked', true);
+ $('#highlightPostWordList textarea').val(localStorage.highlightPostWordList);
+
var notificationTimeoutSlider = document.getElementById('notificationTimeout');
notificationTimeoutSlider.value = localStorage.notificationTimeout;
onNotificationTimeoutChanged();
@@ -117,6 +136,8 @@ kindling.module(function () {
$('#themeColor').change(onThemeColorChanged);
+ $('#highlightPostWordList').change(onHighlightPostWordListChanged);
+
initOptions();
}
};