Skip to content

Instantly share code, notes, and snippets.

@kurai021
Created September 22, 2014 15:38
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 kurai021/cda507512bc1a9e2fa29 to your computer and use it in GitHub Desktop.
Save kurai021/cda507512bc1a9e2fa29 to your computer and use it in GitHub Desktop.
window.onunload = function() {
var request_reopen = navigator.mozAlarms.add(new Date((+new Date()) + 30000), 'ignoreTimezone', {
type: 'yolo'
});
console.log('setting to', new Date((+new Date()) + 30000) + '')
request_reopen.onsuccess = function() {
console.log('success');
}
request_reopen.onerror = function() {
console.error('err');
}
navigator.mozSetMessageHandler('alarm', function() {
console.log('alarm');
launchSelf();
});
function launchSelf() {
var request_launchself = window.navigator.mozApps.getSelf();
request_launchself.onsuccess = function() {
if (request_launchself.result) {
request_launchself.result.launch();
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment