aboutsummaryrefslogtreecommitdiff
path: root/templates/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/index.html')
-rw-r--r--templates/index.html18
1 files changed, 6 insertions, 12 deletions
diff --git a/templates/index.html b/templates/index.html
index dba7d79..6903a10 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -13,12 +13,13 @@
13 $.ajax("/power-status/").done(function(data) { 13 $.ajax("/power-status/").done(function(data) {
14 for (key in data) { 14 for (key in data) {
15 var value = data[key] ? "on" : "off"; 15 var value = data[key] ? "on" : "off";
16 var key = key.replace("'", "-").replace(" ", "_");
16 $("#"+key).val(value).slider("refresh"); 17 $("#"+key).val(value).slider("refresh");
17 } 18 }
18 }); 19 });
19 $("select[data-role=slider]").on("change", function() { 20 $("select[data-role=slider]").on("change", function() {
20 var data = {}; 21 var data = {};
21 data[this.name] = $(this).val(); 22 data[$(this).attr("data-name")] = $(this).val();
22 $.ajax({ url: "/power-status/", data: data, type: "POST" }); 23 $.ajax({ url: "/power-status/", data: data, type: "POST" });
23 }); 24 });
24 }); 25 });
@@ -32,24 +33,17 @@
32 33
33 <div data-role="content"> 34 <div data-role="content">
34 <form> 35 <form>
36 {% for name, id in ports %}
35 <div class="ui-grid-a"> 37 <div class="ui-grid-a">
36 <div class="ui-block-a"><div class="ui-bar" style="height:60px"> 38 <div class="ui-block-a"><div class="ui-bar" style="height:60px">
37 <label for="relay2">Light</label> 39 <label for="{{ id }}">{{ name }}</label>
38 <select name="relay2" id="relay2" data-role="slider"> 40 <select name="{{ id }}" id="{{ id }}" data-name="{{ name }}" data-role="slider">
39 <option value="off">Off</option>
40 <option value="on">On</option>
41 </select>
42 </div></div>
43 </div><!-- /grid-a -->
44 <div class="ui-grid-a">
45 <div class="ui-block-a"><div class="ui-bar" style="height:60px">
46 <label for="relay1">Fan</label>
47 <select name="relay1" id="relay1" data-role="slider">
48 <option value="off">Off</option> 41 <option value="off">Off</option>
49 <option value="on">On</option> 42 <option value="on">On</option>
50 </select> 43 </select>
51 </div></div> 44 </div></div>
52 </div><!-- /grid-a --> 45 </div><!-- /grid-a -->
46 {% end %}
53 </form> 47 </form>
54 </div><!-- /content --> 48 </div><!-- /content -->
55 </div> 49 </div>