diff --git a/couchpotato/core/notifications/core/static/notification.js b/couchpotato/core/notifications/core/static/notification.js index 891d7e8a..6a5393a1 100644 --- a/couchpotato/core/notifications/core/static/notification.js +++ b/couchpotato/core/notifications/core/static/notification.js @@ -7,9 +7,12 @@ var NotificationBase = new Class({ var self = this; self.setOptions(options); + // Listener App.addEvent('load', self.request.bind(self)); - self.addEvent('notification', self.notify.bind(self)) + + // Add test buttons to settings page + App.addEvent('load', self.addTestButtons.bind(self)); }, @@ -35,6 +38,37 @@ var NotificationBase = new Class({ Array.each(json.result, function(result){ App.fireEvent(result.type, result.data) }) + }, + + addTestButtons: function(){ + var self = this; + + var setting_page = App.getPage('Settings') + setting_page.addEvent('create', function(){ + Object.each(setting_page.tabs.notifications.groups, self.addTestButton.bind(self)) + }) + + }, + + addTestButton: function(fieldset, plugin_name){ + var self = this; + + var name = fieldset.getElement('h2').get('text'); + + new Element('.ctrlHolder').adopt( + new Element('a.button', { + 'text': 'Test '+name, + 'events': { + 'click': function(){ + Api.request('notify.'+plugin_name+'.test', { + 'onComplete': function(json){ + alert(json.success) + } + }); + } + } + }) + ).inject(fieldset); } });