[whatwg] HTML vs Plain Text in Notifications

On Wed, Sep 10, 2008 at 9:26 PM, Dmitry Titov <dimich at google.com> wrote:
>
> So instead of:
>   <script>
>    function callback() { ... }
>    ...
>    window.showNotification("You've got mail!",
>                                        "From: Santa Claus",
>                                        "What's in your wishlist?",
>                                        "http://.../icon.png",
>                                        callback);
>    ...
>    </script>
>
> it would be closer to:
>   <script>
>    ...
>    balloon_window = window.open("http://.../mail_notification?id=....",
> "_notification");
>    ...
>    </script>

Something else to consider, though more verbose, once you start
passing this many arguments it is a lot easier to make sense out of
the arguments as an object rather than an array. This is how it would
look in a JavaScript framework:

window.showNotification({
	title: 'You\'ve got mail!',
	subtitle: 'From: Santa Claus',
	description: 'What\'s in your wishlist?',
	icon: 'http://www.foo.com/icon.png',
	onclick: function(){
		// Do something
	}
});

or

window.showNotification({
	id: 'myNotification',
	class: 'myNotificationClass',
	title: 'You\'ve got mail!',
	url: 'http://www.foo.com/my_notification.html',
	icon: 'http://www.foo.com/icon.png',
	onclick: function(){
		// Do something
	},
	onSuccess: function(){
		// Do something after the URL is loaded. Could also be called onload
or onComplete
	}	
});

- Greg

Received on Wednesday, 10 September 2008 22:07:58 UTC