Skip to content

Commit

Permalink
Add DeviceLight API test app.
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonseok committed Aug 7, 2013
1 parent d72168f commit d57a19f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Binary file added Light_Sensor/DeviceLight/icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Light_Sensor/DeviceLight/icon_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions Light_Sensor/DeviceLight/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Device Light API</title>
</head>
<body>
<p style="background-color: #fff">
Current Light in lux: <span id="light"></span>
</p>
<script>
var el = document.getElementById('light');
var body = document.getElementsByTagName('body')[0];
var lights = new Array('000', '110', '220', '330', '440', '550', '660', '770', '880', '990', 'aa0', 'bb0', 'cc0', 'dd0', 'ee0', 'ff0');
window.addEventListener('devicelight', function(event) {
var value = event.value;
el.innerHTML = value;

var color = parseInt(value / 16);
if (color > 16) {
color = 16;
}

body.style.backgroundColor = '#' + lights[color];
});
</script>
</body>
</html>
14 changes: 14 additions & 0 deletions Light_Sensor/DeviceLight/manifest.webapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.1",
"description": "DeviceLightAPI",
"name": "DeviceLight",
"launch_path": "/index.html",
"developer": {
"name": "Hyeonseok Shin",
"url": "http://hyeonseok.com/"
},
"icons": {
"128": "/icon_256.png",
"256": "/icon_256.png"
}
}

0 comments on commit d57a19f

Please sign in to comment.