sending reorganized, dynamically create the first select of par56
This commit is contained in:
parent
7d2fe8fd04
commit
e60ffe6360
|
@ -20,15 +20,20 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(
|
$(document).ready(
|
||||||
function() {
|
function() {
|
||||||
var dataChanged = false;
|
|
||||||
var par56eins = $.parseJSON('{"deviceId":1, "options": {"red":0,"blue":0,"green":0} }');
|
|
||||||
var par56null = $.parseJSON('{"deviceId":0, "options": {"red":0,"blue":0,"green":0} }');
|
|
||||||
var volumes = $.parseJSON('{"room1":0,"room2":0,"room3":0,"room4":0}');
|
var volumes = $.parseJSON('{"room1":0,"room2":0,"room3":0,"room4":0}');
|
||||||
|
var devices = [
|
||||||
|
{"red":72,"green":69,"blue":255,"startAddress":1,"type":"Par56Spot","deviceId":0,"deviceName":"Par56 Lampe 1","picture":null},
|
||||||
|
{"red":111,"green":222,"blue":23,"startAddress":6,"type":"Par56Spot","deviceId":1,"deviceName":"Par56 Lampe 2","picture":null},
|
||||||
|
{"red":0,"green":0,"blue":0,"startAddress":11,"type":"Par56Spot","deviceId":2,"deviceName":"Par56 Lampe 3","picture":null},
|
||||||
|
{"red":0,"green":0,"blue":0,"startAddress":16,"type":"Par56Spot","deviceId":3,"deviceName":"Par56 Lampe 4","picture":null},
|
||||||
|
{"mode":0,"speed":0,"intensity":0,"startAddress":21,"type":"Strobe1500","deviceId":4,"deviceName":"Stroboskop 1","picture":null},
|
||||||
|
{"red":0,"green":0,"blue":0,"startAddress":508,"type":"Par56Spot","deviceId":5,"deviceName":"Par56 Lampe 5","picture":null}
|
||||||
|
];
|
||||||
|
|
||||||
function sendData(data) {
|
function sendData(data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: "/control/devices/0",
|
url: "/control/devices",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: JSON.stringify(data)
|
data: JSON.stringify(data)
|
||||||
|
@ -36,13 +41,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var senden = function sendOutAllDevices() {
|
var senden = function sendOutAllDevices() {
|
||||||
if(dataChanged) {
|
var changedDevs = new Array();
|
||||||
dataChanged = false;
|
for(var i=0;i<devices.length;i++) {
|
||||||
sendData(par56null);
|
if(devices[i].type=="Par56Spot" && devices[i].dirty) {
|
||||||
console.log("send data");
|
delete devices[i].dirty;
|
||||||
|
changedDevs.push(devices[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changedDevs.length > 0) {
|
||||||
|
sendData(changedDevs);
|
||||||
}
|
}
|
||||||
console.log("set new interval for sending");
|
console.log("set new interval for sending");
|
||||||
window.setTimeout(senden, 200);
|
//window.setTimeout(senden, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
// vielleicht baut man lieber was mit setTimeout und setzt das jeweils neu wenn man daten ändert
|
// vielleicht baut man lieber was mit setTimeout und setzt das jeweils neu wenn man daten ändert
|
||||||
|
@ -68,39 +78,34 @@
|
||||||
volumes.room4 = ui.value;
|
volumes.room4 = ui.value;
|
||||||
dataChanged = true;
|
dataChanged = true;
|
||||||
} });
|
} });
|
||||||
|
$("#tabs").tabs();
|
||||||
$("#buttonLampe1").click(function() {
|
$("#v-tabs").tabs().addClass('ui-tabs-vertical');
|
||||||
|
$(".lampel .circle").click(function() {
|
||||||
$.getJSON('/control/devices/1', function(data) {
|
if($(this).hasClass('black')){
|
||||||
|
$(this).removeClass('black');
|
||||||
$("#messages").append("type: " + data.type + " name=" + data.deviceName + "<br/>" );
|
} else {
|
||||||
});
|
$(this).addClass('black');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$(document).ready(function() {
|
var colorpicker_raum1 = new jQuery.ColorPicker('#colorpicker-raum1', {
|
||||||
$("#tabs").tabs();
|
imagepath: '/resources/images/colorpicker/',
|
||||||
$("#v-tabs").tabs().addClass('ui-tabs-vertical');
|
change: function(hexcolor) {
|
||||||
$(".lampel .circle").click(function() {
|
red = hexcolor.substr(1,2);
|
||||||
if($(this).hasClass('black')){
|
green = hexcolor.substr(3,2);
|
||||||
$(this).removeClass('black');
|
blue = hexcolor.substr(5,2);
|
||||||
} else {
|
console.log("data changed");
|
||||||
$(this).addClass('black');
|
dataChanged = true;
|
||||||
}
|
|
||||||
});
|
|
||||||
var colorpicker_raum1 = new jQuery.ColorPicker('#colorpicker-raum1', {
|
|
||||||
imagepath: '/resources/images/colorpicker/',
|
|
||||||
change: function(hexcolor) {
|
|
||||||
red = hexcolor.substr(1,2);
|
|
||||||
green = hexcolor.substr(3,2);
|
|
||||||
blue = hexcolor.substr(5,2);
|
|
||||||
par56null.options.red = parseInt(red, 16);
|
|
||||||
par56null.options.blue = parseInt(blue, 16);
|
|
||||||
par56null.options.green = parseInt(green, 16);
|
|
||||||
console.log("data changed");
|
|
||||||
dataChanged = true;
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$.getJSON('/control/devices', function(data) {
|
||||||
|
devices = data;
|
||||||
|
for(var i=0;i<devices.length;i++) {
|
||||||
|
if(devices[i].type=="Par56Spot") {
|
||||||
|
$('#par56select').append("<option name=" + devices[i].deviceId + ">" + devices[i].deviceName + "</option>");
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -138,14 +143,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
<div id="v-tabs-1">
|
<div id="v-tabs-1">
|
||||||
<div id="colorpicker-raum1"></div>
|
<div id="colorpicker-raum1"></div>
|
||||||
<select multiple="multiple">
|
<select multiple="multiple" id="par56select">
|
||||||
<option>Par 56 Lampe 1</option>
|
|
||||||
<option>Par 56 Lampe 2</option>
|
|
||||||
<option>Par 56 Lampe 3</option>
|
|
||||||
<option>Par 56 Lampe 4</option>
|
|
||||||
<option>Par 56 Lampe 5</option>
|
|
||||||
<option>Par 56 Lampe 6</option>
|
|
||||||
<option>Par 56 Lampe 7</option>
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue