66 lines
1.6 KiB
HTML
66 lines
1.6 KiB
HTML
<!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">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<title>Lights</title>
|
|
<style>
|
|
html, body {
|
|
width: 100%;
|
|
height: 100%;
|
|
margin: 0;
|
|
}
|
|
|
|
body {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: #000;
|
|
color: #fff;
|
|
transition: background 1s, color 1s;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
|
}
|
|
|
|
.toggle {
|
|
border: 4px solid #fff;
|
|
padding: 3rem;
|
|
width: 16rem;
|
|
text-align: center;
|
|
font-size: 3em;
|
|
font-weight: 300;
|
|
}
|
|
|
|
body.on {
|
|
background: #fff;
|
|
color: #000;
|
|
}
|
|
body.on .toggle {
|
|
border-color: #000;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="toggle">
|
|
Lights On
|
|
</div>
|
|
<script>
|
|
let on = false;
|
|
document.querySelector('body').addEventListener('click', () => {
|
|
fetch((on ? '/off' : '/on') + window.location.search, {
|
|
method: 'POST',
|
|
}).then(res => {
|
|
on = !on;
|
|
update();
|
|
});
|
|
})
|
|
const update = () => {
|
|
document.querySelector('.toggle').innerText = on ? 'Lights Off' : 'Lights On';
|
|
document.querySelector('body').classList[on ? 'add' : 'remove']('on');
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|