Skip to content

Commit

Permalink
Add ability to select sound notification (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
olsh authored Mar 8, 2023
1 parent 3439c33 commit 7f8ab67
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@
"Sorting": {
"message": "Sorting"
},
"Sound": {
"message": "Sound"
},
"SoundVolume": {
"message": "Sound volume"
},
"Theme": {
"message": "Theme"
},
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Feedly Notifier",
"description": "__MSG_ExtensionDescription__",
"version": "2.27.6",
"version": "2.28.0",
"default_locale": "en",
"permissions": [
"storage",
Expand Down
11 changes: 10 additions & 1 deletion src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,16 @@ <h3 data-locale-value="Notifications"></h3>
<input id="playSound" type="checkbox" data-option-name="playSound" /><br/>

<label for="soundVolume" class="label" data-locale-value="SoundVolume"></label>
<input id="soundVolume" type="range" data-enable-parent="playSound" min="0" max="1" step="0.01" data-option-name="soundVolume" /><br>
<input id="soundVolume" type="range" data-enable-parent="playSound" min="0.01" max="1" step="0.01" data-option-name="soundVolume" /><br>

<label for="sound" class="label" data-locale-value="Sound"></label>
<select id="sound" data-enable-parent="playSound" data-option-name="sound">
<option value="sound/alert.mp3">Alert</option>
<option value="sound/no-problem.mp3">No problem</option>
<option value="sound/whistling.mp3">Whistling</option>
<option value="sound/quite-impressed.mp3">Quite impressed</option>
<option value="sound/light-hearted.mp3">Light hearted</option>
</select><br>
<!-- @endif -->

<div id="filters-settings">
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var appGlobal = {
filters: [],
showCounter: true,
playSound: true,
sound: "sound/alert.mp3",
soundVolume: 0.8,
sortBy: "newest",
theme: "light",
Expand Down Expand Up @@ -386,7 +387,7 @@ function removeFeedFromCache(feedId) {

/* Plays alert sound */
function playSound(){
var audio = new Audio("sound/alert.mp3");
var audio = new Audio(appGlobal.options.sound);
audio.volume = appGlobal.options.soundVolume;
audio.play();
}
Expand Down
17 changes: 13 additions & 4 deletions src/scripts/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $("body").on("click", "#logout", function () {
$("#userInfo, #filters-settings").hide();
});

$("#options").on("change", "input", function (e) {
$("#options").on("change", "input, select", function (e) {
$("[data-enable-parent]").each(function(key, value){
var child = $(value);
var parent = $("input[data-option-name='" + child.data("enable-parent") + "']");
Expand All @@ -48,11 +48,20 @@ $("#options").on("change", "input", function (e) {
parent.is(":checked") ? child.attr("disabled", "disable") : child.removeAttr("disabled");
});

if (e.target.id === "soundVolume") {
if (optionsGlobal.loaded) {
if (e.target.id === "soundVolume" || e.target.id === "sound") {
if (!optionsGlobal.loaded) {
return;
}

if (e.target.id === "soundVolume") {
chrome.extension.getBackgroundPage().appGlobal.options.soundVolume = e.target.value;
chrome.extension.getBackgroundPage().playSound();
}

if (e.target.id === "sound") {
chrome.extension.getBackgroundPage().appGlobal.options.sound = e.target.value;
}

chrome.extension.getBackgroundPage().playSound();
}
});

Expand Down
Binary file added src/sound/light-hearted.mp3
Binary file not shown.
Binary file added src/sound/no-problem.mp3
Binary file not shown.
Binary file added src/sound/quite-impressed.mp3
Binary file not shown.
Binary file added src/sound/whistling.mp3
Binary file not shown.

0 comments on commit 7f8ab67

Please sign in to comment.