diff --git a/fancy-settings/manifest.js b/fancy-settings/manifest.js index 7e540f5..64e4136 100755 --- a/fancy-settings/manifest.js +++ b/fancy-settings/manifest.js @@ -74,6 +74,13 @@ this.manifest = { "type": "checkbox", "label": "Check for orangereds" }, + { + "tab": "Preferences", + "group": "Orangered Notifications", + "name": "mailSound", + "type": "checkbox", + "label": "Play a sound when you have an orangered" + }, { "tab": "Preferences", "group": "Orangered Notifications", @@ -86,10 +93,25 @@ this.manifest = { "display": true, "displayModifier": function (value) { if (value === 0) - return "every 30 seconds"; + return "Check every 30 seconds"; else if (value === 1) - return "every minute"; - return "every " + value.toString() + " minutes"; + return "Check every minute"; + return "Check every " + value.toString() + " minutes"; + } + + }, + { + "tab": "Preferences", + "group": "Orangered Notifications", + "name": "mailDisplayTime", + "type": "slider", + "label": "", + "max": 20, + "min": 5, + "step": 1, + "display": true, + "displayModifier": function (value) { + return "Show the notification for " + value.toString() + " seconds"; } }, diff --git a/js/common.js b/js/common.js index de7110c..710a16b 100644 --- a/js/common.js +++ b/js/common.js @@ -9,6 +9,8 @@ settings = new Store('settings', { 'waitForClick': false, 'checkMail': true, 'mailInterval': 1, + 'mailDisplayTime': 10, + 'mailSound': false, 'excludedDomains': 'secure.ingdirect.com\nchaseonline.chase.com\nonline.wellsfargo.com', 'excludedRegex': 'chrome://.*\nchrome-extension://.*\nview-source://.*\nftp://.*\nhttps?://www\.google\.com/search.*\nhttps?://search\.yahoo\.com/search.*\nhttps?://www\.bing\.com/search.*\nhttps?://www.reddit.com/(?:r/(?:\w|\+)+/?)?(?:$|\?count)' }); @@ -794,7 +796,7 @@ Background.prototype.prepareBrowserAction = function (tabId, info, tab) { * @method */ Background.prototype.watchMail = function () { - var mailProcess; + var mailProcess, pop; function showNotification (hasMail) { var notification, notificationTimeout, mailInterval; @@ -802,6 +804,10 @@ Background.prototype.watchMail = function () { mailInterval = (settings.get('mailInterval') === 0) ? 1000 * 30 : settings.get('mailInterval') * 1000 * 60; if (hasMail === true) { + if (settings.get('mailSound') === true) { + pop.play(); + } + notification = webkitNotifications.createNotification( '/pix/mail.png', // icon url - can be relative chrome.i18n.getMessage('orangered_received'), // notification title @@ -809,7 +815,7 @@ Background.prototype.watchMail = function () { ); notificationTimeout = window.setTimeout(function () { notification.cancel(); - }, 1000 * 5); + }, settings.get('mailDisplayTime') * 1000); notification.onclick = function () { chrome.tabs.create({'url': 'http://' + reddit.domain + '/message/unread/', 'selected': true}); notification.cancel(); @@ -832,6 +838,8 @@ Background.prototype.watchMail = function () { } } + pop = document.createElement('audio'); + pop.src = '/pix/pop.ogg'; checkPrefs(); }; diff --git a/pix/pop.ogg b/pix/pop.ogg new file mode 100644 index 0000000..276dddc Binary files /dev/null and b/pix/pop.ogg differ