-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
7,182 additions
and
2,869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<html> | ||
<head> | ||
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script> | ||
<script async src="../../build/dev/prebid.js"></script> | ||
<script> | ||
var FAILSAFE_TIMEOUT = 3000; | ||
|
||
var adUnits = [ | ||
{ | ||
code: 'div-gpt-ad-1683695049516-0', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[320, 320]] | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'adnuntius', | ||
params: { | ||
auId: "201208", | ||
network: "adnuntius", | ||
bidType: 'netBid' | ||
} | ||
}] | ||
}, | ||
]; | ||
var googletag = googletag || {}; | ||
googletag.cmd = googletag.cmd || []; | ||
googletag.cmd.push(function() { | ||
googletag.pubads().disableInitialLoad(); | ||
}); | ||
|
||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
pbjs.que.push(function() { | ||
pbjs.setConfig({ | ||
enableSendAllBids: true, | ||
targetingControls: { | ||
alwaysIncludeDeals: true | ||
}, | ||
userSync: { | ||
syncEnabled: false | ||
} | ||
}); | ||
|
||
pbjs.setBidderConfig({ | ||
bidders: ['adnuntius'], | ||
config: { | ||
bidType: 'netBid' | ||
} | ||
}); | ||
|
||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({bidsBackHandler: initAdserver}); | ||
}); | ||
|
||
function initAdserver() { | ||
if (pbjs.initAdserverSet) return; | ||
pbjs.initAdserverSet = true; | ||
googletag.cmd.push(function() { | ||
pbjs.que.push(function() { | ||
pbjs.setTargetingForGPTAsync('div-gpt-ad-1683695049516-0'); | ||
googletag.pubads().refresh(); | ||
}); | ||
}); | ||
} | ||
|
||
// in case PBJS doesn't load | ||
setTimeout(function() { | ||
initAdserver(); | ||
}, FAILSAFE_TIMEOUT); | ||
|
||
window.googletag = window.googletag || {cmd: []}; | ||
googletag.cmd.push(function() { | ||
googletag.defineSlot('/19660636/320x320', [320, 320], 'div-gpt-ad-1683695049516-0').addService(googletag.pubads()); | ||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h2>Adnuntius Prebid Adaptor Test</h2> | ||
<h5>Ad Slot 1</h5> | ||
|
||
<!-- /19660636/320x320 --> | ||
<div id='div-gpt-ad-1683695049516-0' style='min-width: 320px; min-height: 320px;'> | ||
<script> | ||
googletag.cmd.push(function() { | ||
googletag.display('div-gpt-ad-1683695049516-0'); | ||
}); | ||
</script> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
<html> | ||
|
||
<head> | ||
<script type="text/javascript" src="../../build/dev/prebid.js" async></script> | ||
|
||
<script> | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
pbjs.que.push(function () { | ||
const adUnits = [{ | ||
code: 'native-div', | ||
mediaTypes: { | ||
native: { | ||
adTemplate: document.getElementById('native-template').innerHTML, | ||
title: { | ||
required: true, | ||
len: 800 | ||
}, | ||
image: { | ||
required: true, | ||
sizes: [989, 742], | ||
}, | ||
sponsoredBy: { | ||
required: true | ||
} | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'appnexus', | ||
params: { | ||
placementId: 13232354, | ||
allowSmallerSizes: true | ||
} | ||
|
||
}] | ||
}]; | ||
|
||
pbjs.setConfig({ | ||
debug: true, | ||
s2sConfig: { | ||
accountId: '1', | ||
enabled: true, | ||
bidders: ['appnexuspsp'], | ||
timeout: 1000, | ||
adapter: 'prebidServer', | ||
endpoint: 'https://ib.adnxs.com/openrtb2/prebid', | ||
} | ||
}); | ||
|
||
pbjs.requestBids({ | ||
adUnits, | ||
bidsBackHandler: function (bidResponses) { | ||
Object.entries(bidResponses).forEach(([slot, {bids}]) => { | ||
bids?.length && renderNative(slot, bids[0]); | ||
}); | ||
} | ||
}); | ||
|
||
function renderNative(divId, bid) { | ||
const slot = document.getElementById(divId); | ||
const content = ` | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/native-render.js"> <\/script> | ||
<script> | ||
window.pbNativeData = { | ||
pubUrl: '${encodeURI(document.location)}', | ||
adId: '${bid.adId}', | ||
requestAllAssets: true | ||
}; | ||
pbNativeTag.renderNativeAd(pbNativeData); | ||
<\/script> | ||
</body> | ||
</html> | ||
`; | ||
|
||
const iframe = document.createElement('iframe'); | ||
slot.appendChild(iframe); | ||
Object.entries({ | ||
frameBorder: 0, | ||
marginWidth: 0, | ||
marginHeight: 0, | ||
srcdoc: content | ||
}).forEach(([prop, val]) => iframe.setAttribute(prop, val)); | ||
} | ||
}); | ||
|
||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<template id="native-template"> | ||
<style> | ||
body { | ||
display: inline-block; | ||
} | ||
|
||
.container { | ||
display: inline-block; | ||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; | ||
font-size: 14px; | ||
line-height: 1.42857143; | ||
color: #333; | ||
background: #fff url(##hb_native_image##) no-repeat center; | ||
background-size: cover; | ||
} | ||
|
||
|
||
.card { | ||
border: 4px solid #ffd724; | ||
display: inline-block; | ||
padding: 20px; | ||
height: 300px; | ||
width: 320px; | ||
} | ||
|
||
|
||
h1 a:link, a:active, a:visited, a:hover, a:focus { | ||
text-decoration: none; | ||
color: #fff; | ||
} | ||
|
||
h1 { | ||
line-height: 1.3; | ||
color: #fff; | ||
font-size: 26px; | ||
background-color: rgba(0, 0, 0, 0.7); | ||
display: inline; | ||
font-family: Roboto, serif; | ||
font-weight: 100; | ||
} | ||
|
||
.attribution { | ||
color: #fff; | ||
display: inline-block; | ||
letter-spacing: 2px; | ||
background-color: #ffd724; | ||
font-size: 12px; | ||
line-height: 1; | ||
padding: 6px 6px 0 6px; | ||
height: 24px; | ||
margin: 5px 0 10px 0; | ||
border-radius: 4px; | ||
} | ||
</style> | ||
<div class="container"> | ||
<div class="card"> | ||
<div class="title"> | ||
<h1> | ||
<a href="##hb_native_linkurl##">##hb_native_title##</a> | ||
</h1> | ||
</div> | ||
<div class="attribution"> | ||
##hb_native_brand## | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<h2>Prebid Native</h2> | ||
<div id='native-div'> | ||
</div> | ||
|
||
<br> | ||
<br> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {getGlobal} from '../../src/prebidGlobal.js'; | ||
import {keyCompare} from '../../src/utils/reducers.js'; | ||
|
||
/** | ||
* Attempt to convert `amount` from the currency `fromCur` to the currency `toCur`. | ||
* | ||
* By default, when the conversion is not possible (currency module not present or | ||
* throwing errors), the amount is returned unchanged. This behavior can be | ||
* toggled off with bestEffort = false. | ||
*/ | ||
export function convertCurrency(amount, fromCur, toCur, bestEffort = true) { | ||
if (fromCur === toCur) return amount; | ||
let result = amount; | ||
try { | ||
result = getGlobal().convertCurrency(amount, fromCur, toCur); | ||
} catch (e) { | ||
if (!bestEffort) throw e; | ||
} | ||
return result; | ||
} | ||
|
||
export function currencyNormalizer(toCurrency = null, bestEffort = true, convert = convertCurrency) { | ||
return function (amount, currency) { | ||
if (toCurrency == null) toCurrency = currency; | ||
return convert(amount, currency, toCurrency, bestEffort); | ||
} | ||
} | ||
|
||
export function currencyCompare(get = (obj) => [obj.cpm, obj.currency], normalize = currencyNormalizer()) { | ||
return keyCompare(obj => normalize.apply(null, get(obj))) | ||
} |
Oops, something went wrong.