hello

index.html

 <!DOCTYPE html>
 <html>
     <head>
         <meta charset="utf-8">
         <title>我的App</title>
         <meta name="format-detection" content="telephone=no">
         <meta name="msapplication-tap-highlight" content="no">
         <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
         <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
         <script src="js/jquery-2.1.3.min.js"></script>
         <script>
         $(document).on('mobileinit', function() {
             $.mobile.pushStateEnabled = false;
         });
         </script>
         <script src="js/jquery.mobile-1.4.5.min.js"></script>
     </head>
     <body>
         <div data-role="page" id="p1">
             <div data-role="header">
                 <h1>第 1 页</h1>
             </div>
             <div data-role="content">
                 <ul data-role="listview">
                     <li><a href="#p2">第 2 页</a></li>
                     <li><a href="#p3">第 3 页</a></li>
                 </ul>
             </div>
             <div data-role="footer" data-position="fixed">
                 <h4>页脚</h4>
             </div>
         </div>

         <div data-role="page" id="p2">
             <div data-role="header">
                 <h1>第 2 页</h1>
             </div>
             <div data-role="content">
                 内容
             </div>
             <div data-role="footer" data-position="fixed">
                 <h4>页脚</h4>
             </div>
         </div>

         <div data-role="page" id="p3">
             <div data-role="header">
                 <h1>第 3 页</h1>
             </div>
             <div data-role="content">
                 内容
             </div>
             <div data-role="footer" data-position="fixed">
                 <h4>页脚</h4>
             </div>
         </div>

     </body>
 </html>

hello_back

index.html

 <!DOCTYPE html>
 <html>
     <head>
         <meta charset="utf-8">
         <title>我的App</title>
         <meta name="format-detection" content="telephone=no">
         <meta name="msapplication-tap-highlight" content="no">
         <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
         <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
         <script src="js/jquery-2.1.3.min.js"></script>
         <script>
         $(document).on('mobileinit', function() {
             $.mobile.pushStateEnabled = false;
         });
         </script>
         <script src="js/jquery.mobile-1.4.5.min.js"></script>
     </head>
     <body>
         <div data-role="page" id="p1">
             <div data-role="header">
                 <h1>第 1 页</h1>
             </div>
             <div data-role="content">
                 <ul data-role="listview">
                     <li><a href="#p2">第 2 页</a></li>
                     <li><a href="#p3">第 3 页</a></li>
                 </ul>
                 <br>
                 <a href="#popAbout" data-rel="popup" data-role="button">App简介</a>
                 <div data-role="popup" id="popAbout" class="ui-content">
                     <h2>App简介</h2>
                     <p>这是用jQuery Mobile打造的App接口</p>
                 </div>
             </div>
             <div data-role="footer" data-position="fixed">
                 <h4>页脚</h4>
             </div>
         </div>

         <div data-role="page" id="p2">
             <div data-role="header">
                 <h1>第 2 页</h1>
             </div>
             <div data-role="content">
                 <a href="#" data-role="button" data-inline="true" data-rel="back">上一页</a>
                 <br>
                 <a href="faq.html" data-role="button" rel="external">开启FAQ</a>
             </div>
             <div data-role="footer" data-position="fixed">
                 <h4>页脚</h4>
             </div>
         </div>

         <div data-role="page" id="p3">
             <div data-role="header">
                 <h1>第 3 页</h1>
             </div>
             <div data-role="content">
                 <a href="#" data-role="button" data-inline="true" data-rel="back">上一页</a>
             </div>
             <div data-role="footer" data-position="fixed">
                 <h4>页脚</h4>
             </div>
         </div>

     </body>
 </html>

wifiBot

index.html

 <!DOCTYPE html>
 <html>
     <head>
         <meta charset="utf-8">
         <title>灯光控制器</title>
         <meta name="format-detection" content="telephone=no">
         <meta name="msapplication-tap-highlight" content="no">
         <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
         <link rel="stylesheet" href="css/jquery.mobile-1.4.5.min.css" />
         <script src="cordova.js"></script>
         <script src="js/jquery-2.1.3.min.js"></script>
         <script>
         $(document).on('mobileinit', function() {
             $.mobile.pushStateEnabled = false;
         });
         </script>
         <script src="js/jquery.mobile-1.4.5.min.js"></script>
         <script src="js/index.js"></script>
         <style type="text/css">
         #splashPage {
             background-color:#fac800;
             text-align: center;
         }
         #splashPage div h1 {
             border-radius: 10px;
             padding:10px 30px;
             display:inline-block;
             background-color:#fff;
             margin-bottom:30px;
         }
         </style>
     </head>
     <body>
     <!-- 起始画面 -->
     <div data-role="page" id="splashPage">
         <div role="main" class="ui-content">
             <h1>网络灯光控制器</h1>
             <img src="data:images/app_logo.svg" width="300" height="300">
         </div>
     </div>

     <!-- 主控画面 --->
     <div data-role="page" id="ctrlPage" data-theme="a">
         <div data-role="header">
             <h1>灯光控制器</h1>
             <a href="#netPage" class="ui-btn-right ui-btn ui-btn-inline ui-mini ui-corner-all ui-btn-icon-right ui-icon-gear">网络设置</a>
         </div>

         <div role="main" class="ui-content">
             <div class="ui-field-contain">
                 <label for="ledSw">壁灯</label>
                 <select name="ledSw" id="ledSw" data-role="slider" data-mini="true">
                     <option value="0">关</option>
                     <option value="1">开</option>
                 </select>
             </div>
             <div class="ui-field-contain">
                 <label for="pwmSlider">台灯</label>
                 <input type="range" name="pwmSlider" id="pwmSlider" value="25" min="0" max="100"  data-highlight="true">
             </div>
             <div id="msg"></div>
         </div>

         <div data-role="footer" data-position="fixed">
           &copy; 2016 swf.com.tw
         </div>
     </div>

     <!-- "WiFi设置画面" -->
     <div data-role="page" id="netPage" data-theme="a">
         <div data-role="header">
             <h1>网络链接设置</h1>
         </div>

         <div role="main" class="ui-content">
             <form>
                 <label for="deviceIP">设备IP地址或网域名</label>
                 <input type="text" name="deviceIP" id="deviceIP" value="" placeholder="jarvis.local" data-clear-btn="true">
                 <label for="devicePort">设备端口号</label>
                 <input type="number" name="devicePort" id="devicePort" value="80" data-clear-btn="true">
             </form>
             <p><a href="#" id="saveBtn" class="ui-btn ui-corner-all ui-btn-b ui-btn-icon-left ui-icon-refresh ui-shadow-icon">保存设置</a></p>
             <p><a href="#ctrlPage" class="ui-btn ui-shadow ui-corner-all ui-btn-b">回主控画面</a></p>

         </div>
         <div data-role="footer" data-position="fixed">
           &copy; 2016 swf.com.tw
         </div>
     </div>
 </body>
 </html>

