forked from andreeuuetoa/litsimaja
Add python led programs
This commit is contained in:
103
pyleds/templates/index.html
Normal file
103
pyleds/templates/index.html
Normal file
@@ -0,0 +1,103 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>litsimaja</title>
|
||||
<script src="jscolor.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
jscolor.presets.default = {
|
||||
format:'rgb', previewPosition:'right', previewSize:700, width:800,
|
||||
height:400, sliderSize:50
|
||||
};
|
||||
|
||||
function show_loading(visible)
|
||||
{
|
||||
document.getElementById('loading').style.visibility = visible ? 'visible' : 'hidden';
|
||||
}
|
||||
|
||||
function send_get(url)
|
||||
{
|
||||
show_loading(true);
|
||||
var http = new XMLHttpRequest();
|
||||
http.open('GET', url, true);
|
||||
http.onreadystatechange = function() {
|
||||
if (http.readyState == 4 && http.status == 200) {
|
||||
show_loading(false);
|
||||
}
|
||||
}
|
||||
http.send();
|
||||
}
|
||||
|
||||
function send_post(url, data)
|
||||
{
|
||||
show_loading(true);
|
||||
var http = new XMLHttpRequest();
|
||||
http.open('POST', url, true);
|
||||
http.setRequestHeader('Content-Type', 'application/json');
|
||||
http.onreadystatechange = function() {
|
||||
if (http.readyState == 4 && http.status == 200) {
|
||||
show_loading(false);
|
||||
}
|
||||
}
|
||||
let json = JSON.stringify(data);
|
||||
http.send(json);
|
||||
}
|
||||
|
||||
function getProgramSelection()
|
||||
{
|
||||
let select = document.getElementById('program');
|
||||
return select.value;
|
||||
}
|
||||
|
||||
function isLoop()
|
||||
{
|
||||
let looping = document.getElementById('looping');
|
||||
return looping.checked;
|
||||
}
|
||||
|
||||
function isChanged(value)
|
||||
{
|
||||
let rgb = value.split('(')[1].split(')')[0].split(',');
|
||||
let data = {color: [Number(rgb[0]), Number(rgb[1]), Number(rgb[2])], loop: isLoop()};
|
||||
send_post('program/' + getProgramSelection(), data);
|
||||
}
|
||||
|
||||
function doInit()
|
||||
{
|
||||
send_post('/program/siinus/Wipes', {color: [100, 50, 0]})
|
||||
}
|
||||
|
||||
function doBlind()
|
||||
{
|
||||
send_post('/program/siinus/Static', {color: [0, 0, 0]})
|
||||
}
|
||||
|
||||
function doCancel()
|
||||
{
|
||||
send_get('/crash');
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<button onclick="doInit()">init</button>
|
||||
<button onclick="doCancel()">end loop</button>
|
||||
<button onclick="doBlind()">off</button>
|
||||
<label><input type="checkbox" id="looping"/>loop</label>
|
||||
<div id='loading' style="visibility: hidden">LOADING!</div>
|
||||
<select id="program" size="10">
|
||||
{% for group in programs %}
|
||||
<optgroup label="{{ group.group }}">
|
||||
{% for program in group.programs %}
|
||||
<option label="{{ program.name }}">{{ program.prg }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input id="rgbinput" data-jscolor="" onchange="isChanged(this.value)">
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user