Created
November 20, 2016 18:29
-
-
Save leovarmak/f98a0ea24cb210c8189e86decffa06b5 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Testing something</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
<script src="https://alexgibson.github.io/notify.js/js/notify.js"></script> | |
<script> | |
$(document).ready(function(){ | |
var date = new Date('November 21, 2016'); | |
if (date.getDate() == new Date().getDate()) { | |
alert("Hi"); | |
function onShowNotification () { | |
console.log('notification is shown!'); | |
} | |
function onCloseNotification () { | |
console.log('notification is closed!'); | |
} | |
function onClickNotification () { | |
console.log('notification was clicked!'); | |
} | |
function onErrorNotification () { | |
console.error('Error showing notification. You may need to request permission.'); | |
} | |
function onPermissionGranted () { | |
console.log('Permission has been granted by the user'); | |
doNotification(); | |
} | |
function onPermissionDenied () { | |
console.warn('Permission has been denied by the user'); | |
} | |
function doNotification () { | |
var myNotification = new Notify('Yo dawg!', { | |
body: 'This is an awesome notification', | |
tag: 'My unique id', | |
notifyShow: onShowNotification, | |
notifyClose: onCloseNotification, | |
notifyClick: onClickNotification, | |
notifyError: onErrorNotification, | |
timeout: 4 | |
}); | |
myNotification.show(); | |
} | |
if (!Notify.needsPermission) { | |
doNotification(); | |
} else if (Notify.isSupported()) { | |
Notify.requestPermission(onPermissionGranted, onPermissionDenied); | |
} | |
} | |
}); | |
</script> | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment