Skip to content

Commit

Permalink
Move index global paramaters into the params object to follow Prebid …
Browse files Browse the repository at this point in the history
…convention
  • Loading branch information
charles.black committed Dec 11, 2015
1 parent 20679ff commit 716e1ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 39 deletions.
6 changes: 4 additions & 2 deletions integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@
},
{
bidder: 'indexExchange',
siteID: 'TO ADD',
timeout: 'TO ADD',
params: {
id: 'TO ADD',
siteID: 'TO ADD',
timeout: 'TO ADD', //Optional
tier2SiteID: 'TO ADD', //Optional
tier3SiteID: 'TO ADD' //Optional
}
}]
}];
Expand Down
59 changes: 22 additions & 37 deletions src/adapters/indexExchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() {
var slotIdMap = {};
var requiredParams = [
/* 0 */
'id'
'id',
/* 1 */
'siteID'
];
var firstAdUnitCode = '';

Expand All @@ -222,41 +224,16 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() {
return;
}

var bid;

var tier2SiteID;
var tier3SiteID;

//Grab the global data for cygnus_index_args
for (var i = 0; i < bidArr.length; i++) {
bid = bidArr[i];

if (bid.timeout) {
cygnus_index_args.timeout = bid.timeout;
}

if (bid.siteID) {
cygnus_index_args.siteID = bid.siteID;
}

if (bid.tier2SiteID) {
tier2SiteID = bid.tier2SiteID;
}

if (bid.tier3SiteID) {
tier3SiteID = bid.tier3SiteID;
}
}

if (!cygnus_index_args.siteID) {
return;
}

cygnus_index_args.slots = [];
var bidCount = 0;

//Grab the slot level data for cygnus_index_args
for (i = 0; i < bidArr.length; i++) {
bid = bidArr[i];
var bid = bidArr[i];

var width;
var height;
Expand All @@ -272,12 +249,20 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() {
}
}

if (bid.sqps && typeof cygnus_index_args.SQPS === 'undefined') {
if (bid.params.timeout && typeof cygnus_index_args.timeout === 'undefined') {
cygnus_index_args.timeout = bid.params.timeout;
}

if (bid.params.siteID && typeof cygnus_index_args.timeout === 'undefined') {
cygnus_index_args.siteID = bid.params.siteID;
}

if (bid.params.sqps && typeof cygnus_index_args.SQPS === 'undefined') {
cygnus_index_args.slots.push({
id:"SPQS",
width: bid.sqps.width,
height: bid.sqps.height,
siteID: bid.sqps.siteID || cygnus_index_args.siteID
width: bid.params.sqps.width,
height: bid.params.sqps.height,
siteID: bid.params.sqps.siteID || cygnus_index_args.siteID
});
}

Expand All @@ -296,20 +281,20 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() {

bidCount++;

if (bid.params.tier2SiteID || tier2SiteID) {
if (bid.params.tier2SiteID) {
cygnus_index_args.slots.push({
id: "T1_"+bid.params.id,
width: width,
height: height,
siteID: bid.params.tier2SiteID || tier2SiteID
siteID: bid.params.tier2SiteID
});
}
if (bid.params.tier3SiteID || tier3SiteID) {
if (bid.params.tier3SiteID) {
cygnus_index_args.slots.push({
id:"T2_"+bid.params.id,
width:width,
height:height,
siteID:bid.params.tier3SiteID || tier3SiteID
siteID:bid.params.tier3SiteID
});
}
}
Expand Down Expand Up @@ -349,7 +334,7 @@ var IndexExchangeAdapter = function IndexExchangeAdapter() {
bid.bidderCode = ADAPTER_CODE;
bid.width = slotObj.width;
bid.height = slotObj.height;
bid.siteId = slotObj.siteID;
bid.siteID = slotObj.siteID;

bidmanager.addBidResponse(adUnitCode, bid);
}
Expand Down

0 comments on commit 716e1ad

Please sign in to comment.