Skip to content

Commit 243c9a9

Browse files
tiffwuWill Alexander
authored andcommitted
Add flash detection to TripleLift adapter (prebid#855)
* add flash detection to TripleLift adapter * add window
1 parent 3bcf2b2 commit 243c9a9

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

src/adapters/triplelift.js

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ var TripleLiftAdapter = function TripleLiftAdapter() {
1414
var tlReq = params.bids;
1515
var bidsCount = tlReq.length;
1616

17-
//set expected bids count for callback execution
18-
//bidmanager.setExpectedBidsCount('triplelift',bidsCount);
17+
// set expected bids count for callback execution
18+
// bidmanager.setExpectedBidsCount('triplelift',bidsCount);
1919

2020
for (var i = 0; i < bidsCount; i++) {
2121
var bidRequest = tlReq[i];
2222
var callbackId = bidRequest.bidId;
2323
adloader.loadScript(buildTLCall(bidRequest, callbackId));
24-
//store a reference to the bidRequest from the callback id
25-
//bidmanager.pbCallbackMap[callbackId] = bidRequest;
24+
// store a reference to the bidRequest from the callback id
25+
// bidmanager.pbCallbackMap[callbackId] = bidRequest;
2626
}
27-
2827
}
2928

3029

@@ -33,8 +32,7 @@ var TripleLiftAdapter = function TripleLiftAdapter() {
3332
var inventoryCode = utils.getBidIdParameter('inventoryCode', bid.params);
3433
var floor = utils.getBidIdParameter('floor', bid.params);
3534

36-
37-
//build our base tag, based on if we are http or https
35+
// build our base tag, based on if we are http or https
3836
var tlURI = '//tlx.3lift.com/header/auction?';
3937
var tlCall = document.location.protocol + tlURI;
4038

@@ -45,17 +43,20 @@ var TripleLiftAdapter = function TripleLiftAdapter() {
4543
tlCall = utils.tryAppendQueryString(tlCall, 'inv_code', inventoryCode);
4644
tlCall = utils.tryAppendQueryString(tlCall, 'floor', floor);
4745

48-
//sizes takes a bit more logic
46+
// indicate whether flash support exists
47+
tlCall = utils.tryAppendQueryString(tlCall, 'fe', isFlashEnabled());
48+
49+
// sizes takes a bit more logic
4950
var sizeQueryString = utils.parseSizesInput(bid.sizes);
5051
if (sizeQueryString) {
5152
tlCall += 'size=' + sizeQueryString + '&';
5253
}
5354

54-
//append referrer
55+
// append referrer
5556
var referrer = utils.getTopWindowUrl();
5657
tlCall = utils.tryAppendQueryString(tlCall, 'referrer', referrer);
5758

58-
//remove the trailing "&"
59+
// remove the trailing "&"
5960
if (tlCall.lastIndexOf('&') === tlCall.length - 1) {
6061
tlCall = tlCall.substring(0, tlCall.length - 1);
6162
}
@@ -64,22 +65,36 @@ var TripleLiftAdapter = function TripleLiftAdapter() {
6465
utils.logMessage('tlCall request built: ' + tlCall);
6566
// @endif
6667

67-
//append a timer here to track latency
68+
// append a timer here to track latency
6869
bid.startTime = new Date().getTime();
6970

7071
return tlCall;
71-
7272
}
7373

74+
function isFlashEnabled() {
75+
var hasFlash = 0;
76+
try {
77+
// check for Flash support in IE
78+
var fo = new window.ActiveXObject('ShockwaveFlash.ShockwaveFlash');
79+
if (fo) { hasFlash = 1; }
80+
} catch (e) {
81+
if (navigator.mimeTypes &&
82+
navigator.mimeTypes['application/x-shockwave-flash'] !== undefined &&
83+
navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
84+
hasFlash = 1;
85+
}
86+
}
87+
return hasFlash;
88+
}
7489

75-
//expose the callback to the global object:
90+
// expose the callback to the global object:
7691
$$PREBID_GLOBAL$$.TLCB = function(tlResponseObj) {
7792
if (tlResponseObj && tlResponseObj.callback_id) {
7893
var bidObj = utils.getBidRequest(tlResponseObj.callback_id);
7994
var placementCode = bidObj && bidObj.placementCode;
8095

8196
// @if NODE_ENV='debug'
82-
if (bidObj) {utils.logMessage('JSONP callback function called for inventory code: ' + bidObj.params.inventoryCode);}
97+
if (bidObj) { utils.logMessage('JSONP callback function called for inventory code: ' + bidObj.params.inventoryCode); }
8398
// @endif
8499

85100
var bid = [];
@@ -95,7 +110,7 @@ var TripleLiftAdapter = function TripleLiftAdapter() {
95110
bidmanager.addBidResponse(placementCode, bid);
96111

97112
} else {
98-
//no response data
113+
// no response data
99114
// @if NODE_ENV='debug'
100115
if (bidObj) {utils.logMessage('No prebid response from TripleLift for inventory code: ' + bidObj.params.inventoryCode);}
101116
// @endif
@@ -105,7 +120,7 @@ var TripleLiftAdapter = function TripleLiftAdapter() {
105120
}
106121

107122
} else {
108-
//no response data
123+
// no response data
109124
// @if NODE_ENV='debug'
110125
utils.logMessage('No prebid response for placement %%PLACEMENT%%');
111126
// @endif

0 commit comments

Comments
 (0)