forked from iStig/JavaScriptCoreDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOSTest.html
More file actions
246 lines (187 loc) · 6.94 KB
/
IOSTest.html
File metadata and controls
246 lines (187 loc) · 6.94 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!doctype html>
<html>
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
<style type='text/css'>
html {
font-family: Helvetica;
color: #222;
}
h1 {
color: steelblue;
font-size: 24px;
margin-top: 24px;
}
button {
margin: 0 3px 10px;
font-size: 12px;
}
.logLine {
border-bottom: 1px solid #ccc;
padding: 4px 2px;
font-family: courier;
font-size: 11px;
}
</style>
</head>
<body>
<h1>JS Call</h1>
<input type="button" value="setupkeyvalue" onclick="setuplocalstoragekeyValue({'key':'a'},{'value':'b'})">
<input type="button" value="fetchvaluewithkey" onclick="fetchLocalStorageWithKey({'key':'a'})">
<input type="button" value="removevaluewithkey" onclick="removeLocalStorageWithKey({'key':'a'})">
<input type="button" value="pay" onclick="jsCallPayment({'price':'0.02'})">
<input type="button" value="Wechat Timeline" onclick="shareSDK({'ios':'0'})">
<input type="button" value="Wechat Session" onclick="shareSDK({'ios':'1'})">
<input type="button" value="QQ Friend" onclick="shareSDK({'ios':'2'})">
<input type="button" value="QQ Zone" onclick="shareSDK({'ios':'3'})">
<input type="button" value="Tencent Weibo" onclick="shareSDK({'ios':'4'})">
<input type="button" value="Call System Camera" onclick="callSystemCamera()">
<input type="button" value="Call QR Scan" onclick="callSystemQRScan()">
<input type="button" value="upload image" onclick="callWithDict({'name': 'testname', 'age': 10, 'height': 170})">
<input type="button" value="Show System Location" onclick="jsCallObjcAndObjcCallJsWithDict({'name': 'testname1', 'age': 101, 'height': 180})">
<input type="button" value="buji testshare wxpyq" onclick="bujiShareSDK({'type':'0','image':'','title':'','url':''})">
<input type="button" value="buji testshare wxhy" onclick="bujiShareSDK({'type':'1','image':'','title':'','url':''})">
<input type="button" value="buji testshare qqhy" onclick="bujiShareSDK({'type':'2','image':'','title':'','url':''})">
<input type="button" value="buji testshare qqzone" onclick="bujiShareSDK({'type':'3','image':'','title':'','url':''})">
<input type="button" value="wxlogin" onclick="thirdLogin({'tag':'0'})">
<input type="button" value="qqlogin" onclick="thirdLogin({'tag':'1'})">
<div>
<span id="jsParamFuncSpan" style="color: red; font-size: 50px;"></span>
</div>
<h1>Log List</h1>
<ul id="parentUl"></ul>
<div id='buttons'></div> <div id='log'></div>
<div>
<!-- <img id="img" src="http://huizuche.com/Content/Images/recommend/car/Jeep_Grand%20Cherokee_L.jpg" onclick="imgCallBack(this.src)" />-->
</div>
</body>
</html>
<script type="text/javascript">
var uploadimage = function(argument) {
addElementImg(argument['image']);
//alert("update image completed.");
}
var jsFunc = function(argument) {
log(argument['scan']);
}
var paysuccess = function(argument) {
log(argument['paysuccess']);
}
var jsParamFunc = function(argument) {
log(argument['latitude']);
log(argument['longitude']);
}
function shareSDK(argument) {
log("share");
window.MobilePhoneCall.shareSDK(argument);
}
function thirdLogin(argument) {
log("thirdLogin");
window.MobilePhoneCall.thirdLogin(argument);
}
function bujiShareSDK(argument) {
log("bujiShareSDK");
window.MobilePhoneCall.bujiShareSDK(argument);
}
//app端callback callSystemQRScan()
function callSystemQRScan() {
log("call system qr scan");
window.MobilePhoneCall.callSystemQRScan();
}
function test() {
log("test");
}
//app端callback callSystemCamera()
function callSystemCamera() {
log("call system camera");
window.MobilePhoneCall.callSystemCamera();
}
//app端callback showAlertMsg()
function showAlertMsg(a,b) {
log(JSON.stringify(a));
log(JSON.stringify(b));
window.MobilePhoneCall.showAlertMsg(a,b);
}
function setuplocalstoragekeyValue(a,b){
window.MobilePhoneCall.setuplocalstoragekeyValue(a,b);
}
function fetchLocalStorageWithKey(a){
log(window.MobilePhoneCall.fetchLocalStorageWithKey(a));
}
function removeLocalStorageWithKey(a) {
window.MobilePhoneCall.removeLocalStorageWithKey(a);
}
//app端callback callWithDict()
function callWithDict(a) {
log(JSON.stringify(a));
window.MobilePhoneCall.callWithDict(a);
}
//app端callback jsCallObjcAndObjcCallJsWithDict()
function jsCallObjcAndObjcCallJsWithDict(a) {
<!-- log(JSON.stringify(a));-->
window.MobilePhoneCall.jsCallObjcAndObjcCallJsWithDict(a);
}
window.setTimeout(jsCallObjcAndObjcCallJsWithDict, 1000);
function jsCallPayment(a) {
log(JSON.stringify(a));
window.MobilePhoneCall.jsCallPayment(a);
}
function AutoResizeImage(maxWidth,maxHeight,objImg){
var img = new Image();
img.src = objImg.src;
var hRatio;
var wRatio;
var Ratio = 1;
var w = img.width;
var h = img.height;
wRatio = maxWidth / w;
hRatio = maxHeight / h;
if (maxWidth ==0 && maxHeight==0){
Ratio = 1;
}else if (maxWidth==0){//
if (hRatio<1) Ratio = hRatio;
}else if (maxHeight==0){
if (wRatio<1) Ratio = wRatio;
}else if (wRatio<1 || hRatio<1){
Ratio = (wRatio<=hRatio?wRatio:hRatio);
}
if (Ratio<1){
w = w * Ratio;
h = h * Ratio;
}
objImg.height = h;
objImg.width = w;
}
function addElementImg(objImg) {
var ul = document.getElementById("parentUl");
var li = document.createElement("li");
var img = document.createElement("img");
img.setAttribute("id", "newImg");
img.src = objImg;
li.appendChild(img);
ul.appendChild(li);
}
function imgCallBack(src) {
log("click img");
log(JSON.stringify(src));
if (window.MobilePhoneCall) {
log("called>>>>>");
log(window.MobilePhoneCall.imgCallBack('http://huizuche.com/Content/Images/recommend/car/Jeep_Grand%20Cherokee_L.jpg'));
}
else {
alert("window.MobilePhoneCall is nil");
}
}
var uniqueId = 1;
function log(message, data) {
var logContainner = document.getElementById('log');
var el = document.createElement('div');
el.className = 'logLine';
el.innerHTML = uniqueId++ + '. ' + message + (data?(':<br/>' + JSON.stringify(data)):"");
if (logContainner.children && logContainner.children.length) { logContainner.insertBefore(el, logContainner.children[0]); }
else { logContainner.appendChild(el); }
}
window.onerror = function (err) {
log('window.onerror: ' + err);
}
</script>