-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
113 lines (107 loc) · 3.39 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title></title>
<script type="text/javascript">
loadTimeout = null;
wChat = null;
document.addEventListener('plusready', function(){
//console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。"
var ws = plus.webview.open('http://eloli.moe/','eloli');
// ws.setJsFile('js/a.js');
ws.setPullToRefresh({
support:true,
height:"50px",
range:"200px",
contentdown:{
caption:"下拉可以刷新"
},
contentover:{
caption:"释放立即刷新"
},
contentrefresh:{
caption:"正在刷新..."
}
},function(){
ws.reload();
});
var time = new Date().getTime();
plus.key.addEventListener("backbutton",function(){
if(wChat != null){
wChat.close();
wChat = null;
return;
}
var canBack = true;
ws.canBack(function(e){canBack=e.canBack;});
if((!canBack)||ws.getURL()=="http://eloli.moe/m/"){
if(new Date().getTime()-time<800){
ws.close();
plus.runtime.quit();
}else{
plus.nativeUI.toast("再按一次退出应用");
time = new Date().getTime();
}
}else{
ws.back();
}
});
ws.addEventListener("loading",function(){
ws.setStyle({mask:'rgba(0,0,0,0.3)'});
plus.nativeUI.showWaiting("loading...",{back:"transmit",background:"rgba(0,0,0,0.3)"});
//TODO:超时
loadTimeout = setTimeout(function(){
ws.endPullToRefresh();
ws.setStyle({mask:'none'});
plus.nativeUI.closeWaiting();
plus.nativeUI.toast("加载超时!请检查网络或稍后再试");
},60000);
});
ws.addEventListener("loaded",function(){
clearTimeout(loadTimeout);
ws.endPullToRefresh();
ws.setStyle({mask:'none'});
plus.nativeUI.closeWaiting();
});
ws.overrideUrlLoading({mode:"reject",match:"http://chat.eloli.moe/"},function(e){
var styles = {};
if(!plus.webview.defaultHardwareAccelerated()&&parseInt(plus.os.version)>=5){
styles.hardwareAccelerated=true;
}
wChat = plus.webview.open("http://chat.eloli.moe/",'chat',styles);
wChat.setStyle({'zindex':10});
wChat.setPullToRefresh({
support:true,
height:"50px",
range:"200px",
contentdown:{
caption:"下拉可以打开或关闭软键盘"
},
contentover:{
caption:"释放立即打开或关闭软键盘"
},
contentrefresh:{
caption:"..."
}
},function(){
var Context = plus.android.importClass("android.content.Context");
var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
var main = plus.android.runtimeMainActivity();
var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0,InputMethodManager.SHOW_FORCED);
});
var Context = plus.android.importClass("android.content.Context");
var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");
var main = plus.android.runtimeMainActivity();
var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0,InputMethodManager.SHOW_FORCED);
wChat.reload(false);
});
});
</script>
</head>
<body>
</body>
</html>