/*
Displays a notification with the current time. Requires "notifications"
permission in the manifest file (or calling
- "webkitNotifications.requestPermission" beforehand).
+ "Notification.requestPermission" beforehand).
*/
function show() {
var time = /(..)(:..)/.exec(new Date()); // The prettyprinted time.
var hour = time[1] % 12 || 12; // The prettyprinted hour.
var period = time[1] < 12 ? 'a.m.' : 'p.m.'; // The period of the day.
- var notification = window.webkitNotifications.createNotification(
- '48.png', // The image.
- hour + time[2] + ' ' + period, // The title.
- 'Time to make the toast.' // The body.
- );
- notification.show();
+ new Notification(hour + time[2] + ' ' + period, {
+ icon: '48.png',
+ body: 'Time to make the toast.'
+ });
}
// Conditionally initialize the options.
}
// Test for notification support.
-if (window.webkitNotifications) {
+if (window.Notification) {
// While activated, show notifications at the display frequency.
if (JSON.parse(localStorage.isActivated)) { show(); }