Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
- <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
- <meta charset="UTF-8">
- <script>
- $(document).on("pageshow", "#mainPage", function(){
- var refreshID = setInterval(function(){
- $.get("?requestState=0", function(data, status){
- alert("worked1");
- if(status=="success"){
- alert("worked2");
- if(data.indexOf("ventswitch=true") > -1){
- $("#switchvent").attr("checked", null);
- alert("inside");
- }
- else if(data.indexOf("ventswitch=false") > -1)
- $("#switchvent").attr("checked", "checked");
- if(data.indexOf("lampswitch=true") > -1)
- $("#switchlamp").attr("checked", null);
- else if(data.indexOf("lampswitch=false") > -1)
- $("#switchlamp").attr("checked", "checked");
- alert("worked3");
- }
- });
- }, 5000);
- //$.ajaxSetup({ cache: false });
- $("#lampswitch").on("tap", function(){
- $.get("?requestState=1");
- });
- $("#ventswitch").on("tap", function(){
- $.get("?requestState=3");
- });
- });
- </script>
- </head>
- <body>
- <div data-role="page" id="mainPage" data-theme="b">
- <div data-role="header" class="ui-content">
- <h1> Sistema de Automação Residencial </h1>
- </div>
- <div data-role="main" class="ui-content">
- <form id="form" style="text-align:center">
- <label for="switchvent">Lampada:</label>
- <span id="lampswitch"><input type="checkbox" id="switchvent" name="switch1"
- data-role="flipswitch" data-on-text="On" data-off-text="Off" ></span>
- <!-- THE ONLY REASON TO USE <SPAN> ELEMENT IS BECAUSE <input
- type="checkbox" data-role="flipswitch"> doesn't work with any click or touch events -->
- <label for="switchlamp">Ventilador:</label>
- <span id="ventswitch"><input type="checkbox" id="switchlamp" name="switch2"
- data-role="flipswitch" data-on-text="On" data-off-text="Off" ></span>
- </form>
- </div>
- <div data-role="footer" class="ui-content">
- <h1> Versão 0.0.1 </h1>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement