Created
June 29, 2014 07:33
-
-
Save chikoski/142d67564b6672b7202c to your computer and use it in GitHub Desktop.
alarmtest.app
This file contains hidden or 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
| (function(){ | |
| document.querySelector("#start").addEventListener("click", function(event){ | |
| var now = new Date(); | |
| var due = new Date(now.valueOf() + 10000); | |
| console.log("now = " + now); | |
| console.log("due = " + due); | |
| navigator.mozSetMessageHandler("alarm", function (message) { | |
| console.log("alarm fired"); | |
| }); | |
| console.log(navigator.mozSetMessageHandler); | |
| console.log(navigator.mozAlarms); | |
| var request = navigator.mozAlarms.add(due, "honorTimezone"); | |
| request.onsuccess = function(event){ | |
| console.log(event); | |
| }; | |
| console.log("alarm request = " + request); | |
| console.log(navigator.mozAlarms.getAll()); | |
| }); | |
| })(); |
This file contains hidden or 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 lang="ja"> | |
| <head> | |
| <title>alarm test</title> | |
| <meta charset="utf-8"> | |
| </head> | |
| <body> | |
| <button id="start">スタート</button> | |
| <script src="app.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or 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
| { | |
| "name": "test app", | |
| "description": "test alarm", | |
| "launch_path": "/index.html", | |
| "permissions": { | |
| "alarms": { | |
| "description": "set alarm" | |
| } | |
| }, | |
| "messages": [ | |
| { "alarm": "/index.html" } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment