first commit
This commit is contained in:
160
index.html
Normal file
160
index.html
Normal file
@@ -0,0 +1,160 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Esp32 FM pirate</title>
|
||||
<style>
|
||||
* {
|
||||
color: #7295c4;
|
||||
border-color: #353535;
|
||||
background: #121212;
|
||||
}
|
||||
h1 {
|
||||
font-size: 18px;
|
||||
}
|
||||
.main {
|
||||
background: #212121;
|
||||
height: auto;
|
||||
}
|
||||
.main header {
|
||||
height: auto;
|
||||
padding: 15px 16px;
|
||||
justify-content: center;
|
||||
}
|
||||
.main .content {
|
||||
padding: 20px;
|
||||
}
|
||||
.main {
|
||||
border: 3px solid;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
width: 22em;
|
||||
min-width: 300px;
|
||||
margin: 50px auto;
|
||||
height: auto;
|
||||
text-align: center;
|
||||
}
|
||||
.form-row {
|
||||
padding: 4px 0;
|
||||
}
|
||||
.form-row > label {
|
||||
display: block;
|
||||
line-height: 2em;
|
||||
}
|
||||
.form-row > input {
|
||||
padding: 8px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
input {
|
||||
border: 2px solid;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* далее стили для слидеров */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 34px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 26px;
|
||||
width: 26px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked + .slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:checked + .slider:before {
|
||||
transform: translateX(26px);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="main">
|
||||
<header><h1>Lamps4 by Vlados31 & ESP32</h1></header>
|
||||
<div class="content">
|
||||
<div id="form-content">
|
||||
|
||||
<div class="form-row">
|
||||
<label class="required" for="control-rds">RDS текст</label>
|
||||
<input type="text" maxlength="16" size="20" id="control-rds" onchange="sendParam('rds', document.getElementById('control-rds').value)">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label class="required" for="control-frq">Частота (96.00fm = 9600)</label>
|
||||
<input type="number" maxlength="5" id="control-frq" onchange="sendParam('frq', document.getElementById('control-frq').value)">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="control-fmen">FM Enable</label>
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="control-fmen" onchange="sendParam('fmen', document.getElementById('control-fmen').checked ? 1 : 0)">
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function sendParam(io_interface, value) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
let url = `/`
|
||||
if (io_interface !== null) {
|
||||
url += `?${io_interface}=${encodeURIComponent(value)}`
|
||||
}
|
||||
xhr.onload = function () {
|
||||
if (xhr.status !== 200) {
|
||||
alert(`Ошибка ${xhr.status}: ${xhr.statusText}`);
|
||||
} else {
|
||||
let res = JSON.parse(xhr.response)
|
||||
if ("frq" in res) {
|
||||
document.getElementById('control-frq').value = res["frq"]
|
||||
}
|
||||
if ("rds" in res) {
|
||||
document.getElementById('control-rds').value = res["rds"]
|
||||
}
|
||||
if ("fmen" in res) {
|
||||
document.getElementById('control-fmen').checked = !!res["fmen"]
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.open('POST', url)
|
||||
xhr.send()
|
||||
}
|
||||
|
||||
sendParam(null)
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user