-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathled.html
181 lines (152 loc) · 4.37 KB
/
led.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html>
<head>
<title>Schanzer LED System</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 30px;
}
h1 {
text-align: center;
font-size: 24px;
}
.form-group {
margin-bottom: 30px;
}
label {
display: block;
font-weight: bold;
font-size: 18px;
margin-bottom: 10px;
}
input[type="text"],
input[type="range"],
select {
width: 100%;
padding: 15px;
font-size: 16px;
box-sizing: border-box;
}
.checkbox-group label {
display: inline-block;
margin-right: 15px;
font-size: 16px;
}
.checkbox-group input[type="checkbox"] {
vertical-align: middle;
}
.button-group {
text-align: center;
margin-bottom: 30px;
}
button {
padding: 15px 30px;
font-size: 18px;
}
#url-field {
width: 100%;
padding: 15px;
font-size: 16px;
box-sizing: border-box;
border: 1px solid #ccc;
margin-bottom: 30px;
}
#status {
width: 100%;
min-height: 120px;
padding: 15px;
font-size: 18px;
box-sizing: border-box;
background-color: #f0f0f0;
overflow: auto;
}
.error {
border: 1px solid red;
}
</style>
</head>
<body onload="validateIP()">
<h1>Schanzer LED System</h1>
<div class="form-group">
<label for="ip">IP Address:</label>
<input type="text" id="ip" placeholder="Enter IP address" oninput="validateIP()">
</div>
<div class="form-group">
<label for="pattern">Pattern:</label>
<select id="pattern">
<option value="0">0 - Color Change</option>
<option value="1">1 - Rainbow Wave</option>
<option value="2">2 - Running Light Sync</option>
<option value="3">3 - Running Pixel Trail</option>
<option value="4">4 - Pixels Off</option>
</select>
</div>
<div class="form-group">
<label for="brightness">Brightness:</label>
<input type="range" id="brightness" min="0" max="255" value="255">
</div>
<div class="form-group checkbox-group">
<label>Schanzer Blau:</label>
<input type="checkbox" id="schanzerBlue">
</div>
<div class="form-group">
<label for="color">Color:</label>
<input type="color" id="color" value="#FFFFFF">
</div>
<div class="button-group">
<button onclick="sendRequest()">Send</button>
<button onclick="clearStatus()">Clear</button>
</div>
<input type="text" id="url-field" readonly>
<div id="status"></div>
<script>
function validateIP() {
var ipInput = document.getElementById("ip");
if (ipInput.value.trim() === "") {
ipInput.classList.add("error");
} else {
ipInput.classList.remove("error");
}
}
// Check IP Address field on page load
document.addEventListener("DOMContentLoaded", function() {
validateIP();
});
function sendRequest() {
var ip = document.getElementById("ip").value;
var pattern = document.getElementById("pattern").value;
var brightness = document.getElementById("brightness").value;
var colorInput = document.getElementById("color");
var color = colorInput.value.substring(1); // Remove the '#' character
// Check if Schanzer Blau checkbox is checked
var schanzerBlueCheckbox = document.getElementById("schanzerBlue");
if (schanzerBlueCheckbox.checked) {
color = "009EE0";
}
var url = "http://" + ip + "/led?pattern=" + pattern + "&brightness=" + brightness + "&color=" + encodeURIComponent(color);
var urlField = document.getElementById("url-field");
urlField.value = url;
var statusField = document.getElementById("status");
statusField.textContent = "Sending request...";
fetch(url, {method: "GET", mode:"no-cors", cache: "no-cache"})
.then(function(response) {
if (response.ok) {
statusField.textContent = "Request sent successfully! ";
} else {
statusField.textContent = "Request failed!";
}
})
.catch(function(error) {
statusField.textContent = "Error: " + error;
});
}
function clearStatus() {
var statusField = document.getElementById("status");
statusField.textContent = "";
var urlField = document.getElementById("url-field");
urlField.value = "";
}
</script>
</body>
</html>