-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Ephemera/master
Add Clock \& Time API test app
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
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> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "Time_Clock", | ||
"description": "Time & Clock API test app", | ||
"launch_path": "/index.html", | ||
"icons": { | ||
"128": "nothing.png" | ||
}, | ||
"developer": { | ||
"name": "고윤지, 변상필, 정규용", | ||
"url": "" | ||
}, | ||
"default_locale": "ko", | ||
"type": "certified", | ||
"permissions": { | ||
"time": {} | ||
} | ||
} |