From 4e6ce0c7f6d1f8fd09b64a3a542e4a94e8540ad6 Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Sat, 27 Jul 2013 00:04:12 +0100 Subject: [PATCH 1/8] highlights all posts with 'something' in it --- src/manifest.json | 1 + ...ling.highlightpostifpersonsayssomething.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/scripts/kindling.highlightpostifpersonsayssomething.js 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/scripts/kindling.highlightpostifpersonsayssomething.js b/src/scripts/kindling.highlightpostifpersonsayssomething.js new file mode 100644 index 0000000..85a3756 --- /dev/null +++ b/src/scripts/kindling.highlightpostifpersonsayssomething.js @@ -0,0 +1,19 @@ +kindling.module(function () { + 'use strict'; + + function highlightPostIfPersonSaysSomething(e, options, username) { + + if (!options || username === '') { + return; + } + + $('#chat-wrapper div:contains("something")').css("border","9px solid red"); + + } + + return { + init: function () { + $.subscribe('newMessage', highlightPostIfPersonSaysSomething); + } + }; +}()); From dab19799aa9c33e3a09b6dafac658cf25567dc10 Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Sat, 27 Jul 2013 00:59:49 +0100 Subject: [PATCH 2/8] Added responsive option --- src/_locales/en_US/messages.json | 3 +++ src/options.html | 8 ++++++++ src/scripts/kindling.background.js | 1 + ...ling.highlightpostifpersonsayssomething.js | 19 +++++++++++++++---- src/scripts/kindling.options.js | 3 ++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/_locales/en_US/messages.json b/src/_locales/en_US/messages.json index 24445d4..8b40954 100644 --- a/src/_locales/en_US/messages.json +++ b/src/_locales/en_US/messages.json @@ -85,5 +85,8 @@ }, "playMessageSounds":{ "message": "Play sound messages" + }, + "highlightPostIfPersonSaysSomething":{ + "message": "Highlight posts with these words" } } diff --git a/src/options.html b/src/options.html index c4f6fc9..57ab7b2 100644 --- a/src/options.html +++ b/src/options.html @@ -97,6 +97,14 @@

+

+ + + +

