preset flipswitch works

This commit is contained in:
hg
2015-06-01 21:58:05 +02:00
parent a949f4d261
commit b127096c98
2 changed files with 13 additions and 2 deletions

View File

@ -18,7 +18,7 @@ switchMapping = {
}
loadedSwitchStates = ['x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7']
loadedSwitchStates = ['on', 'on', 'off', 'x3', 'x4', 'x5', 'x6', 'x7']
#def on_message(client, userdata, msg):

View File

@ -12,6 +12,7 @@
$.ajaxSetup({
async: false
});
$("#flip-checkbox-1").flipswitch({"defaults": true});
var switchMapping = $.getJSON('http://' + serverAddress + '/switchMapping').responseJSON;
var firstListItem = $("li:first", "#switchlist");
for (var key in switchMapping) {
@ -37,9 +38,19 @@
});
$(".switchlink").click(function() {
var v = $(this).attr("id");
$("#target").text(v);
var w = $("span:first", this).text();
$("#dialogTitle").text(w);
$("#target").text(v);
var x = $("span:last", this).text();
console.debug(x);
if (x == 'on') {
console.debug('x:on');
$("#flip-checkbox-1").prop('checked', true);
} else {
console.debug('x:off');
$("#flip-checkbox-1").prop('checked', false);
}
$("#flip-checkbox-1").flipswitch( "refresh" );
});
function updateState() {
for (var key in switchMapping) {