This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request prebid#97 in AOLP_ADS_JS/prebid.js from release/1.…
…21.0 to aolgithub-master * commit '4d573b42c5fbbabf23fed48fa042b75a72dd16b2': (31 commits) Added prebidServer in aolPartnersIds.json. Added adapters in aolPartnersIds.json. Added changelog entry. Prebid 0.23.1 Release Add trafficSourceCode + test (prebid#1184) Clear cookie sync to prevent multiple calls (prebid#1181) change s2s adapter to filter out units with empty sizes array (prebid#1179) Sharethrough: Change to using a closure for the callback from ajax to preserve bidObj (prebid#1108) check array length when mapping sizes (prebid#1180) Bugfix/encoding url (prebid#1178) add lodash as dependency (prebid#1174) fix size mapping for s2s (prebid#1175) Improve footer styling (prebid#1171) Bugfix: internal bids requested overwritten (prebid#1173) pre-release version bump Prebid 0.23.0 Release Yieldbot adapter - multiple requestBids per pageview (prebid#1146) Widespace adapter validate size fix (prebid#1140) Audience Network: bid when at least one valid slot size (prebid#1148) Quantcast adaptor (prebid#1063) ...
- Loading branch information
Showing
43 changed files
with
2,445 additions
and
279 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.js] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true |
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
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> | ||
var PREBID_TIMEOUT = 3000; | ||
|
||
var googletag = googletag || {}; | ||
var sizes = [[728, 90],[300, 250], [300,600]]; | ||
googletag.cmd = googletag.cmd || []; | ||
|
||
function initAdserver() { | ||
if (pbjs.initAdserverSet) return; | ||
(function() { | ||
var gads = document.createElement('script'); | ||
gads.async = true; | ||
gads.type = 'text/javascript'; | ||
var useSSL = 'https:' == document.location.protocol; | ||
gads.src = (useSSL ? 'https:' : 'http:') + | ||
'//www.googletagservices.com/tag/js/gpt.js'; | ||
var node = document.getElementsByTagName('script')[0]; | ||
node.parentNode.insertBefore(gads, node); | ||
})(); | ||
pbjs.initAdserverSet = true; | ||
}; | ||
setTimeout(initAdserver, PREBID_TIMEOUT); | ||
|
||
var pbjs = pbjs || {}; | ||
pbjs.bidderTimeout = 3000; | ||
pbjs.que = pbjs.que || []; | ||
(function() { | ||
var pbjsEl = document.createElement("script"); | ||
pbjsEl.type = "text/javascript"; | ||
pbjsEl.async = true; | ||
pbjsEl.src = '/build/dev/prebid.js'; | ||
var pbjsTargetEl = document.getElementsByTagName("head")[0]; | ||
pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild); | ||
})(); | ||
|
||
pbjs.que.push(function() { | ||
var adUnits = [{ | ||
code: 'div-gpt-ad-1460505748561-0', | ||
sizes: [[300, 250], [300,600]], | ||
bids: [ | ||
{ | ||
bidder: 'appnexus', | ||
params: { | ||
placementId: '10433394' | ||
} | ||
} | ||
] | ||
}]; | ||
|
||
pbjs.setS2SConfig({ | ||
accountId : '1', | ||
enabled : true, //default value set to false | ||
bidders : ['appnexus'], | ||
timeout : 1000, //default value is 1000 | ||
adapter : 'prebidServer', //if we have any other s2s adapter, default value is s2s | ||
endpoint : 'https://prebid.adnxs.com/pbs/v1/auction?url_override=http%3A%2F%2Fwww.nytimes.com' | ||
}); | ||
|
||
pbjs.addAdUnits(adUnits); | ||
|
||
pbjs.requestBids({ | ||
bidsBackHandler: function(bidResponses) { | ||
initAdserver(); | ||
} | ||
}) | ||
}); | ||
</script> | ||
|
||
<script> | ||
googletag.cmd.push(function() { | ||
var rightSlot = googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads()); | ||
|
||
pbjs.que.push(function() { | ||
pbjs.setTargetingForGPTAsync(); | ||
}); | ||
|
||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<h2>Prebid.js S2S Example</h2> | ||
|
||
<h5>Div-1</h5> | ||
<div id='div-gpt-ad-1460505748561-0'> | ||
<script type='text/javascript'> | ||
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-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
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,86 @@ | ||
var bidfactory = require('../bidfactory.js'); | ||
var bidmanager = require('../bidmanager.js'); | ||
var adloader = require('../adloader'); | ||
var utils = require('../utils'); | ||
const ADSUPPLY_CODE = 'adsupply'; | ||
|
||
var AdSupplyAdapter = function AdSupplyAdapter() { | ||
function _validateParams(params) { | ||
if (!params || !params.siteId || !params.zoneId || !params.endpointUrl || !params.clientId) { | ||
return false; | ||
} | ||
|
||
if (typeof params.zoneId !== 'number' || params.zoneId <= 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function _getRequestUrl(bid) { | ||
var referrerUrl = encodeURIComponent(window.document.referrer); | ||
var rand = encodeURIComponent(Math.floor(Math.random() * 100000 + 1)); | ||
var time = encodeURIComponent(new Date().getTimezoneOffset()); | ||
return '//' + bid.params.endpointUrl + '/banner.engine?id=' + bid.params.siteId + '&z=' + bid.params.zoneId + '&rand=' + rand + '&ver=async' + '&time=' + time + '&referrerurl=' + referrerUrl + '&abr=false' + '&hbt=1&cid=' + encodeURIComponent(bid.params.clientId); | ||
} | ||
|
||
$$PREBID_GLOBAL$$.adSupplyResponseHandler = function (bidId) { | ||
if (!bidId) return; | ||
|
||
var bidRequest = utils.getBidRequest(bidId); | ||
|
||
if (!bidRequest || !bidRequest.params) return; | ||
|
||
var clientId = bidRequest.params.clientId; | ||
var zoneProp = 'b' + bidRequest.params.zoneId; | ||
|
||
if (!window[clientId] || !window[clientId][zoneProp]) return; | ||
|
||
var media = window[clientId][zoneProp].Media; | ||
|
||
if (!media) return; | ||
|
||
if (!media.Url || !media.Ecpm || typeof media.Ecpm !== 'number' || media.Ecpm <= 0) { | ||
var noFillbject = bidfactory.createBid(2, bidRequest); | ||
noFillbject.bidderCode = ADSUPPLY_CODE; | ||
bidmanager.addBidResponse(bidRequest.placementCode, noFillbject); | ||
} else { | ||
var bidObject = bidfactory.createBid(1, bidRequest); | ||
bidObject.bidderCode = ADSUPPLY_CODE; | ||
bidObject.cpm = media.Ecpm; | ||
bidObject.ad = '<iframe style="z-index: 5000001; margin: 0px; padding: 0px; border: none; width: ' + media.Width + 'px; height: ' + media.Height + 'px; " src="//' + bidRequest.params.endpointUrl + media.Url + '"></iframe>'; | ||
bidObject.width = media.Width; | ||
bidObject.height = media.Height; | ||
bidmanager.addBidResponse(bidRequest.placementCode, bidObject); | ||
} | ||
}; | ||
|
||
function _makeCallBackHandler(bidId) { | ||
return function () { | ||
$$PREBID_GLOBAL$$.adSupplyResponseHandler(bidId); | ||
}; | ||
} | ||
|
||
function _callBids(params) { | ||
var bids = params.bids || []; | ||
for (var i = 0; i < bids.length; i++) { | ||
var bid = bids[i]; | ||
if (!_validateParams(bid.params)) continue; | ||
|
||
var clientId = bid.params.clientId; | ||
var zoneProp = 'b' + bid.params.zoneId; | ||
window[clientId] = window[clientId] || {}; | ||
window.window[clientId][zoneProp] = window.window[clientId][zoneProp] || {}; | ||
window.window[clientId][zoneProp].Media = {}; | ||
|
||
var requestUrl = _getRequestUrl(bid); | ||
adloader.loadScript(requestUrl, _makeCallBackHandler(bid.bidId)); | ||
} | ||
} | ||
|
||
return { | ||
callBids: _callBids | ||
}; | ||
}; | ||
|
||
module.exports = AdSupplyAdapter; |
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
Oops, something went wrong.