+
+ +
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 index 85a3756..ee86dfe 100644 --- a/src/scripts/kindling.highlightpostifpersonsayssomething.js +++ b/src/scripts/kindling.highlightpostifpersonsayssomething.js @@ -1,19 +1,30 @@ kindling.module(function () { 'use strict'; + function changePostsBorder(borderStyle){ + $('#chat-wrapper div:contains("something")').css("border", borderStyle); + } + function highlightPostIfPersonSaysSomething(e, options, username) { - if (!options || username === '') { - return; + if(options.highlightPostIfPersonSaysSomething === 'true'){ + changePostsBorder("9px solid red"); } - - $('#chat-wrapper div:contains("something")').css("border","9px solid red"); } + function onOptionsChanged(e, options) { + if(options.highlightPostIfPersonSaysSomething === 'true'){ + changePostsBorder("9px solid red") + }else{ + changePostsBorder(""); + } + } + 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..003d02d 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() { From eeb3509bf099bbd821f839d6c5ccadfd0f940427 Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Sat, 27 Jul 2013 01:11:50 +0100 Subject: [PATCH 3/8] Can load and save changes to word list --- src/scripts/kindling.options.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/scripts/kindling.options.js b/src/scripts/kindling.options.js index 003d02d..64c83c3 100644 --- a/src/scripts/kindling.options.js +++ b/src/scripts/kindling.options.js @@ -74,6 +74,10 @@ kindling.module(function () { onOptionChanged(); } + function onHighlightPostWordListChanged() { + localStorage.highlightPostWordList = $('#highlightPostWordList textarea').val(); + } + function onToggle(e) { var option = $(e.currentTarget).attr('for'); var value = localStorage[option]; @@ -95,6 +99,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(); @@ -118,6 +124,8 @@ kindling.module(function () { $('#themeColor').change(onThemeColorChanged); + $('#highlightPostWordList').change(onHighlightPostWordListChanged); + initOptions(); } }; From 56ad18ba94292013ca00f072848c4c51bd379415 Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Sat, 27 Jul 2013 01:34:54 +0100 Subject: [PATCH 4/8] Highlights posts with words in word list --- ...ling.highlightpostifpersonsayssomething.js | 20 +++++++++++++------ src/scripts/kindling.options.js | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/scripts/kindling.highlightpostifpersonsayssomething.js b/src/scripts/kindling.highlightpostifpersonsayssomething.js index ee86dfe..5bec87b 100644 --- a/src/scripts/kindling.highlightpostifpersonsayssomething.js +++ b/src/scripts/kindling.highlightpostifpersonsayssomething.js @@ -1,23 +1,31 @@ kindling.module(function () { 'use strict'; - function changePostsBorder(borderStyle){ - $('#chat-wrapper div:contains("something")').css("border", borderStyle); + function resetPostBorders(){ + $('#chat-wrapper div').css("border", ""); + } + + function changePostsBorder(wordList, borderStyle){ + 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("9px solid red"); + changePostsBorder(options.highlightPostWordList, "9px solid red"); } } function onOptionsChanged(e, options) { + + resetPostBorders(); + if(options.highlightPostIfPersonSaysSomething === 'true'){ - changePostsBorder("9px solid red") - }else{ - changePostsBorder(""); + changePostsBorder(options.highlightPostWordList, "9px solid red") } } diff --git a/src/scripts/kindling.options.js b/src/scripts/kindling.options.js index 64c83c3..79c6fb7 100644 --- a/src/scripts/kindling.options.js +++ b/src/scripts/kindling.options.js @@ -76,6 +76,7 @@ kindling.module(function () { function onHighlightPostWordListChanged() { localStorage.highlightPostWordList = $('#highlightPostWordList textarea').val(); + onOptionChanged(); } function onToggle(e) { From 85363b6bdecf830c44a73915c8454247c9bac29a Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Sat, 27 Jul 2013 01:39:57 +0100 Subject: [PATCH 5/8] Tweaked layout and default word list --- src/options.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/options.html b/src/options.html index 57ab7b2..7287a13 100644 --- a/src/options.html +++ b/src/options.html @@ -103,7 +103,7 @@

- +
From d1da343c89347126d54e991060f6b2d79fc7e1ca Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Sat, 27 Jul 2013 10:31:09 +0100 Subject: [PATCH 6/8] Clarified instructions --- src/_locales/en_US/messages.json | 3 +++ src/options.html | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/_locales/en_US/messages.json b/src/_locales/en_US/messages.json index 8b40954..cfb2a4a 100644 --- a/src/_locales/en_US/messages.json +++ b/src/_locales/en_US/messages.json @@ -88,5 +88,8 @@ }, "highlightPostIfPersonSaysSomething":{ "message": "Highlight posts with these words" + }, + "highlightPostIfPersonSaysSomethingDescription":{ + "message": "Put a word or phrase on each line:" } } diff --git a/src/options.html b/src/options.html index 7287a13..6bdb761 100644 --- a/src/options.html +++ b/src/options.html @@ -103,7 +103,8 @@

- +

{highlightPostIfPersonSaysSomethingDescription}

+
From 5d42938598fde69a136d344ed6ea988aed0f13c8 Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Tue, 30 Jul 2013 09:47:14 +0100 Subject: [PATCH 7/8] Fixed bug where empty lines in wordlist highlighted everything --- .../kindling.highlightpostifpersonsayssomething.js | 2 ++ src/scripts/kindling.options.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/scripts/kindling.highlightpostifpersonsayssomething.js b/src/scripts/kindling.highlightpostifpersonsayssomething.js index 5bec87b..a5bc3d3 100644 --- a/src/scripts/kindling.highlightpostifpersonsayssomething.js +++ b/src/scripts/kindling.highlightpostifpersonsayssomething.js @@ -6,6 +6,8 @@ kindling.module(function () { } 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); diff --git a/src/scripts/kindling.options.js b/src/scripts/kindling.options.js index 79c6fb7..8442368 100644 --- a/src/scripts/kindling.options.js +++ b/src/scripts/kindling.options.js @@ -75,10 +75,21 @@ kindling.module(function () { } function onHighlightPostWordListChanged() { - localStorage.highlightPostWordList = $('#highlightPostWordList textarea').val(); + 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]; From 4405404d6cadce8c4e2c46d79a6cb9524fae3baf Mon Sep 17 00:00:00 2001 From: kevinpluckivendi Date: Tue, 30 Jul 2013 09:56:31 +0100 Subject: [PATCH 8/8] Converted spaces to tabs --- src/scripts/kindling.options.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/kindling.options.js b/src/scripts/kindling.options.js index 8442368..d8669f8 100644 --- a/src/scripts/kindling.options.js +++ b/src/scripts/kindling.options.js @@ -76,7 +76,7 @@ kindling.module(function () { function onHighlightPostWordListChanged() { var wordList = $('#highlightPostWordList textarea').val().split("\n"); - wordList = removeEmptiesFromWordList(wordList); + wordList = removeEmptiesFromWordList(wordList); localStorage.highlightPostWordList = wordList.join("\n"); onOptionChanged(); } @@ -84,7 +84,7 @@ kindling.module(function () { function removeEmptiesFromWordList(originalArray){ var i = 0; - while(i < originalArray.length) + while(i < originalArray.length) originalArray[i] === "" ? originalArray.splice( i, 1 ) : i++; return originalArray;