preset flipswitch works
This commit is contained in:
@ -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):
|
||||
|
13
index.html
13
index.html
@ -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) {
|
||||
|
Reference in New Issue
Block a user