Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mui
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mui
Commits
aa80b5e5
Commit
aa80b5e5
authored
Aug 07, 2015
by
hbcui1984
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加网络判断
parent
fd7967f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
51 deletions
+77
-51
examples/hello-mui/examples/ad.html
examples/hello-mui/examples/ad.html
+49
-42
examples/hello-mui/examples/ajax.html
examples/hello-mui/examples/ajax.html
+15
-1
examples/hello-mui/examples/clouddb_wilddog.html
examples/hello-mui/examples/clouddb_wilddog.html
+13
-8
No files found.
examples/hello-mui/examples/ad.html
View file @
aa80b5e5
...
@@ -26,51 +26,58 @@
...
@@ -26,51 +26,58 @@
</body>
</body>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
mui
.
plusReady
(
function
()
{
mui
.
plusReady
(
function
()
{
//屏幕真实宽度
if
(
plus
.
networkinfo
.
getCurrentType
()
==
plus
.
networkinfo
.
CONNECTION_NONE
){
var
width
=
window
.
innerWidth
;
mui
.
toast
(
"
当前网络不给力,无法加载广告
"
);
var
height
=
window
.
innerHeight
;
//根据投放广告的比例,计算广告高度
var
adHeight
=
parseInt
(
width
)
*
3
/
20
;
//广告投放域名地址
var
ltu
=
encodeURIComponent
(
'
http://www.dcloud.io/ad/
'
);
//投放广告的服务端页面标题
var
title
=
encodeURIComponent
(
'
DCloud HBuilder-做最好的HTML5开发工具||MUI-最接近原生体验的高性能前端框架
'
);
var
url
=
'
http://pos.baidu.com/acom?adn=1&at=97&aurl=&cad=1&ccd=24&cec=UTF-8&cfv=18&ch=0&col=en-US&conOP=0&cpa=1&dai=1&dis=0<r=&lunum=6&n=99099160_cpr&pis=10000x10000&ps=0x0&qn=31f2f2a7de233256&rad=&rsi5=4&rss0=&rss1=&rss2=&rss3=&rss4=&rss5=&rss6=&rss7=&scale=20.3&skin=mobile_skin_white_blue&td_id=2206321&tn=template_inlay_all_mobile&tpr=1436841400149&ts=1&xuanting=0&tt=1436841400136.14.87.89&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&wt=1&distp=1001
'
;
url
+=
'
&conW=
'
+
width
+
'
&conH=
'
+
adHeight
+
'
<u=
'
+
ltu
;
url
+=
'
&di=u2206321
'
;
//广告id
url
+=
'
&pcs=
'
+
width
+
'
x
'
+
height
;
url
+=
'
&psr=
'
+
width
+
'
x
'
+
height
;
url
+=
'
&pss=
'
+
width
+
'
x0
'
;
url
+=
'
&rsi0=
'
+
width
+
'
&rsi1=
'
+
adHeight
;
url
+=
'
&ti=
'
+
title
;
var
adBottom
=
mui
.
os
.
ios
?(
'
-
'
+
adHeight
+
'
px
'
):
'
0
'
;
var
ad
=
plus
.
webview
.
create
(
url
,
'
ad
'
,{
height
:
adHeight
+
'
px
'
,
bottom
:
adBottom
});
//目前Android平台不支持子webview的setStyle动画,因此分平台处理;
if
(
mui
.
os
.
ios
){
//为了支持iOS平台左侧边缘滑动关闭页面,需要append进去;
plus
.
webview
.
currentWebview
().
append
(
ad
);
ad
.
addEventListener
(
'
loaded
'
,
function
()
{
ad
.
setStyle
({
bottom
:
'
0
'
,
transition
:
{
duration
:
150
}
});
});
}
else
{
}
else
{
ad
.
addEventListener
(
'
loaded
'
,
function
()
{
//屏幕真实宽度
ad
.
show
(
'
slide-in-bottom
'
);
var
width
=
window
.
innerWidth
;
});
var
height
=
window
.
innerHeight
;
//根据投放广告的比例,计算广告高度
var
adHeight
=
parseInt
(
width
)
*
3
/
20
;
//广告投放域名地址
var
ltu
=
encodeURIComponent
(
'
http://www.dcloud.io/ad/
'
);
//投放广告的服务端页面标题
var
title
=
encodeURIComponent
(
'
DCloud HBuilder-做最好的HTML5开发工具||MUI-最接近原生体验的高性能前端框架
'
);
var
url
=
'
http://pos.baidu.com/acom?adn=1&at=97&aurl=&cad=1&ccd=24&cec=UTF-8&cfv=18&ch=0&col=en-US&conOP=0&cpa=1&dai=1&dis=0<r=&lunum=6&n=99099160_cpr&pis=10000x10000&ps=0x0&qn=31f2f2a7de233256&rad=&rsi5=4&rss0=&rss1=&rss2=&rss3=&rss4=&rss5=&rss6=&rss7=&scale=20.3&skin=mobile_skin_white_blue&td_id=2206321&tn=template_inlay_all_mobile&tpr=1436841400149&ts=1&xuanting=0&tt=1436841400136.14.87.89&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&wt=1&distp=1001
'
;
url
+=
'
&conW=
'
+
width
+
'
&conH=
'
+
adHeight
+
'
<u=
'
+
ltu
;
url
+=
'
&di=u2206321
'
;
//广告id
url
+=
'
&pcs=
'
+
width
+
'
x
'
+
height
;
url
+=
'
&psr=
'
+
width
+
'
x
'
+
height
;
url
+=
'
&pss=
'
+
width
+
'
x0
'
;
url
+=
'
&rsi0=
'
+
width
+
'
&rsi1=
'
+
adHeight
;
url
+=
'
&ti=
'
+
title
;
var
adBottom
=
mui
.
os
.
ios
?(
'
-
'
+
adHeight
+
'
px
'
):
'
0
'
;
var
ad
=
plus
.
webview
.
create
(
url
,
'
ad
'
,{
height
:
adHeight
+
'
px
'
,
bottom
:
adBottom
});
//目前Android平台不支持子webview的setStyle动画,因此分平台处理;
if
(
mui
.
os
.
ios
){
//为了支持iOS平台左侧边缘滑动关闭页面,需要append进去;
plus
.
webview
.
currentWebview
().
append
(
ad
);
ad
.
addEventListener
(
'
loaded
'
,
function
()
{
ad
.
setStyle
({
bottom
:
'
0
'
,
transition
:
{
duration
:
150
}
});
});
}
else
{
ad
.
addEventListener
(
'
loaded
'
,
function
()
{
ad
.
show
(
'
slide-in-bottom
'
);
});
}
ad
.
appendJsFile
(
'
_www/js/ad.js
'
);
//设置主页面的底部留白,否则会被遮住;
document
.
querySelector
(
'
.mui-content
'
).
style
.
paddingBottom
=
adHeight
+
'
px
'
;
}
}
ad
.
appendJsFile
(
'
_www/js/ad.js
'
);
//设置主页面的底部留白,否则会被遮住;
document
.
querySelector
(
'
.mui-content
'
).
style
.
paddingBottom
=
adHeight
+
'
px
'
;
});
});
</script>
</script>
...
...
examples/hello-mui/examples/ajax.html
View file @
aa80b5e5
...
@@ -71,6 +71,16 @@
...
@@ -71,6 +71,16 @@
$
.
init
({
$
.
init
({
swipeBack
:
true
//启用右滑关闭功能
swipeBack
:
true
//启用右滑关闭功能
});
});
var
network
=
true
;
if
(
mui
.
os
.
plus
){
mui
.
plusReady
(
function
()
{
if
(
plus
.
networkinfo
.
getCurrentType
()
==
plus
.
networkinfo
.
CONNECTION_NONE
){
network
=
false
;
}
});
}
var
methodEl
=
document
.
getElementById
(
"
method
"
);
var
methodEl
=
document
.
getElementById
(
"
method
"
);
var
dataTypeEl
=
document
.
getElementById
(
"
dataType
"
);
var
dataTypeEl
=
document
.
getElementById
(
"
dataType
"
);
var
respnoseEl
=
document
.
getElementById
(
"
response
"
);
var
respnoseEl
=
document
.
getElementById
(
"
response
"
);
...
@@ -121,7 +131,11 @@
...
@@ -121,7 +131,11 @@
};
};
//发送请求按钮的点击事件
//发送请求按钮的点击事件
document
.
getElementById
(
"
confirm
"
).
addEventListener
(
'
tap
'
,
function
()
{
document
.
getElementById
(
"
confirm
"
).
addEventListener
(
'
tap
'
,
function
()
{
ajax
();
if
(
network
){
ajax
();
}
else
{
mui
.
toast
(
"
当前网络不给力,请稍后再试
"
);
}
});
});
//点击描述中链接时,打开对应网页介绍;
//点击描述中链接时,打开对应网页介绍;
$
(
'
body
'
).
on
(
'
tap
'
,
'
a
'
,
function
(
e
)
{
$
(
'
body
'
).
on
(
'
tap
'
,
'
a
'
,
function
(
e
)
{
...
...
examples/hello-mui/examples/clouddb_wilddog.html
View file @
aa80b5e5
...
@@ -106,13 +106,18 @@
...
@@ -106,13 +106,18 @@
</div>
</div>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
var
ref
=
new
Wilddog
(
"
https://muidemo.wilddogio.com/demo
"
);
var
network
=
false
;
if
(
!
ref
){
var
ref
=
null
;
mui
.
toast
(
"
当前网络不给力,请稍后再试
"
);
mui
.
plusReady
(
function
()
{
}
else
{
if
(
plus
.
networkinfo
.
getCurrentType
()
==
plus
.
networkinfo
.
CONNECTION_NONE
){
//dom ready之后就可以直接获取数据了
mui
.
toast
(
"
当前网络不给力,无法连接云端数据库~
"
);
mui
.
ready
(
getList
);
}
else
{
}
network
=
true
;
ref
=
new
Wilddog
(
"
https://muidemo.wilddogio.com/demo
"
);
getList
();
}
});
var
list
=
document
.
getElementById
(
"
list
"
);
var
list
=
document
.
getElementById
(
"
list
"
);
var
col1
=
document
.
getElementById
(
"
col1
"
);
var
col1
=
document
.
getElementById
(
"
col1
"
);
var
col2
=
document
.
getElementById
(
"
col2
"
);
var
col2
=
document
.
getElementById
(
"
col2
"
);
...
@@ -124,7 +129,7 @@
...
@@ -124,7 +129,7 @@
var
title
=
document
.
getElementById
(
"
title
"
);
var
title
=
document
.
getElementById
(
"
title
"
);
document
.
getElementById
(
"
open
"
).
addEventListener
(
'
tap
'
,
function
()
{
document
.
getElementById
(
"
open
"
).
addEventListener
(
'
tap
'
,
function
()
{
if
(
!
ref
){
if
(
!
network
){
mui
.
toast
(
"
当前网络不给力,请稍后再试
"
);
mui
.
toast
(
"
当前网络不给力,请稍后再试
"
);
}
else
{
}
else
{
//清空数据
//清空数据
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment