Skip to content

Commit

Permalink
Add Clock \& Time API test app
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephemera committed Aug 7, 2013
1 parent d57a19f commit b8c90f2
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Time_Clock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<input type="date" name="" id="date" value="">
<input type="time" name="" id="time" value="">
<button id="set">set</button>
<input type="text" id="now" value="" readonly>
<script type="text/javascript">
(function(){
'use strict';

var dt = {
year: '',
month: '',
day: '',
hour: '',
minute: ''
};

setInterval(function() {
document.getElementById('now').value = new Date();
}, 1000)

function setTime(time) {
navigator.mozTime.set(time);
}

window.addEventListener('moztimechange', function() {
console.log('changed');
});

document.getElementById('date').addEventListener('blur', function(ev) {
var val = this.value.split(/\D/);
dt.year = val[0];
dt.month = --val[1];
dt.day = val[2];
});

document.getElementById('time').addEventListener('blur', function(ev) {
var val = this.value.split(/\D/);
dt.hour = val[0];
dt.minute = val[1];
});

document.getElementById('set').addEventListener('click', function(ev) {
setTime(new Date(dt.year, dt.month, dt.day, dt.hour, dt.minute));
});

})();
</script>
</body>
</html>
17 changes: 17 additions & 0 deletions Time_Clock/manifest.webapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "testapp",
"description": "it is a test app",
"launch_path": "/index.html",
"icons": {
"128": "test.png"
},
"developer": {
"name": "test user",
"url": "http://localhost"
},
"default_locale": "ko",
"type": "certified",
"permissions": {
"time": {}
}
}

0 comments on commit b8c90f2

Please sign in to comment.