index.js

 var app = {
     nextPage:"",
     host:"",
     port:80,
     splashTime:3000,
     init: function() {
         $(document).on('deviceready', app.onDeviceReady);
     },
     onDeviceReady: function() {
         $("#ledSw").on("change", function(e){
             var val = $(this).val();
             var swData = {"pin":13, "sw":val};
             // 向第13脚送出开关信号
             $.ajax({
                 url: "http://" + app.host + ":" + app.port + "/sw",
                 data: swData,
                 success: function( d ) {
                     app.showMsg("收到服务器回应:" + d );
                 }
             });
         });

         $('#saveBtn').on('tap', function(){
             app.host = $("#deviceIP").val();
             app.port = $("#devicePort").val();
             localStorage.setItem('deviceIP', app.host);
             localStorage.setItem('devicePort', app.port);
             location.hash = 'ctrlPage';
         });
     },
     timeoutId: 0,
     showMsg: function(msg) {
         if (app.timeoutId) {
             clearTimeout(app.timeoutId);
         }
         $('#msg').text(msg);
         app.timeoutId = setTimeout(function() { $('#msg').text(""); }, 4000);
     },
     splashTimer : function(){
        setTimeout(function() {
            // 进入下一页
           location.hash = app.nextPage;
        }, app.splashTime);
     }
 };

 $(document).on("pageshow", "#ctrlPage", pageEvt);
 function pageEvt (e) {
   $( "#pwmSlider" ).on( "slidestop", function( e ) {
     var pwm = Math.ceil($(this).val() * 2.55);
     var pwmData = {"pin":9, "pwm":pwm};
     // 向第9脚送出PWM信号
     $.ajax({
         url: "http://" + app.host + ":" + app.port + "/pwm",
         data: pwmData,
         success: function( d ) {
             app.showMsg("收到服务器回应:" + d );
         }
     });
   });

   $(document).off("pageshow", "#ctrlPage", pageEvt);
 }

 $(document).on("pageshow", "#splashPage", function( e ) {
     var host = localStorage.getItem('deviceIP');
     if (host === null) {
       app.nextPage = "netPage";
     } else {
       app.host = host;
       app.port = localStorage.getItem('devicePort');
       $("#deviceIP").val(app.host);
       $("#devicePort").val(app.port);
       app.nextPage = "ctrlPage";
     }
     // 启动计时器
     app.splashTimer();
 });

 app.init();

最新文章

  1. Spring和mybatis整合后的mybais-config.xml配置
  2. checkbox与说明文字无法对齐的问题
  3. 与众不同 windows phone (44) - 8.0 位置和地图
  4. MJExtension的使用:https://github.com/CoderMJLee/MJExtension
  5. 解决ultravnc在win2008 R2下CTRL+ALT+DELETEA组合键发送失败的问题
  6. VS2008的默认打开重置为VS2008
  7. Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)--reference
  8. PL/SQL Developer远程连接Oracle数据库
  9. 在java中和javascript中过滤掉类似于img形式的字符串,从而不显示图片
  10. OI队内测试——石门一
  11. Java集合之Vector
  12. 【64】Spring mvc详解
  13. Centos7 二进制安装 Kubernetes 1.13
  14. App设计:消息推送和界面路由跳转
  15. ajax实现跨域访问
  16. 【转】gcc命令中参数c和o混合使用的详解
  17. POJ 1458 Common Subsequence (DP+LCS,最长公共子序列)
  18. Sass进阶之路,之一(基础篇)
  19. Python练习-不知道弄个什么鬼
  20. 广州高清卫星地图 用百度卫星地图server下载 含标签、道路数据叠加 可商用

热门文章

  1. DRF之版本控制、认证和权限组件
  2. Django+Vue打造购物网站(十)
  3. 11.4 Flask session,闪现
  4. python学习日记(OOP——静态方法和类方法)
  5. oracle 查询数据库的各种命令
  6. 关于ddl(新增字段)对数据库锁表|读写操作的影响_资料
  7. 1.5分布式通讯框架-RMI
  8. windows上编译zlib-1.2.8
  9. SNMP源码分析之(一)配置文件部分
  10. Hadoop记录-JMX参数