Mercurial > code > home > repos > homeauto
diff service/frontDoorArduino/index.html @ 17:d6c2b9b87f7b
yard light toggle button
Ignore-this: c003731daf656c377440278527522d75
author | drewp@bigasterisk.com |
---|---|
date | Sat, 03 Dec 2011 19:03:07 -0800 |
parents | 6fd208b97616 |
children |
line wrap: on
line diff
--- a/service/frontDoorArduino/index.html Sat Dec 03 19:01:18 2011 -0800 +++ b/service/frontDoorArduino/index.html Sat Dec 03 19:03:07 2011 -0800 @@ -15,8 +15,8 @@ background: none repeat scroll 0 0 #E1E1DF; border: 1px solid #595555; float: left; - margin: 20px; - padding: 20px; + margin: 5px; + padding: 10px; } /* ]]> */ </style> @@ -48,6 +48,13 @@ <button id="getDoor">refresh</button> </div> </section> + <section> + <h1>yard light</h1> + <div>Current: <span id="yardLight"/> + <button id="toggleYardLight">toggle</button> + </div> + </section> + <script type="text/javascript"> // <![CDATA[ $(function () { @@ -84,6 +91,22 @@ getDoor(); $("#getDoor").click(getDoor); + function refreshYardLight() { + $.getJSON("yardLight", function (data) { + $("#yardLight").text(data.yardLight); + }); + } + refreshYardLight(); + $("#toggleYardLight").click(function () { + $.getJSON("yardLight", function (data) { + $.ajax({ + type: "PUT", + url: "yardLight", + data: JSON.stringify(!data.yardLight), + success: refreshYardLight + }); + }); + }); }); // ]]> </script>