 				Notification.requestPermission (permission) =>
 					if permission == 'granted'
 						@hasPermission = true
-						cback?()
 					else
 						@denied = true
 			else
 				webkitNotifications.requestPermission () =>
 					if webkitNotifications.checkPermission() == 0
 						@hasPermission = true
-						cback?()
 					else
 						@denied = true
 

webkitNotifications = window.webkitNotifications or {}
class window.NotificationCenter
	constructor: () ->
		@denied = false;
		@hasPermission = false;
		if window.localStorage.getItem 'notifications-enabled'
			@getPermission()
			# Just in case we're using an older ver of the speck, ask on the first click as well.
			clickus = () =>
				document.removeEventListener 'click', clickus
				@getPermission()
			document.addEventListener 'click', clickus

	getPermission: (cback = null) ->
		if @hasPermission or Notification.permission == 'granted' or webkitNotifications.checkPermission?() == 0
			@hasPermission = true
			cback?()
		else if @denied or Notification.permission == 'denied' or webkitNotifications.checkPermission?() == 2
			@denied = true
		else

	enableNotifications: () ->
		@getPermission();
		window.localStorage.setItem 'notifications-enabled', true
		@enabled = true

	disableNotifications: () ->
		window.localStorage.deleteItem 'notifications-enabled'
		@enabled = false

	setNotificationRegex: ( str ) ->
		try
			regex = new RegExp str, 'gim'
		catch e
			return e.message
		@enableNotifications()
		@regex = regex
		window.localStorage.setItem 'notifications-regex', regex.source
		return false

	checkMessage: (message) -> @enabled and @regex? and @regex.test message
