Cordova IOT Lesson002
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">
© 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">
© 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();
Cordova IOT Lesson002的更多相关文章
- Cordova IOT Lesson003
bot index.html <!DOCTYPE html> <html> <head> <title>Arduino蓝牙机械昆虫控制器</tit ...
- H5程序员如何利用cordova开发跨平台应用
什么是Cordova? Cordova以前也叫PhoneGap,它提供了一组设备相关的API,通过这组API,移动应用能够以JavaScript访问原生的设备功能,如摄像头.麦克风等.Cordova还 ...
- Apache Cordova开发Android应用程序——番外篇
很多天之前就安装了visual studio community 2015,今天闲着么事想试一下Apache Cordova,用它来开发跨平台App.在这之前需要配置N多东西,这里找到了一篇MS官方文 ...
- Win10 UWP开发系列:使用VS2015 Update2+ionic开发第一个Cordova App
安装VS2015 Update2的过程是非常曲折的.还好经过不懈的努力,终于折腾成功了. 如果开发Cordova项目的话,推荐大家用一下ionic这个框架,效果还不错.对于Cordova.PhoneG ...
- VS2015 Update2中有关cordova和xamarin安装的问题
最近VS2015出了Update2,当然是第一时间进行了安装,中间过程曲折,反复安装卸载n次,也算是获得了一定的安装经验值.现在说一下经常出的问题. Update2里最吸引人的当然是跨平台开发的部分, ...
- 《连载 | 物联网框架ServerSuperIO教程》-4.如开发一套设备驱动,同时支持串口和网络通讯。附:将来支持Windows 10 IOT
1.C#跨平台物联网通讯框架ServerSuperIO(SSIO)介绍 <连载 | 物联网框架ServerSuperIO教程>1.4种通讯模式机制. <连载 | 物联网框架Serve ...
- 开源物联网框架ServerSuperIO 3.0正式发布(C#),跨平台:Win&Win10 Iot&Ubuntu&Ubuntu Mate,一套设备驱动跨平台挂载,附:开发套件和教程。
3.0版本主要更新内容: 1.增加跨平台能力:Win&Win10 Iot&Ubuntu&Ubuntu Mate 2.统一设备驱动接口:可以一套设备驱动,跨平台挂载运行,降低人力 ...
- 开源物联网通讯框架ServerSuperIO,成功移植到Windows10 IOT,在物联网和集成系统建设中降低成本。附:“物联网”交流大纲
[开源]C#跨平台物联网通讯框架ServerSuperIO(SSIO)介绍 一.概述 经过一个多月晚上的时间,终于把开源物联网通讯框架ServerSuperIO成功移植到Windows10 IOT上, ...
- 玩儿转物联网IoT - 在Beagle Bone Black上运行node.js 程序
物联网(IoT)技术方兴未艾,智能手环,智能血压计,智能眼镜甚至智能鞋垫都开始进入我们的生活,各种智能设备层出不穷,世界已经到了一个"人有多大胆,地有多大产"的时代,不玩儿点物联网 ...
随机推荐
- mpvue——引入iconfont字体图标
前言 有问题可以随时提问,评论私信,只要我有时间我都会第一时间回复.当大家发现这篇文章不适用的时候烦请告知下,我好做好更改! 放置 下载好的字体图标放在static目录下,我是自己又创建了一个icon ...
- 倍增\ tarjan求lca
对于每个节点v,记录anc[v][k],表示从它向上走2k步后到达的节点(如果越过了根节点,那么anc[v][k]就是根节点). dfs函数对树进行的dfs,先求出anc[v][0],再利用anc[v ...
- Magento 最佳开发配置
概观 典型的软件开发流程如下: 本地开发机器 > QA /集成服务器 > 预览服务器(可选)> 生产服务器 无论您是在编写新的Magento 2 扩展 还是为代码库做贡献,任何开发人 ...
- 天气预测(CNN)
import torch import torch.nn as nn import torch.utils.data as Data import numpy as np import pymysql ...
- CQOI2018异或序列 [莫队]
莫队板子 用于复习 #include <cstdio> #include <cstdlib> #include <algorithm> #include <c ...
- 越光后端开发——ygapi(2.新建Model)
1.新建Model 1.users数据 1.在apps/users/models.py中: from datetime import datetime from django.db import mo ...
- Ubuntu16.04 安装g++6
https://blog.csdn.net/qq_34877350/article/details/81182022 1.安装gcc-6: sudo apt-get update && ...
- django系列4 :创建管理员
以下复制粘贴自官网 创建管理员用户¶ 首先,我们需要创建一个可以登录管理站点的用户.运行以下命令: / $ python manage.py createsuperuser 输入所需的用户名, ...
- mybatis 模糊查询 like的三种方式
第一种 public void selectBykeyWord(String keyword) { String id = "%" + keyword + "%" ...
- (转)如何阅读OpenStack源码
1 关于该项目 本项目使用在线绘图工具web sequencediagrams完成,目标是图形化OpenStack的所有操作流程,通过操作序列图能快速学习Openstack的工作原理,理清各个组件的关 ...