add code
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="misapplication-tap-highlight" content="no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function getAcc() {
|
||||
outSet('获取设备当前加速度');
|
||||
plus.accelerometer.getCurrentAcceleration(function(a){
|
||||
outLine('X轴:'+a.xAxis+'\nY轴:'+a.yAxis+'\nZ轴:'+a.zAxis);
|
||||
}, function(e){
|
||||
outLine('获取失败:'+e.message);
|
||||
} );
|
||||
}
|
||||
var aid = null;
|
||||
function watchAcc(){
|
||||
if(aid){
|
||||
return;
|
||||
}
|
||||
outSet('监听设备加速度变化');
|
||||
aid = plus.accelerometer.watchAcceleration(function(a){
|
||||
outSet('监听设备加速度变化\n'+'X轴:'+a.xAxis+'\nY轴:'+a.yAxis+'\nZ轴:'+a.zAxis);
|
||||
}, function(e){
|
||||
outLine('监听失败:'+e.message);
|
||||
});
|
||||
}
|
||||
function watchStop() {
|
||||
if(aid){
|
||||
outSet('停止监听设备加速度变化');
|
||||
plus.accelerometer.clearWatch(aid);
|
||||
aid = null;
|
||||
}else{
|
||||
outSet('没有监听设备加速度变化');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Accelerometer</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Accelerometer Document','/doc/accelerometer.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="clicked('accelerometer_shake.html',true)">
|
||||
摇一摇
|
||||
</div>
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="getAcc()">获取设备当前加速度</li>
|
||||
<li class="ditem" onclick="watchAcc()">监听设备加速度变化 </li>
|
||||
<li class="ditem" onclick="watchStop()">停止监听设备加速度变化</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Accelerometer可获取设备加速度传感器信息,包括x轴(屏幕水平方向)、y轴(垂直屏幕水平方向)、z轴(垂直屏幕平面方向)三个方向的加速度信息。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,101 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var p=null;
|
||||
var iLast=2,MAX=20;
|
||||
var up=null,down=null,offset=50;
|
||||
var t=null;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
// 锁定只能竖屏显示
|
||||
plus.screen.lockOrientation('portrait-primary');
|
||||
// 监听加速度
|
||||
plus.accelerometer.watchAcceleration(function(a){
|
||||
if(!up){
|
||||
return;
|
||||
}
|
||||
if(!p && ( Math.abs(a.xAxis)+Math.abs(a.yAxis)+Math.abs(a.zAxis) > MAX )){
|
||||
// Play audio
|
||||
p = plus.audio.createPlayer('_www/audio/shake.wav');
|
||||
p.play();
|
||||
setTimeout(function(){
|
||||
// Change background image
|
||||
var index = Math.round(Math.random()*3+1);
|
||||
if ( iLast == index ) {
|
||||
index++;
|
||||
if ( index > 4 ) {
|
||||
index = 1;
|
||||
}
|
||||
}
|
||||
document.body.style.backgroundImage='url(../img/shake/'+index+'.jpg)';
|
||||
iLast = index;
|
||||
// Stop play audio
|
||||
p.stop();
|
||||
delete p;
|
||||
p = null;
|
||||
}, 2000 );
|
||||
// Animation
|
||||
offset=up.offsetHeight/2;
|
||||
up.style.webkitTransform = 'translateY(-'+offset+'px)';
|
||||
up.style.msTransform = 'translateY(-'+offset+'px)';
|
||||
down.style.webkitTransform = 'translateY('+offset+'px)';
|
||||
down.style.msTransform = 'translateY('+offset+'px)';
|
||||
if(t){
|
||||
clearTimeout(t);
|
||||
}
|
||||
t = setTimeout(function(){
|
||||
t = null;
|
||||
up.style.webkitTransform = '';
|
||||
up.style.msTransform = '';
|
||||
down.style.webkitTransform = '';
|
||||
down.style.msTransform = '';
|
||||
}, 700 );
|
||||
}
|
||||
}, function(e){
|
||||
//outSet('Watch failed: '+e.message);
|
||||
}, {frequency:100});
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
// 监听DOMContentLoaded事件
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
up=document.getElementById('up');
|
||||
down=document.getElementById('down');
|
||||
offset=up.offsetHeight/2;
|
||||
},false);
|
||||
// 解锁并关闭
|
||||
var _back=window.back;
|
||||
function unlockback(){
|
||||
plus.screen.unlockOrientation();
|
||||
_back();
|
||||
}
|
||||
window.back=unlockback;
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body style="background: center center no-repeat url(../img/shake/1.jpg);">
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">摇一摇</div>
|
||||
</header>
|
||||
<div style="height:100%;text-align:center;overflow:hidden;">
|
||||
<div id="up" style="width:100%;height:50%;background:#333;-webkit-transition:all .5s ease-in-out;-ms-transition:all .5s ease-in-out;">
|
||||
<img style="height:100%;" src="../img/shakeup.png"/>
|
||||
</div>
|
||||
<div id="down" style="padding-bottom:20px;width:100%;height:50%;background:#333;-webkit-transition:all .5s ease-in-out;-ms-transition:all .5s ease-in-out;">
|
||||
<img style="height:100%;" src="../img/shakedown.png"/>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,356 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+ 2</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var gentry=null,hl=null,le=null;
|
||||
var er=null,ep=null;
|
||||
var bUpdated=false; //用于兼容可能提前注入导致DOM未解析完更新的问题
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
// 获取音频目录对象
|
||||
plus.io.resolveLocalFileSystemURL('_doc/', function(entry){
|
||||
entry.getDirectory('audio', {create:true}, function(dir){
|
||||
gentry = dir;
|
||||
updateHistory();
|
||||
}, function(e){
|
||||
outSet('Get directory "audio" failed: '+e.message);
|
||||
});
|
||||
}, function(e){
|
||||
outSet('Resolve "_doc/" failed: '+e.message);
|
||||
} );
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
// DOMContentLoaded事件处理
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
// 获取DOM元素对象
|
||||
hl = document.getElementById('history');
|
||||
le = document.getElementById('empty');
|
||||
er = document.getElementById('record');
|
||||
rt = document.getElementById('rtime');
|
||||
ep = document.getElementById('play');
|
||||
pt = document.getElementById('ptime');
|
||||
pp = document.getElementById('progress')
|
||||
ps = document.getElementById('schedule');
|
||||
updateHistory();
|
||||
},false);
|
||||
// 添加播放项
|
||||
function createItem( entry ) {
|
||||
var li = document.createElement('li');
|
||||
li.className = 'ditem';
|
||||
li.innerHTML = '<span class="iplay"><font class="aname"></font><br/><font class="ainf"></font></span>';
|
||||
li.setAttribute('onclick', 'playAudio(this)');
|
||||
hl.insertBefore(li, le.nextSibling);
|
||||
li.querySelector('.aname').innerText = entry.name;
|
||||
li.querySelector('.ainf').innerText = '...';
|
||||
li.entry = entry;
|
||||
updateInformation(li);
|
||||
// 设置空项不可见
|
||||
le.style.display = 'none';
|
||||
}
|
||||
// 开始录音
|
||||
var r=null,t=0,ri=null,rt=null;
|
||||
function startRecord(){
|
||||
outSet('开始录音:');
|
||||
r = plus.audio.getRecorder();
|
||||
if ( r == null ) {
|
||||
outLine('录音对象未获取');
|
||||
return;
|
||||
}
|
||||
r.record({filename:'_doc/audio/'}, function(p){
|
||||
outLine('录音完成:'+p);
|
||||
plus.io.resolveLocalFileSystemURL(p, function(entry){
|
||||
createItem(entry);
|
||||
}, function(e){
|
||||
outLine('读取录音文件错误:'+e.message);
|
||||
});
|
||||
}, function(e){
|
||||
outLine('录音失败:'+e.message);
|
||||
} );
|
||||
er.style.display = 'block';
|
||||
t = 0;
|
||||
ri = setInterval(function(){
|
||||
t++;
|
||||
rt.innerText = timeToStr(t);
|
||||
}, 1000);
|
||||
}
|
||||
// 停止录音
|
||||
function stopRecord(){
|
||||
er.style.display = 'none';
|
||||
rt.innerText = '00:00:00';
|
||||
clearInterval(ri);
|
||||
ri = null;
|
||||
r.stop();
|
||||
w = null;
|
||||
r = null;
|
||||
t = 0;
|
||||
}
|
||||
// 清除历史记录
|
||||
function cleanHistory(){
|
||||
hl.innerHTML = '<li id="empty" class="ditem-empty">无历史记录</li>';
|
||||
le = document.getElementById('empty');
|
||||
// 删除音频文件
|
||||
outSet('清空录音历史记录:');
|
||||
gentry.removeRecursively(function(){
|
||||
// Success
|
||||
outLine('操作成功!');
|
||||
}, function(e){
|
||||
ouline('操作失败:'+e.message);
|
||||
});
|
||||
}
|
||||
// 获取录音历史列表
|
||||
function updateHistory(){
|
||||
if(bUpdated||!gentry||!document.body){//兼容可能提前注入导致DOM未解析完更新的问题
|
||||
return;
|
||||
}
|
||||
var reader = gentry.createReader();
|
||||
reader.readEntries(function(entries){
|
||||
for(var i in entries){
|
||||
if(entries[i].isFile){
|
||||
createItem(entries[i]);
|
||||
}
|
||||
}
|
||||
}, function(e){
|
||||
outLine('读取录音列表失败:'+e.message);
|
||||
});
|
||||
bUpdated = true;
|
||||
}
|
||||
// 获取录音文件信息
|
||||
function updateInformation(li){
|
||||
if(!li || !li.entry){
|
||||
return;
|
||||
}
|
||||
var entry = li.entry;
|
||||
entry.getMetadata(function(metadata){
|
||||
li.querySelector('.ainf').innerText = dateToStr(metadata.modificationTime);
|
||||
}, function(e){
|
||||
outLine('获取文件"'+entry.name+'"信息失败:'+e.message);
|
||||
} );
|
||||
}
|
||||
// 播放音频文件
|
||||
function playAudio(li){
|
||||
if(!li || !li.entry){
|
||||
ouSet('无效的音频文件');
|
||||
return;
|
||||
}
|
||||
outSet('播放音频文件:'+li.entry.name);
|
||||
startPlay('_doc/audio/'+li.entry.name);
|
||||
}
|
||||
// 播放文件相关对象
|
||||
var p=null,pt=null,pp=null,ps=null,pi=null;
|
||||
// 开始播放
|
||||
function startPlay(url){
|
||||
ep.style.display = 'block';
|
||||
var L = pp.clientWidth;
|
||||
p = plus.audio.createPlayer(url);
|
||||
p.play(function(){
|
||||
outLine('播放完成!');
|
||||
// 播放完成
|
||||
pt.innerText = timeToStr(d)+'/'+timeToStr(d);
|
||||
ps.style.webkitTransition = 'all 0.3s linear';
|
||||
ps.style.width = L+'px';
|
||||
stopPlay();
|
||||
}, function(e){
|
||||
outLine('播放音频文件"'+url+'"失败:'+e.message);
|
||||
});
|
||||
// 获取总时长
|
||||
var d = p.getDuration();
|
||||
if(!d){
|
||||
pt.innerText = '00:00:00/'+timeToStr(d);
|
||||
}
|
||||
pi = setInterval(function(){
|
||||
if(!d){ // 兼容无法及时获取总时长的情况
|
||||
d = p.getDuration();
|
||||
}
|
||||
var c = p.getPosition();
|
||||
if(!c){ // 兼容无法及时获取当前播放位置的情况
|
||||
return;
|
||||
}
|
||||
pt.innerText = timeToStr(c)+'/'+timeToStr(d);
|
||||
var pct = Math.round(L*c/d);
|
||||
if(pct < 8){
|
||||
pct = 8;
|
||||
}
|
||||
ps.style.width = pct+'px';
|
||||
}, 1000);
|
||||
}
|
||||
// 停止播放
|
||||
function stopPlay(){
|
||||
clearInterval(pi);
|
||||
pi=null;
|
||||
setTimeout(resetPlay, 500);
|
||||
// 操作播放对象
|
||||
if(p){
|
||||
p.stop();
|
||||
p=null;
|
||||
}
|
||||
}
|
||||
// 重置播放页面内容
|
||||
function resetPlay(){
|
||||
ep.style.display = 'none';
|
||||
ps.style.width = '8px';
|
||||
ps.style.webkitTransition = 'all 1s linear';
|
||||
pt.innerText = '00:00:00/00:00:00';
|
||||
}
|
||||
// 重写关闭
|
||||
var _back=window.back;
|
||||
function resetback(){
|
||||
// 停止播放
|
||||
if(ep.style.display == 'block'){
|
||||
stopPlay();
|
||||
}else if(er.style.display == 'block'){
|
||||
stopRecord();
|
||||
}else{
|
||||
_back();
|
||||
}
|
||||
}
|
||||
window.back=resetback;
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
.rp {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: none;
|
||||
text-align: center;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
background: rgba(0,0,0,0.8);
|
||||
z-index: 9999;
|
||||
overflow: hidden;
|
||||
}
|
||||
.aname {
|
||||
font-size: 16px;
|
||||
}
|
||||
.ainf {
|
||||
font-size: 12px;
|
||||
}
|
||||
.rtime {
|
||||
font-size: 22px;
|
||||
color: #FF0000;
|
||||
}
|
||||
.ptime {
|
||||
margin-top: 40%;
|
||||
font-size: 22px;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
.rprogress {
|
||||
background: url(../img/arecord.png) no-repeat center center;
|
||||
background-size: 32px 32px;
|
||||
}
|
||||
.rschedule {
|
||||
background-color: rgba(0,0,0,0);
|
||||
border: 5px solid rgba(0,183,229,0.9);
|
||||
opacity: .9;
|
||||
border-left: 5px solid rgba(0,0,0,0);
|
||||
border-right: 5px solid rgba(0,0,0,0);
|
||||
border-radius: 50px;
|
||||
box-shadow: 0 0 15px #2187e7;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin: 0 auto;
|
||||
-webkit-animation: spin 1s infinite linear;
|
||||
animation: spin 1s infinite linear;
|
||||
}
|
||||
@-webkit-keyframes spin {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
.progress {
|
||||
width: 90%;
|
||||
background-color: #666;
|
||||
margin: 0 5%;
|
||||
border: 1px solid #222;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.schedule {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
margin: 1px 0;
|
||||
background-color: #FFCC33;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
-webkit-transition: all 1s linear;
|
||||
transition: all 1s linear;
|
||||
}
|
||||
.stop {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
background: url(../img/astop.png) center center;
|
||||
background-size: 72px 72px;
|
||||
margin: auto;
|
||||
-webkit-border-radius: 72px;
|
||||
border-radius: 72px;
|
||||
}
|
||||
.stop:active{
|
||||
-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5) inset;
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5) inset;
|
||||
}
|
||||
.iplay {
|
||||
display: block;
|
||||
background: no-repeat right center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwOS8xMi8xM5w+I3MAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAAD9UlEQVR4nO2b3XETMRRGDwzvoYOkg5hRAVkqiKmAdIA7wHSQVECoALsC1gXciV0BTge4gvCwgnHk9d/+WF8m97ztxrlXs8fS1Urym6enJxwd3uZugPMcFyKGCxHDhYjhQsRwIWK4EDFciBguRAwXIoYLEcOFiOFCxHAhYrgQMVyIGC5EDBcihgsRw4WI4ULEcCFiuBAx3uVuwDGY2XtgCBTAALjc8tEFMAdKYBJC+HOK9nXBm5dwUM7MCmAEXDcMMQVuQwhlV23qC2khZjYAboGrjkLOgFEIYd5RvM6RrSFmdgs80J0MYqyHGFsSuR4S60TJ9vrwCEziZ+YhhGXy/xdU9aWgqjfnW+IsgEKtvkgJiUPUPfUyZsD42DoQ68+Y+p62AG6UhjAZITt6xopq3L9vGf+Gqh6dJX+S6ilKNaRkU8YCGLSVARBjDGLMdS5jbgkkhMQiWyejSGtEG2KsghopKoU++5AV68ZDcrvXYWTH8Pghdz1R6CHpN3MFDPsc02PsYcy1qy0nJ6uQOANKZz+jfcOUmd3H6W1jYo5RcvsqtikbuXtI+kBmBxbwz8DczMZtksdcsz1tOinZhMRxPF2bGh8R4gz4amZLMxu2aEqa8zq2LQs5e0j6EB8bLv6dAz/NrGwyjMWcj3vadjJyCimS60nLeFfAbzO7bfANT3MXLdvSmJxCBsl12VHcL8AyvpkfSpo7bdvJyCkkfQfocv5/Bnw3s/mBs6Y097aFzd7JPcv6T5dv5GtcAr/2TZN7yt0IGSE908k0+RS8FiEvhhd1yKEFUw5YAVBApoe0XQrZwgL4GEIY7pLRU+5G5OwhC57PZgbAsqPYK6rdxUMXC9Npbro8fzJy9pB0qll0FPcOuDhCRl3ubEvwOYWUyXXb5YoZ1X7GqMHSfZq7bNmWxuQUki5XnDdc+n4EPoUQiiabSzFnejKl7TJOY7IJid/iaXJ7fESIFfCNas+9zQNMc05zHnjIPctKx/mrA9egflCJGLd5eDFXukGWdddQYU+95PlDWVE97GXPeS+oivf6saBZCKHoM+8+cvcQ2NyhOwMmfW4SxdgTNs9oZd0tBAEhsRDfJbcvgbIPKTtOnNzlPnECAkPWP8xsTv3ZrJ1v2UfmuKDqGRt5QgjZ9kDWyd5D1iioP1U4P3KzqZYYY5v0om38rpDpIeCHrUFMCPjPEeSE/COetf3SU/i7EEL2GVUdSjXkGfGBfWDzIFsb/q93dRizU2R7yDr+o09R/GfRzsmRrSGvFRcihgsRw4WI4ULEcCFiuBAxXIgYLkQMFyKGCxHDhYjhQsRwIWK4EDFciBguRAwXIoYLEcOFiOFCxHAhYrgQMf4CVuqCm+17t3sAAAAASUVORK5CYII=);
|
||||
background-size: 50px 44px;
|
||||
-ms-touch-action: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Audio</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Audio Document','/doc/audio.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="startRecord()">开始录音</div>
|
||||
<div class="button" onclick="startPlay('_www/audio/friendship.mp3')">播放音乐</div>
|
||||
<br/>
|
||||
<!-- History list -->
|
||||
<ul id="history" class="dlist" style="text-align:left;">
|
||||
<li id="empty" class="ditem-empty">无历史记录</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button button-waring" onclick="cleanHistory()">清空历史记录</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
Audio用于管理音频设备,可调用麦克风录制音频文件,也可播放音频文件。
|
||||
</div>
|
||||
<div id="play" class="rp">
|
||||
<div id="ptime" class="ptime">00:00:00/00:00:00</div><br/>
|
||||
<div id="progress" class="progress"><div id="schedule" class="schedule"></div></div>
|
||||
<br/>
|
||||
<div class="stop" onclick="stopPlay(),outSet('停止播放!')"></div>
|
||||
</div>
|
||||
<div id="record" class="rp">
|
||||
<div style="width:100%;height:20%;"></div>
|
||||
<div class="rprogress"><div class="rschedule"></div></div>
|
||||
<br/>
|
||||
<div id="rtime" class="rtime">00:00:00</div><br/>
|
||||
<div class="stop" onclick="stopRecord()"></div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,122 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var img = null;
|
||||
var blist = [];
|
||||
function scaned(t, r, f){
|
||||
var d = new Date();
|
||||
var h=d.getHours(),m=d.getMinutes(),s=d.getSeconds(),ms=d.getMilliseconds();
|
||||
if(h < 10){ h='0'+h; }
|
||||
if(m < 10){ m='0'+m; }
|
||||
if(s < 10){ s='0'+s; }
|
||||
if(ms < 10){ ms='00'+ms; }
|
||||
else if(ms < 100){ ms='0'+ms; }
|
||||
var ts = '['+h+':'+m+':'+s+'.'+ms+']';
|
||||
var li=null,hl = document.getElementById('history');
|
||||
if(blist.length > 0){
|
||||
li = document.createElement('li');
|
||||
li.className = 'ditem';
|
||||
hl.insertBefore(li, hl.childNodes[0]);
|
||||
} else{
|
||||
li = document.getElementById('nohistory');
|
||||
}
|
||||
li.id = blist.length;
|
||||
var html = '['+h+':'+m+':'+s+'.'+ms+']'+' '+t+'码<div class="hdata">';
|
||||
html += r;
|
||||
html += '</div>';
|
||||
li.innerHTML = html;
|
||||
li.setAttribute('onclick', 'selected(id)');
|
||||
blist[blist.length] = {type:t,result:r,file:f};
|
||||
update(t, r, f);
|
||||
}
|
||||
function selected(id){
|
||||
var h = blist[id];
|
||||
update( h.type, h.result, h.file );
|
||||
if(h.result.indexOf('http://')==0 || h.result.indexOf('https://')==0){
|
||||
plus.nativeUI.confirm(h.result, function(i){
|
||||
if(i.index == 0){
|
||||
plus.runtime.openURL(h.result);
|
||||
}
|
||||
}, '', ['打开', '取消']);
|
||||
} else{
|
||||
plus.nativeUI.alert(h.result);
|
||||
}
|
||||
}
|
||||
function update(t, r, f){
|
||||
outSet('扫描成功:');
|
||||
outLine(t);
|
||||
outLine(r);
|
||||
outLine('\n图片地址:'+f);
|
||||
if(!f || f=='null'){
|
||||
img.src = '../img/barcode.png';
|
||||
} else{
|
||||
plus.io.resolveLocalFileSystemURL(f, function(entry){
|
||||
img.src=entry.toLocalURL();
|
||||
});
|
||||
//img.src = 'http://localhost:13131/'+f;
|
||||
}
|
||||
}
|
||||
function onempty(){
|
||||
if(window.plus){
|
||||
plus.nativeUI.alert('无扫描记录');
|
||||
} else {
|
||||
alert('无扫描记录');
|
||||
}
|
||||
}
|
||||
function cleanHistroy(){
|
||||
if(blist.length > 0){
|
||||
var hl = document.getElementById('history');
|
||||
hl.innerHTML = '<li id="nohistory" class="ditem" onclick="onempty();">无历史记录 </li>';
|
||||
}
|
||||
plus.io.resolveLocalFileSystemURL('_doc/barcode/', function(entry){
|
||||
entry.removeRecursively(function(){
|
||||
// Success
|
||||
}, function(e){
|
||||
//alert( "failed"+e.message );
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css" media="screen">
|
||||
.hdata {
|
||||
color: #e1673e;
|
||||
font-size: 14px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="img=document.getElementById('bimg')">
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Barcode</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Barcode Document','/doc/barcode.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<img style="width:40%" id="bimg" src="../img/barcode.png"/>
|
||||
<br/>
|
||||
<div class="button" onclick="clicked('barcode_scan.html',true,true)">扫一扫</div>
|
||||
<div class="button" onclick="clicked('barcode_scan2.html',true,true)">扫一扫(自定义)</div>
|
||||
<br/>
|
||||
<ul id="history" class="dlist" style="text-align:left;">
|
||||
<li id="nohistory" class="ditem" onclick="onempty()">无历史记录 </li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button button-waring" onclick="cleanHistroy()">清空历史记录</div>
|
||||
</div>
|
||||
<div id="output">
|
||||
Barcode提供二维码扫描识别功能,支持调用摄像头即时扫描二维码,也可直接输入图片进行扫描识别。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,117 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var ws=null,wo=null;
|
||||
var scan=null,domready=false;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
if(ws||!window.plus||!domready){
|
||||
return;
|
||||
}
|
||||
// 获取窗口对象
|
||||
ws=plus.webview.currentWebview();
|
||||
wo=ws.opener();
|
||||
// 开始扫描
|
||||
ws.addEventListener('show', function(){
|
||||
scan=new plus.barcode.Barcode('bcid');
|
||||
scan.onmarked=onmarked;
|
||||
scan.start({conserve:true,filename:'_doc/barcode/'});
|
||||
}, false);
|
||||
// 显示页面并关闭等待框
|
||||
ws.show('pop-in');
|
||||
wo.evalJS('closeWaiting()');
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
// 监听DOMContentLoaded事件
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
domready=true;
|
||||
plusReady();
|
||||
}, false);
|
||||
// 二维码扫描成功
|
||||
function onmarked(type, result, file){
|
||||
switch(type){
|
||||
case plus.barcode.QR:
|
||||
type = 'QR';
|
||||
break;
|
||||
case plus.barcode.EAN13:
|
||||
type = 'EAN13';
|
||||
break;
|
||||
case plus.barcode.EAN8:
|
||||
type = 'EAN8';
|
||||
break;
|
||||
default:
|
||||
type = '其它'+type;
|
||||
break;
|
||||
}
|
||||
result = result.replace(/\n/g, '');
|
||||
wo.evalJS("scaned('"+ type +"','"+ result +"','"+ file +"');");
|
||||
back();
|
||||
}
|
||||
// 从相册中选择二维码图片
|
||||
function scanPicture(){
|
||||
plus.gallery.pick(function(path){
|
||||
plus.barcode.scan(path,onmarked,function(error){
|
||||
plus.nativeUI.alert('无法识别此图片');
|
||||
});
|
||||
}, function(err){
|
||||
console.log('Failed: '+err.message);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#bcid {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
bottom: 44px;
|
||||
text-align: center;
|
||||
}
|
||||
.tip {
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
text-shadow: 0px -1px #103E5C;
|
||||
}
|
||||
footer {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
line-height: 44px;
|
||||
text-align: center;
|
||||
color: #FFF;
|
||||
}
|
||||
.fbt {
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
background-color: #FFCC33;
|
||||
float: left;
|
||||
}
|
||||
.fbt:active {
|
||||
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
|
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: #000000;">
|
||||
<div id="bcid">
|
||||
<div style="height:40%"></div>
|
||||
<p class="tip">...载入中...</p>
|
||||
</div>
|
||||
<footer>
|
||||
<div class="fbt" onclick="back()">取 消</div>
|
||||
<div class="fbt" onclick="scanPicture()">从相册选择二维码</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var ws=null,wo=null;
|
||||
var scan=null,domready=false,bCancel=false;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
if(ws||!window.plus||!domready){
|
||||
return;
|
||||
}
|
||||
// 获取窗口对象
|
||||
ws=plus.webview.currentWebview();
|
||||
wo=ws.opener();
|
||||
// 开始扫描
|
||||
ws.addEventListener('show',function(){
|
||||
scan=new plus.barcode.Barcode('bcid',[plus.barcode.QR,plus.barcode.EAN8,plus.barcode.EAN13],{frameColor:'#00FF00',scanbarColor:'#00FF00'});
|
||||
scan.onmarked=onmarked;
|
||||
scan.start({conserve:true,filename:'_doc/barcode/'});
|
||||
});
|
||||
// 显示页面并关闭等待框
|
||||
ws.show('pop-in');
|
||||
wo.evalJS('closeWaiting()');
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
// 监听DOMContentLoaded事件
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
domready=true;
|
||||
plusReady();
|
||||
}, false);
|
||||
// 二维码扫描成功
|
||||
function onmarked(type, result, file){
|
||||
switch(type){
|
||||
case plus.barcode.QR:
|
||||
type = 'QR';
|
||||
break;
|
||||
case plus.barcode.EAN13:
|
||||
type = 'EAN13';
|
||||
break;
|
||||
case plus.barcode.EAN8:
|
||||
type = 'EAN8';
|
||||
break;
|
||||
default:
|
||||
type = '其它'+type;
|
||||
break;
|
||||
}
|
||||
result = result.replace(/\n/g, '');
|
||||
wo.evalJS("scaned('"+ type +"','"+ result +"','"+ file +"');");
|
||||
back();
|
||||
}
|
||||
// 从相册中选择二维码图片
|
||||
function scanSwitch() {
|
||||
if(bCancel){
|
||||
scan.start({conserve:true,filename:'_doc/barcode/'});
|
||||
btCancel&&(btCancel.innerText='暂 停');
|
||||
}else{
|
||||
scan.cancel();
|
||||
btCancel&&(btCancel.innerText='开 始');
|
||||
}
|
||||
bCancel=!bCancel;
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#bcid {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
bottom: 44px;
|
||||
text-align: center;
|
||||
}
|
||||
.tip {
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
text-shadow: 0px -1px #103E5C;
|
||||
}
|
||||
footer {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
line-height: 44px;
|
||||
text-align: center;
|
||||
color: #FFF;
|
||||
}
|
||||
.fbt {
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
background-color: #FFCC33;
|
||||
float: left;
|
||||
}
|
||||
.fbt:active {
|
||||
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
|
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: #000000;">
|
||||
<div id="bcid">
|
||||
<div style="height:40%"></div>
|
||||
<p class="tip">...载入中...</p>
|
||||
</div>
|
||||
<footer>
|
||||
<div class="fbt" onclick="back()">取 消</div>
|
||||
<div id="btCancel" class="fbt" onclick="scanSwitch()">暂 停</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,219 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var i=1,gentry=null,w=null;
|
||||
var hl=null,le=null,de=null,ie=null;
|
||||
var unv=true;
|
||||
var bUpdated=false; //用于兼容可能提前注入导致DOM未解析完更新的问题
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
// 获取摄像头目录对象
|
||||
plus.io.resolveLocalFileSystemURL('_doc/', function(entry){
|
||||
entry.getDirectory('camera', {create:true}, function(dir){
|
||||
gentry = dir;
|
||||
updateHistory();
|
||||
}, function(e){
|
||||
outSet('Get directory "camera" failed: '+e.message);
|
||||
} );
|
||||
}, function(e){
|
||||
outSet('Resolve "_doc/" failed: '+e.message);
|
||||
});
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
// 监听DOMContentLoaded事件
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
// 获取DOM元素对象
|
||||
hl=document.getElementById('history');
|
||||
le=document.getElementById('empty');
|
||||
de=document.getElementById('display');
|
||||
if(ie=document.getElementById('index')){
|
||||
ie.onchange=indexChanged;
|
||||
}
|
||||
// 判断是否支持video标签
|
||||
unv=!document.createElement('video').canPlayType;
|
||||
updateHistory();
|
||||
},false );
|
||||
function changeIndex(){
|
||||
outSet('选择摄像头:');
|
||||
ie.focus();
|
||||
}
|
||||
function indexChanged(){
|
||||
de.innerText = ie.options[ie.selectedIndex].innerText;
|
||||
i = parseInt(ie.value);
|
||||
outLine(de.innerText);
|
||||
}
|
||||
// 拍照
|
||||
function getImage(){
|
||||
outSet('开始拍照:');
|
||||
var cmr = plus.camera.getCamera();
|
||||
cmr.captureImage(function(p){
|
||||
outLine('成功:'+p);
|
||||
plus.io.resolveLocalFileSystemURL(p, function(entry){
|
||||
createItem(entry);
|
||||
}, function(e){
|
||||
outLine('读取拍照文件错误:'+e.message);
|
||||
});
|
||||
}, function(e){
|
||||
outLine('失败:'+e.message);
|
||||
}, {filename:'_doc/camera/',index:1});
|
||||
}
|
||||
// 录像
|
||||
function getVideo(){
|
||||
outSet('开始录像:');
|
||||
var cmr = plus.camera.getCamera();
|
||||
cmr.startVideoCapture(function(p){
|
||||
outLine('成功:'+p);
|
||||
plus.io.resolveLocalFileSystemURL(p, function(entry){
|
||||
createItem(entry);
|
||||
}, function(e){
|
||||
outLine('读取录像文件错误:'+e.message);
|
||||
} );
|
||||
}, function(e){
|
||||
outLine('失败:'+e.message);
|
||||
}, {filename:'_doc/camera/',index:i});
|
||||
}
|
||||
// 显示文件
|
||||
function displayFile(li){
|
||||
if(w){
|
||||
outLine('重复点击!');
|
||||
return;
|
||||
}
|
||||
if(!li || !li.entry){
|
||||
ouSet('无效的媒体文件');
|
||||
return;
|
||||
}
|
||||
var name = li.entry.name;
|
||||
var suffix = name.substr(name.lastIndexOf('.'));
|
||||
var url = '';
|
||||
if(suffix=='.mov' || suffix=='.3gp' || suffix=='.mp4' || suffix=='.avi'){
|
||||
//if(unv){plus.runtime.openFile('_doc/camera/'+name);return;}
|
||||
url = '/plus/camera_video.html';
|
||||
} else {
|
||||
url = '/plus/camera_image.html';
|
||||
}
|
||||
w=plus.webview.create(url,url,{hardwareAccelerated:true,scrollIndicator:'none',scalable:true,bounce:'all'});
|
||||
w.addEventListener('loaded', function(){
|
||||
w.evalJS('loadMedia("'+li.entry.toLocalURL()+'")');
|
||||
//w.evalJS('loadMedia("'+'http://localhost:13131/_doc/camera/'+name+'")');
|
||||
}, false );
|
||||
w.addEventListener('close', function(){
|
||||
w = null;
|
||||
}, false);
|
||||
w.show('pop-in');
|
||||
}
|
||||
|
||||
// 添加播放项
|
||||
function createItem(entry){
|
||||
var li = document.createElement('li');
|
||||
li.className = 'ditem';
|
||||
li.innerHTML = '<span class="iplay"><font class="aname"></font><br/><font class="ainf"></font></span>';
|
||||
li.setAttribute('onclick', 'displayFile(this)' );
|
||||
hl.insertBefore( li, le.nextSibling );
|
||||
li.querySelector('.aname').innerText = entry.name;
|
||||
li.querySelector('.ainf').innerText = '...';
|
||||
li.entry = entry;
|
||||
updateInformation(li);
|
||||
// 设置空项不可见
|
||||
le.style.display = 'none';
|
||||
}
|
||||
// 获取录音文件信息
|
||||
function updateInformation(li){
|
||||
if(!li || !li.entry){
|
||||
return;
|
||||
}
|
||||
var entry = li.entry;
|
||||
entry.getMetadata(function(metadata){
|
||||
li.querySelector('.ainf').innerText = dateToStr(metadata.modificationTime);
|
||||
}, function(e){
|
||||
outLine('获取文件"'+entry.name+'"信息失败:'+e.message);
|
||||
} );
|
||||
}
|
||||
// 获取录音历史列表
|
||||
function updateHistory(){
|
||||
if(bUpdated||!gentry||!document.body){//兼容可能提前注入导致DOM未解析完更新的问题
|
||||
return;
|
||||
}
|
||||
var reader = gentry.createReader();
|
||||
reader.readEntries(function(entries){
|
||||
for(var i in entries){
|
||||
if(entries[i].isFile){
|
||||
createItem(entries[i]);
|
||||
}
|
||||
}
|
||||
}, function(e){
|
||||
outLine('读取录音列表失败:'+e.message);
|
||||
});
|
||||
bUpdated = true;
|
||||
}
|
||||
// 清除历史记录
|
||||
function cleanHistory(){
|
||||
hl.innerHTML = '<li id="empty" class="ditem-empty">无历史记录</li>';
|
||||
le = document.getElementById('empty');
|
||||
// 删除音频文件
|
||||
outSet('清空拍照录像历史记录:');
|
||||
gentry.removeRecursively(function(){
|
||||
// Success
|
||||
outLine('成功!');
|
||||
}, function(e){
|
||||
outLine('失败:'+e.message);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
.aname {
|
||||
font-size: 16px;
|
||||
}
|
||||
.ainf {
|
||||
font-size: 12px;
|
||||
}
|
||||
.iplay {
|
||||
display: block;
|
||||
background: no-repeat right center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwOS8xMi8xM5w+I3MAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAAD9UlEQVR4nO2b3XETMRRGDwzvoYOkg5hRAVkqiKmAdIA7wHSQVECoALsC1gXciV0BTge4gvCwgnHk9d/+WF8m97ztxrlXs8fS1Urym6enJxwd3uZugPMcFyKGCxHDhYjhQsRwIWK4EDFciBguRAwXIoYLEcOFiOFCxHAhYrgQMVyIGC5EDBcihgsRw4WI4ULEcCFiuBAx3uVuwDGY2XtgCBTAALjc8tEFMAdKYBJC+HOK9nXBm5dwUM7MCmAEXDcMMQVuQwhlV23qC2khZjYAboGrjkLOgFEIYd5RvM6RrSFmdgs80J0MYqyHGFsSuR4S60TJ9vrwCEziZ+YhhGXy/xdU9aWgqjfnW+IsgEKtvkgJiUPUPfUyZsD42DoQ68+Y+p62AG6UhjAZITt6xopq3L9vGf+Gqh6dJX+S6ilKNaRkU8YCGLSVARBjDGLMdS5jbgkkhMQiWyejSGtEG2KsghopKoU++5AV68ZDcrvXYWTH8Pghdz1R6CHpN3MFDPsc02PsYcy1qy0nJ6uQOANKZz+jfcOUmd3H6W1jYo5RcvsqtikbuXtI+kBmBxbwz8DczMZtksdcsz1tOinZhMRxPF2bGh8R4gz4amZLMxu2aEqa8zq2LQs5e0j6EB8bLv6dAz/NrGwyjMWcj3vadjJyCimS60nLeFfAbzO7bfANT3MXLdvSmJxCBsl12VHcL8AyvpkfSpo7bdvJyCkkfQfocv5/Bnw3s/mBs6Y097aFzd7JPcv6T5dv5GtcAr/2TZN7yt0IGSE908k0+RS8FiEvhhd1yKEFUw5YAVBApoe0XQrZwgL4GEIY7pLRU+5G5OwhC57PZgbAsqPYK6rdxUMXC9Npbro8fzJy9pB0qll0FPcOuDhCRl3ubEvwOYWUyXXb5YoZ1X7GqMHSfZq7bNmWxuQUki5XnDdc+n4EPoUQiiabSzFnejKl7TJOY7IJid/iaXJ7fESIFfCNas+9zQNMc05zHnjIPctKx/mrA9egflCJGLd5eDFXukGWdddQYU+95PlDWVE97GXPeS+oivf6saBZCKHoM+8+cvcQ2NyhOwMmfW4SxdgTNs9oZd0tBAEhsRDfJbcvgbIPKTtOnNzlPnECAkPWP8xsTv3ZrJ1v2UfmuKDqGRt5QgjZ9kDWyd5D1iioP1U4P3KzqZYYY5v0om38rpDpIeCHrUFMCPjPEeSE/COetf3SU/i7EEL2GVUdSjXkGfGBfWDzIFsb/q93dRizU2R7yDr+o09R/GfRzsmRrSGvFRcihgsRw4WI4ULEcCFiuBAxXIgYLkQMFyKGCxHDhYjhQsRwIWK4EDFciBguRAwXIoYLEcOFiOFCxHAhYrgQMf4CVuqCm+17t3sAAAAASUVORK5CYII=);
|
||||
background-size: 50px 44px;
|
||||
-ms-touch-action: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Camera</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Camera Document','/doc/camera.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<!--<div class="button" onclick="changeIndex();">
|
||||
选择:<span id="display" style="color:#FF0000">主摄像头</span>
|
||||
<div style="width:0px;height:0px;overflow:hidden;"><select id="index">
|
||||
<option value='1' selected="true">主摄像头</option>
|
||||
<option value='2' >辅摄像头</option>
|
||||
</select></div>
|
||||
</div>-->
|
||||
<div class="button" onclick="getImage()">拍照</div>
|
||||
<div class="button" onclick="getVideo()">录像</div>
|
||||
<br/>
|
||||
<!-- History list -->
|
||||
<ul id="history" class="dlist" style="text-align:left;">
|
||||
<li id="empty" class="ditem-empty">无历史记录</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button button-waring" onclick="cleanHistory()">清空历史记录</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
Camera管理摄像头设备,可用于拍摄照片、录制视频文件。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=3.0, user-scalable=yes"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var w=null;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
function imgLoaded(){
|
||||
w&&(w.close(),w=null);
|
||||
var b = document.body;
|
||||
var img = document.getElementById('img');
|
||||
var pb = b.clientHeight/b.clientWidth,
|
||||
pi = img.clientHeight/img.clientWidth;
|
||||
if(pb > pi){
|
||||
img.style.width = '100%';
|
||||
}else{
|
||||
img.style.height = '100%';
|
||||
}
|
||||
b.style.lineHeight = b.clientHeight+'px';
|
||||
}
|
||||
function imgError(){
|
||||
w&&(w.close(),w=null);
|
||||
document.getElementById('img').style.display = 'none';
|
||||
plus.nativeUI.alert('无效的图片资源', function(){
|
||||
back();
|
||||
});
|
||||
}
|
||||
function loadMedia(src){
|
||||
document.getElementById('img').src=src;
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css" media="screen">
|
||||
img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="text-align:center;background:#000000;">
|
||||
<img id="img" onclick="back()" onload="imgLoaded()" onerror="imgError()"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var v=null;
|
||||
function loadMedia( src ) {
|
||||
v.src = src;
|
||||
v.play();
|
||||
}
|
||||
function videoFinished() {
|
||||
back();
|
||||
}
|
||||
function videoError(e) {
|
||||
switch (e.target.error.code) {
|
||||
case e.target.error.MEDIA_ERR_ABORTED:
|
||||
alert('You aborted the video playback.');
|
||||
break;
|
||||
case e.target.error.MEDIA_ERR_NETWORK:
|
||||
alert('A network error caused the video download to fail part-way.');
|
||||
break;
|
||||
case e.target.error.MEDIA_ERR_DECODE:
|
||||
alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
|
||||
break;
|
||||
case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
|
||||
alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
|
||||
break;
|
||||
default:
|
||||
alert('An unknown error occurred.');
|
||||
break;
|
||||
}
|
||||
|
||||
plus.nativeUI.alert( "无效的视频资源", function(){
|
||||
back();
|
||||
} );
|
||||
}
|
||||
function init() {
|
||||
v = document.getElementById("video");
|
||||
//v.onended = videoFinished;
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body style="text-align:center;background:#DDDDDD;" onload="init();">
|
||||
<div style="width:100%;height:100%;display:table;" onclick="back();">
|
||||
<div style="display:table-cell;vertical-align:middle;">
|
||||
<video id="video" style="width:100%;" autoplay controls onerror="videoError(event);"></video>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function getDeviceInfo(){
|
||||
var str = "",i;
|
||||
str += "设备型号:" + plus.device.model + "\n";
|
||||
str += "设备厂商:" + plus.device.vendor + "\n";
|
||||
str += "IMEI:" + plus.device.imei + "\n";
|
||||
str += "UUID: " + plus.device.uuid + "\n";
|
||||
str += "IMSI:";
|
||||
for ( i=0; i<plus.device.imsi.length; i++ ) {
|
||||
str += plus.device.imsi[i];
|
||||
}
|
||||
str += "\n";
|
||||
str += "屏幕分辨率:" + plus.screen.resolutionWidth*plus.screen.scale + " x " + plus.screen.resolutionHeight*plus.screen.scale + "\n";
|
||||
str += "DPI:" + plus.screen.dpiX + " x " + plus.screen.dpiY;
|
||||
outSet( str );
|
||||
}
|
||||
function getSysInfo() {
|
||||
var str = "";
|
||||
str += "名称:" + plus.os.name + "\n";
|
||||
str += "版本:" + plus.os.version + "\n";
|
||||
str += "语言:" + plus.os.language + "\n";
|
||||
str += "厂商:" + plus.os.vendor + "\n";
|
||||
str += "网络类型:";
|
||||
var types = {};
|
||||
types[plus.networkinfo.CONNECTION_UNKNOW] = "未知";
|
||||
types[plus.networkinfo.CONNECTION_NONE] = "未连接网络";
|
||||
types[plus.networkinfo.CONNECTION_ETHERNET] = "有线网络";
|
||||
types[plus.networkinfo.CONNECTION_WIFI] = "WiFi网络";
|
||||
types[plus.networkinfo.CONNECTION_CELL2G] = "2G蜂窝网络";
|
||||
types[plus.networkinfo.CONNECTION_CELL3G] = "3G蜂窝网络";
|
||||
types[plus.networkinfo.CONNECTION_CELL4G] = "4G蜂窝网络";
|
||||
str += types[plus.networkinfo.getCurrentType()];
|
||||
outSet( str );
|
||||
}
|
||||
function deviceBeep() {
|
||||
var str = "";
|
||||
switch ( plus.os.name ) {
|
||||
case "iOS":
|
||||
if ( plus.device.model.indexOf("iPhone") >= 0 ) {
|
||||
plus.device.beep();
|
||||
str += "设备蜂鸣中...";
|
||||
} else {
|
||||
str += "此设备不支持蜂鸣";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
plus.device.beep();
|
||||
str += "设备蜂鸣中...";
|
||||
break;
|
||||
}
|
||||
outSet( str );
|
||||
}
|
||||
function deviceVibrate() {
|
||||
var str = "";
|
||||
switch ( plus.os.name ) {
|
||||
case "iOS":
|
||||
if ( plus.device.model.indexOf("iPhone") >= 0 ) {
|
||||
plus.device.vibrate();
|
||||
str += "设备振动中...";
|
||||
} else {
|
||||
str += "此设备不支持振动";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
plus.device.vibrate();
|
||||
str += "设备振动中...";
|
||||
break;
|
||||
}
|
||||
outSet( str );
|
||||
}
|
||||
function dial(){
|
||||
plus.device.dial("10086",false);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Device</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Device Document','/doc/device.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="getDeviceInfo()">获取设备信息</li>
|
||||
<li class="ditem" onclick="getSysInfo()">获取系统信息</li>
|
||||
<li class="ditem" onclick="deviceBeep()">蜂鸣</li>
|
||||
<li class="ditem" onclick="deviceVibrate()">震动</li>
|
||||
<li class="ditem" onclick="dial()">直接拨打电话</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Device可获取手机设备相关信息,包括硬件、软件、网络等信息。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,156 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript">
|
||||
// 空函数
|
||||
function shield(){
|
||||
return false;
|
||||
}
|
||||
//取消浏览器的所有事件,使得active的样式在手机上正常生效
|
||||
document.addEventListener('touchstart',shield,false);
|
||||
document.oncontextmenu=shield;
|
||||
// H5 plus事件处理
|
||||
var ws=null,wc=null,as='slide-in-right';
|
||||
var aw=false,ac=null;//加载文档内容子窗口
|
||||
function plusReady(){
|
||||
// 获取自身窗口
|
||||
ws=plus.webview.currentWebview();
|
||||
ws.addEventListener('hide',function(){
|
||||
nvtt.innerText='';
|
||||
wc.clear();
|
||||
wc.hide();
|
||||
},false);
|
||||
// Android处理返回键
|
||||
plus.key.addEventListener('backbutton',function(){
|
||||
back();
|
||||
},false);
|
||||
// iOS平台使用新动画
|
||||
if('iOS'==plus.os.name){
|
||||
as='pop-in';
|
||||
}
|
||||
// 检测是否需要自动显示
|
||||
aw&&ws.show(as);
|
||||
aw=false;
|
||||
// 创建加载内容窗口
|
||||
var topoffset='45px';
|
||||
if(plus.navigator.isImmersedStatusbar()){// 兼容immersed状态栏模式
|
||||
topoffset=(Math.round(plus.navigator.getStatusbarHeight())+45)+'px';
|
||||
}
|
||||
wc=plus.webview.create(null,'doccontent',{top:topoffset,bottom:'0px',bounce:'vertical',bounceBackground:'#FFFFFF'});
|
||||
// 内容更新后自动显示
|
||||
wc.addEventListener('loaded',function(){
|
||||
wc.show('fade-in');
|
||||
},false);
|
||||
wc.hide();
|
||||
ws.append(wc);
|
||||
// 检测是否需要自动加载内容
|
||||
ac&&wc.loadURL(ac);
|
||||
ac=null;
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
}
|
||||
// 处理返回事件
|
||||
function back(){
|
||||
if(ws){
|
||||
if(ws.preate){
|
||||
ws.hide('auto');
|
||||
}else{
|
||||
ws.close('auto');
|
||||
}
|
||||
}else if(history.length>1){
|
||||
history.back();
|
||||
}else{
|
||||
close();
|
||||
}
|
||||
}
|
||||
// 更新标题和内容
|
||||
function updateDoc(t,c){
|
||||
nvtt.innerText=t;
|
||||
if(ws){
|
||||
ws.show(as,null,function(){
|
||||
if(!wc){
|
||||
ac=c;
|
||||
}else{
|
||||
wc.loadURL(c);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
aw=true;
|
||||
ac=c;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
* {
|
||||
-webkit-user-select: none;
|
||||
-ms-touch-select: none;
|
||||
}
|
||||
html {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color:#666;
|
||||
background-color:#EAEAEA;
|
||||
font-family: Verdana, Arial, Helvetica , "Microsoft YaHei" , sans-serif;
|
||||
font-size:14px;
|
||||
word-break: break-all;
|
||||
-webkit-touch-callout:none;
|
||||
-webkit-tap-highlight-color:rgba(0,0,0,0);
|
||||
-webkit-text-size-adjust:none;
|
||||
}
|
||||
header {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
font-size: 17px;
|
||||
text-align: center;
|
||||
line-height: 44px;
|
||||
background: rgba(215,75,40,1);
|
||||
border-bottom: 1px solid rgba(215,75,40,0.8);
|
||||
-ms-touch-action: none;
|
||||
}
|
||||
.nvbt {
|
||||
width: 15%;
|
||||
height: 100%;
|
||||
float: left;
|
||||
}
|
||||
.nvbt:active {
|
||||
background-color: rgba(170,170,170,0.1);
|
||||
}
|
||||
#nvtt {
|
||||
width:70%;
|
||||
height:100%;
|
||||
color: #cccccc;
|
||||
float:left;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
}
|
||||
.iback {
|
||||
background: no-repeat center center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwOS8xMi8xM5w+I3MAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAACcklEQVR4nO3a0XESURiG4TeO99iBWoGZ+RvADtKBpAPtwBLsANJBrEAs4MyYDmIHSQXkgk0mMLK7ILt8/+F778ici394OGfDsher1Qqn05tTD+A2M4hYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYb089wNCVUq6Ay+blfUQsTjhOZxc1P9tbSlkAX7b+/C0ifpxgnF5Ve2TtwAD4OvIoe1UlSAsGwPsRR9m76kA6MAD+jjTKQVUF0gMD4HaEUQ6umot6T4ybiJgNP83hVbFDasGACnZIT4yfEXE1wjj/Xeod0hPjDpgNPsyRSguyB8Y0Ih6Gn+g4pQSpFQMSgtSMAclAaseARCDngAFJQM4FAxKAnBMGiH8xLKVMgV89ln6MiPthpxkn6R0SEUvgusfSZSnlsnuZftI75LlSygyYdyx7ZH1s/Rl+ouFKAQIvx9ctMGlZlh4lDQhAcywtqRhF+hqyXfMmT1m/6buasL6mzMaY6dilAoENlLuWZRNgnhEl1ZH1ulLKO9bH16eOpdfqz2K9Lt0Oea75EjilfadAsp2SFgQ2UH53LJ2XUr4PPtARSntkbVfL7+rVgEBvlM/NHQDJUh9Z2zWf/puOZbPhJzm8qkDgBaXt/teHcSY5rOpAAJp/c/vclJSrShDYifKI+NPvVV3U/1VzU3LavFyo/25SPUi2qj2ysmYQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsZ4Ak9fPFwUy/HsAAAAASUVORK5CYII=);
|
||||
background-size: 50px 44px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onselectstart="return false;">
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div id="nvtt"></div>
|
||||
</header>
|
||||
<br/><br/><br/><br/>
|
||||
<p style="text-align:center;color:#666">正在加载中...</p>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,94 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var dtask=null;
|
||||
function createDownloadTask(){
|
||||
if ( dtask ) {
|
||||
outLine( "下载任务已创建!" );
|
||||
return;
|
||||
}
|
||||
var url = "http://snip.qq.com/resources/Snip_V2.0_5771.dmg";
|
||||
var options = {method:"GET"};
|
||||
dtask = plus.downloader.createDownload( url, options );
|
||||
dtask.addEventListener( "statechanged", function(task,status){
|
||||
if(!dtask){return;}
|
||||
switch(task.state) {
|
||||
case 1: // 开始
|
||||
outLine( "开始下载..." );
|
||||
break;
|
||||
case 2: // 已连接到服务器
|
||||
outLine( "链接到服务器..." );
|
||||
break;
|
||||
case 3: // 已接收到数据
|
||||
outSet( "下载数据更新:" );
|
||||
outLine( task.downloadedSize+"/"+task.totalSize );
|
||||
break;
|
||||
case 4: // 下载完成
|
||||
outSet( "下载完成!" );
|
||||
outLine( task.totalSize );
|
||||
break;
|
||||
}
|
||||
} );
|
||||
outSet( "创建下载任务成功!" );
|
||||
}
|
||||
function startDownloadTask(){
|
||||
if ( !dtask ) {
|
||||
outSet( "请先创建下载任务!" );
|
||||
return;
|
||||
}
|
||||
dtask.start();
|
||||
}
|
||||
// 暂停下载任务
|
||||
function pauseDownloadTask(){
|
||||
dtask.pause();
|
||||
outSet( "暂停下载!" );
|
||||
}
|
||||
// 恢复下载任务
|
||||
function resumeDownloadTask(){
|
||||
dtask.resume();
|
||||
outSet( "恢复下载!" );
|
||||
}
|
||||
function cancelDownloadTask(){
|
||||
dtask.abort();
|
||||
dtask = null;
|
||||
outSet( "取消下载任务!" );
|
||||
}
|
||||
function clearDownloadTask(){
|
||||
|
||||
}
|
||||
function startAll(){
|
||||
plus.downloader.startAll();
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Downloader</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Downloader Document','/doc/downloader.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="createDownloadTask()">创建下载任务</li>
|
||||
<li class="ditem" onclick="startDownloadTask()">启动下载任务</li>
|
||||
<li class="ditem" onclick="pauseDownloadTask()">暂停下载任务</li>
|
||||
<li class="ditem" onclick="resumeDownloadTask()">恢复下载任务</li>
|
||||
<li class="ditem" onclick="cancelDownloadTask()">取消下载任务</li>
|
||||
<!--<li class="ditem" onclick="clearDownloadTask()">清除所有任务</li>-->
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Downloader用于管理文件的下载,可从网络下载各种文件,并支持跨域访问。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
if(window.plus){
|
||||
if(document.body){
|
||||
outLine( currentTimeString()+" HTML5 Plus已准备" );
|
||||
}else{
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
outLine( currentTimeString()+" HTML5 Plus已准备" );
|
||||
},false);
|
||||
}
|
||||
}else{
|
||||
document.addEventListener("plusready",function(){
|
||||
outLine( currentTimeString()+" HTML5 Plus已准备" );
|
||||
}, false );
|
||||
}
|
||||
document.addEventListener("pause",function(){
|
||||
outLine( currentTimeString()+" 应用从前台切换到后台" );
|
||||
}, false );
|
||||
document.addEventListener("resume",function(){
|
||||
outLine( currentTimeString()+" 应用从后台切换到前台" );
|
||||
}, false );
|
||||
document.addEventListener("netchange",function(){
|
||||
var types = {};
|
||||
types[plus.networkinfo.CONNECTION_UNKNOW] = "未知";
|
||||
types[plus.networkinfo.CONNECTION_NONE] = "未连接网络";
|
||||
types[plus.networkinfo.CONNECTION_ETHERNET] = "有线网络";
|
||||
types[plus.networkinfo.CONNECTION_WIFI] = "WiFi网络";
|
||||
types[plus.networkinfo.CONNECTION_CELL2G] = "2G蜂窝网络";
|
||||
types[plus.networkinfo.CONNECTION_CELL3G] = "3G蜂窝网络";
|
||||
types[plus.networkinfo.CONNECTION_CELL4G] = "4G蜂窝网络";
|
||||
outLine( currentTimeString()+" 切换网络:"+types[plus.networkinfo.getCurrentType()] );
|
||||
}, false );
|
||||
document.addEventListener("newintent",function(){
|
||||
outLine( currentTimeString()+" 从第三方应用启动:"+plus.runtime.arguments );
|
||||
}, false );
|
||||
function currentTimeString(){
|
||||
var d = new Date();
|
||||
return d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+"."+d.getMilliseconds()+" - ";
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Events</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Events Document','/doc/events.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<p class="des">按“HOME”键切换应用触发“pause”和“resume”事件,在设置中改变网络配置触发“netchange”事件。</p>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
Events模块管理客户端事件,包括系统事件,如扩展API加载完毕、程序前后台切换等。<br/>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,254 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var dir="",root=[],current=null,parent=null,pitem=null,list=null;
|
||||
var htmlItem='<img class="ficon"></img><div><span class="fname"></span><br/><span class="finf">...</span></div>';
|
||||
document.addEventListener( "plusready", function () {
|
||||
pitem = document.getElementById("pdir");
|
||||
list = document.getElementById("dcontent");
|
||||
|
||||
// Get root item information
|
||||
var items = list.querySelectorAll(".fitem");
|
||||
for ( var i = 1; i < items.length; i++ ) {
|
||||
updateRootItem( items[i] );
|
||||
}
|
||||
}, false );
|
||||
// Update root information with item(HTMLUIElement)
|
||||
function updateRootItem( item ) {
|
||||
plus.io.resolveLocalFileSystemURL( dir+item.id, function ( entry ) {
|
||||
root.push( entry );
|
||||
item.entry = entry;
|
||||
updateInf( item, entry );
|
||||
}, function ( e ) {
|
||||
outLine( "Update "+item.id+" information failed: "+e.message );
|
||||
} );
|
||||
}
|
||||
// Update HTMLUIElement information with entry object
|
||||
function updateInf( item, entry ) {
|
||||
entry.getMetadata( function ( metadata ) {
|
||||
var inf = item.querySelector(".finf");
|
||||
if ( entry.isDirectory ) {
|
||||
inf.innerText = "文件夹:"+metadata.directoryCount+"项,文件:"+metadata.fileCount+"项";
|
||||
} else {
|
||||
inf.innerText = dateToStr(metadata.modificationTime);
|
||||
}
|
||||
}, function ( e ) {
|
||||
outLine( "Get metadata "+entry.name+" failed: "+e.message );
|
||||
}, false );
|
||||
}
|
||||
// Update ui with entries
|
||||
function updateList( entries ) {
|
||||
var i,items = [].slice.apply(list.querySelectorAll(".fitem"));
|
||||
items.shift();
|
||||
// sort the entries
|
||||
entries.sort( sortCompareEntry )
|
||||
// Update item to ui
|
||||
for ( i = 0; i < entries.length; i++ ) {
|
||||
var di = null;
|
||||
if ( i < items.length ) {
|
||||
di=items[i];
|
||||
di.style.display = "block";
|
||||
} else {
|
||||
di = document.createElement("div");
|
||||
di.className = "fitem";
|
||||
di.setAttribute( "onclick", "openDir(this);" );
|
||||
di.innerHTML = htmlItem;
|
||||
list.appendChild( di );
|
||||
}
|
||||
di.entry = entries[i];
|
||||
di.id = di.entry.name;
|
||||
di.querySelector(".fname").innerText = di.id;
|
||||
di.querySelector(".finf").innerText = "";
|
||||
if ( entries === root ) {
|
||||
di.querySelector(".ficon").src = "../img/fdisk.png";
|
||||
} else {
|
||||
di.querySelector(".ficon").src = di.entry.isDirectory?"../img/fdir.png":"../img/ffile.png";
|
||||
}
|
||||
updateInf( di, di.entry );
|
||||
}
|
||||
// Hide other items
|
||||
for ( ; i < items.length; i++ ) {
|
||||
items[i].style.display = "none";
|
||||
items[i].entry = null;
|
||||
}
|
||||
// Reset scroll offset
|
||||
list.scrollTop = 0;
|
||||
}
|
||||
// Open directory with item(HTMLUIElement)
|
||||
function openDir( item ) {
|
||||
var entry = item.entry;
|
||||
if ( !entry ) {
|
||||
outSet( "Open directory \""+item.id+"\" with null!" );
|
||||
return;
|
||||
}
|
||||
if ( entry.isDirectory ) {
|
||||
outSet( "Open directory: \""+dir+item.id+"\"" );
|
||||
var dirReader = entry.createReader();
|
||||
dirReader.readEntries( function( entries ) {
|
||||
parent = current;
|
||||
current = item.entry;
|
||||
dir = entry.toURL()+"/";
|
||||
// Dispaly up to parent item
|
||||
pitem.style.display = "block";
|
||||
// Update ui
|
||||
updateList( entries );
|
||||
}, function ( e ) {
|
||||
outLine( "Read directory "+item.id+" failed: "+e.message );
|
||||
} );
|
||||
} else {
|
||||
outSet( "Open file: \""+dir+item.id+"\"" );
|
||||
plus.runtime.openFile( dir+item.id, {}, function ( e ) {
|
||||
plus.nativeUI.alert( "无法打开此文件:"+e.emssage );
|
||||
} );
|
||||
}
|
||||
}
|
||||
// Back to parent directory
|
||||
function parentDir() {
|
||||
outSet( "Go to previous directory: \""+dir+"\"");
|
||||
var p = dir.lastIndexOf( "/", dir.length-2 );
|
||||
if ( p < 0 || !parent ) { // Up to root
|
||||
dir = "";
|
||||
current = parent = null;
|
||||
// hide up to parent item
|
||||
pitem.style.display = "none";
|
||||
// Update ui
|
||||
updateList( root );
|
||||
} else {
|
||||
var dirReader = parent.createReader();
|
||||
dirReader.readEntries( function( entries ) {
|
||||
dir = dir.substr( 0, p+1 );
|
||||
outLine( "Current directory: \""+dir+"\"" );
|
||||
current = parent;
|
||||
current.getParent( function ( entry ) {
|
||||
parent = entry;
|
||||
}, function ( e ) {
|
||||
outLine( "Get \""+current.name+"\" parent directory failed: "+e.emssage );
|
||||
} );
|
||||
parent = null;
|
||||
// Update ui
|
||||
updateList( entries );
|
||||
}, function ( e ) {
|
||||
outLine( "Read directory "+item.id+" failed: "+e.message );
|
||||
} );
|
||||
}
|
||||
}
|
||||
// Entry sort compare
|
||||
function sortCompareEntry( a, b ) {
|
||||
if ( a.isDirectory && b.isFile ) {
|
||||
return -1;
|
||||
} else if ( a.isFile && b.isDirectory ) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.name - b.name;
|
||||
}
|
||||
}
|
||||
// Format data to string
|
||||
function dateToStr( datetime ) {
|
||||
var year = datetime.getFullYear(),
|
||||
month = datetime.getMonth()+1,
|
||||
date = datetime.getDate(),
|
||||
hour = datetime.getHours(),
|
||||
minutes = datetime.getMinutes(),
|
||||
second = datetime.getSeconds();
|
||||
if ( month < 10 ) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if ( date < 10 ) {
|
||||
date = "0" + date;
|
||||
}
|
||||
if ( hour < 10 ) {
|
||||
hour = "0" + hour;
|
||||
}
|
||||
if ( minutes < 10 ) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
if ( second < 10 ) {
|
||||
second = "0" + second;
|
||||
}
|
||||
return (year+"-"+month+"-"+date+" "+hour+":"+minutes+":"+second);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
.fitem {
|
||||
width: 96%;
|
||||
overflow: hidden;
|
||||
padding: 10px 2%;
|
||||
border-bottom: 1px solid #c6c6c6;
|
||||
text-align: left;
|
||||
}
|
||||
.fitem:active {
|
||||
background: #f4f4f4;
|
||||
}
|
||||
.ficon {
|
||||
height: 40px;
|
||||
float: left;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.fup {
|
||||
line-height:40px;
|
||||
}
|
||||
.fname {
|
||||
font-weight: bolder;
|
||||
height: 22px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.finf {
|
||||
height: 18px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">File System</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('File System Document','/doc/io.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<div id="pdir" class="fitem" style="display:none" onclick="parentDir()">
|
||||
<img class="ficon" src="../img/fup.png"/>
|
||||
<div class="fup"><span class="fname">返回上一级</span></div>
|
||||
</div>
|
||||
<div id="_www" class="fitem" onclick="openDir(this)">
|
||||
<img class="ficon" src="../img/fdisk.png"/>
|
||||
<div>
|
||||
<span class="fname">www</span><br/>
|
||||
<span class="finf">...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="_doc" class="fitem" onclick="openDir(this)">
|
||||
<img class="ficon" src="../img/fdisk.png"/>
|
||||
<div>
|
||||
<span class="fname">doc</span><br/>
|
||||
<span class="finf">...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="_documents" class="fitem" onclick="openDir(this)">
|
||||
<img class="ficon" src="../img/fdisk.png"/>
|
||||
<div>
|
||||
<span class="fname">documents</span><br/>
|
||||
<span class="finf">...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="_downloads" class="fitem" onclick="openDir(this)">
|
||||
<img class="ficon" src="../img/fdisk.png"/>
|
||||
<div>
|
||||
<span class="fname">downloads</span><br/>
|
||||
<span class="finf">...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="output">
|
||||
File System模块管理本地文件系统,用于文件系统目录的浏览、文件的写入、文件的读取等操作。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,200 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function plusReady(){
|
||||
// 用户侧滑返回时关闭显示的图片
|
||||
plus.webview.currentWebview().addEventListener('popGesture', function(e){
|
||||
if(e.type=='start'){
|
||||
closeImg();
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
|
||||
function getImage(){
|
||||
var cmr = plus.camera.getCamera();
|
||||
cmr.captureImage(function(path){
|
||||
outSet('保存照片到系统相册:');
|
||||
plus.gallery.save(path, function(){
|
||||
outLine('保存成功');
|
||||
}, function(e){
|
||||
outSet('保存失败: '+JSON.stringify(e));
|
||||
});
|
||||
}, function(e){
|
||||
outSet('取消拍照');
|
||||
}, {filename:'_doc/gallery/',index:1});
|
||||
}
|
||||
function galleryImg(){
|
||||
// 从相册中选择图片
|
||||
outSet('从相册中选择图片:');
|
||||
plus.gallery.pick(function(path){
|
||||
outLine(path);
|
||||
//showImg( path );
|
||||
//createItem(path);
|
||||
}, function(e){
|
||||
outSet('取消选择图片');
|
||||
}, {filter:'image'});
|
||||
}
|
||||
function galleryImgs(){
|
||||
// 从相册中选择图片
|
||||
outSet('从相册中选择多张图片:');
|
||||
plus.gallery.pick(function(e){
|
||||
for(var i in e.files){
|
||||
outLine(e.files[i]);
|
||||
}
|
||||
}, function(e){
|
||||
outSet('取消选择图片');
|
||||
},{filter:'image',multiple:true,system:false});
|
||||
}
|
||||
function galleryImgsMaximum(){
|
||||
// 从相册中选择图片
|
||||
outSet('从相册中选择多张图片(限定最多选择3张):');
|
||||
plus.gallery.pick(function(e){
|
||||
for(var i in e.files){
|
||||
outLine(e.files[i]);
|
||||
}
|
||||
}, function(e){
|
||||
outSet('取消选择图片');
|
||||
},{filter:'image',multiple:true,maximum:3,system:false,onmaxed:function(){
|
||||
plus.nativeUI.alert('最多只能选择3张图片');
|
||||
}});// 最多选择3张图片
|
||||
}
|
||||
var lfs=null;// 保留上次选择图片列表
|
||||
function galleryImgsSelected(){
|
||||
// 从相册中选择图片
|
||||
outSet('从相册中选择多张图片(限定最多选择3张):');
|
||||
plus.gallery.pick(function(e){
|
||||
lfs=e.files;
|
||||
for(var i in e.files){
|
||||
outLine(e.files[i]);
|
||||
}
|
||||
}, function(e){
|
||||
outSet('取消选择图片');
|
||||
},{filter:'image',multiple:true,maximum:3,selected:lfs,system:false,onmaxed:function(){
|
||||
plus.nativeUI.alert('最多只能选择3张图片');
|
||||
}});// 最多选择3张图片
|
||||
}
|
||||
function showImg(url){
|
||||
// 兼容以"file:"开头的情况
|
||||
if(0!=url.indexOf('file://')){
|
||||
url='file://'+url;
|
||||
}
|
||||
var _body_ = document.body;
|
||||
var _div_ = document.createElement('div');
|
||||
_div_.style.top='0px';
|
||||
_div_.style.left='0px';
|
||||
_div_.style.height='100%';
|
||||
_div_.style.width='100%';
|
||||
_div_.style.zIndex='99999';
|
||||
_div_.style.position='fixed';
|
||||
_div_.style.background='#ffffff';
|
||||
_div_.id='imgShow';
|
||||
_div_.onclick=closeImg;
|
||||
var _img_=document.createElement('img');
|
||||
_img_.src=url;
|
||||
_img_.style.width='100%';
|
||||
_body_.appendChild(_div_);
|
||||
_div_.appendChild(_img_);
|
||||
}
|
||||
function closeImg(){
|
||||
var trnode=document.getElementById('imgShow');
|
||||
trnode&&trnode.parentNode.removeChild(trnode);
|
||||
}
|
||||
|
||||
var list=null,first=null;
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
list=document.getElementById('list');
|
||||
first=document.getElementById('empty');
|
||||
}, false);
|
||||
// 添加列表项
|
||||
function createItem(path){
|
||||
var li = document.createElement('li');
|
||||
li.className = 'ditem';
|
||||
li.innerHTML = '<span class="iplay"><font class="aname"></font><br/><font class="ainf"></font></span>';
|
||||
li.setAttribute('onclick', 'displayMedia(this);' );
|
||||
list.insertBefore(li, first.nextSibling);
|
||||
var i = path.lastIndexOf('/');
|
||||
if(i<0){
|
||||
i = path.lastIndexOf('\\');
|
||||
}
|
||||
li.querySelector('.aname').innerText = path.substr(i+1);
|
||||
li.querySelector('.ainf').innerText = path;
|
||||
li.path = path;
|
||||
// 设置空项不可见
|
||||
first.style.display = 'none';
|
||||
}
|
||||
// 清除列表记录
|
||||
function cleanList() {
|
||||
list.innerHTML = '<li id="empty" class="ditem-empty">无记录</li>';
|
||||
empty = document.getElementById('empty');
|
||||
// 删除音频文件
|
||||
outSet('清空选择照片记录:');
|
||||
}
|
||||
// 返回后关闭图片显示
|
||||
var _back=window.back;
|
||||
window.back=function(){
|
||||
closeImg();
|
||||
_back();
|
||||
};
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
.aname {
|
||||
font-size: 16px;
|
||||
text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
}
|
||||
.ainf {
|
||||
font-size: 12px;
|
||||
text-overflow:ellipsis;
|
||||
white-space:nowrap;
|
||||
}
|
||||
.iplay {
|
||||
display: block;
|
||||
background: no-repeat right center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwOS8xMi8xM5w+I3MAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAAD9UlEQVR4nO2b3XETMRRGDwzvoYOkg5hRAVkqiKmAdIA7wHSQVECoALsC1gXciV0BTge4gvCwgnHk9d/+WF8m97ztxrlXs8fS1Urym6enJxwd3uZugPMcFyKGCxHDhYjhQsRwIWK4EDFciBguRAwXIoYLEcOFiOFCxHAhYrgQMVyIGC5EDBcihgsRw4WI4ULEcCFiuBAx3uVuwDGY2XtgCBTAALjc8tEFMAdKYBJC+HOK9nXBm5dwUM7MCmAEXDcMMQVuQwhlV23qC2khZjYAboGrjkLOgFEIYd5RvM6RrSFmdgs80J0MYqyHGFsSuR4S60TJ9vrwCEziZ+YhhGXy/xdU9aWgqjfnW+IsgEKtvkgJiUPUPfUyZsD42DoQ68+Y+p62AG6UhjAZITt6xopq3L9vGf+Gqh6dJX+S6ilKNaRkU8YCGLSVARBjDGLMdS5jbgkkhMQiWyejSGtEG2KsghopKoU++5AV68ZDcrvXYWTH8Pghdz1R6CHpN3MFDPsc02PsYcy1qy0nJ6uQOANKZz+jfcOUmd3H6W1jYo5RcvsqtikbuXtI+kBmBxbwz8DczMZtksdcsz1tOinZhMRxPF2bGh8R4gz4amZLMxu2aEqa8zq2LQs5e0j6EB8bLv6dAz/NrGwyjMWcj3vadjJyCimS60nLeFfAbzO7bfANT3MXLdvSmJxCBsl12VHcL8AyvpkfSpo7bdvJyCkkfQfocv5/Bnw3s/mBs6Y097aFzd7JPcv6T5dv5GtcAr/2TZN7yt0IGSE908k0+RS8FiEvhhd1yKEFUw5YAVBApoe0XQrZwgL4GEIY7pLRU+5G5OwhC57PZgbAsqPYK6rdxUMXC9Npbro8fzJy9pB0qll0FPcOuDhCRl3ubEvwOYWUyXXb5YoZ1X7GqMHSfZq7bNmWxuQUki5XnDdc+n4EPoUQiiabSzFnejKl7TJOY7IJid/iaXJ7fESIFfCNas+9zQNMc05zHnjIPctKx/mrA9egflCJGLd5eDFXukGWdddQYU+95PlDWVE97GXPeS+oivf6saBZCKHoM+8+cvcQ2NyhOwMmfW4SxdgTNs9oZd0tBAEhsRDfJbcvgbIPKTtOnNzlPnECAkPWP8xsTv3ZrJ1v2UfmuKDqGRt5QgjZ9kDWyd5D1iioP1U4P3KzqZYYY5v0om38rpDpIeCHrUFMCPjPEeSE/COetf3SU/i7EEL2GVUdSjXkGfGBfWDzIFsb/q93dRizU2R7yDr+o09R/GfRzsmRrSGvFRcihgsRw4WI4ULEcCFiuBAxXIgYLkQMFyKGCxHDhYjhQsRwIWK4EDFciBguRAwXIoYLEcOFiOFCxHAhYrgQMf4CVuqCm+17t3sAAAAASUVORK5CYII=);
|
||||
background-size: 50px 44px;
|
||||
-ms-touch-action: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Gallery</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Gallery Document','/doc/gallery.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="getImage()">拍照并保存到相册</div>
|
||||
<div class="button" onclick="galleryImg()">从相册中单选图片</div>
|
||||
<div class="button" onclick="galleryImgs()">从相册中多选图片</div>
|
||||
<div class="button" onclick="galleryImgsMaximum()">从相册中多选图片(最多三张)</div>
|
||||
<div class="button" onclick="galleryImgsSelected()">从相册中多选图片(保存勾选记录)</div>
|
||||
<br/>
|
||||
<!-- Image list -->
|
||||
<!--<ul id="list" class="dlist" style="text-align:left;">
|
||||
<li id="empty" class="ditem-empty">无记录</li>
|
||||
<li class="ditem" onclick="displayMedia(this);">
|
||||
<span class="iplay">
|
||||
<div class="aname">.BjMobileService_bmcc168.apk.png</div><br>
|
||||
<div class="ainf">file:///storage/sdcard0/QQBrowser/安装包/.BjMobileService_bmcc168.apk.png</div>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button button-waring" onclick="cleanList()">清空列表</div>
|
||||
<br/>-->
|
||||
</div>
|
||||
<div id="output">
|
||||
Gallery模块管理系统相册,如从相册中选择图片或视频文件、保存图片或视频文件到相册等功能。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,94 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var watchId;
|
||||
function geoInf( position ) {
|
||||
var str = "";
|
||||
str += "地址:"+position.addresses+"\n";//获取地址信息
|
||||
str += "坐标类型:"+position.coordsType+"\n";
|
||||
var timeflag = position.timestamp;//获取到地理位置信息的时间戳;一个毫秒数;
|
||||
str += "时间戳:"+timeflag+"\n";
|
||||
var codns = position.coords;//获取地理坐标信息;
|
||||
var lat = codns.latitude;//获取到当前位置的纬度;
|
||||
str += "纬度:"+lat+"\n";
|
||||
var longt = codns.longitude;//获取到当前位置的经度
|
||||
str += "经度:"+longt+"\n";
|
||||
var alt = codns.altitude;//获取到当前位置的海拔信息;
|
||||
str += "海拔:"+alt+"\n";
|
||||
var accu = codns.accuracy;//地理坐标信息精确度信息;
|
||||
str += "精确度:"+accu+"\n";
|
||||
var altAcc = codns.altitudeAccuracy;//获取海拔信息的精确度;
|
||||
str += "海拔精确度:"+altAcc+"\n";
|
||||
var head = codns.heading;//获取设备的移动方向;
|
||||
str += "移动方向:"+head+"\n";
|
||||
var sped = codns.speed;//获取设备的移动速度;
|
||||
str += "移动速度:"+sped;
|
||||
console.log(JSON.stringify(position));
|
||||
outLine( str );
|
||||
}
|
||||
function getPos() {
|
||||
outSet( "获取位置信息:" );
|
||||
plus.geolocation.getCurrentPosition( geoInf, function ( e ) {
|
||||
outSet( "获取位置信息失败:"+e.message );
|
||||
}, {geocode:false} );
|
||||
}
|
||||
function watchPos() {
|
||||
if ( watchId ) {
|
||||
return;
|
||||
}
|
||||
watchId = plus.geolocation.watchPosition( function ( p ) {
|
||||
outSet( "监听位置变化信息:" );
|
||||
geoInf( p );
|
||||
}, function ( e ) {
|
||||
outSet( "监听位置变化信息失败:"+e.message );
|
||||
}, {geocode:false} );
|
||||
}
|
||||
function clearWatch() {
|
||||
if ( watchId ) {
|
||||
outSet( "停止监听位置变化信息" );
|
||||
plus.geolocation.clearWatch( watchId );
|
||||
watchId = null;
|
||||
}
|
||||
}
|
||||
// 通过定位模块获取位置信息
|
||||
function getGeocode(){
|
||||
outSet( "获取定位位置信息:" );
|
||||
plus.geolocation.getCurrentPosition( geoInf, function ( e ) {
|
||||
outSet( "获取定位位置信息失败:"+e.message );
|
||||
},{geocode:true});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Geolocation</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Geolocation Document','/doc/geolocation.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="getPos()">获取设备位置信息</li>
|
||||
<li class="ditem" onclick="watchPos()">监听设备位置信息</li>
|
||||
<li class="ditem" onclick="clearWatch()">停止监听</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button" onclick="getGeocode()">获取定位信息</div>
|
||||
<p class="des">
|
||||
Android平台推荐配置高德或百度定位,避免在部分设备(如三星、HTC等)可能无法获取位置信息的问题。
|
||||
</p>
|
||||
</div>
|
||||
<div id="output">
|
||||
Geolocation可获取设备位置信息,包括经度、纬度、高度等信息。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function navigateWithMap(){
|
||||
if('Android'===plus.os.name&&navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持地图插件');
|
||||
return;
|
||||
}
|
||||
// 设置目标位置坐标点和其实位置坐标点
|
||||
var dst = new plus.maps.Point(116.39131928,39.90793074); // 天安门
|
||||
var src = new plus.maps.Point(116.335,39.966); // 大钟寺
|
||||
// 调用系统地图显示
|
||||
plus.maps.openSysMap( dst, "天安门", src );
|
||||
}
|
||||
function showMaps(){
|
||||
if('Android'===plus.os.name&&navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持地图插件');
|
||||
return;
|
||||
}
|
||||
var ws=plus.webview.currentWebview();
|
||||
var wm=plus.webview.getWebviewById(plus.runtime.appid);
|
||||
wm&&wm.evalJS("preateClear()");
|
||||
clicked('maps_map.html',false,true);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Maps</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Maps Document','/doc/maps.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="navigateWithMap();">调用第三方地图程序导航</div>
|
||||
<div class="button" onclick="showMaps();">应用内置地图</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
Maps模块管理地图控件,用于在web页面中显示地图控件,提供各种接口操作地图控件,如添加标点、路线等。通过plus.maps可获取地图管理对象。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,97 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var ws=null,wo=null;
|
||||
var em=null,map=null,pcenter=null;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
if(!em||ws){return};
|
||||
// 获取窗口对象
|
||||
ws=plus.webview.currentWebview();
|
||||
wo=ws.opener();
|
||||
//高德地图坐标为(116.3974357341,39.9085574220), 百度地图坐标为(116.3975,39.9074)
|
||||
pcenter = new plus.maps.Point(116.3975,39.9074);
|
||||
setTimeout(function(){
|
||||
map=new plus.maps.Map("map");
|
||||
map.centerAndZoom(pcenter,12);
|
||||
createMarker();
|
||||
// 创建子窗口
|
||||
createSubview();
|
||||
},300);
|
||||
// 显示页面并关闭等待框
|
||||
ws.show("pop-in");
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// DOMContentloaded事件处理
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
em=document.getElementById("map");
|
||||
window.plus&&plusReady();
|
||||
},false);
|
||||
function userLocation(){
|
||||
map.showUserLocation( true );
|
||||
map.getUserLocation(function(state,pos){
|
||||
if(0==state){
|
||||
map.setCenter(pos);
|
||||
}
|
||||
});
|
||||
}
|
||||
function createMarker(){
|
||||
//高德地图坐标为(116.3406445236,39.9630878208), 百度地图坐标为(116.347292,39.968716
|
||||
var marker=new plus.maps.Marker(new plus.maps.Point(116.347292,39.968716));
|
||||
marker.setIcon("/logo.png");
|
||||
marker.setLabel("HBuilder");
|
||||
var bubble = new plus.maps.Bubble("打造最好的HTML5移动开发工具");
|
||||
marker.setBubble(bubble);
|
||||
map.addOverlay(marker);
|
||||
}
|
||||
function createSubview(){
|
||||
// 创建加载内容窗口
|
||||
var topoffset='44px';
|
||||
if(plus.navigator.isImmersedStatusbar()){// 兼容immersed状态栏模式
|
||||
topoffset=(Math.round(plus.navigator.getStatusbarHeight())+44)+'px';
|
||||
}
|
||||
var wsub=plus.webview.create('maps_map_sub.html','sub',{top:topoffset,height:'60px',position:'absolute',scrollIndicator:'none',background:'transparent'});
|
||||
ws.append(wsub);
|
||||
}
|
||||
function resetMap(){
|
||||
//map.centerAndZoom(pcenter,12);
|
||||
map.reset();
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 100%;
|
||||
position: fixed;
|
||||
top: 45px;
|
||||
bottom: 0px;
|
||||
line-height: 200px;
|
||||
text-align: center;
|
||||
background: #FFFFFF;
|
||||
}
|
||||
.ipos {
|
||||
background: no-repeat center center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAsCAYAAAAn4+taAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNC8wMS8xNExYUU4AAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAACTklEQVRoge2YO2gUURSGv7PjEkULO4UoFooIFgtzprAPWMiWKewSTadgYWEhBjHCloGUQtYHaGEjGAQtUmgnZO9YpsqC2NgYIwjRInMscoPrYkzhGTIs8zdnzoP578ewM/eumBmjoMZ+L8BLNUjVVINUTTVI1VSDVE0jA3KgjJuGEE6LyI2iKC6JyBkzWxORF8ADVV0rw1O891ohhCngPnDyL+1PZjabZdkTV1OcQUIIV4CHMf0JvAK+A0eANjAWe1dV9ZGbMY6/kTzPzwHzMV0VkZaqTgLTqjopIi1gNfbnQwhnvbzBEcTMbgFHgXURaRdFsRFCWAa+hhCWi6LYEJE2sB7nbnp5g+9b62KMIU3Tvoh0gQm2Fz0hIt00TftAADCztqO3K8h4jJsAZnZ+sDmQ/wAQkXEc5QnyJcZjACLybLApIk/j5YmheRd5gryLMev1elOqesfMrpvZczO7pqqzvV5vGmgNzbvIDUREXsbLRES6IYTbzWZzMcuyy0mSPA4h3BWRxR3PgXkff6/vSJ7nx83sPXBqoLwJFEACHByofxSRC2mafnYxx/GJxEW9GSofAg7zJwTAa08I8N80doG9HrHx++vvJlcQVV0xs6V/zZjZkqquePpCOdv4OWBrl96WiNwrwdMfJMuyHFjYpb2gqh+8PaG8g9Uc0B+q9WO9FJUCoqrfgBm2X73EOBPrpai0o66qvgU6Me3EvDSVctTdUZIknaIoxhqNRmfv6f+T+1F3vzQy/6LUIFVTDVI11SBVUw1SNdUgVdPIgPwCtt+2JPQRVicAAAAASUVORK5CYII=);
|
||||
background-size: 50px 44px;
|
||||
} </style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back();"></div>
|
||||
<div class="nvtt">应用内置地图</div>
|
||||
<div class="nvbt ipos" onclick="userLocation();"></div>
|
||||
</header>
|
||||
<div id="map">地图加载中...</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript">
|
||||
function resetMap(){
|
||||
plus.webview.currentWebview().opener().evalJS('resetMap()');
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
html,body{
|
||||
overflow:hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="button" style="margin:.2em auto;width:50%" onclick="resetMap()">重 置</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,91 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function addachmentMail(){
|
||||
outSet("发送带附件邮件:")
|
||||
var msg = plus.messaging.createMessage(plus.messaging.TYPE_EMAIL);
|
||||
msg.to = ['service@dcloud.io'];
|
||||
msg.body = 'This is an example mail';
|
||||
msg.addAttachment("_www/img/helloh5.jpg");
|
||||
plus.messaging.sendMessage( msg );
|
||||
}
|
||||
function htmlMail(){
|
||||
outSet("发送HTML邮件:");
|
||||
if ( plus.os.name == "iOS" ) {
|
||||
var msg = plus.messaging.createMessage(plus.messaging.TYPE_EMAIL);
|
||||
msg.to = ["service@dcloud.io"];
|
||||
msg.body = '<!DOCTYPE HTML><html><head><meta charset="utf-8"/></head><body><h1>Hello</h1>This is an HTML content mail.</body></html>';
|
||||
msg.bodyType = "html";
|
||||
plus.messaging.sendMessage( msg );
|
||||
outLine("支持");
|
||||
} else {
|
||||
outLine("此平台不支持发送HTML邮件功能!");
|
||||
plus.nativeUI.alert("此平台不支持发送HTML邮件功能!");
|
||||
}
|
||||
}
|
||||
function slientSMS(){
|
||||
outSet("后台发送短信:");
|
||||
if ( plus.os.name == "Android" ) {
|
||||
var bts=["发送到10086","发送到10010","发送到10000"];
|
||||
plus.nativeUI.prompt("短信内容",function(e){
|
||||
var to=null;
|
||||
switch(e.index){
|
||||
case 0:
|
||||
to=['10086'];
|
||||
break;
|
||||
case 1:
|
||||
to=['10086'];
|
||||
break;
|
||||
case 2:
|
||||
to=['10086'];
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
var msg = plus.messaging.createMessage(plus.messaging.TYPE_SMS);
|
||||
msg.to=to;
|
||||
msg.body=e.value;
|
||||
msg.silent=true;
|
||||
plus.messaging.sendMessage( msg );
|
||||
outLine( "\""+e.value+"\""+bts[e.index] );
|
||||
},"发送短信","CXYE",bts);
|
||||
} else {
|
||||
outLine("此平台不支持后台发送短信功能!");
|
||||
plus.nativeUI.alert("此平台不支持后台发送短信功能!");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Messaging</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Messaging Document','/doc/messaging.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="addachmentMail()">发送附件邮件</div>
|
||||
<div class="button" onclick="htmlMail()">发送HTML邮件</div>
|
||||
<div class="button" onclick="slientSMS()">后台发送短信</div>
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem"><a style="text-decoration:none;color:#666;display:block" href="sms:10086">发送短信</a></li>
|
||||
<li class="ditem"><a style="text-decoration:none;color:#666;display:block" href="tel:10086">拨打电话</a></li>
|
||||
<li class="ditem"><a style="text-decoration:none;color:#666;display:block" href="mailto:service@dcloud.io">发送邮件</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Messaging管理设备通讯功能,可用于发送短信、彩信、邮件等。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">NativeObj</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Audio Document','/doc/nativeobj.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="clicked('nativeobj_animation.html',true)">原生View过渡动画示例</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
NativeObj用于管理系统原生对象,如原生View控件、图片对象等。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,148 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var nWaiting,nTitle; // 原生view的等待界面和title
|
||||
var touchX; // nWaiting的点击坐标的x数值
|
||||
var backPressed; //返回箭头是否处于按下状态
|
||||
var contentWebview=null; //准备打开网址的webview
|
||||
var bitmap=null; // 返回图标
|
||||
var topoffset=0;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
if(plus.navigator.isImmersedStatusbar()){// 兼容沉浸式状态栏模式
|
||||
topoffset=Math.round(plus.navigator.getStatusbarHeight());
|
||||
}
|
||||
var bdata = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABZ0RVh0Q3JlYXRpb24gVGltZQAwOS8xMi8xM5w+I3MAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzVxteM2AAACcklEQVR4nO3a0XESURiG4TeO99iBWoGZ+RvADtKBpAPtwBLsANJBrEAs4MyYDmIHSQXkgk0mMLK7ILt8/+F778ici394OGfDsher1Qqn05tTD+A2M4hYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYb089wNCVUq6Ay+blfUQsTjhOZxc1P9tbSlkAX7b+/C0ifpxgnF5Ve2TtwAD4OvIoe1UlSAsGwPsRR9m76kA6MAD+jjTKQVUF0gMD4HaEUQ6umot6T4ybiJgNP83hVbFDasGACnZIT4yfEXE1wjj/Xeod0hPjDpgNPsyRSguyB8Y0Ih6Gn+g4pQSpFQMSgtSMAclAaseARCDngAFJQM4FAxKAnBMGiH8xLKVMgV89ln6MiPthpxkn6R0SEUvgusfSZSnlsnuZftI75LlSygyYdyx7ZH1s/Rl+ouFKAQIvx9ctMGlZlh4lDQhAcywtqRhF+hqyXfMmT1m/6buasL6mzMaY6dilAoENlLuWZRNgnhEl1ZH1ulLKO9bH16eOpdfqz2K9Lt0Oea75EjilfadAsp2SFgQ2UH53LJ2XUr4PPtARSntkbVfL7+rVgEBvlM/NHQDJUh9Z2zWf/puOZbPhJzm8qkDgBaXt/teHcSY5rOpAAJp/c/vclJSrShDYifKI+NPvVV3U/1VzU3LavFyo/25SPUi2qj2ysmYQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsQwilkHEMohYBhHLIGIZRCyDiGUQsZ4Ak9fPFwUy/HsAAAAASUVORK5CYII=';
|
||||
bitmap = new plus.nativeObj.Bitmap('back');
|
||||
bitmap.loadBase64Data(bdata, function(){
|
||||
bitmap.isLoadSuccess = true;
|
||||
nWaiting&&nWaiting.drawBitmap(bitmap,null,{top:topoffset+'px',left:'0px',width:'44px',height:'44px'},'backicon');
|
||||
console.log('Back bitmap load success');
|
||||
}, function(e){
|
||||
console.log('Back bitmap load failed: '+JSON.stringify(e));
|
||||
});
|
||||
|
||||
//创建nWaiting
|
||||
creatWaiting();
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
}
|
||||
// 创建原生View控件
|
||||
function creatWaiting(){
|
||||
console.log('creatWaiting: '+topoffset);
|
||||
//判断view是否已存在,避免重复创建,尤其调试刷新网页时很容易触发重复创建
|
||||
nWaiting = plus.nativeObj.View.getViewById('nWaiting');
|
||||
if(nWaiting){
|
||||
return;
|
||||
}
|
||||
nWaiting = new plus.nativeObj.View('nWaiting',{top:'0px',left:'0px',height:'100%',width:'100%'});
|
||||
nWaiting.interceptTouchEvent(true);
|
||||
|
||||
//初始化绘制nwaiting界面
|
||||
nWaiting.drawRect('#D74B28',{top:'0px',left:'0px',height:(topoffset+44)+'px',width:'100%'}) //绘制title背景色
|
||||
bitmap&&bitmap.isLoadSuccess&&nWaiting.drawBitmap(bitmap,null,{top:topoffset+'px',left:'0px',width:'44px',height:'44px'},'backicon');
|
||||
nWaiting.drawText( '标题', {top:topoffset+'px',left:'0px',width:'100%',height:'44px'}, {size:'17px',color:'#CCCCCC'});
|
||||
nWaiting.drawRect('#EEEEEE',{top:(topoffset+44)+'px',left:'0px',width:'100%'}) //绘制等待内容区背景色
|
||||
nWaiting.drawText( '加 载 中 ...', {top:(topoffset+44)+'px',left:'0px',width:'100%',height:'50%'}, {size:'12px',color:'rgb(100,100,100)'});
|
||||
}
|
||||
// 更新窗口导航栏
|
||||
function updateNavigationbar(){
|
||||
nTitle = contentWebview.getNavigationbar();
|
||||
nTitle.interceptTouchEvent(true);
|
||||
// 处理touchstart、touchmove、touchend事件,实现下效果
|
||||
// nTitle.addEventListener('touchstart', function(e){
|
||||
// console.log('touchstart'+e.pageX);
|
||||
// touchX = e.pageX;
|
||||
// if(touchX>0 && touchX<44){
|
||||
// nTitle.drawRect('#e7e7e7', {top:topoffset+'px',left:'0px',width:'44px',height:'44px'}, 'backbg');
|
||||
// backPressed=true;
|
||||
// }
|
||||
// });
|
||||
// nTitle.addEventListener('touchmove', function(e){
|
||||
// console.log('touchmove'+e.pageX);
|
||||
// touchX = e.pageX;
|
||||
// if(touchX>44 && backPressed){
|
||||
// nTitle.drawRect('#f7f7f7', {top:topoffset+'px',left:'0px',width:'44px',height:'44px'}, 'backbg');
|
||||
// backPressed=false;
|
||||
// }
|
||||
// });
|
||||
// nTitle.addEventListener('touchend', function(e){
|
||||
// console.log('touchend'+e.pageX);
|
||||
// if(backPressed){
|
||||
// nTitle.drawRect('#f7f7f7', {top:topoffset+'px',left:'0px',width:'44px',height:'44px'}, 'backbg');
|
||||
// backPressed=false;
|
||||
// }
|
||||
// });
|
||||
// 处理点击事件
|
||||
nTitle.addEventListener('click', function(e){
|
||||
touchX = e.pageX;
|
||||
if(touchX>3 && touchX<44){
|
||||
back();
|
||||
}
|
||||
});
|
||||
//补充绘制nTitle界面
|
||||
nTitle.drawBitmap(bitmap, null, {top:'0px',left:'0px',width:'44px',height:'44px'}, 'backicon'); // 绘制返回箭头
|
||||
}
|
||||
// 使用原生View控件作为动画模板显示窗口
|
||||
function showWithWaiting(){
|
||||
var bShow=bUpdate=false;
|
||||
contentWebview = plus.webview.create('http://m.weibo.cn/u/3196963860', 'contendWebview', {navigationbar:{backgroundColor:'#D74B28',titletText:'标题',titleColor:'#CCCCCC'}});
|
||||
// 更新Webview的原生头内容
|
||||
updateNavigationbar();//setTimeout(updateNavigationbar, 100);
|
||||
contentWebview.addEventListener('close', function(){
|
||||
contentWebview=null;
|
||||
});
|
||||
contentWebview.addEventListener('titleUpdate', function(){
|
||||
bUpdate=true;
|
||||
bShow&&nWaiting.hide();
|
||||
}, false);
|
||||
contentWebview.addEventListener('loaded', function(){// 兼容titleUpdate事件不触发的情况
|
||||
bUpdate||(bUpdate=true,bShow&&nWaiting.hide());
|
||||
}, false);
|
||||
contentWebview.show('pop-in', null, function(){
|
||||
bShow=true;
|
||||
bUpdate&&nWaiting.hide();
|
||||
}, {capture:nWaiting});
|
||||
}
|
||||
// 重写返回处理
|
||||
var _back=window.back;
|
||||
function safeback(){
|
||||
contentWebview?contentWebview.close('pop-out'):(bitmap&&bitmap.clear(),nWaiting&&nWaiting.clear(),_back());
|
||||
}
|
||||
window.back=safeback;
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">原生View过渡动画示例</div>
|
||||
<div class="nvbt"></div>
|
||||
</header>
|
||||
<div id="content" class="content">
|
||||
<p class="des">
|
||||
使用nview来做转场动画,以及使用原生view做标题栏。
|
||||
</p>
|
||||
<div class="button" onclick="showWithWaiting()">演示</div>
|
||||
<p class="des" style="font-weight:bold;text-indent:0;">
|
||||
逻辑简述:
|
||||
</p>
|
||||
<p class="des">
|
||||
启动后先创建一个原生waiting界面,但不显示。
|
||||
点击show按钮后,原生waiting做动画进来,同时然后创建一个带原生View控件导航栏的contentWebview加载网络页面,等titleUpdate后显示contentWebview并关闭原生waiting界面。
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js"></script>
|
||||
</html>
|
||||
@@ -0,0 +1,113 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function pickDate() {
|
||||
outSet( "打开系统日期选择框:");
|
||||
var dDate=new Date();
|
||||
dDate.setFullYear(2014,0,1);
|
||||
var minDate=new Date();
|
||||
minDate.setFullYear(2010,0,1);
|
||||
var maxDate=new Date();
|
||||
maxDate.setFullYear(2016,11,31);
|
||||
outLine( "[date] "+dDate );
|
||||
outLine( "[minDate] "+minDate );
|
||||
outLine( "[maxDate] "+maxDate );
|
||||
plus.nativeUI.pickDate( function(e) {
|
||||
var d=e.date;
|
||||
outLine( "选择的日期:"+d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate() );
|
||||
},function(e){
|
||||
outSet( "未选择日期:"+e.message );
|
||||
},{title:"请选择日期",date:dDate,minDate:minDate,maxDate:maxDate});
|
||||
}
|
||||
function pickTime() {
|
||||
outSet( "打开系统时间选择框:");
|
||||
var dTime=new Date();
|
||||
dTime.setHours(6,0);
|
||||
outLine( "[time] "+dTime );
|
||||
plus.nativeUI.pickTime(function(e){
|
||||
var d=e.date;
|
||||
outLine( "选择的时间:"+d.getHours()+":"+d.getMinutes() );
|
||||
},function (e){
|
||||
outSet( "取消选择时间!" );
|
||||
},{title:"请选择时间",is24Hour:true,time:dTime});
|
||||
}
|
||||
function showAlert(){
|
||||
outSet( "弹出系统提示对话框:" );
|
||||
plus.nativeUI.alert("系统提示框内容\n第二行内容",function(e){
|
||||
var i=e.index;
|
||||
if(i<0){
|
||||
outLine( "按\"返回\"键关闭提示框!" );
|
||||
}else{
|
||||
outLine( "提示框已关闭!" );
|
||||
}
|
||||
},"nativeUI","好");
|
||||
}
|
||||
function showConfirm(){
|
||||
outSet( "弹出系统确认对话框:" );
|
||||
var bts=["是","否","取消"];
|
||||
plus.nativeUI.confirm("系统确认对话框内容\n第二行内容",function(e){
|
||||
var i=e.index;
|
||||
outLine( "按\""+((i>=0)?bts[e.index]:"返回")+"\"关闭!" );
|
||||
},"nativeUI",bts);
|
||||
}
|
||||
function showPrompt(){
|
||||
outSet( "弹出系统输入对话框:" );
|
||||
var bts=["确认","取消"];
|
||||
plus.nativeUI.prompt("请输入内容",function(e){
|
||||
var i=e.index;
|
||||
outLine( "按\""+((i>=0)?bts[e.index]:"返回")+"\"关闭:"+e.value );
|
||||
},"nativeUI","内容",bts);
|
||||
}
|
||||
function showActionSheet(){
|
||||
outSet( "弹出系统选择按钮框:" );
|
||||
var bts=[{title:"警告",style:"destructive"},{title:"按钮1"},{title:"按钮2"},{title:"按钮3"}];
|
||||
plus.nativeUI.actionSheet({title:"ActionSheet标题",cancel:"取消",buttons:bts},
|
||||
function(e){
|
||||
outLine( "选择了\""+((e.index>0)?bts[e.index-1].title:"取消")+"\"");
|
||||
}
|
||||
);
|
||||
}
|
||||
function showToast(){
|
||||
plus.nativeUI.toast("您好!正在使用HBuilder开发应用!",{duration:"long"});
|
||||
}
|
||||
function showWaiting(){
|
||||
var nw = clicked('nativeui_waiting.html',false,false,{popGesture:'none'});
|
||||
nw.addEventListener("close",function(){
|
||||
plus.nativeUI.closeWaiting();
|
||||
},false);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">nativeUI</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('NativeUI Document','/doc/nativeUI.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="pickDate()">系统日期选择框</li>
|
||||
<li class="ditem" onclick="pickTime()">系统时间选择框</li>
|
||||
<li class="ditem" onclick="showAlert()">提示框</li>
|
||||
<li class="ditem" onclick="showConfirm()">确认框</li>
|
||||
<li class="ditem" onclick="showPrompt()">输入框</li>
|
||||
<li class="ditem" onclick="showActionSheet()">弹出菜单ActionSheet</li>
|
||||
<li class="ditem" onclick="showToast()">自动消失提示框</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button" onclick="showWaiting()">等待框</div>
|
||||
</div>
|
||||
<div id="output">
|
||||
nativeUI管理系统原生界面,可用于弹出系统原生提示对话框窗口、时间日期选择对话框、等待对话框等。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,195 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
|
||||
<meta name="misapplication-tap-highlight" content="no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
function defaultWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...\n5");
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待...\n"+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function nomodalWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...\n5",{modal:false});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待...\n"+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function padlockWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...\n5", {padlock:true});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待...\n"+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function customWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...\n5", {loading:{icon:"/img/waiting.png"}});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待...\n"+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function lineWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...5", {loading:{display:"inline"}});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待..."+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function transWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...5", {style:"black",color:"#FF0000",background:"rgba(0,0,0,0)",loading:{display:"inline"}});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待..."+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function noneWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...5", {color:"#FF0000",background:"rgba(0,0,0,0)",loading:{display:"none"}});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待..."+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function fontWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...\n5",{color:"#FF0000",size:"24px"});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待...\n"+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
function blockBackWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...\n5",{back:"none"});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待...\n"+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
|
||||
}
|
||||
function transBackWaiting(){
|
||||
var w=plus.nativeUI.showWaiting("处理中,请等待...\n5",{back:"transmit"});
|
||||
w.onclose=function(){
|
||||
clearInterval(t);
|
||||
}
|
||||
var n=5;
|
||||
var t=setInterval(function(){
|
||||
n--;
|
||||
w.setTitle("处理中,请等待...\n"+n);
|
||||
if(n<=0){
|
||||
w.close();
|
||||
clearInterval(t);
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Waiting</div>
|
||||
</header>
|
||||
<div id="scontent" class="scontent">
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="defaultWaiting()">默认等待框</li>
|
||||
<li class="ditem" onclick="nomodalWaiting()">非模态等待框</li>
|
||||
<li class="ditem" onclick="padlockWaiting()">点击关闭等待框</li>
|
||||
<li class="ditem" onclick="customWaiting()">自定义图标等待框</li>
|
||||
<li class="ditem" onclick="lineWaiting()">图标与文字同行</li>
|
||||
<li class="ditem" onclick="transWaiting()">背景透明</li>
|
||||
<li class="ditem" onclick="noneWaiting()">无图标等待框</li>
|
||||
<li class="ditem" onclick="fontWaiting()">大字体等待框</li>
|
||||
<li class="ditem" onclick="blockBackWaiting()">不响应返回键等待框</li>
|
||||
<li class="ditem" onclick="transBackWaiting()">透传返回键等待框</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function fullscreen(){
|
||||
outSet( "应用全屏显示!" );
|
||||
plus.navigator.setFullscreen(true);
|
||||
}
|
||||
function unfullscreen(){
|
||||
outSet( "应用非全屏显示!" );
|
||||
plus.navigator.setFullscreen(false);
|
||||
}
|
||||
function isfullscreen(){
|
||||
outSet( "是否全屏:"+(plus.navigator.isFullscreen()?"是":"否") );
|
||||
}
|
||||
|
||||
function customerNavigator(){
|
||||
var wn=clicked('navigator_status.html');
|
||||
var bcolor=plus.navigator.getStatusBarBackground();
|
||||
var bstyle=plus.navigator.getStatusBarStyle();
|
||||
wn.addEventListener('close',function(){
|
||||
//页面关闭后状态栏重置回以前的颜色
|
||||
plus.navigator.setStatusBarBackground(bcolor);
|
||||
//页面关闭后状态栏重置回以前的样式
|
||||
plus.navigator.setStatusBarStyle(bstyle);
|
||||
},false);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Navigator</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Navigator Document','/doc/navigator.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="fullscreen()">全屏显示</li>
|
||||
<li class="ditem" onclick="unfullscreen()">非全屏显示</li>
|
||||
<li class="ditem" onclick="isfullscreen()">是否全屏</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button" onclick="customerNavigator()">状态栏样式</div>
|
||||
</div>
|
||||
<div id="output">
|
||||
Navigator用于管理浏览器运行环境信息,可用于设置应用全屏显示等。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
|
||||
<meta name="misapplication-tap-highlight" content="no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
// H5 plus事件处理
|
||||
var ws=null;
|
||||
function plusReady(){
|
||||
// 设置状态栏背景颜色
|
||||
ws=plus.webview.currentWebview();
|
||||
ws.addEventListener('show',function(){
|
||||
plus.navigator.setStatusBarBackground("#FF0000");
|
||||
},false);
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// 设置系统状态栏为深色前景色(黑色文字)
|
||||
function darkStyle(){
|
||||
plus.navigator.setStatusBarStyle('dark');
|
||||
}
|
||||
// 设置系统状态栏为浅色前景色(白色文字)
|
||||
function lightStyle(){
|
||||
plus.navigator.setStatusBarStyle('light');
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header" style="background:#FF0000">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Statusbar</div>
|
||||
</header>
|
||||
<div class="scontent">
|
||||
<br/>
|
||||
<p class="des">
|
||||
Android平台需要5.0及以上版本支持设置系统状态栏背景颜色。
|
||||
</p>
|
||||
<div class="button" onclick="darkStyle()">系统状态栏黑色样式</div>
|
||||
<div class="button" onclick="lightStyle()">系统状态栏白色样式</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,156 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
// 保存iOS平台导入的类对象
|
||||
var UIAlertView=null;
|
||||
// 保存Android导入对象和全局环境对象
|
||||
var AlertDialog=null,mainActivity=null;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
// 程序全局环境对象
|
||||
mainActivity = plus.android.runtimeMainActivity();
|
||||
// 导入AlertDialog类
|
||||
AlertDialog = plus.android.importClass("android.app.AlertDialog");
|
||||
break;
|
||||
case "iOS":
|
||||
// 导入UIAlertView类
|
||||
UIAlertView = plus.ios.importClass("UIAlertView");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在iOS平台通过NJS显示系统提示框
|
||||
*/
|
||||
function njsAlertForiOS(){
|
||||
/*
|
||||
* Objective-C 代码
|
||||
*
|
||||
// 创建UIAlertView类的实例对象
|
||||
UIAlertView *view = [UIAlertView alloc];
|
||||
// 设置提示对话上的内容
|
||||
[view initWithTitle:@"自定义标题" // 提示框标题
|
||||
message:@"使用NJS的原生弹出框,可自定义弹出框的标题、按钮" // 提示框上显示的内容
|
||||
delegate:nil // 点击提示框后的通知代理对象,nil类似js的null,意为不设置
|
||||
cancelButtonTitle:@"确定(或者其他字符)" // 提示框上取消按钮的文字
|
||||
otherButtonTitles:nil]; // 提示框上其它按钮的文字,设置为nil表示不显示
|
||||
// 调用show方法显示提示对话框,在OC中使用[]语法调用对象的方法
|
||||
[view show];
|
||||
*/
|
||||
|
||||
// 创建UIAlertView类的实例对象
|
||||
var view = new UIAlertView();
|
||||
// 设置提示对话上的内容
|
||||
view.initWithTitlemessagedelegatecancelButtonTitleotherButtonTitles("自定义标题" // 提示框标题
|
||||
, "使用NJS的原生弹出框,可自定义弹出框的标题、按钮" // 提示框上显示的内容
|
||||
, null // 操作提示框后的通知代理对象,暂不设置
|
||||
, "确定(或者其他字符)" // 提示框上取消按钮的文字
|
||||
, null ); // 提示框上其它按钮的文字,设置为null表示不显示
|
||||
// 调用show方法显示提示对话框
|
||||
view.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在Android平台通过NJS显示系统提示框
|
||||
*/
|
||||
function njsAlertForAndroid(){
|
||||
/*
|
||||
* Android平台 java代码
|
||||
*
|
||||
// 创建提示框构造对象,Builder是AlertDialog的内部类。参数this指代Android的主Activity对象,该对象启动应用时自动生成
|
||||
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
|
||||
// 设置提示框标题
|
||||
dlg.setTitle("自定义标题");
|
||||
// 设置提示框内容
|
||||
dlg.setMessage("使用NJS的原生弹出框,可自定义弹出框的标题、按钮");
|
||||
// 设置提示框按钮
|
||||
dlg.setPositiveButton("确定(或者其他字符)", null);
|
||||
// 显示提示框
|
||||
dlg.show();
|
||||
*/
|
||||
|
||||
// 创建提示框构造对象,构造函数需要提供程序全局环境对象,通过plus.android.runtimeMainActivity()方法获取
|
||||
var dlg = new AlertDialog.Builder(mainActivity);
|
||||
// 设置提示框标题
|
||||
dlg.setTitle("自定义标题");
|
||||
// 设置提示框内容
|
||||
dlg.setMessage("使用NJS的原生弹出框,可自定义弹出框的标题、按钮");
|
||||
// 设置提示框按钮
|
||||
dlg.setPositiveButton("确定(或者其他字符)",null);
|
||||
// 显示提示框
|
||||
dlg.show();
|
||||
}
|
||||
function showNjsView(){
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
njsAlertForAndroid();
|
||||
break;
|
||||
case "iOS":
|
||||
njsAlertForiOS();
|
||||
break;
|
||||
default:
|
||||
alert( "此平台不支持!" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function gamecenter(){
|
||||
if ( 'iOS' == plus.os.name ) {
|
||||
clicked('njs_ios_gamecenter.html',true);
|
||||
}else{
|
||||
plus.nativeUI.alert( "此平台不支持!" );
|
||||
}
|
||||
}
|
||||
|
||||
function shortcut(){
|
||||
if ( 'Android' == plus.os.name ) {
|
||||
clicked('njs_android_shortcut.html',true);
|
||||
}else{
|
||||
plus.nativeUI.alert( "此平台不支持!" );
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back(true)"></div>
|
||||
<div class="nvtt">Native.JS</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Native.JS Document','/doc/native.js.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<!--div class="button" onclick="gamecenter()">Game Center</div>
|
||||
<div class="button" onclick="shortcut()">Shortcut</div>
|
||||
<br/-->
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="showNjsView()">native.js调用系统提示框</li>
|
||||
<li class="ditem" onclick="clicked('njs_efficient.html')">native.js高级API</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<div class="button button-waring" onclick="plus.runtime.openURL('http://ask.dcloud.net.cn/article/114')">更多示例...</div>
|
||||
</div>
|
||||
<div id="output">
|
||||
Native.JS一种把操作系统的原生对象转义,映射为JS对象,在JS里编写原生代码的技术。可通过plus.android.*和plus.ios.*提供的API分别调用Android和iOS平台的Native API。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,146 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
* 首先是供参考对比的Android源代码,用Android的java代码创建手机桌面快捷方式
|
||||
*
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.app.Activity;
|
||||
|
||||
// 获取主Activity
|
||||
Activity main = this;
|
||||
// 创建快捷方式意图
|
||||
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
// 设置快捷方式的名称
|
||||
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloH5+");
|
||||
// 设置不可重复创建
|
||||
shortcut.putExtra("duplicate",false);
|
||||
// 设置快捷方式图标
|
||||
Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/icon.png");
|
||||
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
|
||||
// 设置快捷方式启动执行动作
|
||||
Intent action = new Intent(Intent.ACTION_MAIN);
|
||||
action.setComponent( main.getComponentName() );
|
||||
shortcut.putExtra( Intent.EXTRA_SHORTCUT_INTENT, action );
|
||||
// 广播创建快捷方式
|
||||
context.sendBroadcast(shortcut);
|
||||
*/
|
||||
/*
|
||||
* 如下开始是HTML5plus的js代码,演示如何通过js桥技术调用Android的原生api,从而完成手机桌面快捷方式创建。
|
||||
*/
|
||||
var Intent=null,BitmapFactory=null;
|
||||
var main=null;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
if ( plus.os.name == "Android" ) {
|
||||
// 导入要用到的类对象
|
||||
Intent = plus.android.importClass("android.content.Intent");
|
||||
BitmapFactory = plus.android.importClass("android.graphics.BitmapFactory");
|
||||
// 获取主Activity
|
||||
main = plus.android.runtimeMainActivity();
|
||||
}
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// DOMContentLoaded事件处理
|
||||
var _domReady=false;
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
eStart = document.getElementById( "start" );
|
||||
},false);
|
||||
/**
|
||||
* 创建桌面快捷方式
|
||||
*/
|
||||
function createShortcut(){
|
||||
// 创建快捷方式意图
|
||||
var shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
// 设置快捷方式的名称
|
||||
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloH5+");
|
||||
// 设置不可重复创建
|
||||
shortcut.putExtra("duplicate",false);
|
||||
// 设置快捷方式图标
|
||||
var iconPath = plus.io.convertLocalFileSystemURL("_www/icon.png"); // 将相对路径资源转换成系统绝对路径
|
||||
var bitmap = BitmapFactory.decodeFile(iconPath);
|
||||
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON,bitmap);
|
||||
// 设置快捷方式启动执行动作
|
||||
var action = new Intent(Intent.ACTION_MAIN);
|
||||
//action.setComponent(main.getComponentName());
|
||||
action.setClassName(main.getPackageName(), 'io.dcloud.PandoraEntry');
|
||||
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,action);
|
||||
// 广播创建快捷方式
|
||||
main.sendBroadcast(shortcut);
|
||||
outSet( "桌面快捷方式已创建完成!" );
|
||||
}
|
||||
|
||||
/*
|
||||
* 供参考对比的Android源代码,用Android的java代码删除手机桌面快捷方式
|
||||
*
|
||||
* // 获取主Activity
|
||||
* Activity main = this;
|
||||
* // 创建快捷方式意图
|
||||
* Intent shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
|
||||
* // 设置快捷方式的名称
|
||||
* shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,"HelloH5+");
|
||||
* // 设置快捷方式启动执行动作
|
||||
* Intent action = new Intent(Intent.ACTION_MAIN);
|
||||
* action.setComponent(main.getComponentName());
|
||||
* shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,action);
|
||||
* // 广播删除快捷方式
|
||||
* main.sendBroadcast(shortcut);
|
||||
*/
|
||||
/*
|
||||
* 删除桌面快捷方式
|
||||
*/
|
||||
function deleteShortcut(){
|
||||
// 创建快捷方式意图
|
||||
var shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");
|
||||
// 设置快捷方式的名称
|
||||
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,"HelloH5+");
|
||||
// 设置快捷方式启动执行动作
|
||||
var action = new Intent(Intent.ACTION_MAIN);
|
||||
//action.setComponent(main.getComponentName());
|
||||
action.setClassName(main.getPackageName(), 'io.dcloud.PandoraEntry');
|
||||
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,action);
|
||||
// 广播创建快捷方式
|
||||
main.sendBroadcast(shortcut);
|
||||
outSet( "桌面快捷方式已删除!" );
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back();"></div>
|
||||
<div class="nvtt">Shortcut</div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="createShortcut()">创建桌面快捷方式</div>
|
||||
<div class="button" onclick="deleteShortcut()">删除桌面快捷方式</div>
|
||||
<br/>
|
||||
<br/>
|
||||
<p class="des">
|
||||
快捷方式操作是通过向Android系统发送广播的方式来实现,可能在一些定制的ROM上没有实现此类广播的处理,导致无法创建桌面快捷方式。
|
||||
</p>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
Native.JS for Android,可通过plus.android.*调用几乎所有的系统API。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,120 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
// 保存Android全局环境对象
|
||||
var mainActivity=null;
|
||||
// H5+事件处理
|
||||
document.addEventListener("plusready",function(){
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
// 程序全局环境对象
|
||||
mainActivity = plus.android.runtimeMainActivity();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},false);
|
||||
/**
|
||||
* 在iOS平台通过NJS显示系统提示框
|
||||
*/
|
||||
function njsAlertForiOS(){
|
||||
/*
|
||||
* Objective-C 代码
|
||||
*
|
||||
// 创建UIAlertView类的实例对象
|
||||
UIAlertView *view = [UIAlertView alloc];
|
||||
// 设置提示对话上的内容
|
||||
[view initWithTitle:@"自定义标题" // 提示框标题
|
||||
message:@"使用NJS的原生弹出框,可自定义弹出框的标题、按钮" // 提示框上显示的内容
|
||||
delegate:nil // 点击提示框后的通知代理对象,nil类似js的null,意为不设置
|
||||
cancelButtonTitle:@"确定(或者其他字符)" // 提示框上取消按钮的文字
|
||||
otherButtonTitles:nil]; // 提示框上其它按钮的文字,设置为nil表示不显示
|
||||
// 调用show方法显示提示对话框,在OC中使用[]语法调用对象的方法
|
||||
[view show];
|
||||
*/
|
||||
|
||||
// 创建UIAlertView类的实例对象
|
||||
var view = plus.ios.newObject("UIAlertView");
|
||||
// 设置提示对话上的内容,这里的方法名称中必须包含':'字符
|
||||
plus.ios.invoke(view,"initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:"
|
||||
, "自定义标题" // 提示框标题
|
||||
, "使用NJS的原生弹出框,可自定义弹出框的标题、按钮" // 提示框上显示的内容
|
||||
, null // 操作提示框后的通知代理对象,暂不设置
|
||||
, "确定(或者其他字符)" // 提示框上取消按钮的文字
|
||||
, null ); // 提示框上其它按钮的文字,设置为null表示不显示
|
||||
// 调用show方法显示提示对话框,在JS中使用()语法调用对象的方法
|
||||
plus.ios.invoke(view,"show");
|
||||
}
|
||||
|
||||
/**
|
||||
* 在Android平台通过NJS显示系统提示框
|
||||
*/
|
||||
function njsAlertForAndroid(){
|
||||
/*
|
||||
* Android平台 java代码
|
||||
*
|
||||
// 创建提示框构造对象,Builder是AlertDialog的内部类。参数this指代Android的主Activity对象,该对象启动应用时自动生成
|
||||
AlertDialog.Builder dlg = new AlertDialog.Builder(this);
|
||||
// 设置提示框标题
|
||||
dlg.setTitle("自定义标题");
|
||||
// 设置提示框内容
|
||||
dlg.setMessage("使用NJS的原生弹出框,可自定义弹出框的标题、按钮");
|
||||
// 设置提示框按钮
|
||||
dlg.setPositiveButton("确定(或者其他字符)", null);
|
||||
// 显示提示框
|
||||
dlg.show();
|
||||
*/
|
||||
|
||||
// 由于Builder类是android.app.AlertDialog类的内部类,这里需要使用$符号分割
|
||||
var dlg = plus.android.newObject("android.app.AlertDialog$Builder",mainActivity);
|
||||
// 设置提示框标题
|
||||
plus.android.invoke(dlg,"setTitle","自定义标题");
|
||||
// 设置提示框内容
|
||||
plus.android.invoke(dlg,"setMessage","使用NJS的原生弹出框,可自定义弹出框的标题、按钮");
|
||||
// 设置提示框按钮
|
||||
plus.android.invoke(dlg,"setPositiveButton","确定(或者其他字符)",null);
|
||||
// 显示提示框
|
||||
plus.android.invoke(dlg,"show");
|
||||
}
|
||||
function showNjsView(){
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
njsAlertForAndroid();
|
||||
break;
|
||||
case "iOS":
|
||||
njsAlertForiOS();
|
||||
break;
|
||||
default:
|
||||
alert( "此平台不支持!" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back();"></div>
|
||||
<div class="nvtt">Native.JS-高级API</div>
|
||||
</header>
|
||||
<div id="content" class="content">
|
||||
<br/>
|
||||
<p class="des">虽然导入类对象(plus.android.importClass和plus.ios.importClass)后,可以方便的通过“.”操作符来访问对象的常量、调用对象的方法,但导入类对象也需要消耗较多的系统资源,所以在实际开发时应该尽可能的减少导入类对象,以提高程序效率。</p>
|
||||
<p class="des">NJS中“高级API”提供的方法可以在不导入类对象的情况下调用Native API:</p>
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="showNjsView();">NJS高级API调用系统提示框</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,257 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
/*
|
||||
NSNotificationCenter *nc = nil;
|
||||
|
||||
// 游戏玩家登录状态监听函数
|
||||
- (void)authenticationChanged:(NSNotification*)notification
|
||||
{
|
||||
// 获取游戏玩家共享实例对象
|
||||
GKLocalPlayer *player = notification.object;
|
||||
if ( player.isAuthenticated ) {
|
||||
// 玩家已登录认证,获取玩家信息
|
||||
[self playerInformation:player];
|
||||
} else {
|
||||
// 玩家未登录认证,提示用户登录
|
||||
NSLog(@"请登录!");
|
||||
}
|
||||
// 释放使用的对象
|
||||
[player release];
|
||||
}
|
||||
|
||||
// 获取游戏玩家状态信息
|
||||
- (void)playerInformation:(GKPlayer *)player
|
||||
{
|
||||
// 获取游戏玩家的名称
|
||||
NSLog(@"Name: %@",player.displayName);
|
||||
}
|
||||
|
||||
// 登录到游戏中心
|
||||
- (void)loginGamecenter
|
||||
{
|
||||
// 获取游戏玩家共享实例对象
|
||||
GKLocalPlayer *localplayer = [GKLocalPlayer localPlayer];
|
||||
// 判断游戏玩家是否已经登录认证
|
||||
if ( localplayer.isAuthenticated ) {
|
||||
// 玩家已登录认证,获取玩家信息
|
||||
[self playerInformation:localplayer];
|
||||
} else {
|
||||
// 监听用户登录状态变更事件
|
||||
if(!nc){
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
[nc addObserver:self
|
||||
selector:@selector(authenticationChanged)
|
||||
name:@"GKPlayerAuthenticationDidChangeNotificationName"
|
||||
object:nil];
|
||||
}
|
||||
// 玩家未登录认证,发起认证请求
|
||||
[localplayer authenticateWithCompletionHandler:nil];
|
||||
NSLog(@"登录中...");
|
||||
}
|
||||
// 释放使用的对象
|
||||
[localplayer release];
|
||||
}
|
||||
|
||||
// 停止监听登录游戏状态变化
|
||||
- (void)logoutGamecenter
|
||||
{
|
||||
// 取消监听用户登录状态变化
|
||||
if(nc){
|
||||
[nc removeObserver:self
|
||||
name:@"GKPlayerAuthenticationDidChangeNotificationName"
|
||||
object:nil];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// H5 plus事件处理
|
||||
var GKLocalPlayer=null,NSNotificationCenter=null;
|
||||
var nc=null,delegate=null;
|
||||
function plusReady(){
|
||||
plus.webview.currentWebview().setStyle({popGesture:"none"});
|
||||
if ( plus.os.name == "iOS" ) {
|
||||
GKLocalPlayer = plus.ios.importClass("GKLocalPlayer");
|
||||
NSNotificationCenter = plus.ios.importClass("NSNotificationCenter");
|
||||
longinGamecenter();
|
||||
} else {
|
||||
eStart.innerText = "欢迎您";
|
||||
bLogin = true;
|
||||
setTimeout( function(){
|
||||
plus.nativeUI.toast( "此平台不支持Game Center功能!" );
|
||||
}, 500 );
|
||||
}
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// DOMContentLoaded事件处理
|
||||
var eStart=null,bLogin=false;
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
eStart = document.getElementById( "start" );
|
||||
},false);
|
||||
|
||||
// 游戏玩家登录状态监听函数
|
||||
function authenticationChanged( notification ){
|
||||
// 获取游戏玩家共享实例对象
|
||||
var player = notification.plusGetAttribute("object");
|
||||
if ( player.plusGetAttribute("isAuthenticated") ) {
|
||||
// 玩家已登录认证,获取玩家信息
|
||||
playerInformation(player);
|
||||
bLogin = true;
|
||||
} else {
|
||||
// 玩家未登录认证,提示用户登录
|
||||
setTimeout(function(){
|
||||
eStart.innerText = "请登录";
|
||||
bLogin = false;
|
||||
},500);
|
||||
}
|
||||
// 释放使用的对象
|
||||
// plus.ios.deleteObject(player);
|
||||
}
|
||||
|
||||
// 获取游戏玩家状态信息
|
||||
function playerInformation( player ){
|
||||
var name = player.plusGetAttribute("displayName");
|
||||
eStart.innerText = name+" 已登录!";
|
||||
}
|
||||
|
||||
// 登录到游戏中心
|
||||
function longinGamecenter(){
|
||||
if ( bLogin ){
|
||||
return;
|
||||
}
|
||||
// 获取游戏玩家共享实例对象
|
||||
var localplayer = GKLocalPlayer.localPlayer();
|
||||
// 判断游戏玩家是否已经登录认证
|
||||
if ( localplayer.plusGetAttribute("isAuthenticated") ) {
|
||||
// 玩家已登录认证,获取玩家信息
|
||||
playerInformation( localplayer );
|
||||
bLogin = true;
|
||||
} else {
|
||||
eStart.innerText = "登录中...";
|
||||
// 监听用户登录状态变更事件
|
||||
if(!nc){
|
||||
nc = NSNotificationCenter.defaultCenter();
|
||||
delegate||(delegate=plus.ios.implements("NSObject",{"authenticationChanged:":authenticationChanged}));
|
||||
nc.addObserverselectornameobject(delegate,
|
||||
plus.ios.newObject("@selector","authenticationChanged:"),
|
||||
"GKPlayerAuthenticationDidChangeNotificationName",
|
||||
null);
|
||||
}
|
||||
// 玩家未登录认证,发起认证请求
|
||||
localplayer.authenticateWithCompletionHandler(null);
|
||||
}
|
||||
// 释放使用的对象
|
||||
plus.ios.deleteObject(localplayer);
|
||||
}
|
||||
|
||||
// 停止监听登录游戏状态变化
|
||||
function stopGamecenterObserver()
|
||||
{
|
||||
// 取消监听用户登录状态变化
|
||||
nc&&nc.removeObservernameobject(delegate,"GKPlayerAuthenticationDidChangeNotificationName",null);
|
||||
plus.ios.deleteObject(nc);nc = null;
|
||||
plus.ios.deleteObject(delegate);delegate = null;
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
* {
|
||||
-webkit-user-select: none;
|
||||
-ms-touch-select: none;
|
||||
}
|
||||
html {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
-webkit-touch-callout:none;
|
||||
-webkit-tap-highlight-color:rgba(0,0,0,0);
|
||||
}
|
||||
header {
|
||||
height: 44px;
|
||||
font-size: 22px;
|
||||
line-height: 44px;
|
||||
font-weight: bold;
|
||||
color: #000000;
|
||||
}
|
||||
.game {
|
||||
position:fixed;
|
||||
top:44px;
|
||||
width:100%;
|
||||
bottom: 60px;
|
||||
background: no-repeat center center url(../img/5.jpg);
|
||||
}
|
||||
.button {
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
background-color: #FFCC33;
|
||||
border: 1px solid #ECB100;
|
||||
padding: .5em 0em;
|
||||
margin: .5em .7em;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.button:active {
|
||||
outline: 0;
|
||||
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
||||
}
|
||||
.start {
|
||||
width: 50%;
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
text-align: center;
|
||||
color: #666;
|
||||
background-color: #EBEBEB;
|
||||
border: 1px solid #E0E0E0;
|
||||
padding: .5em 0em;
|
||||
margin: .5em auto;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css" media="screen and (min-aspect-ratio: 1/1)">
|
||||
.autobg {
|
||||
background-size: auto 100%;
|
||||
}
|
||||
</style>
|
||||
<style type="text/css" media="screen and (max-aspect-ratio: 1/1)">
|
||||
.autobg {
|
||||
background-size: 100% auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background:#CCCCCC;">
|
||||
<header id=header>五子棋</header>
|
||||
<div class="game autobg">
|
||||
</div>
|
||||
<div style="position:fixed;bottom:0;width:100%;height:60px;text-align:center;">
|
||||
<div class="button" onclick="try{stopGamecenterObserver();}catch(e){}back();">退出</div>
|
||||
</div>
|
||||
<div style="position:fixed;top:30%;width:100%;text-align:center;">
|
||||
<div id="start" class="start" onclick="longinGamecenter();">登录中...</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,131 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<!--<meta name="MobileOptimized" content="320"/>-->
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var auths={};
|
||||
function plusReady(){
|
||||
// 获取登录认证通道
|
||||
plus.oauth.getServices(function(services){
|
||||
var content=document.getElementById('dcontent');
|
||||
var info=document.getElementById("info");
|
||||
var txt="登录认证通道信息:";
|
||||
for(var i in services){
|
||||
var service=services[i];
|
||||
console.log(service.id+": "+service.authResult+", "+service.userInfo);
|
||||
auths[service.id]=service;
|
||||
txt += "id:"+service.id+", ";
|
||||
txt += "description:"+service.description+", ";
|
||||
var de=document.createElement('div');
|
||||
de.setAttribute('class','button');
|
||||
de.setAttribute('onclick','login(this.id)');
|
||||
de.id=service.id;
|
||||
de.innerText=service.description+"登录";
|
||||
oauth.appendChild(de);
|
||||
}
|
||||
info.innerText=txt;
|
||||
},function(e){
|
||||
outLine("获取登录认证失败:"+e.message);
|
||||
});
|
||||
}
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
// 登录认证
|
||||
function login(id){
|
||||
outSet("----- 登录认证 -----");
|
||||
var auth=auths[id];
|
||||
if(auth){
|
||||
var w=null;
|
||||
if(plus.os.name=="Android"){
|
||||
w=plus.nativeUI.showWaiting();
|
||||
}
|
||||
document.addEventListener("pause",function(){
|
||||
setTimeout(function(){
|
||||
w&&w.close();w=null;
|
||||
},2000);
|
||||
}, false );
|
||||
auth.login(function(){
|
||||
w&&w.close();w=null;
|
||||
outLine("登录认证成功:");
|
||||
outLine(JSON.stringify(auth.authResult));
|
||||
userinfo(auth);
|
||||
},function(e){
|
||||
w&&w.close();w=null;
|
||||
outLine("登录认证失败:");
|
||||
outLine("["+e.code+"]:"+e.message);
|
||||
plus.nativeUI.alert("详情错误信息请参考授权登录(OAuth)规范文档:http://www.html5plus.org/#specification#/specification/OAuth.html",null,"登录失败["+e.code+"]:"+e.message);
|
||||
});
|
||||
}else{
|
||||
outLine("无效的登录认证通道!");
|
||||
plus.nativeUI.alert("无效的登录认证通道!",null,"登录");
|
||||
}
|
||||
}
|
||||
// 获取用户信息
|
||||
function userinfo(a){
|
||||
outLine("----- 获取用户信息 -----");
|
||||
a.getUserInfo(function(){
|
||||
outLine("获取用户信息成功:");
|
||||
outLine(JSON.stringify(a.userInfo));
|
||||
var nickname=a.userInfo.nickname||a.userInfo.name||a.userInfo.miliaoNick;
|
||||
plus.nativeUI.alert("欢迎“"+nickname+"”登录!");
|
||||
},function(e){
|
||||
outLine("获取用户信息失败:");
|
||||
outLine("["+e.code+"]:"+e.message);
|
||||
plus.nativeUI.alert("获取用户信息失败!",null,"登录");
|
||||
});
|
||||
}
|
||||
// 注销登录
|
||||
function logoutAll(){
|
||||
outSet("----- 注销登录认证 -----");
|
||||
for(var i in auths){
|
||||
logout(auths[i]);
|
||||
}
|
||||
}
|
||||
function logout(auth){
|
||||
auth.logout(function(){
|
||||
outLine("注销\""+auth.description+"\"成功");
|
||||
},function(e){
|
||||
outLine("注销\""+auth.description+"\"失败:"+e.message);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#total{
|
||||
-webkit-user-select:text;
|
||||
text-align:right;
|
||||
padding:0 1em;
|
||||
border: 0px;
|
||||
border-bottom:1px solid #ECB100;
|
||||
border-radius: 0;
|
||||
font-size:16px;
|
||||
width:30%;
|
||||
outline:none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">OAuth</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('OAuth Document','/doc/oauth.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<p id="info" style="padding: 0 1em;text-align:left;">登录认证通道信息:</p>
|
||||
<div style="padding: 0.5em 1em;"><hr color="#EEE"/></div>
|
||||
<br/>
|
||||
<div id="oauth"></div>
|
||||
<br/>
|
||||
<div class="button button-waring" onclick="logoutAll()">注销登录</div>
|
||||
</div>
|
||||
<div id="output">
|
||||
OAuth模块管理客户端的用户授权登录验证功能,允许应用访问第三方平台的资源。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,70 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function getOrient() {
|
||||
outSet( "获取设备当前方向信息" );
|
||||
plus.orientation.getCurrentOrientation( function ( o ) {
|
||||
outLine( "alpha:" + o.alpha + "\nbeta:" + o.beta + "\ngamma:" + o.gamma );
|
||||
}, function ( e ) {
|
||||
outLine( "获取失败:" + e.message );
|
||||
} );
|
||||
}
|
||||
var id = null;
|
||||
function watchOrient() {
|
||||
if ( id ) {
|
||||
return;
|
||||
}
|
||||
outSet( "监听设备方向变化信息" );
|
||||
id = plus.orientation.watchOrientation( function ( o ) {
|
||||
outSet( "监听设备方向变化信息\n" + "alpha:" + o.alpha + "\nbeta:" + o.beta + "\ngamma:" + o.gamma );
|
||||
}, function ( e ) {
|
||||
plus.orientation.clearWatch( id );
|
||||
id = null;
|
||||
outLine( "监听失败:" + e.message );
|
||||
} );
|
||||
}
|
||||
function watchStop() {
|
||||
if ( id ) {
|
||||
outSet( "停止监听设备方向变化信息" );
|
||||
plus.orientation.clearWatch( id );
|
||||
id = null;
|
||||
} else {
|
||||
outSet( "没有监听设备方向变化" );
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Orientation</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Orientation Document','/doc/orientation.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<div class="button" onclick="clicked('orientation_level.html',true)">
|
||||
水平仪
|
||||
</div>
|
||||
<div class="button" onclick="clicked('orientation_compass.html',true)">
|
||||
指南针
|
||||
</div>
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="getOrient()">获取设备的方向信息</li>
|
||||
<li class="ditem" onclick="watchOrient()">监听设备的方向变化</li>
|
||||
<li class="ditem" onclick="watchStop()">停止监听</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Orientation可获取设备的方向信息,包括alpha(以垂直地心轴旋转的角度)、beta(以水平轴旋转的角度)、gamma(以垂直水平轴旋转的角度)三个方向信息。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,186 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript" >
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
// 锁定只能竖屏显示
|
||||
plus.screen.lockOrientation( "portrait-primary" );
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// 解锁并关闭
|
||||
var _back=window.back;
|
||||
function unlockback(){
|
||||
plus.screen.unlockOrientation();
|
||||
_back();
|
||||
}
|
||||
window.back=unlockback;
|
||||
|
||||
var t, x;
|
||||
var ld;
|
||||
var tran="0.1s", empty="0s";
|
||||
var bani=false, bsp=true;
|
||||
function update(d) {
|
||||
var c = ld - d;
|
||||
var ac = Math.abs(c);
|
||||
if (ac <= 1) {
|
||||
return;
|
||||
} else if (ac > 180) {
|
||||
if ( bani ) {
|
||||
t.style.webkitTransitionDuration = empty;
|
||||
}
|
||||
ld = (c > 0) ? ld - 360 : ld + 360;
|
||||
t.style.webkitTransform = "rotate(" + (bsp?(-ld):(ld)) + "deg)";
|
||||
setTimeout(adjust, 1);
|
||||
} else {
|
||||
t.style.webkitTransform = "rotate(" + (bsp?(-d):(d)) + "deg)";
|
||||
}
|
||||
ld = d;
|
||||
var r = Math.round(d);
|
||||
var txt = "";
|
||||
if (r >= 338 || r < 23) {
|
||||
txt = "北";
|
||||
} else if (r < 68) {
|
||||
txt = "东北";
|
||||
} else if (r < 113) {
|
||||
txt = "东";
|
||||
} else if (r < 158) {
|
||||
txt = "东南";
|
||||
} else if (r < 203) {
|
||||
txt = "南";
|
||||
} else if (r < 248) {
|
||||
txt = "西南";
|
||||
} else if (r < 293) {
|
||||
txt = "西";
|
||||
} else {
|
||||
txt = "西北";
|
||||
}
|
||||
x.innerHTML = txt + r + "°";
|
||||
}
|
||||
function adjust() {
|
||||
if ( bani ) {
|
||||
t.style.webkitTransitionDuration = tran;
|
||||
}
|
||||
t.style.webkitTransform = "rotate(" + (bsp?(-ld):(ld)) + "deg)";
|
||||
}
|
||||
function gohome() {
|
||||
plus.webview.currentWebview().close();
|
||||
}
|
||||
document.addEventListener("plusready", function() {
|
||||
t = document.getElementById("compass");
|
||||
x = document.getElementById("inf");
|
||||
|
||||
if ( plus.os.name == "iOS" ) {
|
||||
t.style.webkitTransition = "all 0.1s linear";
|
||||
bani = true;
|
||||
if ( plus.device.model.indexOf("iPhone") < 0 ) {
|
||||
bsp = false;
|
||||
document.getElementById("tip").innerText = "此设备方向数据不准确";
|
||||
}
|
||||
}
|
||||
plus.orientation.watchOrientation(function(r) {
|
||||
update(bsp?r.trueHeading:r.alpha);//update(r.alpha);
|
||||
}, function(e) {
|
||||
// error
|
||||
}, {
|
||||
frequency : 100
|
||||
});
|
||||
}, false);
|
||||
// Adjective select.
|
||||
document.onselectstart = function() {
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#front {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
}
|
||||
#container {
|
||||
width: 80%;
|
||||
position: relative;
|
||||
margin: auto;
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
line-height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
#bg {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
z-index: -1;
|
||||
}
|
||||
#compass {
|
||||
width: 100%;
|
||||
vertical-align: middle;
|
||||
/*
|
||||
-webkit-transition: all 0.1s linear;
|
||||
-moz-transform: rotate(45deg);
|
||||
-webkit-transform: rotate(45deg);
|
||||
-o-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
*/
|
||||
|
||||
}
|
||||
#inf {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
a.bh {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
position: fixed;
|
||||
bottom: 0px;
|
||||
background: rgb(128,128,128);
|
||||
text-align: center;
|
||||
line-height: 32px;
|
||||
}
|
||||
a.bh:active {
|
||||
background: rgb(64,64,64);
|
||||
}
|
||||
#hi {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header" style="position:static">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">指南针</div>
|
||||
</header>
|
||||
<div id="front">
|
||||
<img style="height:100%;" src="../img/orientationa.png"/>
|
||||
</div>
|
||||
<div id="inf">
|
||||
北0°
|
||||
</div>
|
||||
<div id="container">
|
||||
<img id="bg" src="../img/orientationbg.png"/>
|
||||
<img id="compass" src="../img/orientationc.png"/>
|
||||
</div>
|
||||
<div id="tip" style="width:100%;position:absolute;bottom:0;text-align:center;color:red"></div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,166 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript" >
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
// 锁定只能竖屏显示
|
||||
plus.screen.lockOrientation( "portrait-primary" );
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// 解锁并关闭
|
||||
var _back=window.back;
|
||||
function unlockback(){
|
||||
plus.screen.unlockOrientation();
|
||||
_back();
|
||||
}
|
||||
window.back=unlockback;
|
||||
|
||||
var t, xh, xv;
|
||||
var R = 100;
|
||||
function update(h, v) {
|
||||
var ch = 0, cv = 0;
|
||||
if (h > 90) {
|
||||
h = 180 - h;
|
||||
} else if (h < -90) {
|
||||
h = -180 - h;
|
||||
}
|
||||
if (v > 90) {
|
||||
v = 180 - v;
|
||||
} else if (v < -90) {
|
||||
v = -180 - v;
|
||||
}
|
||||
var r = Math.max(Math.abs(h), Math.abs(v)) / 90;
|
||||
var range = Math.round(R * r);
|
||||
if (h == 0) {
|
||||
cv = range * v / 90;
|
||||
} else if (v == 0) {
|
||||
ch = range * h / 90;
|
||||
} else {
|
||||
var a = Math.atan2(v, h);
|
||||
ch = range * Math.cos(a);
|
||||
cv = range * Math.sin(a);
|
||||
}
|
||||
ch = Math.round(ch);
|
||||
cv = Math.round(cv);
|
||||
|
||||
t.style.webkitTransform = "translate(" + ch + "px," + cv + "px)";
|
||||
|
||||
h = h.toFixed(1);
|
||||
v = v.toFixed(1);
|
||||
xh.innerHTML = "" + (-h);
|
||||
xv.innerHTML = "" + (-v);
|
||||
}
|
||||
document.addEventListener("plusready", function() {
|
||||
t = document.getElementById("bubble");
|
||||
R = Math.floor(t.offsetWidth * 130 / 320);
|
||||
xh = document.getElementById("h");
|
||||
xv = document.getElementById("v");
|
||||
|
||||
plus.orientation.watchOrientation(function(r) {
|
||||
update(-r.gamma, -r.beta);
|
||||
}, function(e) {
|
||||
// error
|
||||
}, {
|
||||
frequency : 100
|
||||
});
|
||||
}, false);
|
||||
// Adjective select.
|
||||
document.onselectstart = function() {
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#front {
|
||||
width: 60%;
|
||||
height: 80px;
|
||||
margin: auto;
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.inf {
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
line-height: 40px;
|
||||
font-size: 28px;
|
||||
text-align: center;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
float: left;
|
||||
}
|
||||
#container {
|
||||
width: 80%;
|
||||
position: relative;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
line-height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.bg {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
z-index: -1;
|
||||
}
|
||||
#bubble {
|
||||
width: 100%;
|
||||
vertical-align: middle;
|
||||
-webkit-transition: all 0.1s linear;
|
||||
}
|
||||
a.bh {
|
||||
width: 100%;
|
||||
height: 10%;
|
||||
position: fixed;
|
||||
bottom: 0px;
|
||||
background: rgb(128,128,128);
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
a.bh:active {
|
||||
background: rgb(64,64,64);
|
||||
}
|
||||
#hi {
|
||||
height: 80%;
|
||||
margin: auto;
|
||||
margin-top: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header" style="position:static">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">水平仪</div>
|
||||
</header>
|
||||
<div id="front">
|
||||
<div class="inf" style="font-weight:bold;">
|
||||
横向
|
||||
</div>
|
||||
<div class="inf" style="font-weight:bold;">
|
||||
纵向
|
||||
</div>
|
||||
<div id="h" class="inf">
|
||||
0
|
||||
</div>
|
||||
<span id="v" class="inf">0</span>
|
||||
</div>
|
||||
<div id="container">
|
||||
<img class="bg" src="../img/orientationbg.png"/>
|
||||
<img class="bg" src="../img/orientationl.png"/>
|
||||
<img id="bubble" src="../img/orientationb.png"/>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,162 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<!--<meta name="MobileOptimized" content="320"/>-->
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var pays={};
|
||||
function plusReady(){
|
||||
// 获取支付通道
|
||||
plus.payment.getChannels(function(channels){
|
||||
var content=document.getElementById('dcontent');
|
||||
var info=document.getElementById('info');
|
||||
var txt='支付通道信息:';
|
||||
for(var i in channels){
|
||||
var channel=channels[i];
|
||||
if(channel.id=='qhpay'||channel.id=='qihoo'){ // 过滤掉不支持的支付通道:暂不支持360相关支付
|
||||
continue;
|
||||
}
|
||||
pays[channel.id]=channel;
|
||||
txt += 'id:'+channel.id+', ';
|
||||
txt += 'description:'+channel.description+', ';
|
||||
txt += 'serviceReady:'+channel.serviceReady+'; ';
|
||||
var de=document.createElement('div');
|
||||
de.setAttribute('class', 'button');
|
||||
de.setAttribute('onclick', 'pay(this.id)');
|
||||
de.id=channel.id;
|
||||
de.innerText=channel.description+'支付';
|
||||
content.appendChild(de);
|
||||
checkServices(channel);
|
||||
}
|
||||
info.innerText=txt;
|
||||
},function(e){
|
||||
outLine('获取支付通道失败:'+e.message);
|
||||
});
|
||||
}
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
// 检测是否安装支付服务
|
||||
function checkServices(pc){
|
||||
if(!pc.serviceReady){
|
||||
var txt=null;
|
||||
switch(pc.id){
|
||||
case 'alipay':
|
||||
txt='检测到系统未安装“支付宝快捷支付服务”,无法完成支付操作,是否立即安装?';
|
||||
break;
|
||||
default:
|
||||
txt='系统未安装“'+pc.description+'”服务,无法完成支付,是否立即安装?';
|
||||
break;
|
||||
}
|
||||
plus.nativeUI.confirm(txt, function(e){
|
||||
if(e.index==0){
|
||||
pc.installService();
|
||||
}
|
||||
}, pc.description);
|
||||
}
|
||||
}
|
||||
|
||||
var w=null;
|
||||
var PAYSERVER='http://demo.dcloud.net.cn/payment/?payid=';
|
||||
// 支付
|
||||
function pay(id){
|
||||
if(w){return;}//检查是否请求订单中
|
||||
if(id==='appleiap'){
|
||||
outSet('应用内支付');
|
||||
clicked('payment_iap.html');
|
||||
return;
|
||||
}
|
||||
outSet('----- 请求支付 -----');
|
||||
var url=PAYSERVER;
|
||||
if(id=='alipay'||id=='wxpay'){
|
||||
url+=id;
|
||||
}else{
|
||||
plus.nativeUI.alert('当前环境不支持此支付通道!', null, '捐赠');
|
||||
return;
|
||||
}
|
||||
var appid=plus.runtime.appid;
|
||||
if(navigator.userAgent.indexOf('StreamApp')>=0){
|
||||
appid='Stream';
|
||||
}
|
||||
url+='&appid='+appid+'&total=';
|
||||
|
||||
w=plus.nativeUI.showWaiting();
|
||||
// 请求支付订单
|
||||
var amount = document.getElementById('total').value;
|
||||
var xhr=new XMLHttpRequest();
|
||||
xhr.onreadystatechange=function(){
|
||||
switch(xhr.readyState){
|
||||
case 4:
|
||||
w.close();w=null;
|
||||
if(xhr.status==200){
|
||||
outLine('----- 请求订单成功 -----');
|
||||
outLine(xhr.responseText);
|
||||
var order=xhr.responseText;
|
||||
plus.payment.request(pays[id],order,function(result){
|
||||
outLine('----- 支付成功 -----');
|
||||
outLine(JSON.stringify(result));
|
||||
plus.nativeUI.alert('支付成功:感谢你的支持,我们会继续努力完善产品。',function(){
|
||||
back();
|
||||
},'捐赠');
|
||||
},function(e){
|
||||
outLine('----- 支付失败 -----');
|
||||
outLine('['+e.code+']:'+e.message);
|
||||
plus.nativeUI.alert('更多错误信息请参考支付(Payment)规范文档:http://www.html5plus.org/#specification#/specification/Payment.html', null, '支付失败:'+e.code);
|
||||
});
|
||||
}else{
|
||||
outLine('----- 请求订单失败 -----');
|
||||
outLine( xhr.status );
|
||||
plus.nativeUI.alert('获取订单信息失败!', null, '捐赠');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
xhr.open('GET',url+amount);
|
||||
outLine('请求支付订单:'+url+amount);
|
||||
xhr.send();
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#total{
|
||||
-webkit-user-select:text;
|
||||
text-align:right;
|
||||
padding:0 1em;
|
||||
border: 0px;
|
||||
border-bottom:1px solid #ECB100;
|
||||
border-radius: 0;
|
||||
font-size:16px;
|
||||
width:30%;
|
||||
outline:none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Payment</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Payment Document','/doc/payment.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<p id="info" style="padding: 0 1em;text-align:left;">支付通道信息:
|
||||
</p>
|
||||
<div style="padding: 0.5em 1em;"><hr color="#EEE"/></div>
|
||||
<p style="padding: 0 1em;text-align:left;">为DCloud提供的免费软件进行赞助吧。</p>
|
||||
<br/>
|
||||
<div style="padding: 0 1em;text-align:left">
|
||||
捐赠金额:<input id="total" type="number" value="1"/> 元
|
||||
</div>
|
||||
<br/>
|
||||
<!--<div class="button" onclick="clicked('payment_iap.html')">Apple IAP</div>-->
|
||||
</div>
|
||||
<div id="output">
|
||||
Payment模块管理支付功能,可通过js调用第三方支付服务。通过plus.payment可获取支付管理对象。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,100 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>In-App Purchase</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var iap=null;
|
||||
var ids=['donation','donation6'];//应用内购项目
|
||||
function plusReady(){
|
||||
// 获取支付通道
|
||||
plus.payment.getChannels(function(channels){
|
||||
for(var i in channels){
|
||||
var channel=channels[i];
|
||||
if(channel.id==='appleiap'){
|
||||
iap=channel;
|
||||
}
|
||||
}
|
||||
requestOrder();
|
||||
},function(e){
|
||||
console.log("获取支付通道失败:"+e.message);
|
||||
});
|
||||
}
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
// 获取订单
|
||||
function requestOrder(){
|
||||
plus.nativeUI.showWaiting('检测支付环境...');
|
||||
iap.requestOrder(ids,function(e){
|
||||
plus.nativeUI.closeWaiting();
|
||||
console.log('requestOrder success: '+JSON.stringify(e));
|
||||
},function(e){
|
||||
console.log('requestOrder failed: '+JSON.stringify(e));
|
||||
plus.nativeUI.closeWaiting();
|
||||
plus.nativeUI.confirm("错误信息:"+JSON.stringify(e),function(e){
|
||||
if(e.index==0){
|
||||
requestOrder();
|
||||
}else{
|
||||
back();
|
||||
}
|
||||
},'重新请求支付',['确定','取消']);
|
||||
});
|
||||
}
|
||||
// 支付
|
||||
function pay(id){
|
||||
plus.nativeUI.showWaiting('',{style:"black",background:"rgba(0,0,0,0)"});
|
||||
plus.payment.request(iap, {productid:id}, function(result){
|
||||
plus.nativeUI.closeWaiting();
|
||||
alert('成功:'+JSON.stringify(result));
|
||||
plus.nativeUI.alert("支付成功:感谢你的支持,我们会继续努力完善产品。",function(){
|
||||
back();
|
||||
},"捐赠");
|
||||
},function(e){
|
||||
plus.nativeUI.closeWaiting();
|
||||
plus.nativeUI.alert("错误信息:"+e.message,null,"支付失败:"+e.code);
|
||||
});
|
||||
}
|
||||
// 获取已购买商品(非消耗性商品和订阅商品)
|
||||
function restoreComplateRequest(){
|
||||
plus.nativeUI.showWaiting('',{style:"black",background:"rgba(0,0,0,0)"});
|
||||
iap.restoreComplateRequest({},function(results){
|
||||
plus.nativeUI.closeWaiting();
|
||||
alert(results.length);
|
||||
for(var i in results){
|
||||
alert('restoreComplateRequest['+i+']: '+JSON.stringify(results[i]));
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">In-App Purchase</div>
|
||||
</header>
|
||||
<div id="content" class="content">
|
||||
<br/><br/>
|
||||
<p class="des" style="font-size:16px;line-height:30px;margin: 0px .5em;">
|
||||
DCloud 是W3C会员、中国HTML5产业联盟发起单位,致力于推进HTML5发展,构建HTML5生态。
|
||||
</p>
|
||||
<br/>
|
||||
<strong>
|
||||
支持HTML5开发工具HBuilder
|
||||
</strong>
|
||||
<div class="button" onclick="pay(ids[0])">
|
||||
捐赠1元
|
||||
</div>
|
||||
<div class="button" onclick="pay(ids[1])">
|
||||
捐赠6元
|
||||
</div>
|
||||
<div class="button" onclick="restoreComplateRequest()">
|
||||
restoreComplateRequest
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var ws=null;
|
||||
document.addEventListener( "plusready", function(){
|
||||
//watchProximity();
|
||||
ws=plus.webview.currentWebview();
|
||||
// 页面隐藏时自动停止监听
|
||||
ws.addEventListener('hide',function(){
|
||||
watchStop();
|
||||
},false);
|
||||
}, false );
|
||||
function getProximity() {
|
||||
outSet( "获取设备当前距离传感器信息" );
|
||||
plus.proximity.getCurrentProximity( function ( d ) {
|
||||
outLine( "距离为:" + d );
|
||||
}, function ( e ) {
|
||||
outLine( "获取失败:" + e.message );
|
||||
} );
|
||||
}
|
||||
var id=null,bright=null;
|
||||
function watchProximity() {
|
||||
if ( id ) {
|
||||
return;
|
||||
}
|
||||
outSet( "监听设备距离传感器信息" );
|
||||
bright = plus.screen.getBrightness();
|
||||
id = plus.proximity.watchProximity( function ( d ) {
|
||||
outLine( "距离变化:"+d );
|
||||
plus.screen.setBrightness( (d<1)?0.01:bright );
|
||||
}, function ( e ) {
|
||||
plus.proximity.clearWatch( id );
|
||||
id = null;
|
||||
outLine( "监听失败:" + e.message );
|
||||
} );
|
||||
}
|
||||
function watchStop() {
|
||||
if ( id ) {
|
||||
outSet( "停止监听设备距离传感器信息" );
|
||||
plus.proximity.clearWatch( id );
|
||||
id = null;
|
||||
} else {
|
||||
outSet( "没有监听设备距离传感器" );
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="watchStop(),back()"></div>
|
||||
<div class="nvtt">Proximity</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Proximity Document','/doc/proximity.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<p class="des">距离传感器一般都在手机听筒的两侧或者是在手机听筒凹槽中,当有物体接近时(如将手机靠近耳朵接听或拨打电话),距离感应器可以检测并通知屏幕背景灯熄灭,拿开时再度点亮背景灯,这样可方便用户操作并节省电量。</p>
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="getProximity()">获取距离传感器信息</li>
|
||||
<li class="ditem" onclick="watchProximity()">监听距离传感器变化</li>
|
||||
<li class="ditem" onclick="watchStop()">停止监听</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Proximity模块管理设备距离传感器,可获取当前设备的接近距离信息,通过plus.proximity可获取设备距离传感管理对象。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,234 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var pushServer = "http://demo.dcloud.net.cn/push/?";
|
||||
var message = null;
|
||||
// 监听plusready事件
|
||||
document.addEventListener( "plusready", function(){
|
||||
message = document.getElementById("message");
|
||||
// 监听点击消息事件
|
||||
plus.push.addEventListener( "click", function( msg ) {
|
||||
// 判断是从本地创建还是离线推送的消息
|
||||
switch( msg.payload ) {
|
||||
case "LocalMSG":
|
||||
outSet( "点击本地创建消息启动:" );
|
||||
break;
|
||||
default:
|
||||
outSet( "点击离线推送消息启动:");
|
||||
break;
|
||||
}
|
||||
// 提示点击的内容
|
||||
plus.nativeUI.alert( msg.content );
|
||||
// 处理其它数据
|
||||
logoutPushMsg( msg );
|
||||
}, false );
|
||||
// 监听在线消息事件
|
||||
plus.push.addEventListener( "receive", function( msg ) {
|
||||
if ( msg.aps ) { // Apple APNS message
|
||||
outSet( "接收到在线APNS消息:" );
|
||||
} else {
|
||||
outSet( "接收到在线透传消息:" );
|
||||
}
|
||||
logoutPushMsg( msg );
|
||||
}, false );
|
||||
}, false );
|
||||
|
||||
/**
|
||||
* 日志输入推送消息内容
|
||||
*/
|
||||
function logoutPushMsg( msg ) {
|
||||
outLine( "title: "+msg.title );
|
||||
outLine( "content: "+msg.content );
|
||||
if ( msg.payload ) {
|
||||
if ( typeof(msg.payload)=="string" ) {
|
||||
outLine( "payload(String): "+msg.payload );
|
||||
} else {
|
||||
outLine( "payload(JSON): "+JSON.stringify(msg.payload) );
|
||||
}
|
||||
} else {
|
||||
outLine( "payload: undefined" );
|
||||
}
|
||||
if ( msg.aps ) {
|
||||
outLine( "aps: "+JSON.stringify(msg.aps) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本地推送标识信息
|
||||
*/
|
||||
function getPushInfo(){
|
||||
var info = plus.push.getClientInfo();
|
||||
outSet( "获取客户端推送标识信息:" );
|
||||
outLine("id: "+info.id);
|
||||
outLine( "token: "+info.token );
|
||||
outLine( "clientid: "+info.clientid );
|
||||
outLine( "appid: "+info.appid );
|
||||
outLine( "appkey: "+info.appkey );
|
||||
}
|
||||
/**
|
||||
* 本地创建一条推动消息
|
||||
*/
|
||||
function createLocalPushMsg(){
|
||||
var options = {cover:false};
|
||||
var str = dateToStr(new Date());
|
||||
str += ": 欢迎使用HTML5+创建本地消息!";
|
||||
plus.push.createMessage( str, "LocalMSG", options );
|
||||
outSet( "创建本地消息成功!" );
|
||||
outLine( "请到系统消息中心查看!" );
|
||||
if(plus.os.name=="iOS"){
|
||||
outLine('*如果无法创建消息,请到"设置"->"通知"中配置应用在通知中心显示!');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 读取所有推送消息
|
||||
*/
|
||||
function listAllPush(){
|
||||
var msgs=null;
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
msgs = plus.push.getAllMessage();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( !msgs ) {
|
||||
outSet( "此平台不支持枚举推送消息列表!" );
|
||||
return;
|
||||
}
|
||||
outSet( "枚举消息列表("+msgs.length+"):" );
|
||||
for ( var i in msgs ) {
|
||||
var msg = msgs[i];
|
||||
outLine( i+": "+msg.title+" - "+msg.content );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 清空所有推动消息
|
||||
*/
|
||||
function clearAllPush(){
|
||||
plus.push.clear();
|
||||
outSet( "清空所有推送消息成功!" );
|
||||
}
|
||||
/**
|
||||
* 请求‘简单通知’推送消息
|
||||
*/
|
||||
function requireNotiMsg(){
|
||||
if(navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持发送推送消息');
|
||||
return;
|
||||
}
|
||||
var inf = plus.push.getClientInfo();
|
||||
var url = pushServer+'type=noti&appid='+encodeURIComponent(plus.runtime.appid);
|
||||
inf.id&&(url+='&id='+inf.id);
|
||||
url += ('&cid='+encodeURIComponent(inf.clientid));
|
||||
if(plus.os.name == 'iOS'){
|
||||
url += ('&token='+encodeURIComponent(inf.token));
|
||||
}
|
||||
url += ('&title='+encodeURIComponent('Hello H5+'));
|
||||
url += ('&content='+encodeURIComponent('欢迎回来体验HTML5 plus应用!'));
|
||||
url += ('&version='+encodeURIComponent(plus.runtime.version));
|
||||
plus.runtime.openURL( url );
|
||||
}
|
||||
/**
|
||||
* 请求‘打开网页’推送消息
|
||||
*/
|
||||
function requireLinkMsg(){
|
||||
if(navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持发送推送消息');
|
||||
return;
|
||||
}
|
||||
var inf = plus.push.getClientInfo();
|
||||
var url = pushServer+"type=link&appid="+encodeURIComponent(plus.runtime.appid);
|
||||
inf.id&&(url+='&id='+inf.id);
|
||||
url += ('&cid='+encodeURIComponent(inf.clientid));
|
||||
if(plus.os.name == 'iOS'){
|
||||
url += ('&token='+encodeURIComponent(inf.token));
|
||||
}
|
||||
url += ('&title='+encodeURIComponent('HBuilder飞一样的编码'));
|
||||
url += ('&content='+encodeURIComponent('看HBuilder如何追求代码编写速度的极致!立即去瞧一瞧?'));
|
||||
url += ('&url='+encodeURIComponent('http://www.dcloud.io/'));
|
||||
url += ('&version='+encodeURIComponent(plus.runtime.version));
|
||||
plus.runtime.openURL( url );
|
||||
}
|
||||
/**
|
||||
* 请求‘下载链接’推送消息
|
||||
*/
|
||||
function requireDownMsg(){
|
||||
if(navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持发送推送消息');
|
||||
return;
|
||||
}
|
||||
if ( plus.os.name != "Android" ) {
|
||||
plus.nativeUI.alert( "此平台不支持!" );
|
||||
return;
|
||||
}
|
||||
var inf = plus.push.getClientInfo();
|
||||
var url = pushServer+'type=down&appid='+encodeURIComponent(plus.runtime.appid);
|
||||
inf.id&&(url+='&id='+inf.id);
|
||||
url += ('&cid='+encodeURIComponent(inf.clientid));
|
||||
url += ('&title='+encodeURIComponent('Hello H5+'));
|
||||
url += ('&content='+encodeURIComponent('新版本发布了!立即下载体验?'));
|
||||
url += ('&ptitle='+encodeURIComponent('Hello H5+'));
|
||||
url += ('&pcontent='+encodeURIComponent('1. 优化用户体验;\n2. 修复在Android2.3.x某些设备可能异常退出的问题.'));
|
||||
url += ('&dtitle='+encodeURIComponent('下载Hello H5+'));
|
||||
url += ('&durl='+encodeURIComponent('http://www.dcloud.io/helloh5/HelloH5.apk'));
|
||||
url += ('&version='+encodeURIComponent(plus.runtime.version));
|
||||
plus.runtime.openURL( url );
|
||||
}
|
||||
/**
|
||||
* 请求‘透传数据’推送消息
|
||||
*/
|
||||
function requireTranMsg(){
|
||||
if(navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持发送推送消息');
|
||||
return;
|
||||
}
|
||||
var inf = plus.push.getClientInfo();
|
||||
var url = pushServer+'type=tran&appid='+encodeURIComponent(plus.runtime.appid);
|
||||
inf.id&&(url+='&id='+inf.id);
|
||||
url += ('&cid='+encodeURIComponent(inf.clientid));
|
||||
if(plus.os.name == 'iOS'){
|
||||
url += ('&token='+encodeURIComponent(inf.token));
|
||||
}
|
||||
url += ('&title='+encodeURIComponent('Hello H5+'));
|
||||
url += ('&content='+encodeURIComponent('带透传数据推送通知,可通过plus.push API获取数据并进行业务逻辑处理!'));
|
||||
url += ('&payload='+encodeURIComponent('{"title":"Hello H5+ Test","content":"test content","payload":"1234567890"}'));
|
||||
url += ('&version='+encodeURIComponent(plus.runtime.version));
|
||||
plus.runtime.openURL( url );
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Push</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Push Document','/doc/push.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<div class="button" onclick="requireNotiMsg()">发送"普通通知"消息</div>
|
||||
<div class="button" onclick="requireLinkMsg()">发送"打开网页"消息</div>
|
||||
<div class="button" onclick="requireDownMsg()">发送"下载链接"消息</div>
|
||||
<div class="button" onclick="requireTranMsg()">发送"透传数据"消息</div>
|
||||
<br/>
|
||||
<ul id="dlist" class="dlist">
|
||||
<li class="ditem" onclick="getPushInfo()">获取客户端推送标识</li>
|
||||
<li class="ditem" onclick="createLocalPushMsg()">创建本地消息</li>
|
||||
<li class="ditem" onclick="listAllPush()">枚举推送消息</li>
|
||||
<li class="ditem" onclick="clearAllPush()">清空推送消息</li>
|
||||
<!--<li class="ditem" onclick="plus.push.setAutoNotification(false)">关闭自动显示消息</li>
|
||||
<li class="ditem" onclick="plus.push.setAutoNotification(true)">开启自动显示消息</li>-->
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Push模块管理推送消息功能,可以实现在线、离线的消息推送,通过plus.push可获取推送消息管理对象。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,124 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function getVersion(){
|
||||
outSet("程序版本号:"+plus.runtime.version+"\n内核版本号:"+plus.runtime.innerVersion);
|
||||
}
|
||||
function getArguments(){
|
||||
outSet("启动方式: "+plus.runtime.launcher+"\n启动参数: "+plus.runtime.arguments);
|
||||
}
|
||||
function restartApp() {
|
||||
plus.runtime.restart();
|
||||
}
|
||||
function getWidgetInfo() {
|
||||
plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
|
||||
//appid属性
|
||||
var wgtStr = "appid:"+wgtinfo.appid;
|
||||
//version属性
|
||||
wgtStr += "\nversion:"+wgtinfo.version;
|
||||
//name属性
|
||||
wgtStr += "\nname:"+wgtinfo.name;
|
||||
//description属性
|
||||
wgtStr += "\ndescription:"+wgtinfo.description;
|
||||
//author属性
|
||||
wgtStr += "\nauthor:"+wgtinfo.author;
|
||||
//email属性
|
||||
wgtStr += "\nemail:"+wgtinfo.email;
|
||||
//licence属性
|
||||
wgtStr += "\nlicense:"+wgtinfo.license;
|
||||
//licensehref属性
|
||||
wgtStr += "\nlicensehref:"+wgtinfo.licensehref;
|
||||
//features 属性
|
||||
wgtStr += "\nfeatures:"+wgtinfo.features;
|
||||
outSet( wgtStr );
|
||||
} );
|
||||
}
|
||||
function setBadge() {
|
||||
plus.runtime.setBadgeNumber( 50 );
|
||||
outSet( "设置程序图标右上角显示的提示数字为50\n请返回桌面查看" );
|
||||
if(plus.os.name=="iOS"){
|
||||
outLine( '*如果无法设置提示数字,请到"设置"->"通知"中配置应用在通知中心显示!' );
|
||||
}else{
|
||||
outLine( "注:仅支持小米(MIUI v5),其它设备暂不支持此功能!" );
|
||||
}
|
||||
}
|
||||
function clearBadge() {
|
||||
plus.runtime.setBadgeNumber( 0 );
|
||||
outSet( "清除程序图标右上角显示的提示数字\n请返回桌面查看" );
|
||||
if(plus.os.name=="iOS"){
|
||||
outLine( '如果无法清除提示数字,请到"设置"->"通知"中配置应用在通知中心显示!' );
|
||||
}else{
|
||||
outLine( "注:仅支持小米(MIUI v5),其它设备暂不支持此功能!" );
|
||||
}
|
||||
}
|
||||
function exitApp(){
|
||||
if(plus.os.name=="Android"){
|
||||
plus.runtime.quit();
|
||||
}else{
|
||||
outSet( "此平台不支持直接退出程序,请按Home键切换应用" );
|
||||
}
|
||||
}
|
||||
function updateApp(){
|
||||
var url='http://demo.dcloud.net.cn/helloh5/update/HelloH5.wgtu';
|
||||
plus.nativeUI.showWaiting("升级中...");
|
||||
var dtask = plus.downloader.createDownload( url, {method:"GET"}, function(d,status){
|
||||
if ( status == 200 ) {
|
||||
console.log( "Download wgtu success: " + d.filename );
|
||||
plus.runtime.install(d.filename,{},function(){
|
||||
plus.nativeUI.closeWaiting();
|
||||
plus.nativeUI.alert("Update wgtu success, restart now!",function(){
|
||||
plus.runtime.restart();
|
||||
});
|
||||
},function(e){
|
||||
plus.nativeUI.closeWaiting();
|
||||
alert("Update wgtu failed: "+e.message);
|
||||
});
|
||||
} else {
|
||||
plus.nativeUI.closeWaiting();
|
||||
alert( "Download wgtu failed: " + status );
|
||||
}
|
||||
} );
|
||||
dtask.addEventListener('statechanged',function(d,status){
|
||||
console.log("statechanged: "+d.state);
|
||||
});
|
||||
dtask.start();
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Runtime</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Runtime Document','/doc/runtime.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="clicked('runtime_launch.html',true);">
|
||||
调用第三方程序
|
||||
</div>
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="getVersion()">获取版本信息</li>
|
||||
<li class="ditem" onclick="getArguments()">获取启动信息</li>
|
||||
<li class="ditem" onclick="restartApp()">重启当前应用</li>
|
||||
<li class="ditem" onclick="getWidgetInfo()">获取当前应用的基本属性</li>
|
||||
<li class="ditem" onclick="setBadge()">设置程序图标右上角数字</li>
|
||||
<li class="ditem" onclick="clearBadge()">清除程序图标右上角数字</li>
|
||||
<li class="ditem" onclick="exitApp()">退出当前应用</li>
|
||||
<!--li class="ditem" onclick="updateApp()">WGTU Update</li-->
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Runtime管理程序运行时环境,可用于获取程序的各种信息、与第三方程序通讯等。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,175 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function androidMarket( pname ) {
|
||||
plus.runtime.openURL( "market://details?id="+pname );
|
||||
}
|
||||
function iosAppstore( url ) {
|
||||
plus.runtime.openURL( "itms-apps://"+url );
|
||||
}
|
||||
function openBrowser() {
|
||||
var url = "http://www.dcloud.io/";
|
||||
plus.runtime.openURL( url );
|
||||
}
|
||||
function openMap() {
|
||||
var url = "";
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
url = "geo:39.96310,116.340698?q=%e6%95%b0%e5%ad%97%e5%a4%a9%e5%a0%82";
|
||||
break;
|
||||
case "iOS":
|
||||
url = "http://maps.apple.com/?q=%e6%95%b0%e5%ad%97%e5%a4%a9%e5%a0%82&ll=39.96310,116.340698&spn=0.008766,0.019441";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
plus.runtime.openURL( url, function( e ) {
|
||||
plus.nativeUI.alert( "检查到您未安装地图程序\n" );
|
||||
} );
|
||||
}
|
||||
function openBMap() {
|
||||
var url=null,id=null,f=null;
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
// 规范参考官方网站:http://developer.baidu.com/map/index.php?title=uri/api/android
|
||||
url = "baidumap://map/marker?location=39.968789,116.347247&title=DCloud&content=%e6%89%93%e9%80%a0HTML5%e6%9c%80%e5%a5%bd%e7%9a%84%e7%a7%bb%e5%8a%a8%e5%bc%80%e5%8f%91%e5%b7%a5%e5%85%b7&src=HelloH5";
|
||||
f = androidMarket;
|
||||
id = "com.baidu.BaiduMap";
|
||||
break;
|
||||
case "iOS":
|
||||
// 规范参考官方网站:http://developer.baidu.com/map/index.php?title=uri/api/ios
|
||||
url = "baidumap://map/marker?location=39.968789,116.347247&title=DCloud&content=%e6%89%93%e9%80%a0HTML5%e6%9c%80%e5%a5%bd%e7%9a%84%e7%a7%bb%e5%8a%a8%e5%bc%80%e5%8f%91%e5%b7%a5%e5%85%b7&src=HelloH5";
|
||||
f = iosAppstore;
|
||||
id = "itunes.apple.com/cn/app/bai-du-de-tu-yu-yin-dao-hang/id452186370?mt=8";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
plus.runtime.openURL( url, function(e) {
|
||||
plus.nativeUI.confirm( "检查到您未安装\"百度地图\",是否到商城搜索下载?", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
f(id);
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
function openAMap() {
|
||||
var url=null,id=null,f=null;
|
||||
switch ( plus.os.name ) {
|
||||
case "Android":
|
||||
// 规范参考官方网站:http://lbs.amap.com/api/uri-api/android-uri-explain/
|
||||
url = "androidamap://viewMap?sourceApplication=HelloH5&poiname=DCloud&lat=39.9631018208&lon=116.3406135236&dev=0";
|
||||
f = androidMarket;
|
||||
id = "com.autonavi.minimap";
|
||||
break;
|
||||
case "iOS":
|
||||
// 规范参考官方网站:http://lbs.amap.com/api/uri-api/ios-uri-explain/
|
||||
url = "iosamap://viewMap?sourceApplication=HelloH5&poiname=DCloud&lat=39.9631018208&lon=116.3406135236&dev=0";
|
||||
f = iosAppstore;
|
||||
id = "itunes.apple.com/cn/app/gao-tu-zhuan-ye-dao-hang-ban/id461703208?mt=8";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
plus.runtime.openURL( url, function( e ) {
|
||||
plus.nativeUI.confirm( "检查到您未安装\"高德地图\",是否到商城搜索下载?", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
f(id);
|
||||
}
|
||||
} );
|
||||
}, id );
|
||||
}
|
||||
function openMarket() {
|
||||
var url="";
|
||||
switch ( plus.os.name ) {
|
||||
case "Android": {
|
||||
//url = "market://details?id=com.dheaven.helloh5";
|
||||
url = "market://details?id=io.dcloud.HelloH5";
|
||||
//url = "market://search?q=HelloH5";
|
||||
//url = "market://search?q=pub:HelloH5";
|
||||
}
|
||||
break;
|
||||
case "iOS": {
|
||||
url = "itms-apps://itunes.apple.com/cn/app/hello-h5+/id682211190?l=zh&mt=8";
|
||||
}
|
||||
break;
|
||||
}
|
||||
plus.runtime.openURL( url );
|
||||
}
|
||||
function openWeixin() {
|
||||
if ( plus.os.name == "Android" ) {
|
||||
plus.runtime.launchApplication( {pname:"com.tencent.mm"}
|
||||
, function ( e ) {
|
||||
plus.nativeUI.confirm( "检查到您未安装\"微信\",是否到商城搜索下载?", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
androidMarket( "com.tencent.mm" );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} else if ( plus.os.name == "iOS" ) {
|
||||
plus.runtime.launchApplication( {action:"weixin://RnUbAwvEilb1rU9g9yBU"}, function ( e ) {
|
||||
plus.nativeUI.confirm( "检查到您未安装\"微信\",是否到商城搜索下载?", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
iosAppstore( "itunes.apple.com/cn/app/wechat/id414478124?mt=8" );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
// var url = "http://weixin.qq.com/r/RnUbAwvEilb1rU9g9yBU";
|
||||
// plus.runtime.openURL( url );
|
||||
}
|
||||
function openWeibo() {
|
||||
if ( plus.os.name == "Android" ) {
|
||||
plus.runtime.launchApplication( {pname:"com.sina.weibo"}
|
||||
, function ( e ) {
|
||||
plus.nativeUI.confirm( "检查到您未安装\"微博\",是否到商城搜索下载?", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
androidMarket( "com.sina.weibo" );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} else if ( plus.os.name == "iOS" ) {
|
||||
plus.runtime.launchApplication( {action:"sinaweibo://dhnetwork"}, function ( e ) {
|
||||
plus.nativeUI.confirm( "检查到您未安装\"微博\",是否到商城搜索下载?", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
iosAppstore( "itunes.apple.com/cn/app/wei-bo/id350962117?mt=8" );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
// var url = "http://weibo.com/dhnetwork";
|
||||
// plus.runtime.openURL( url );
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back();"></div>
|
||||
<div class="nvtt">调用第三方应用</div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent" style="bottom:0;">
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="openBrowser();">浏览器</li>
|
||||
<li class="ditem" onclick="openMarket();">应用市场</li>
|
||||
<li class="ditem" onclick="openMap();">地图</li>
|
||||
<li class="ditem" onclick="openBMap();">百度地图</li>
|
||||
<li class="ditem" onclick="openAMap();">高德地图</li>
|
||||
<li class="ditem" onclick="openWeixin();">微信</li>
|
||||
<li class="ditem" onclick="openWeibo();">微博</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,299 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var shares=null;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
updateSerivces();
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
/**
|
||||
* 更新分享服务
|
||||
*/
|
||||
function updateSerivces(){
|
||||
plus.share.getServices(function(s){
|
||||
shares={};
|
||||
for(var i in s){
|
||||
var t=s[i];
|
||||
shares[t.id]=t;
|
||||
}
|
||||
}, function(e){
|
||||
outSet('获取分享服务列表失败:'+e.message);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 调用系统分享
|
||||
*/
|
||||
function shareSystem(){
|
||||
outSet('调用系统分享');
|
||||
var msg={content:sharecontent.value};
|
||||
if(pic&&pic.realUrl){
|
||||
msg.pictures=[pic.realUrl];
|
||||
}
|
||||
if('iOS'==plus.os.name){//iOS平台添加链接地址
|
||||
msg.href='http://www.dcloud.io/';
|
||||
}
|
||||
outLine(JSON.stringify(msg));
|
||||
plus.share.sendWithSystem?plus.share.sendWithSystem(msg, function(){
|
||||
outLine('Success');
|
||||
console.log('Success');
|
||||
}, function(e){
|
||||
outLine('Failed: '+JSON.stringify(e));
|
||||
console.log('Failed: '+JSON.stringify(e));
|
||||
}):shareSystemNativeJS();
|
||||
}
|
||||
function shareSystemNativeJS() {
|
||||
if(plus.os.name!=='Android'){
|
||||
plus.nativeUI.alert('此平台暂不支持系统分享功能!');
|
||||
return;
|
||||
}
|
||||
var intent=new Intent(Intent.ACTION_SEND);
|
||||
if(pic&&pic.realUrl){
|
||||
var p = '';
|
||||
p = pic.realUrl;
|
||||
if(p.substr(0,7)==='file://'){
|
||||
p=p.substr(7);
|
||||
}else if(p.sub(0)!=='/'){
|
||||
p=plus.io.convertLocalFileSystemURL(p);
|
||||
}
|
||||
}
|
||||
var f = new File(p);
|
||||
var uri = Uri.fromFile(f);
|
||||
if(f.exists()&&f.isFile()){
|
||||
console.log('image/*');
|
||||
intent.setType('image/*');
|
||||
intent.putExtra(Intent.EXTRA_STREAM,uri);
|
||||
}else{
|
||||
console.log('text/plain');
|
||||
intent.setType('text/plain');
|
||||
}
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT,'HelloH5');
|
||||
intent.putExtra(Intent.EXTRA_TEXT,sharecontent.value);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
main.startActivity(Intent.createChooser(intent,'系统分享HelloH5'));
|
||||
}
|
||||
/**
|
||||
* 分享操作
|
||||
* @param {JSON} sb 分享操作对象s.s为分享通道对象(plus.share.ShareService)
|
||||
* @param {Boolean} bh 是否分享链接
|
||||
*/
|
||||
function shareAction(sb,bh) {
|
||||
outSet('分享操作:');
|
||||
if(!sb||!sb.s){
|
||||
outLine('无效的分享服务!');
|
||||
return;
|
||||
}
|
||||
var msg={content:sharecontent.value,extra:{scene:sb.x}};
|
||||
if(bh){
|
||||
msg.href=sharehref.value;
|
||||
if(sharehrefTitle&&sharehrefTitle.value!=''){
|
||||
msg.title=sharehrefTitle.value;
|
||||
}
|
||||
if(sharehrefDes&&sharehrefDes.value!=''){
|
||||
msg.content=sharehrefDes.value;
|
||||
}
|
||||
msg.thumbs=['_www/logo.png'];
|
||||
msg.pictures=['_www/logo.png'];
|
||||
}else{
|
||||
if(pic&&pic.realUrl){
|
||||
msg.pictures=[pic.realUrl];
|
||||
}
|
||||
}
|
||||
// 发送分享
|
||||
if(sb.s.authenticated){
|
||||
outLine('---已授权---');
|
||||
shareMessage(msg, sb.s);
|
||||
}else{
|
||||
outLine('---未授权---');
|
||||
sb.s.authorize(function(){
|
||||
shareMessage(msg,sb.s);
|
||||
}, function(e){
|
||||
outLine('认证授权失败:'+e.code+' - '+e.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 发送分享消息
|
||||
* @param {JSON} msg
|
||||
* @param {plus.share.ShareService} s
|
||||
*/
|
||||
function shareMessage(msg, s){
|
||||
outLine(JSON.stringify(msg));
|
||||
s.send(msg, function(){
|
||||
outLine('分享到"'+s.description+'"成功!');
|
||||
}, function(e){
|
||||
outLine('分享到"'+s.description+'"失败: '+JSON.stringify(e));
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 解除所有分享服务的授权
|
||||
*/
|
||||
function cancelAuth(){try{
|
||||
outSet('解除授权:');
|
||||
for(var i in shares){
|
||||
var s=shares[i];
|
||||
if(s.authenticated){
|
||||
outLine('取消"'+s.description+'"');
|
||||
}
|
||||
s.forbid();
|
||||
}
|
||||
// 取消授权后需要更新服务列表
|
||||
updateSerivces();
|
||||
outLine('操作成功!');}catch(e){alert(e);}
|
||||
}
|
||||
// 拍照添加图片分享
|
||||
function shareCameraPicture(){
|
||||
outSet('拍照添加分享图片:');
|
||||
var cmr=plus.camera.getCamera();
|
||||
cmr.captureImage(function(p){
|
||||
plus.io.resolveLocalFileSystemURL(p,function(entry){
|
||||
pic.src=entry.toLocalURL();
|
||||
pic.realUrl=p;
|
||||
outLine('拍照图片:'+pic.realUrl);
|
||||
},function(e){
|
||||
outLine('读取拍照文件错误:'+e.message);
|
||||
} );
|
||||
},function(e){
|
||||
outLine('拍照失败:'+e.message);
|
||||
});
|
||||
}
|
||||
// 从相册添加图片分享
|
||||
function shareGalleryPicture(){
|
||||
outSet('从相册添加分享图片:');
|
||||
plus.gallery.pick(function(p){
|
||||
// 从相册返回的路径不需要转换可以直接使用
|
||||
pic.src=p;
|
||||
pic.realUrl=pic.src;
|
||||
outLine('选择图片:'+pic.realUrl);
|
||||
// plus.io.resolveLocalFileSystemURL(p,function(entry){
|
||||
// pic.src=entry.toLocalURL();
|
||||
// pic.realUrl=pic.src;
|
||||
// outLine('选择图片:'+pic.realUrl);
|
||||
// },function(e){
|
||||
// outLine('读取拍照文件错误:'+e.message);
|
||||
// } );
|
||||
});
|
||||
}
|
||||
// 使用Logo图片分享
|
||||
function shareLogoPicture(){
|
||||
outSet('使用Logo分享图片:');
|
||||
var url='_www/logo.png';
|
||||
plus.io.resolveLocalFileSystemURL(url, function(entry){
|
||||
pic.src=entry.toLocalURL();
|
||||
pic.realUrl=url;
|
||||
}, function(e){
|
||||
outLine('读取Logo文件错误:'+e.message);
|
||||
});
|
||||
}
|
||||
// 打开分享
|
||||
function shareShow(){
|
||||
var shareBts=[];
|
||||
// 更新分享列表
|
||||
var ss=shares['weixin'];
|
||||
if(navigator.userAgent.indexOf('qihoo')<0){ //在360流应用中微信不支持分享图片
|
||||
ss&&ss.nativeClient&&(shareBts.push({title:'微信朋友圈',s:ss,x:'WXSceneTimeline'}),
|
||||
shareBts.push({title:'微信好友',s:ss,x:'WXSceneSession'}));
|
||||
}
|
||||
ss=shares['sinaweibo'];
|
||||
ss&&shareBts.push({title:'新浪微博',s:ss});
|
||||
ss=shares['qq'];
|
||||
ss&&ss.nativeClient&&shareBts.push({title:'QQ',s:ss});
|
||||
// 弹出分享列表
|
||||
shareBts.length>0?plus.nativeUI.actionSheet({title:'分享',cancel:'取消',buttons:shareBts}, function(e){
|
||||
(e.index>0)&&shareAction(shareBts[e.index-1],false);
|
||||
}):plus.nativeUI.alert('当前环境无法支持分享操作!');
|
||||
}
|
||||
// 分析链接
|
||||
function shareHref(){
|
||||
var shareBts=[];
|
||||
// 更新分享列表
|
||||
var ss=shares['weixin'];
|
||||
ss&&ss.nativeClient&&(shareBts.push({title:'微信朋友圈',s:ss,x:'WXSceneTimeline'}),
|
||||
shareBts.push({title:'微信好友',s:ss,x:'WXSceneSession'}));
|
||||
ss=shares['qq'];
|
||||
ss&&ss.nativeClient&&shareBts.push({title:'QQ',s:ss});
|
||||
// 弹出分享列表
|
||||
shareBts.length>0?plus.nativeUI.actionSheet({title:'分享链接',cancel:'取消',buttons:shareBts},function(e){
|
||||
(e.index>0)&&shareAction(shareBts[e.index-1],true);
|
||||
}):plus.nativeUI.alert('当前环境无法支持分享链接操作!');
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#sharecontent{
|
||||
width:80%;
|
||||
-webkit-user-select:text;
|
||||
border: 1px solid #6C6C6C;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
#pic{
|
||||
width:100px;
|
||||
height:100px;
|
||||
/*border: 1px dashed #CCCCCC;*/
|
||||
}
|
||||
.sharehref{
|
||||
width:80%;
|
||||
-webkit-user-select:text;
|
||||
border: 1px solid #6C6C6C;
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Share</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Share Document','/doc/share.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<p class="heading">分享内容:</p>
|
||||
<textarea id="sharecontent" rows="3">我正在使用HBuilder+HTML5开发移动应用,赶紧跟我一起来体验!</textarea>
|
||||
<br/><br/>
|
||||
<p class="heading">分享图片:</p>
|
||||
<table style="width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:30%"><div class="button button-select" onclick="shareCameraPicture()">拍照</div></td>
|
||||
<td style="width:30%"><div class="button button-select" onclick="shareGalleryPicture()">相册选取</div></td>
|
||||
<td style="width:30%"><div class="button button-select" onclick="shareLogoPicture()">使用logo图</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<img id="pic" src="../img/add.png"/>
|
||||
<br/>
|
||||
<div class="button" onclick="shareShow()">分 享</div>
|
||||
<div class="button" onclick="shareSystem()">系统分享</div>
|
||||
<div style="padding: 0.5em 1em;"><hr color="#EEE"/></div>
|
||||
<p class="heading">链接地址:</p>
|
||||
<input id="sharehref" class="sharehref" type="url" value="http://www.dcloud.io/" placeholder="请输入要分享的链接地址"/>
|
||||
<p class="heading">链接标题:</p>
|
||||
<input id="sharehrefTitle" class="sharehref" type="text" value="DCloud HBuilder-做最好的HTML5开发工具" placeholder="请输入要分享的链接标题"/>
|
||||
<p class="heading">链接描述:</p>
|
||||
<input id="sharehrefDes" class="sharehref" type="text" value="我正在使用HBuilder+HTML5开发移动应用,赶紧跟我一起来体验!" placeholder="请输入要分享的链接描述"/>
|
||||
<div class="button" onclick="shareHref()">分享链接</div>
|
||||
<br/><br/>
|
||||
<div style="padding: 0.5em 1em;"><hr color="#EEE"/></div>
|
||||
<p class="des">如果需要解除分享中绑定的用户信息,请点击解除授权:</p>
|
||||
<div class="button" onclick="cancelAuth()">解除授权</div>
|
||||
</div>
|
||||
<div id="output">
|
||||
Share模块管理客户端的社交分享功能,提供调用终端社交软件的分享能力。通过plus.share可获取社交分享管理对象。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var text=null;
|
||||
function startRecognize() {
|
||||
if(plus.os.name=='Android'&&navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持语音识别插件');
|
||||
return;
|
||||
}
|
||||
var options = {};
|
||||
options.engine = 'iFly';
|
||||
//options.punctuation = false; // 是否需要标点符号
|
||||
text.value = "";
|
||||
outSet( "开始语音识别:" );
|
||||
plus.speech.startRecognize( options, function ( s ) {
|
||||
outLine( s );
|
||||
text.value += s;
|
||||
}, function ( e ) {
|
||||
outSet( "语音识别失败:"+e.message );
|
||||
} );
|
||||
}
|
||||
function startRecognizeEnglish(){
|
||||
if(plus.os.name=='Android'&&navigator.userAgent.indexOf('StreamApp')>0){
|
||||
plus.nativeUI.toast('当前环境暂不支持语音识别插件');
|
||||
return;
|
||||
}
|
||||
var options = {};
|
||||
options.engine = 'iFly';
|
||||
options.lang = 'en-us';
|
||||
text.value = "";
|
||||
outSet( "开始语音识别:" );
|
||||
plus.speech.startRecognize( options, function ( s ) {
|
||||
outLine( s );
|
||||
text.value += s;
|
||||
}, function ( e ) {
|
||||
outSet( "语音识别失败:"+e.message );
|
||||
} );
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
.out {
|
||||
margin: 9px;
|
||||
height: 30%;
|
||||
width: 90%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="text=document.getElementById('text');">
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Speech</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Speech Document','/doc/speech.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="startRecognize()">开始语音识别</div>
|
||||
<br/>
|
||||
<div class="button" onclick="startRecognizeEnglish()">开始语音识别(英语)</div>
|
||||
<br/>
|
||||
<textarea readonly="readonly" id="text" style="margin:2%;padding:2%;height:50%;width:90%;border:1px solid #6C6C6C;-webkit-border-radius: 2px;border-radius: 2px;-webkit-appearance:none;">
|
||||
语音输入内容
|
||||
</textarea>
|
||||
</div>
|
||||
<div id="output">
|
||||
Speech提供语音识别功能,可通过麦克风设备进行语音输入操作。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var duration=null,counter=null,loading=null;
|
||||
document.addEventListener( "plusready", function(){
|
||||
counter = document.getElementById("counter");
|
||||
loading = document.getElementById("loading");
|
||||
duration = document.getElementById("duration");
|
||||
duration.addEventListener( "touchstart", durationStart, false );
|
||||
duration.addEventListener( "touchend", durationEnd, false );
|
||||
plus.statistic.eventTrig( "open" );
|
||||
plus.statistic.eventStart( "stay" );
|
||||
}, false );
|
||||
function statisticBack() {
|
||||
plus.statistic.eventEnd( "stay" );
|
||||
back();
|
||||
}
|
||||
var tc=null,tl=null,count=0;
|
||||
var ds=null;
|
||||
function doCounter(){
|
||||
loading.style.webkitTransition = "all 0.8s ease-in-out";
|
||||
loading.style.borderWidth = "0";
|
||||
loading.style.borderColor = "rgba(128,128,128,0.8)";
|
||||
tc = setTimeout( function(){
|
||||
count++;
|
||||
loading.style.webkitTransition = "";
|
||||
loading.style.borderWidth = "50px";
|
||||
loading.style.borderColor = "rgba(255,255,255,0)";
|
||||
counter.innerText = count;
|
||||
tl=setTimeout( doCounter, 0 );
|
||||
}, 1000 );
|
||||
}
|
||||
function durationStart(){
|
||||
ds = new Date();
|
||||
count = 0;
|
||||
counter.innerText = "0";
|
||||
counter.style.visibility = "visible";
|
||||
doCounter();
|
||||
outSet( "按下开始计时:" );
|
||||
}
|
||||
function durationEnd(){
|
||||
clearTimeout( tc );
|
||||
tc = null;
|
||||
clearTimeout( tl );
|
||||
tl = null;
|
||||
loading.style.webkitTransition = "";
|
||||
loading.style.borderWidth = "50px";
|
||||
loading.style.borderColor = "rgba(255,255,255,0)";
|
||||
counter.style.visibility = "hidden";
|
||||
var d = (new Date()).getTime()-ds.getTime();
|
||||
plus.statistic.eventDuration( "press", d );
|
||||
outLine( "您按下的时间为"+d+"ms,后台会将此数据提交到服务器!" );
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
.counter {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
margin: 0 auto;
|
||||
line-height: 100px;
|
||||
font-size: 48px;
|
||||
visibility: hidden;
|
||||
}
|
||||
.loading {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
border-style:solid;
|
||||
position:relative;
|
||||
top: -100px;
|
||||
display:inline-block;
|
||||
box-sizing:border-box;
|
||||
border-width:50px;
|
||||
border-color:rgba(255,255,255,0);
|
||||
border-radius: 50px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="statisticBack();"></div>
|
||||
<div class="nvtt">Statistic</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Statistic Document','/doc/statistic.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<p class="des">应用会在后台统计打开此页面的次数及在此页面停留的时间,目前应用集成的是友盟统计插件,相关统计数据需要登录到<a href="" onclick="plus.runtime.openURL('http://www.umeng.com/');">友盟官网</a>查看。</p>
|
||||
<div style="height:100px;">
|
||||
<div id="counter" class="counter">0</div>
|
||||
<div id="loading" class="loading"></div>
|
||||
</div>
|
||||
<div id="duration" class="button">统计按下时长</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
Statistic模块管理统计功能,用于提供应用内统计的能力,支持统计和分析用户属性和用户行为数据。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,88 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
function setItemFun( id ) {
|
||||
//循环插入100调数据
|
||||
var dataNum = new Number(id);
|
||||
for ( var i=0; i<dataNum; i++ ) {
|
||||
plus.storage.setItem( "key"+i, "value"+i );
|
||||
}
|
||||
var length = getLengthFun();
|
||||
outSet( "数据存储成功,存储了"+length+"条数据;" );
|
||||
}
|
||||
function getLengthFun(){
|
||||
return plus.storage.getLength();
|
||||
}
|
||||
function getAllItem(){
|
||||
outSet( "获取数据:" );
|
||||
var itemLength = getLengthFun();
|
||||
for ( var i=0; i < itemLength; i++ ) {
|
||||
var key = plus.storage.key(i);
|
||||
var value = plus.storage.getItem(key);
|
||||
outLine( "key:"+key+"-->value:"+value );
|
||||
};
|
||||
}
|
||||
function delItem() {
|
||||
outSet( "删除数据:" );
|
||||
var itemLength = getLengthFun();
|
||||
for (var i=0; i < itemLength; i+=2) {
|
||||
var key = plus.storage.key(i);
|
||||
plus.storage.removeItem(key);
|
||||
};
|
||||
var itemNo = getLengthFun();
|
||||
outLine( "移除了"+(itemLength-itemNo)+"条数据" );
|
||||
}
|
||||
function clearAllItem(){
|
||||
plus.storage.clear();
|
||||
var num = getLengthFun();
|
||||
if ( num == 0 ) {
|
||||
outSet( "storage数据清除成功!" );
|
||||
}else{
|
||||
outSet( "storage数据清除失败!" );
|
||||
}
|
||||
}
|
||||
function modifyTopFive(){
|
||||
outSet( "修改前的数据是:" );
|
||||
for (var i=0; i < 5; i++) {
|
||||
var key = plus.storage.key(i),value = plus.storage.getItem(key);
|
||||
outLine( "key:"+key+"-->value:"+value );
|
||||
plus.storage.setItem( key, "新数据值>>"+i );
|
||||
};
|
||||
outLine( "修改后的数据是:" );
|
||||
for (var i=0; i < 5; i++) {
|
||||
var key = plus.storage.key(i),value = plus.storage.getItem(key);
|
||||
outLine( "key:"+key+"-->value:"+value );
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Storage</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Storage Document','/doc/storage.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="setItemFun('11')">插入11条数据</li>
|
||||
<li class="ditem" onclick="getAllItem()">查询所有数据</li>
|
||||
<li class="ditem" onclick="modifyTopFive()">修改前五条数据的内容</li>
|
||||
<li class="ditem" onclick="delItem()">删除部分Item</li>
|
||||
<li class="ditem" onclick="clearAllItem()">清除所有内容</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Storage管理本地数据存储,用于保存应用的全局数据,可在程序内部跨页面(跨域)共享数据。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,110 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var server="http://demo.dcloud.net.cn/helloh5/uploader/upload.php";
|
||||
var files=[];
|
||||
// 上传文件
|
||||
function upload(){
|
||||
if(files.length<=0){
|
||||
plus.nativeUI.alert("没有添加上传文件!");
|
||||
return;
|
||||
}
|
||||
outSet("开始上传:")
|
||||
var wt=plus.nativeUI.showWaiting();
|
||||
var task=plus.uploader.createUpload(server,
|
||||
{method:"POST"},
|
||||
function(t,status){ //上传完成
|
||||
if(status==200){
|
||||
outLine("上传成功:"+t.responseText);
|
||||
plus.storage.setItem("uploader",t.responseText);
|
||||
var w=plus.webview.create("uploader_ret.html","uploader_ret.html",{scrollIndicator:'none',scalable:false});
|
||||
w.addEventListener("loaded",function(){
|
||||
wt.close();
|
||||
w.show("slide-in-right",300);
|
||||
},false);
|
||||
}else{
|
||||
outLine("上传失败:"+status);
|
||||
wt.close();
|
||||
}
|
||||
}
|
||||
);
|
||||
task.addData("client","HelloH5+");
|
||||
task.addData("uid",getUid());
|
||||
for(var i=0;i<files.length;i++){
|
||||
var f=files[i];
|
||||
task.addFile(f.path,{key:f.name});
|
||||
}
|
||||
task.start();
|
||||
}
|
||||
// 拍照添加文件
|
||||
function appendByCamera(){
|
||||
plus.camera.getCamera().captureImage(function(p){
|
||||
appendFile(p);
|
||||
});
|
||||
}
|
||||
// 从相册添加文件
|
||||
function appendByGallery(){
|
||||
plus.gallery.pick(function(p){
|
||||
appendFile(p);
|
||||
});
|
||||
}
|
||||
// 添加文件
|
||||
var index=1;
|
||||
function appendFile(p){
|
||||
var fe=document.getElementById("files");
|
||||
var li=document.createElement("li");
|
||||
var n=p.substr(p.lastIndexOf('/')+1);
|
||||
li.innerText=n;
|
||||
fe.appendChild(li);
|
||||
files.push({name:"uploadkey"+index,path:p});
|
||||
index++;
|
||||
empty.style.display="none";
|
||||
}
|
||||
// 产生一个随机数
|
||||
function getUid(){
|
||||
return Math.floor(Math.random()*100000000+10000000).toString();
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Uploader</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Uploader Document','/doc/uploader.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<p class="heading">上传文件列表:</p>
|
||||
<ul id="files" style="text-align:left;">
|
||||
<p id="empty" style="font-size:12px;color:#C6C6C6;">无上传文件</p>
|
||||
</ul>
|
||||
<table style="width:100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:40%"><div class="button button-select" onclick="appendByCamera()">拍照</div></td>
|
||||
<td style="width:40%"><div class="button button-select" onclick="appendByGallery()">相册选取</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<div class="button" onclick="upload()">上 传</div>
|
||||
<br/>
|
||||
<!--<ul class="dlist">
|
||||
<li class="ditem" onclick="appendByCamera()">拍照添加文件</li>
|
||||
<li class="ditem" onclick="appendByGallery()">相册添加文件</li>
|
||||
</ul>-->
|
||||
</div>
|
||||
<div id="output">
|
||||
Uploader用于管理文件的上传,用于从本地上传各种文件到网络服务器,支持跨域访问操作。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript">
|
||||
// H5 plus事件处理
|
||||
var ret=null;
|
||||
function plusReady(){
|
||||
ret=plus.storage.getItem("uploader");
|
||||
update();
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// DOM事件
|
||||
var ce=null;
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
ce=document.getElementById("dcontent");
|
||||
update();
|
||||
},false);
|
||||
// 更新内容
|
||||
var fs=null;
|
||||
function update(){
|
||||
if(!ret||!ce)return;
|
||||
var j=JSON.parse(ret);
|
||||
var ih='<br/>Datas:<br/><div style="text-align:left;padding:10px 2%;">';
|
||||
var ds=j.strings;
|
||||
for(d in ds){
|
||||
ih += d+" : "+ds[d]+"<br/>";
|
||||
}
|
||||
ih+='</div><hr/>Files:<br/><div id="fl">';
|
||||
fs=j.files;
|
||||
for(f in fs){
|
||||
ih += '<a class="fitem" onclick="plus.runtime.openURL(\'http://demo.dcloud.net.cn/helloh5/uploader/'+fs[f].url+'\')">'+fs[f].name+'</a>';
|
||||
}
|
||||
ih+='</div>';
|
||||
ce.innerHTML=ih;
|
||||
}
|
||||
// 清除上传返回的数据
|
||||
function resetUploader(){
|
||||
plus.storage.setItem("uploader","");
|
||||
}
|
||||
// 删除上传的文件
|
||||
function deleteFiles(){
|
||||
var url="http://demo.dcloud.net.cn/helloh5/uploader/delete.php?";
|
||||
for(f in fs){
|
||||
url += f+"="+fs[f].name+"&";
|
||||
}
|
||||
var r=new plus.net.XMLHttpRequest();
|
||||
r.open('GET',url);
|
||||
r.send();
|
||||
document.getElementById('fl').innerHTML="";
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<style type="text/css">
|
||||
.fitem {
|
||||
width: 96%;
|
||||
overflow: hidden;
|
||||
padding: 10px 2%;
|
||||
border-bottom: 1px solid #c6c6c6;
|
||||
color: #6c6c6c;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
}
|
||||
.fitem:active {
|
||||
background: #f4f4f4;
|
||||
}
|
||||
.fname {
|
||||
font-weight: bolder;
|
||||
height: 22px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.iclear {
|
||||
background: no-repeat center center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNy8xNy8xNGW7Pb8AAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAAD3ElEQVR4nO2b0W3bSBCG/+Hy/dTBsYOQFvV8ugqsVBB3EHcQuQNdB3IH6uCUZxJYpQOmA+td3LmHIw+KjpIZh5R/w/MBBgxxOTujD9RyiKWoKgweotdOwPgRE0KGCSHDhJBhQsgwIWSYEDJMCBkmhAwTQoYJIcOEkGFCyDAhZJgQMkwIGSaEDBNChgkhw4SQYULIMCFkmBAyTAgZJoSM+LUTOEVEeo8timLunPvf1subm5uvfWOw7dwUuoR6CPHeTw6Hw98iknYdV9VdHMd/Zln29FwsuvrpEnpGyImMv1R1c3L+AsDnvlLo6qdL6IwQ731S1/UfqnovIqmqPsxms2XX2LIsV2ikiMjKOfc1y7Kqayxd/XQJHQnx3ichhE+qegcgORr2mOf53aU4ZVluANwefVSJyDqKosdjOXT10yXUCCmKYikinwFMToZ8c87Nsyx7Ol1Ljn+mvPeTuq63AD6cnP8kIqvpdPrQnDNuQT8JnZDdbndpwd4755IuGS0dUioAv50Gaselafrswn9N6ISUZbkUkS9nDm9EZAcAIYTFpbusKIo2zf8pgMWZcQ95ni8HSHswGPuQ5MLhhaoumnGXYqSNiF+Z61Wg69RVdX2tuZxzq2vN1Rc6IbPZbAvgI4D9iNPsAXzMsmw34hwvgm4NaX+KmkX7XkTuAPw+UPjvqrqO43jVNox09dMl1LE2eO/Tw+HQLuIp+gv6DmDX3FFtuq4IuvrpEur5cNF7nxwOh6TrWBzH1bnO/BS2+qGqVH8tRVEsvffJ0PV675OiKJas9dPd9h4xr+v6S/MIZNs8j3rRItw8B7sFsKjreg6g9+P5a0MrRETaDnqBf79IlGVZAaiaxu9JVasoiqrj80IIiYgkIYRJs+YkdV0nZ2LTQSukeVJ7e/JxAiARkXn78xZC6Dr34lqkqnS3uy10fcg1iKKI9gphFrIdK3AIwa4Qox/UfUhZlqMkl+f5f5Ow1W9XCBnsQr69kZiDQS1EVQe/Gxoj5pBQCxGR6i3EHBJqIapavYWYQ0ItZIwGjrkpBMiFjNHAMTeFALmQ9wh1YwgM3xweN4WANYYvYcjNDmNunBgEeiEico9hvsh9E4saeiHT6XTtnEsBPP5CmEfnXDKdTtcDpTUa9GvIMd77SQjhTlXnAObo2LPbsAewFZFtFEXrS++I0NVPl9BPvNLW7N36YctoHMe7Pm9OtdDVz5bQe4d+DXlvmBAyTAgZJoQME0KGCSHDhJBhQsgwIWSYEDJMCBkmhAwTQoYJIcOEkGFCyDAhZJgQMkwIGSaEDBNChgkhw4SQYULIMCFk/AMqfZUpSkU8pwAAAABJRU5ErkJggg==);
|
||||
background-size: 50px 44px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="resetUploader();back();"></div>
|
||||
<div class="nvtt">Uploaded Data&File</div>
|
||||
<div class="nvbt iclear" onclick="deleteFiles()"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
// 预创建二级页面
|
||||
var preate={};
|
||||
function preateWebivew(id){
|
||||
if(!preate[id]){
|
||||
var w=plus.webview.create(id,id,{scrollIndicator:'none',scalable:false,popGesture:'hide'},{preate:true});
|
||||
preate[id]=w;
|
||||
w.addEventListener('close',function(){//页面关闭后可再次打开
|
||||
_openw=null;
|
||||
preate[id]&&(preate[id]=null);//兼容窗口的关闭
|
||||
},false);
|
||||
}
|
||||
}
|
||||
// 判断预载打开
|
||||
var _openw=null;
|
||||
function pclicked(id){
|
||||
if(_openw){return;}
|
||||
_openw=preate[id];
|
||||
if(_openw){
|
||||
if(_openw.showded){
|
||||
_openw.show('auto');
|
||||
}else{
|
||||
_openw.show(as);
|
||||
_openw.showded=true;
|
||||
}
|
||||
_openw=null;
|
||||
}else{
|
||||
_openw=plus.webview.create(id,id,{scrollIndicator:'none',scalable:false,popGesture:'hide'});
|
||||
preate[id]=_openw;
|
||||
_openw.addEventListener('loaded',function(){//叶面加载完成后才显示
|
||||
// setTimeout(function(){
|
||||
_openw.show(as);
|
||||
_openw.showded=true;
|
||||
_openw=null;
|
||||
// },10);
|
||||
},false);
|
||||
_openw.addEventListener('close',function(){//页面关闭后可再次打开
|
||||
_openw=null;
|
||||
preate[id]&&(preate[id]=null);//兼容窗口的关闭
|
||||
},false);
|
||||
}
|
||||
}
|
||||
// H5 plus事件处理
|
||||
var as='pop-in';// 默认动画类型
|
||||
function plusReady(){
|
||||
// preateWebivew('webview_animation.html');
|
||||
// preateWebivew('webview_pullhead.html');
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
}
|
||||
// 创建悬浮窗口
|
||||
var floatw=null;
|
||||
function floatWebview(){
|
||||
if(floatw){ // 避免快速多次点击创建多个窗口
|
||||
return;
|
||||
}
|
||||
floatw=plus.webview.create("webview_float.html","webview_float.html",{width:'200px',height:'200px',margin:"auto",background:"rgba(0,0,0,0.8)",scrollIndicator:'none',scalable:false,popGesture:'none'});
|
||||
floatw.addEventListener("loaded",function(){
|
||||
floatw.show('fade-in',300);
|
||||
floatw=null;
|
||||
},false);
|
||||
}
|
||||
// 创建自定义下拉刷新窗口
|
||||
function customeRefresh(){
|
||||
if(plus.os.name!="Android"){
|
||||
compatibleConfirm();
|
||||
}else{
|
||||
clicked('webview_pullhead_custom.html',true,true);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Webview</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('Webview Document','/doc/webview.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="pclicked('webview_animation.html',true,true)">窗口动画</div>
|
||||
<div class="button" onclick="clicked('webview_embed.html',true)">窗口嵌套</div>
|
||||
<div class="button" onclick="floatWebview()">悬浮窗口</div>
|
||||
<div class="button" onclick="pclicked('webview_pulltorefresh.html',true,true)">下拉刷新</div>
|
||||
<div class="button" onclick="customeRefresh()">自定义下拉刷新</div>
|
||||
<div class="button" onclick="clicked('webview_mask.html',true)">窗口遮罩</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="output">
|
||||
Webview模块管理应用窗口界面,实现多窗口的逻辑控制管理操作。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ws=null,wp=null,wo=null;
|
||||
// H5 plus事件处理
|
||||
function plusReady(){
|
||||
ws=plus.webview.currentWebview();
|
||||
wo=ws.opener();
|
||||
wp=plus.webview.create('webview_new.html','webview_new.html',{scrollIndicator:'none',scalable:false,popGesture:'none'},{preate:true});
|
||||
wp.addEventListener('close',function(){
|
||||
wp=null;
|
||||
},false);
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
}
|
||||
// 动画窗口
|
||||
function animateWindow(type){
|
||||
wp||(wp=plus.webview.create('webview_new.html','webview_new.html',{scrollIndicator:'none',scalable:false,popGesture:'none'},{preate:true}));
|
||||
wp.show(type);
|
||||
}
|
||||
// 关闭窗口
|
||||
var _back=window.back;
|
||||
function preateBack(){
|
||||
wp&&(wp.close(),wp=null);
|
||||
_back();
|
||||
}
|
||||
window.back=preateBack;
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">系统原生动画</div>
|
||||
</header>
|
||||
<div id="content" class="content">
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="animateWindow('pop-in')">从右侧平移入栈</li>
|
||||
<li class="ditem" onclick="animateWindow('slide-in-right')">从右侧横向滑出</li>
|
||||
<li class="ditem" onclick="animateWindow('slide-in-left')">从左侧横向滑出</li>
|
||||
<li class="ditem" onclick="animateWindow('slide-in-top')">从上侧竖向滑出</li>
|
||||
<li class="ditem" onclick="animateWindow('slide-in-bottom')">从下侧竖向滑出</li>
|
||||
<!--<li class="ditem" onclick="animateWindow('zoom-out')">从小到大逐渐放大</li>-->
|
||||
<li class="ditem" onclick="animateWindow('zoom-fade-out')">从小到大并逐渐透明显示</li>
|
||||
<li class="ditem" onclick="animateWindow('fade-in')">从透明到不透明逐渐显示</li>
|
||||
<!--<li class="ditem" onclick="animateWindow('flip-x')">以x轴从上到下翻转效果</li>
|
||||
<li class="ditem" onclick="animateWindow('flip-rx')">以x轴从下到上翻转转效果</li>
|
||||
<li class="ditem" onclick="animateWindow('flip-y')">以y轴从左到右翻转效果</li>
|
||||
<li class="ditem" onclick="animateWindow('flip-ry')">以y轴从右到左翻转效果</li>
|
||||
<li class="ditem" onclick="animateWindow('page-forward')">向前翻书动画效果</li>-->
|
||||
<li class="ditem" onclick="animateWindow('none')">无动画</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ws=null,embed=null;
|
||||
// 扩展API加载完毕,现在可以正常调用扩展API
|
||||
function plusReady(){
|
||||
ws=plus.webview.currentWebview();
|
||||
ws.addEventListener('show',createEmbed,false);
|
||||
}
|
||||
// 判断扩展API是否准备,否则监听"plusready"事件
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// 创建子Webview
|
||||
function createEmbed(){
|
||||
var topoffset='45px';
|
||||
if(plus.navigator.isImmersedStatusbar()){// 兼容immersed状态栏模式
|
||||
topoffset=(Math.round(plus.navigator.getStatusbarHeight())+45)+'px';
|
||||
}
|
||||
plus.nativeUI.showWaiting('',{style:'black',modal:false,background:'rgba(0,0,0,0)'});
|
||||
embed=plus.webview.create('http://m.weibo.cn/u/3196963860','embed',{top:topoffset,bottom:'0px',position:'dock',dock:'bottom',bounce:'vertical'});
|
||||
ws.append(embed);
|
||||
embed.addEventListener('loaded',function(){
|
||||
plus.nativeUI.closeWaiting();
|
||||
},false);
|
||||
embed.addEventListener('loading',function(){
|
||||
plus.nativeUI.showWaiting('',{style:'black',modal:false,background:'rgba(0,0,0,0)'});
|
||||
},false);
|
||||
}
|
||||
// 打开网址
|
||||
function openUrl(){
|
||||
var url=document.getElementById("url");
|
||||
embed.loadURL(url.value);
|
||||
url.blur();
|
||||
}
|
||||
// 页面加载后自动打开
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
if(embed){
|
||||
openUrl();
|
||||
}else{
|
||||
auto=true;
|
||||
}
|
||||
},false);
|
||||
// 页面跳转完成事件
|
||||
function onBrowserLoading(){
|
||||
document.getElementById("url").value=embed.getURL();
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#url{
|
||||
width:98%;
|
||||
-webkit-user-select:auto;
|
||||
padding-left:0;
|
||||
padding-right:0;
|
||||
background: rgba(0,0,0,0);
|
||||
border: 0px;
|
||||
border-bottom:1px solid #ECB100;
|
||||
border-radius: 0;
|
||||
outline:none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back(),plus.nativeUI.closeWaiting();"></div>
|
||||
<div class="nvtt">
|
||||
<form action="?" method="get" onsubmit="openUrl();return false;">
|
||||
<input id="url" type="url" value="http://m.weibo.cn/u/3196963860"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="nvbt" onclick="openUrl();">Go</div>
|
||||
</header>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;width:100%;height:100%;text-align:center;">
|
||||
<img src="../img/ui.png"/>
|
||||
<div style="width:100%;position:fixed;bottom:0;">
|
||||
<div class="button" onclick="back()">关 闭</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,62 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var ws=null,wc=null;
|
||||
// 扩展API加载完毕,现在可以正常调用扩展API
|
||||
function plusReady(){
|
||||
ws=plus.webview.currentWebview();
|
||||
// 用户点击后
|
||||
ws.addEventListener("maskClick",function(){
|
||||
wc.close("auto");
|
||||
},false);
|
||||
}
|
||||
// 判断扩展API是否准备,否则监听"plusready"事件
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// 显示侧滑页面
|
||||
function showSide(){
|
||||
// 防止快速点击可能导致多次创建
|
||||
if(wc){
|
||||
return;
|
||||
}
|
||||
// 开启遮罩
|
||||
ws.setStyle({mask:"rgba(0,0,0,0.5)"});
|
||||
// 创建侧滑页面
|
||||
wc=plus.webview.create("webview_mask_side.html","side",{left:"30%",width:"70%",popGesture:"none"});
|
||||
// 侧滑页面关闭后关闭遮罩
|
||||
wc.addEventListener('close',function(){
|
||||
ws.setStyle({mask:"none"});
|
||||
wc=null;
|
||||
},false);
|
||||
// 侧滑页面加载后显示(避免白屏)
|
||||
wc.addEventListener("loaded",function(){
|
||||
wc.show("slide-in-right",200);
|
||||
},false);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">Webview Mask</div>
|
||||
</header>
|
||||
<div id="content" class="content">
|
||||
<br/>
|
||||
<div class="button" onclick="showSide()">打开侧滑窗口</div>
|
||||
<div class="des">打开侧滑窗口后,当前Webview窗口会显示遮罩层。</div>
|
||||
<div class="des">Webview的遮罩层会覆盖Webview中所有内容(包括子Webview),并且截获Webview窗口的所有触屏事件。</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body style="text-align:center;">
|
||||
<br/><br/><br/>
|
||||
<div class="button" onclick="back()">关 闭</div>
|
||||
<div style="height:30%;width:100%"></div>
|
||||
这是侧滑页面
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js" ></script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back();"></div>
|
||||
<div class="nvtt">动画页面</div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent" >
|
||||
<p>欢迎进入窗口动画页面</p>
|
||||
<br/>
|
||||
<img src="../img/ui.png"/>
|
||||
<br/>
|
||||
<p>此页面已关闭侧滑返回功能</p>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ws=null,wo=null,list=null;
|
||||
// 扩展API加载完毕,现在可以正常调用扩展API
|
||||
function plusReady(){
|
||||
ws=plus.webview.currentWebview();
|
||||
wo=ws.opener();
|
||||
list=plus.webview.create("webview_pullrefresh.html","webview_pullrefresh.html",{top:"46px",bottom:"0px",bounce:"vertical"});
|
||||
if(!ws.preate){
|
||||
list.addEventListener("loaded",function(){//叶面加载完成后才显示
|
||||
ws.show("pop-in");
|
||||
wo.evalJS("closeWaiting()");
|
||||
if(plus.os.name!="Android"){
|
||||
plus.nativeUI.alert("由于Android性能不足,我们提供了原生的下拉刷新加速方案。iOS设备请使 用iscroll等标准框架来解决下拉刷新问题");
|
||||
}
|
||||
},false);
|
||||
}
|
||||
ws.append(list);
|
||||
}
|
||||
// 判断扩展API是否准备,否则监听"plusready"事件
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back();"></div>
|
||||
<div class="nvtt">下拉刷新</div>
|
||||
</header>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,129 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ws=null,list=null;
|
||||
// 扩展API加载完毕,现在可以正常调用扩展API
|
||||
function plusReady(){
|
||||
ws=plus.webview.currentWebview();
|
||||
wo=ws.opener();
|
||||
var topoffset='45px';
|
||||
if(plus.navigator.isImmersedStatusbar()){// 兼容immersed状态栏模式
|
||||
topoffset=(Math.round(plus.navigator.getStatusbarHeight())+45)+'px';
|
||||
}
|
||||
list=plus.webview.create("webview_pullrefresh_custom.html","webview_pullrefresh_custom.html",{top:topoffset,bottom:"0px",bounce:"vertical"});
|
||||
ws.append(list);
|
||||
ws.addEventListener("show",function(){
|
||||
refresh();
|
||||
},false);
|
||||
if(!ws.preate){
|
||||
list.addEventListener("loaded",function(){//叶面加载完成后才显示
|
||||
ws.show("pop-in");
|
||||
wo.evalJS("closeWaiting()");
|
||||
},false);
|
||||
}
|
||||
ws.append(list);
|
||||
// 实现列表可下拉刷新
|
||||
list.addEventListener("dragBounce",onPullStateChange,false);
|
||||
list.setBounce({position:{top:"100px"},changeoffset:{top:"50px"}});
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// DOMContentLoaded事件处理
|
||||
var etext=null,eicon=null;
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
etext=document.getElementById("text");
|
||||
eicon=document.getElementById("icon");
|
||||
},false);
|
||||
|
||||
// 下拉状态改变
|
||||
function onPullStateChange(e){
|
||||
switch(e.status){
|
||||
case "beforeChangeOffset"://下拉可刷新状态
|
||||
pull1();
|
||||
break;
|
||||
case "afterChangeOffset"://松开可刷新状态
|
||||
pull2();
|
||||
break;
|
||||
case "dragEndAfterChangeOffset"://正在刷新状态
|
||||
list.evalJS("onRefresh();");
|
||||
pull3();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
function pull1(){
|
||||
etext.textContent="下拉可刷新";
|
||||
eicon.style.webkitTransition="all 0.3s ease-in";
|
||||
eicon.style.webkitTransform="rotate(0deg)";
|
||||
}
|
||||
function pull2(){
|
||||
etext.textContent="松开可刷新";
|
||||
eicon.style.webkitTransition="all 0.3s ease-in";
|
||||
eicon.style.webkitTransform="rotate(180deg)";
|
||||
}
|
||||
function pull3(){
|
||||
etext.textContent="正在刷新...";
|
||||
eicon.src="../img/pull_fresh.png";
|
||||
eicon.style.webkitAnimation="spin 1s infinite linear";
|
||||
}
|
||||
function pullReset(){
|
||||
etext.textContent="下拉可刷新";
|
||||
eicon.src="../img/pull_arrow.png";
|
||||
eicon.style.webkitTransition="";
|
||||
eicon.style.webkitTransform="";
|
||||
eicon.style.webkitAnimation="";
|
||||
}
|
||||
function refresh(){
|
||||
pull3();
|
||||
list.setBounce({offset:{top:"50px"}});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
#pull{
|
||||
width:24px;
|
||||
height:100%;
|
||||
display:inline-block;
|
||||
margin:0 1em;
|
||||
}
|
||||
#icon{
|
||||
height:24px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
@-webkit-keyframes spin{
|
||||
0% {
|
||||
-webkit-transform:rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform:rotate(360deg);
|
||||
}
|
||||
}
|
||||
.irefresh {
|
||||
background:no-repeat center center url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABYCAYAAAADWlKCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAAWdEVYdENyZWF0aW9uIFRpbWUAMTEvMTAvMTUgEQA0AAAEP0lEQVR4nO3aTWhcVRTA8f+NQ6ImLqsu7MLuSiOt74SOoJBYDCp0UdG1BUVdWFBR/CiCLqzaClWhLlQUiqCIHwh1EUFqRyshMudRcVRcWdBFsZCVNQzEXhcz1ZeXaTOdN9N3Jp7f7t3J3JzmD52XvBtijDg7RsoewK3kQYzxIMZ4EGM8iDEexBgPYowHMcaDGONBjPEgxngQYzyIMR7EGA9ijAcxxoMY40GM8SDGeBBjPIgxHsQYD2KMBzHGgxjjQYzxIMZUyh6gF/V6fWsIYQa4A9gCbGy/9BvwIzAXYzw2NTX1fTf7qerDIvLGQIa9SGFYDls3Go2RZrO5C9gNbAeuXeMtp4DvgMNjY2OfTU5Onu30Rar6OPC8iFzV14F7NBRBVHUHcACQXrcAnhSRo7l9HwVeBRCRUGjIPjEdpFarhYmJiX3AM33a8qXFxcW9s7OzK2KAB1mTqo4C7wN3d3h5CfgSOA6cAP5or18NbANuAW4Drujw3neBBnAwu+hBLkBVLwM+ZHWMJeC1EMLbSZL8eqE90jS9Psb4APAYcPla39NKEKt3WS+wOoaGEB5MkiTtZoN2sL2q+inwFnBjn2ccCHO/h6jqNPB0bvkYMNNtjCwRqQM30bolNs9UkIWFhQrwem45BXaKyJ8Ftn4OuKbA+y8ZU/9lVSqVncDWzNJfwG4ROdPrnqr6CvBE0dkuFVNBgPtz14dEpNHrZqp6kNaH+tAwE6Rer28OIVQzS2dCCId62UtVR4B9tGL8Ddi7lTwPM0FCCLcDGzJLR5Mk6fWD+CzwJq3Po6GJAYaCxBjvDGHFrwK1XvcSEYCTBUcqhZm7rBDC5tz1D2XNUiYzQfjvT+gAxBhPlTVImSwFcdgK8nv2IoSw1vOOdclMkBjjT7nrG8qapUxmgoQQ5nJL06UMUjIzQYA54HTmekeaphvP98XrlZkgIvIzsJBZGo8x7ilrnrKYCdL2Tu56j6pOljJJSUwFWV5e/hzIHt25EjisquNF907TdGx+ft7Uv7cTUwNWq9Vl4JHccgIcKRJFVcdjjLXR0dFPGo3GaKEhB8xUEAARqQEv55ZvBWqqmlzsfqoqtA5DVIFdzWbzC1XdVHzSwTAXpO1Z4OPcmgDHVXV/Nz9QVd2kqvuBb2idRDlnBnioX4P2m8lTJwCqWgE+AO7p8PIS8BXwdQghjTGeBgghbIgxbgdupvWD73QM6CPgvoKPhAfGbBAAVQ3Ai6w+9NCrAyLyVJ/2GgjTQc4Z1FFSi4YiCPz7WPYu4F66P2z9LfAecEREOh62tmZogmSp6jZguv2UcQtwHa1HtSeBX2j9GaYmIifKm7I3QxlkPbN62/u/5UGM8SDGeBBjPIgxHsQYD2KMBzHGgxjjQYzxIMZ4EGM8iDEexBgPYowHMcaDGONBjPEgxngQYzyIMR7EGA9ijAcxxoMY40GM8SDG/AOZAi+0sACgewAAAABJRU5ErkJggg==);
|
||||
background-size:50px 44px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background:#EAEAEA;">
|
||||
<header id="header" style="position:static">
|
||||
<div class="nvbt iback" onclick="back();"></div>
|
||||
<div class="nvtt">自定义下拉刷新</div>
|
||||
<div class="nvbt irefresh" onclick="refresh()"></div>
|
||||
</header>
|
||||
<div style="text-align:center;height:44px;line-height:44px;">
|
||||
<div id="pull"><img id="icon" src="../img/pull_arrow.png"/></div><font id="text">下拉可刷新</font>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,76 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ws=null;
|
||||
var list=null;
|
||||
// 扩展API加载完毕,现在可以正常调用扩展API
|
||||
function plusReady(){
|
||||
ws=plus.webview.currentWebview();
|
||||
ws.setPullToRefresh({support:true,
|
||||
height:"50px",
|
||||
range:"200px",
|
||||
contentdown:{
|
||||
caption:"下拉可以刷新"
|
||||
},
|
||||
contentover:{
|
||||
caption:"释放立即刷新"
|
||||
},
|
||||
contentrefresh:{
|
||||
caption:"正在刷新..."
|
||||
}
|
||||
},onRefresh);
|
||||
}
|
||||
// 判断扩展API是否准备,否则监听"plusready"事件
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// DOM构建完成获取列表元素
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
list=document.getElementById("list");
|
||||
})
|
||||
// 刷新页面
|
||||
function onRefresh(){
|
||||
setTimeout(function(){
|
||||
if(list){
|
||||
var item=document.createElement("li");
|
||||
item.innerHTML="<span>New Item "+(new Date())+"</span>";
|
||||
list.insertBefore(item,list.firstChild);
|
||||
}
|
||||
ws.endPullToRefresh();
|
||||
},1000);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
li {
|
||||
padding: 1em;
|
||||
border-bottom: 1px solid #eaeaea;
|
||||
}
|
||||
li:active {
|
||||
background: #f4f4f4;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<ul id="list" style="list-style:none;margin:0;padding:0;">
|
||||
<li><span>Initializ List Item 1</span></li>
|
||||
<li><span>Initializ List Item 2</span></li>
|
||||
<li><span>Initializ List Item 3</span></li>
|
||||
<li><span>Initializ List Item 4</span></li>
|
||||
<li><span>Initializ List Item 5</span></li>
|
||||
<li><span>Initializ List Item 6</span></li>
|
||||
<li><span>Initializ List Item 7</span></li>
|
||||
<li><span>Initializ List Item 8</span></li>
|
||||
<li><span>Initializ List Item 9</span></li>
|
||||
<li><span>Initializ List Item 10</span></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ws=null,wo=null;
|
||||
// 扩展API加载完毕,现在可以正常调用扩展API
|
||||
function plusReady(){
|
||||
// 获取自身窗口
|
||||
ws=plus.webview.currentWebview();
|
||||
wo=ws.opener();
|
||||
}
|
||||
// 判断扩展API是否准备,否则监听"plusready"事件
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener("plusready",plusReady,false);
|
||||
}
|
||||
// DOM构建完成获取列表元素
|
||||
var list=null;
|
||||
document.addEventListener("DOMContentLoaded",function(){
|
||||
list=document.getElementById("list");
|
||||
});
|
||||
// 刷新页面
|
||||
function onRefresh(){
|
||||
setTimeout(function(){
|
||||
if(list){
|
||||
var item=document.createElement("li");
|
||||
item.innerHTML="<span>New Item "+(new Date())+"</span>";
|
||||
list.insertBefore(item,list.firstChild);
|
||||
}
|
||||
ws.resetBounce();
|
||||
setTimeout(function(){
|
||||
wo.evalJS("pullReset()");
|
||||
},200);
|
||||
},1000);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
li {
|
||||
padding: 1em;
|
||||
border-bottom: 1px solid #eaeaea;
|
||||
}
|
||||
li:active {
|
||||
background: #f4f4f4;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<ul id="list" style="list-style:none;margin:0;padding:0;">
|
||||
<li><span onclick="alert('ok');">Initializ List Item 1</span></li>
|
||||
<li><span>Initializ List Item 2</span></li>
|
||||
<li><span>Initializ List Item 3</span></li>
|
||||
<li><span>Initializ List Item 4</span></li>
|
||||
<li><span>Initializ List Item 5</span></li>
|
||||
<li><span>Initializ List Item 6</span></li>
|
||||
<li><span>Initializ List Item 7</span></li>
|
||||
<li><span>Initializ List Item 8</span></li>
|
||||
<li><span>Initializ List Item 9</span></li>
|
||||
<li><span>Initializ List Item 10</span></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
var ws=null;
|
||||
var list=null;
|
||||
// 处理沉浸式状态栏
|
||||
var topoffset=0;
|
||||
var ms=(/Html5Plus\/.+\s\(.*(Immersed\/(\d+\.?\d*).*)\)/gi).exec(navigator.userAgent);
|
||||
if(ms&&ms.length>=3){
|
||||
topoffset=parseFloat(ms[2]);
|
||||
}
|
||||
// 扩展API加载完毕,现在可以正常调用扩展API
|
||||
function plusReady(){
|
||||
ws=plus.webview.currentWebview();
|
||||
if(plus.navigator.isImmersedStatusbar()){// 兼容沉浸式状态栏模式
|
||||
topoffset=Math.round(plus.navigator.getStatusbarHeight());
|
||||
}
|
||||
ws.setPullToRefresh({support:true,style:'circle',offset:topoffset+45+'px'},onRefresh);
|
||||
// 第一次打开页面即开始刷新列表
|
||||
setTimeout(function(){
|
||||
console.log('Initializ refresh');
|
||||
ws.beginPullToRefresh();
|
||||
},200);
|
||||
}
|
||||
// 判断扩展API是否准备,否则监听'plusready'事件
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready', plusReady, false);
|
||||
}
|
||||
// DOM构建完成获取列表元素
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
list=document.getElementById('list');
|
||||
var offset=document.getElementById('offset');
|
||||
offset&&(offset.style.height=topoffset+44+'px');
|
||||
});
|
||||
// 刷新页面
|
||||
function onRefresh(){
|
||||
setTimeout(function(){
|
||||
if(list){
|
||||
var item=document.createElement('li');
|
||||
item.innerHTML='<span>New Item '+(new Date())+'</span>';
|
||||
list.insertBefore(item,list.firstChild);
|
||||
}
|
||||
ws.endPullToRefresh();
|
||||
},1000);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
li {
|
||||
padding: 1em;
|
||||
border-bottom: 1px solid #eaeaea;
|
||||
}
|
||||
li:active {
|
||||
background: #f4f4f4;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">下拉刷新</div>
|
||||
</header>
|
||||
<div id='offset' style="height:44px;width:100%;"></div>
|
||||
<ul id="list" style="list-style:none;margin:0;padding:0;">
|
||||
<li><span>Initializ List Item 1</span></li>
|
||||
<li><span>Initializ List Item 2</span></li>
|
||||
<li><span>Initializ List Item 3</span></li>
|
||||
<li><span>Initializ List Item 4</span></li>
|
||||
<li><span>Initializ List Item 5</span></li>
|
||||
<li><span>Initializ List Item 6</span></li>
|
||||
<li><span>Initializ List Item 7</span></li>
|
||||
<li><span>Initializ List Item 8</span></li>
|
||||
<li><span>Initializ List Item 9</span></li>
|
||||
<li><span>Initializ List Item 10</span></li>
|
||||
</ul>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,97 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var url="http://www.dcloud.io/";
|
||||
var xhr=null;
|
||||
|
||||
function xhrCreate() {
|
||||
if ( xhr ) {
|
||||
outLine( "xhr请求已创建" );
|
||||
return;
|
||||
}
|
||||
outSet( "创建请求:" );
|
||||
xhr = new plus.net.XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
switch ( xhr.readyState ) {
|
||||
case 0:
|
||||
outLine( "xhr请求已初始化" );
|
||||
break;
|
||||
case 1:
|
||||
outLine( "xhr请求已打开" );
|
||||
break;
|
||||
case 2:
|
||||
outLine( "xhr请求已发送" );
|
||||
break;
|
||||
case 3:
|
||||
outLine( "xhr请求已响应");
|
||||
break;
|
||||
case 4:
|
||||
outLine( "xhr请求已完成");
|
||||
if ( xhr.status == 200 ) {
|
||||
outLine( "xhr请求成功:"+xhr.responseText );
|
||||
} else {
|
||||
outLine( "xhr请求失败:"+xhr.status );
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
xhr.open( "GET", url );
|
||||
xhr.send();
|
||||
}
|
||||
function xhrResponseHeader() {
|
||||
if ( xhr ) {
|
||||
if ( xhr.readyState != 4 ) {
|
||||
outLine( "xhr请求未完成" );
|
||||
} else if ( xhr.status != 200 ) {
|
||||
outSet( "xhr请求失败:"+xhr.readyState );
|
||||
} else {
|
||||
outSet( "xhr请求响应头数据:" );
|
||||
outLine( xhr.getAllResponseHeaders() );
|
||||
}
|
||||
} else {
|
||||
outSet( "未发送请求" );
|
||||
}
|
||||
}
|
||||
function xhrAbort() {
|
||||
if ( xhr ) {
|
||||
outSet( "取消请求" );
|
||||
if ( xhr.readyState != 4 ) {
|
||||
xhr.abort();
|
||||
}
|
||||
xhr = null;
|
||||
} else {
|
||||
outSet( "未发送请求" );
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">XmlHttpRequest</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('XmlHttpRequest Document','/doc/xhr.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="xhrCreate();">发送请求</li>
|
||||
<li class="ditem" onclick="xhrResponseHeader();">获取所有响应头</li>
|
||||
<li class="ditem" onclick="xhrAbort();">取消请求</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
XMLHttpRequest管理网络请求操作,可进行跨域网络数据请求。
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
@@ -0,0 +1,132 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Hello H5+</title>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script type="text/javascript">
|
||||
var zip = "_doc/zip/index.zip",
|
||||
unzip = "_doc/zip/index/";
|
||||
function doCompress(){
|
||||
plus.zip.compress( "_www/index.html", zip, function(){
|
||||
outLine( "操作成功!保存路径为:"+zip );
|
||||
}, function(e){
|
||||
outLine( "操作失败:"+e.message );
|
||||
} );
|
||||
}
|
||||
function compress(){
|
||||
outSet( "压缩文件:" );
|
||||
plus.io.resolveLocalFileSystemURL( zip, function(entry){
|
||||
outLine( "文件已存在,中止操作!" );
|
||||
plus.nativeUI.confirm( "压缩文件已存在,是否立即删除", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
entry.remove();
|
||||
}
|
||||
} );
|
||||
}, function(e){
|
||||
doCompress();
|
||||
} );
|
||||
}
|
||||
function doDecompress(){
|
||||
plus.zip.decompress( zip, unzip, function(){
|
||||
outLine( "操作成功!保存路径为:"+unzip );
|
||||
}, function(e){
|
||||
outLine( "操作失败:"+e.message );
|
||||
} );
|
||||
}
|
||||
function decompress(){
|
||||
outSet( "解压文件:" );
|
||||
plus.io.resolveLocalFileSystemURL( unzip, function(entry){
|
||||
outLine( "目录已存在,中止操作!" );
|
||||
plus.nativeUI.confirm( "解压目录已存在,是否立即删除", function(i){
|
||||
if ( i.index == 0 ) {
|
||||
entry.removeRecursively();
|
||||
}
|
||||
} );
|
||||
}, function(e){
|
||||
plus.io.resolveLocalFileSystemURL( zip, function(entry){
|
||||
doDecompress();
|
||||
}, function(e){
|
||||
plus.nativeUI.alert( "压缩文件不存在,请先压缩文件!" );
|
||||
outLine( "压缩文件不存在,中止操作!" );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
function clearZip(){
|
||||
outSet( "清空数据!" );
|
||||
plus.io.resolveLocalFileSystemURL( "_doc/zip/", function(entry){
|
||||
entry.removeRecursively();
|
||||
} );
|
||||
}
|
||||
|
||||
// 压缩图片
|
||||
function compressImage(){
|
||||
outSet("开始压缩图片:");
|
||||
plus.nativeUI.showWaiting();
|
||||
plus.zip.compressImage({
|
||||
src:"_www/img/shake/1.jpg",
|
||||
dst:"_doc/cm.jpg",
|
||||
quality:20,
|
||||
overwrite:true,
|
||||
width:'50%',
|
||||
clip:{
|
||||
top:"25%",
|
||||
left:"25%",
|
||||
width:"50%",
|
||||
height:"50%"
|
||||
}
|
||||
},
|
||||
function(i){
|
||||
plus.nativeUI.closeWaiting();
|
||||
display.style.display="block";
|
||||
clipimg.src=i.target;
|
||||
outLine("压缩图片成功:"+JSON.stringify(i));
|
||||
},function(e){
|
||||
plus.nativeUI.closeWaiting();
|
||||
outLine("压缩图片失败: "+JSON.stringify(e));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
|
||||
<style type="text/css">
|
||||
.display {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: none;
|
||||
text-align: center;
|
||||
padding-top: 30%;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
background: rgba(0,0,0,0.8);
|
||||
z-index: 9999;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="nvbt iback" onclick="back()"></div>
|
||||
<div class="nvtt">ZIP</div>
|
||||
<div class="nvbt idoc" onclick="openDoc('ZIP Document','/doc/zip.html')"></div>
|
||||
</header>
|
||||
<div id="dcontent" class="dcontent">
|
||||
<br/>
|
||||
<div class="button" onclick="compressImage()">压缩图片</div>
|
||||
<ul class="dlist">
|
||||
<li class="ditem" onclick="compress();">压缩文件</li>
|
||||
<li class="ditem" onclick="decompress();">解压文件</li>
|
||||
<li class="ditem" onclick="clearZip();">清理数据</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="output">
|
||||
Zip管理压缩文件,用于Zip文件的压缩与解压缩。
|
||||
</div>
|
||||
<div id='display' class="display" onclick="this.style.display='none';">
|
||||
<img id="clipimg" style="margin:auto;"/>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="../js/immersed.js" ></script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user