-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
193 lines (178 loc) · 5.98 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport"
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'">
<title>Hello World</title>
<script type="text/javascript" src="cordova.js"></script>
<style type="text/css">
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background-color: gray;
color: white;
}
div#fullpage {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
border: 0px solid red;
text-align: center;
vertical-align: middle;
}
button {
font-size: 18px;
}
</style>
</head>
<body onload="onLoad()" onresize="onResize()">
<script>
function onLoad() {
if ((/(ipad|iphone|ipod|android)/i.test(navigator.userAgent))) {
document.addEventListener('deviceready', initApp, false);
} else {
initApp();
}
}
var ad_units = {
ios : "3b7e06658db07c264f841f65a60eaf94",
android : "95a375ad3c575e2289a8ed095bc4fe73"
};
// select the right Ad Id according to platform
var publisherId = (/(android)/i.test(navigator.userAgent)) ? ad_units.android : ad_units.ios;
function initApp() {
if (! MobFox) {
alert('MobFox plugin not ready');
return;
}
registerAdEvents();
MobFox.setOptions({
// adId: publisherId,
isTesting: true,
// width: integer,
// height: integer,
position : MobFox.AD_POSITION.BOTTOM_CENTER,
// x: integer, // valid when set position to 0 / POS_XY
// y: integer, // valid when set position to 0 / POS_XY
// autoShow: true // auto show interstitial ad when loaded, set to false if prepare/show
});
createSelectedBanner();
}
// optional, in case respond to events or handle error
function registerAdEvents() {
document.addEventListener('onAdFailLoad', function(data){
alert('error: ' + data.error +
', reason: ' + data.reason +
', adNetwork:' + data.adNetwork +
', adType:' + data.adType +
', adEvent:' + data.adEvent); // adType: 'banner' or 'interstitial'
});
document.addEventListener('onAdLoaded', function(data){});
document.addEventListener('onAdPresent', function(data){});
document.addEventListener('onAdLeaveApp', function(data){});
document.addEventListener('onAdDismiss', function(data){});
}
// click button to call following functions
function getSelectedAdSize() {
var i = document.getElementById("adSize").selectedIndex;
var items = document.getElementById("adSize").options;
return items[i].value;
}
function getSelectedPosition() {
var i = document.getElementById("adPosition").selectedIndex;
var items = document.getElementById("adPosition").options;
return parseInt(items[i].value);
}
function createSelectedBanner() {
var overlap = document.getElementById('overlap').checked;
MobFox.createBanner({
adId : publisherId,
overlap : overlap,
adSize : getSelectedAdSize(),
position : getSelectedPosition()
});
}
function createBannerOfGivenSize() {
var w = document.getElementById('w').value;
var h = document.getElementById('h').value;
MobFox.createBanner({
adId : publisherId,
width : w,
height : h,
position : getSelectedPosition()
});
}
function showBannerAtSelectedPosition() {
MobFox.showBanner(getSelectedPosition());
}
function showBannerAtGivenXY() {
var x = document.getElementById('x').value;
var y = document.getElementById('y').value;
MobFox.showBannerAtXY(x, y);
}
function prepareInterstitial() {
var autoshow = document.getElementById('autoshow').checked;
var enablevideo = document.getElementById('enablevideo').checked;
MobFox.prepareInterstitial({
adId : publisherId,
enableVideo : enablevideo,
autoShow : autoshow
});
}
function onResize() {
var s = document.getElementById('sizeinfo');
s.innerHTML = "web view: " + window.innerWidth + " x "
+ window.innerHeight;
}
</script>
<div id="fullpage">
<p>Demo for MobFox Plugin</p>
Banner<br /> Standard: <select id="adSize">
<option value='SMART_BANNER'>SMART_BANNER</option>
<option value='BANNER'>BANNER</option>
<option value='MEDIUM_RECTANGLE'>MEDIUM_RECTANGLE</option>
<option value='FULL_BANNER'>FULL_BANNER</option>
<option value='LEADERBOARD'>LEADERBOARD</option>
<option value='SKYSCRAPER'>SKYSCRAPER</option>
</select><br /> <input type='checkbox' id='overlap' />overlap
<button onclick="createSelectedBanner();">create</button>
<br /> Custom Size: (<input id='w' type='text' size=3 /> x <input
id='h' type='text' size=3>)
<button onclick="createBannerOfGivenSize();">create</button>
<br />
<button onclick="MobFox.removeBanner();">remove banner</button>
<hr />
<select id="adPosition">
<option value='1'>Top Left</option>
<option value='2'>Top Center</option>
<option value='3'>Top Right</option>
<option value='4'>Left</option>
<option value='5'>Center</option>
<option value='6'>Right</option>
<option value='7'>Bottom Left</option>
<option value='8' selected>Bottom Center</option>
<option value='9'>Bottom Right</option>
</select>
<button onclick="showBannerAtSelectedPosition();">show</button>
<br /> (<input id='x' type='text' size=3 />,<input id='y'
type='text' size=3>)
<button onclick="showBannerAtGivenXY();">show At XY</button>
<br />
<button onclick="MobFox.hideBanner();">hide banner</button>
<hr />
<p>Interstitial</p>
<input type='checkbox' id='autoshow' checked />auto show when ready<br />
<input type='checkbox' id='enablevideo' checked />enable video<br />
<button onclick="prepareInterstitial();">Prepare</button>
<button onclick="MobFox.showInterstitial();">Show</button>
<div id='sizeinfo'></div>
</div>
</body>
</html>