fixes
This commit is contained in:
14
index.html
14
index.html
@ -7,18 +7,15 @@
|
||||
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
|
||||
<script>
|
||||
$("document").ready(function() {
|
||||
var serverAddress = '127.0.0.1:8080';
|
||||
|
||||
$.ajaxSetup({
|
||||
async: false
|
||||
});
|
||||
$("#flip-checkbox-1").flipswitch({"defaults": true});
|
||||
var switchMapping = $.getJSON('http://' + serverAddress + '/switchMapping').responseJSON;
|
||||
var switchMapping = $.getJSON('/switchMapping').responseJSON;
|
||||
var firstListItem = $("li:first", "#switchlist");
|
||||
for (var key in switchMapping) {
|
||||
var newListItem = firstListItem.clone()
|
||||
var href = newListItem.children('a')
|
||||
href.attr('id', 'switch' + key);
|
||||
href.attr('id', key);
|
||||
href.attr('href', '#dialog?switch=' + switchMapping[key]['index'])
|
||||
var span = newListItem.find("#statusEmpty0");
|
||||
span.attr('id', 'state' + key);
|
||||
@ -32,8 +29,9 @@
|
||||
$("#button").click(function() {
|
||||
var v = ($("#flip-checkbox-1").is(":checked")) ? 1 : 0;
|
||||
var w = switchMapping[$("#target").text()]['index'];
|
||||
console.debug('y:' + v + ', ' + w);
|
||||
$.ajax({
|
||||
url: 'http://' + serverAddress + '/switchCommand?target=' + w + '&state=' + v
|
||||
url: '/switchCommand?target=' + w + '&state=' + v
|
||||
});
|
||||
});
|
||||
$(".switchlink").click(function() {
|
||||
@ -43,7 +41,7 @@
|
||||
$("#dialogTitle").text(w);
|
||||
var x = $("span:last", this).text();
|
||||
console.debug(x);
|
||||
if (x == 'on') {
|
||||
if (x == 'an') {
|
||||
console.debug('x:on');
|
||||
$("#flip-checkbox-1").prop('checked', true);
|
||||
} else {
|
||||
@ -55,7 +53,7 @@
|
||||
function updateState() {
|
||||
for (var key in switchMapping) {
|
||||
$.ajax({
|
||||
url: 'http://' + serverAddress + '/switchStatus?target=' + switchMapping[key]['index'],
|
||||
url: '/switchStatus?target=' + switchMapping[key]['index'],
|
||||
success: function(data) {
|
||||
$('#state' + key).text(data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user