-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.html
239 lines (224 loc) · 8.88 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
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
<!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>
<script type="text/javascript" src="jquery-1.9.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 : '2DYY249X5G798HMF3MTH',
android : 'G56KN4J49YT66CFRD5K6'
};
var adid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.ios;
function initApp() {
if (! FlurryAds ) { alert( 'flurry ads plugin not ready' ); return; }
initAd();
// display the banner at startup
createSelectedBanner();
}
function initAd(){
var defaultOptions = {
// adSize: 'SMART_BANNER',
// width: integer, // valid when set adSize 'CUSTOM'
// height: integer, // valid when set adSize 'CUSTOM'
position: FlurryAds.AD_POSITION.BOTTOM_CENTER,
// x: integer, // valid when set position to 0 / POS_XY
// y: integer, // valid when set position to 0 / POS_XY
isTesting: true, // set to true, to receiving test ad for testing purpose
// autoShow: true // auto show interstitial ad when loaded, set to false if prepare/show
};
FlurryAds.setOptions( defaultOptions );
registerAdEvents();
}
var nativeId = null;
function updateClickArea(){
if (nativeId != null) {
// change the click area
var offset = $("#nativead").offset();
var y = offset.top - $(window).scrollTop();
var x = offset.left - $(window).scrollLeft();
var w = $("#nativead").width();
var h = $("#nativead").height();
FlurryAds.setNativeAdClickArea(nativeId, x, y, w, h);
}
}
$(window).scroll(function(){
updateClickArea();
});
// optional, in case respond to events or handle error
function registerAdEvents() {
// new events, with variable to differentiate: adNetwork, adType, adEvent
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){
if (data.adType == "native") {
var adRes = data.adRes;
//alert( JSON.stringify(adRes) );
// show ad
nativeId = data.adId;
var nativeAdContent = adRes.headline
+ '<br/>summary:'
+ adRes.summary
+ "<br/>source: "
+ adRes.source
+ "<br/>";
if(adRes.secBrandingLogo) {
nativeAdContent += "<img src='" + adRes.secBrandingLogo.url + "' width='" + adRes.secBrandingLogo.width + "' height='" + adRes.secBrandingLogo.height + "'/><br/>";
}
if(adRes.secHqBrandingLogo) {
nativeAdContent += "<img src='" + adRes.secHqBrandingLogo.url + "' width='" + adRes.secHqBrandingLogo.width + "' height='" + adRes.secHqBrandingLogo.height + "'/><br/>";
}
/* if(adRes.secOrigImg) {
nativeAdContent += "<img src='" + adRes.secOrigImg.url + "' width='" + adRes.secOrigImg.width + "' height='" + adRes.secOrigImg.height + "'/><br/>";
}
if(adRes.secHqImage) {
nativeAdContent += "<img src='" + adRes.secHqImage.url + "' width='" + adRes.secHqImage.width + "' height='" + adRes.secHqImage.height + "'/><br/>";
}
*/
if(adRes.secImage) {
nativeAdContent += "<img src='" + adRes.secImage.url + "' width='" + adRes.secImage.width + "' height='" + adRes.secImage.height + "'/><br/>";
}
$('#nativead').html(nativeAdContent);
updateClickArea();
}
});
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;
FlurryAds.createBanner( {adId:adid, overlap:overlap, adSize: getSelectedAdSize(), position:getSelectedPosition()} );
}
function createBannerOfGivenSize() {
var w = document.getElementById('w').value;
var h = document.getElementById('h').value;
FlurryAds.createBanner( {adId:adid,
adSize:'CUSTOM', width:w, height:h,
position:getSelectedPosition()} );
}
function showBannerAtSelectedPosition() {
FlurryAds.showBanner( getSelectedPosition() );
}
function showBannerAtGivenXY() {
var x = document.getElementById('x').value;
var y = document.getElementById('y').value;
FlurryAds.showBannerAtXY(x, y);
}
function prepareInterstitial() {
var autoshow = document.getElementById('autoshow').checked;
FlurryAds.prepareInterstitial({adId:adid, autoShow:autoshow});
}
function onResize(){
var s = document.getElementById('sizeinfo');
s.innerHTML = "web view: " + window.innerWidth + " x " + window.innerHeight;
}
function createNativeAd() {
FlurryAds.createNativeAd(adid);
}
function removeNativeAd() {
$('#nativead').html("<br/>");
FlurryAds.removeNativeAd(nativeId);
}
</script>
<div id="fullpage">
<p>Demo for FlurryAds 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="FlurryAds.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="FlurryAds.hideBanner();">hide banner</button>
<hr />
<p>Interstitial</p>
<input type='checkbox' id='autoshow' checked />auto show when ready<br />
<button onclick="prepareInterstitial();">Prepare</button>
<button onclick="FlurryAds.showInterstitial();">Show</button>
<div id='sizeinfo'></div>
<hr />
<p>Native Ad</p>
<div id='nativead' style="border:1pt solid red;width:300;"><br/></div>
<button onclick="createNativeAd();">Create</button>
<button onclick="removeNativeAd();">Remove</button>
</div>
</body>
</html>