-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
45 lines (32 loc) · 1.01 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Device light (ambient light sensor) experiment by Will Murray</title>
<style>
body {
text-align: center;
background-color: black;
color: white;
}
</style>
</head>
<body>
<div id="devicelightValue">0</div>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/DeviceLightEvent"
target="_blank"
style="position: absolute; top: 1em; right: 1em; opacity: .4; color: white">
<small>More info & compatibility</small>
</a>
<script>
window.addEventListener('devicelight', function (event) {
var html = document.getElementsByTagName('html')[0];
var devicelightValue = document.getElementById('devicelightValue')
devicelightValue.innerText = event.value
devicelightValue.style.fontSize = (event.value + 10) + 'px'
})
</script>
</body>
</html>