Skip to content

Instantly share code, notes, and snippets.

@tayles
Created January 22, 2010 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tayles/283940 to your computer and use it in GitHub Desktop.
Save tayles/283940 to your computer and use it in GitHub Desktop.
Experimenting with browser notifications for Fluid, Prism and Google Gears
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