refactoring
This commit is contained in:
15
index.html
15
index.html
@ -8,11 +8,11 @@
|
||||
<script>
|
||||
$("document").ready(function() {
|
||||
var serverAddress = '127.0.0.1:8080';
|
||||
var switchMapping = {
|
||||
'kitchen': { 'index': 0, 'label': 'Kueche' },
|
||||
'oven': { 'index': 1, 'label': 'Herd' },
|
||||
'laundry': { 'index': 2, 'label': 'Waschkueche' },
|
||||
};
|
||||
|
||||
$.ajaxSetup({
|
||||
async: false
|
||||
});
|
||||
var switchMapping = $.getJSON('http://' + serverAddress + '/switchMapping').responseJSON;
|
||||
var firstListItem = $("li:first", "#switchlist");
|
||||
for (var key in switchMapping) {
|
||||
var newListItem = firstListItem.clone()
|
||||
@ -44,7 +44,6 @@
|
||||
function updateState() {
|
||||
for (var key in switchMapping) {
|
||||
$.ajax({
|
||||
async:false,
|
||||
url: 'http://' + serverAddress + '/switchStatus?target=' + switchMapping[key]['index'],
|
||||
success: function(data) {
|
||||
$('#state' + key).text(data);
|
||||
@ -70,10 +69,6 @@
|
||||
<div data-role="main" class="ui-content">
|
||||
<ul id="switchlist" data-role="listview" data-inset="true" data-count-theme="b">
|
||||
<li><a class="switchlink" id="itemEmpty0" href="#dialog?switch=0"><span id="labelEmpty0">Vorlage</span> <span id="statusEmpty0" class="ui-li-count">on</span></a></li>
|
||||
<!--
|
||||
<li><a class="switchlink" id="oven" href="#dialog?switch=1"><span>Herd</span> <span id="stateHerd" class="ui-li-count">on</span></a></li>
|
||||
<li><a class="switchlink" id="laundry" href="#dialog?switch=2"><span>Waschküche</span> <span id="stateWaschkueche" class="ui-li-count">off</span></a></li>
|
||||
-->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user