Improved website, added styling, replaced bad JS color picker with HTML5 picker.
This commit is contained in:
@@ -1,103 +1,107 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>litsimaja</title>
|
||||
<script src="jscolor.js"></script>
|
||||
<title>Litsimaja</title>
|
||||
<link rel="stylesheet" href="normalize.css">
|
||||
<link rel="stylesheet" href="skeleton.css">
|
||||
<link rel="stylesheet" href="custom.css">
|
||||
|
||||
<script type="text/javascript">
|
||||
jscolor.presets.default = {
|
||||
format:'rgb', previewPosition:'right', previewSize:700, width:800,
|
||||
height:400, sliderSize:50
|
||||
};
|
||||
const hexToRgb = hex =>
|
||||
hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i
|
||||
,(m, r, g, b) => '#' + r + r + g + g + b + b)
|
||||
.substring(1).match(/.{2}/g)
|
||||
.map(x => parseInt(x, 16));
|
||||
|
||||
function show_loading(visible)
|
||||
{
|
||||
document.getElementById('loading').style.visibility = visible ? 'visible' : 'hidden';
|
||||
}
|
||||
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_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 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 getProgramSelection() {
|
||||
let select = document.getElementById('program');
|
||||
return select.value;
|
||||
}
|
||||
|
||||
function isLoop()
|
||||
{
|
||||
let looping = document.getElementById('looping');
|
||||
return looping.checked;
|
||||
}
|
||||
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');
|
||||
}
|
||||
function isChanged(value) {
|
||||
let rgb = hexToRgb(value);
|
||||
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)">
|
||||
|
||||
<div class="spacer-row"></div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<button onclick="doInit()">init</button>
|
||||
<button onclick="doCancel()">end loop</button>
|
||||
<button onclick="doBlind()">off</button>
|
||||
<span><input type="checkbox" id="looping" /><b> loop</b></span>
|
||||
</div>
|
||||
<div class="row" id='loading' style="visibility: hidden"><b>LOADING!</b></div>
|
||||
<div class="section-rgb">
|
||||
<div class="row">
|
||||
<div class="one-third column">
|
||||
<select id="program" size="10">
|
||||
{% for group in programs %}
|
||||
<optgroup label="{{ group.group }}">
|
||||
{% for program in group.programs %}
|
||||
<option label="{{ program.name }}">{{ program.prg.split(".")[1] }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class ="one-third column">
|
||||
<input class="colorpicker" type="color" value="#ff0000" oninput="isChanged(this.value)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user