-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
175 lines (164 loc) · 4.86 KB
/
index.html
File metadata and controls
175 lines (164 loc) · 4.86 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Mediafuse Prebid Multi-Format Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
font-family: Arial, sans-serif;
padding: 40px;
background: #f5f5f5;
}
h2 { margin-top: 40px; }
.slot {
border: 2px dashed #999;
background: #fff;
padding: 10px;
margin-bottom: 30px;
position: relative;
}
#banner { width: 300px; height: 250px; }
#video { width: 640px; height: 360px; }
#native { width: 300px; }
.error { border-color: #d32f2f; color: #d32f2f; }
</style>
</head>
<body>
<h1>Mediafuse Prebid Multi-Format Test</h1>
<h2>Banner Test</h2>
<div id="banner" class="slot"></div>
<h2>Video Test (Instream)</h2>
<div id="video" class="slot"></div>
<h2>Native Test</h2>
<div id="native" class="slot"></div>
<script src="./prebid-new-adapter-n2.js"></script>
<!-- <script src="./prebid-n5.js"></script> -->
<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function () {
console.log("Prebid version:", pbjs.version);
pbjs.setConfig({
debug: true,
useSrcdoc: false
});
pbjs.addAdUnits([
/* ================= BANNER ================= */
{
code: 'banner',
mediaTypes: {
banner: { sizes: [[300, 250]] }
},
bids: [{
bidder: 'mediafuse',
params: { placementId: '37151837' }
}]
},
/* ================= VIDEO ================= */
{
code: 'video',
mediaTypes: {
video: {
context: 'instream',
playerSize: [640, 360],
mimes: ['video/mp4'],
protocols: [2,3,5,6],
api: [2],
playbackmethod: [1]
}
},
bids: [{
bidder: 'mediafuse',
params: { placementId: '37151841' }
}]
},
/* ================= NATIVE ================= */
{
code: 'native',
mediaTypes: {
native: {
title: { required: true, len: 80 },
image: { required: true, sizes: [150, 150] },
sponsoredBy: { required: true }
}
},
bids: [{
bidder: 'mediafuse',
params: { placementId: '37151838' }
}]
}
]);
pbjs.requestBids({
timeout: 3000,
bidsBackHandler: renderAds
});
});
function renderAds() {
/* ================= BANNER ================= New*/
var bannerResp = pbjs.getBidResponsesForAdUnitCode('banner');
if (bannerResp && bannerResp.bids.length) {
var bid = bannerResp.bids[0];
console.log("Banner bid:", bid);
var bannerContainer = document.getElementById('banner');
bannerContainer.innerHTML = '';
var iframe = document.createElement('iframe');
iframe.width = bid.width || 300;
iframe.height = bid.height || 250;
iframe.style.border = "0";
iframe.setAttribute("scrolling", "no");
bannerContainer.appendChild(iframe);
var doc = iframe.contentWindow.document;
doc.open();
doc.write(bid.ad);
doc.close();
} else {
document.getElementById('banner').innerHTML = "No banner bid";
document.getElementById('banner').classList.add("error");
}
/* ================= VIDEO ================= */
var videoResp = pbjs.getBidResponsesForAdUnitCode('video');
if (videoResp && videoResp.bids.length) {
var bid = videoResp.bids[0];
console.log("Video bid:", bid);
if (bid.vastUrl) {
document.getElementById('video').innerHTML =
"<iframe width='640' height='360' frameborder='0' " +
"src='" + bid.vastUrl + "' allow='autoplay'></iframe>";
}
else if (bid.vastXml) {
document.getElementById('video').innerHTML =
"<pre style='font-size:10px;overflow:auto'>" +
bid.vastXml.replace(/</g,"<") +
"</pre>";
}
else {
document.getElementById('video').innerHTML = "Video bid returned but no VAST";
}
} else {
document.getElementById('video').innerHTML = "No video bid";
document.getElementById('video').classList.add("error");
}
/* ================= NATIVE ================= */
var nativeResp = pbjs.getBidResponsesForAdUnitCode('native');
if (nativeResp && nativeResp.bids.length) {
var bid = nativeResp.bids[0];
console.log("Native bid:", bid);
if (bid.native) {
var n = bid.native;
document.getElementById('native').innerHTML =
"<h3>" + n.title + "</h3>" +
"<img src='" + n.image.url + "' width='150'><br>" +
"<p><strong>" + n.sponsoredBy + "</strong></p>" +
"<a href='" + n.clickUrl + "' target='_blank'>Learn More</a>";
} else {
document.getElementById('native').innerHTML = "Native object missing";
}
} else {
document.getElementById('native').innerHTML = "No native bid";
document.getElementById('native').classList.add("error");
}
}
</script>
</body>
</html>