Added orangered sound option (default off).

This commit is contained in:
Kerrick Long
2011-07-19 00:42:25 -05:00
parent b17818cde5
commit 20c5da1fe0
3 changed files with 35 additions and 5 deletions

View File

@@ -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";
}
},

View File

@@ -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();
};

BIN
pix/pop.ogg Normal file

Binary file not shown.