Created
January 22, 2010 17:26
-
-
Save tayles/283940 to your computer and use it in GitHub Desktop.
Experimenting with browser notifications for Fluid, Prism and Google Gears
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Platform = { | |
platforms: { | |
fluid: 'Fluid', | |
prism: 'Prism', | |
gears: 'Google Gears' | |
} | |
determinePlatform: function() { | |
if( 'fluid' in window ) this.platform = this.platforms.fluid; | |
else if( 'platform' in window ) this.platform = this.platforms.prism; | |
else if( false ) this.platform = this.platforms.gears; | |
}, | |
showNotification: function( title, msg, icon, priority, app, subtitle, callback ) { | |
if( !this.platform ) this.determinePlatform(); | |
switch( this.platform ) { | |
case this.platforms.fluid: | |
window.fluid.showGrowlNotification({ title: title, description: msg, priority: priority, sticky: false, identifier: app, onclick: callback, icon: icon }); | |
break; | |
case this.platforms.prism: | |
window.prism.shown( title, msg, icon ); | |
break; | |
case this.platforms.gears: | |
var n = desktop.createNotification(); | |
n.title = title; | |
n.icon = icon; | |
//n.subtitle = subtitle; | |
n.description = msg; | |
//n.displayAtTime = new Date(2008, 5, 27, 14, 0, 0); | |
//n.displayUntilTime = new Date(2008, 5, 27, 14, 0, 15); | |
//n.addAction('View', 'http://mail.google.com/view?id=...'); | |
desktop.showNotification(n); | |
break; | |
default: | |
// not supported | |
break; | |
} | |
} | |
}; | |
Platform.showNotification( "Title", "Message payload", "http://icon.url" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment