Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adtech-manager

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adtech-manager - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

143

adtech-manager.js

@@ -71,3 +71,21 @@ (function (root, factory) {

var raf = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(cb) {
setTimeout(cb, 1000 / 60);
};
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
// Adscript

@@ -78,9 +96,9 @@ var AdtechManager = function(config) {

}
if (typeof window.ADTECH === 'undefined') {
throw 'AdTechManager requires Dac.js.'
}
this.config = extend(config, this.config);
ADTECH.config.page = this.config.adtech;

@@ -99,2 +117,3 @@ ADTECH.debugMode = this.config.debugMode;

usefif: true,
disableFriendlyFlag: true
},

@@ -108,6 +127,7 @@ params: {loc : '100'}

},
blockingAds: [],
device: 'desktop',
route: null,
keywords: [],
emptyPixel: 'Default_Size_16_1x1.gif',
emptyPixel: 'blank_pix_house.gif',
onAdLoaded: null,

@@ -117,3 +137,3 @@ onAllAdsLoaded: null,

},
adsQueued: 0,
adsLoaded: [],
adsRendered: 0,

@@ -124,37 +144,69 @@ getKeywords: function() {

getPlacements: function(device, route) {
var device = device,
placements = null;
var placements = null;
placements = this.config.placements[device][route];
device = device || this.config.device;
route = route || this.config.route;
if (typeof(placements) === 'string') {
placements = this.getPlacements(device, placements);
placements = this.config.placements[device];
if (placements[route]) {
if (typeof(placements[route]) === 'string') {
return this.getPlacements(device, placements[route]);
}
return placements[route];
} else {
var regexPlacements = null;
each(placements, function(placements, placementRoute) {
if (route.match('^'+placementRoute)) {
regexPlacements = placements;
}
});
return regexPlacements;
}
return placements;
},
renderAd: function(placement, placementId) {
renderAd: function(placement, placementId, callback) {
var params = {},
el = $('#ad-' + placement);
if (el) {
if(this.adsLoaded.indexOf(placement) !== -1) {
return;
}
if (el) {
params.keywords = this.getKeywords();
ADTECH.enqueueAd({
params: params,
placement: placementId,
adContainerId: 'ad-' + placement,
complete: bind(function() {
this.onAdLoaded.call(this, placement, el)
}, this)
});
this.adsQueued++;
} else {
raf(bind(function() {
this.adsLoaded.push(placement);
ADTECH.loadAd({
params: params,
placement: placementId,
complete: bind(function() {
this.onAdLoaded.call(this, placement, el)
if (callback) {
callback.call(null, placement, el)
}
}, this),
adContainerId: 'ad-' + placement
});
}, this));
} else {
if (this.config.debugMode) {
console.error ('Placement ' + placement + '('+ placementId + ') not found for route ' + this.config.route + ' on device ' + this.config.device);
}
}
}
},
renderAds: function() {
var placements = this.getPlacements(this.config.device, this.config.route);
renderPlacement: function(placement, callback) {
var placements = this.getPlacements();
if (placements && typeof(placements[placement]) !== 'undefined') {
this.renderAd(placement, placements[placement], callback);
}
},
renderAds: function(config) {
var placements = this.getPlacements();
if (typeof(config) !== 'object') {
config = {};
}
if (placements) {

@@ -164,5 +216,3 @@ each(placements, function(id, name) {

}, this);
if (this.adsQueued > 0) {
ADTECH.executeQueue();
}
} else {

@@ -172,6 +222,8 @@ if (this.config.debugMode) {

}
this.hideNotRendered();
}
},
adsLoaded: function() {
return this.adsQueued > 0 && (this.adsQueued === this.adsRendered);
allAdsLoaded: function() {
return this.adsLoaded.length > 0 && (this.adsLoaded.length === this.adsRendered);
},

@@ -181,12 +233,11 @@ onAdLoaded: function(placement, el) {

ifDoc = iframe.contentDocument;
if (ifDoc.querySelector('[src*="'+ this.config.emptyPixel +'"]')) {
el.style.display = 'none';
el.style['display'] = 'none';
el.removeChild(iframe);
} else {
iframe.onload = function() {
iframe.setAttribute('height', ifDoc.body.clientHeight);
iframe.setAttribute('width', '100%');
};
el.style.display = 'block';
el.style['display'] = 'block';
el.className = el.className +' ad-loaded';
if (typeof(this.config.onAdLoaded) === 'function') {
this.config.onAdLoaded.call(this, placement, el);
this.config.onAdLoaded.apply(this, arguments);
}

@@ -196,7 +247,17 @@ }

this.adsRendered++;
if (this.adsQueued === this.adsRendered) {
if (this.adsLoaded.length === this.adsRendered) {
if (typeof(this.config.onAllAdsLoaded) === 'function') {
this.config.onAllAdsLoaded.call(this);
this.config.onAllAdsLoaded.call(this, this.adsLoaded);
}
if (this.adsLoaded.length > 1) {
this.hideNotRendered();
}
}
},
hideNotRendered: function() {
var positions = document.querySelectorAll('.adtech:not(.ad-loaded)');
each(positions, function(position) {
position.style['display'] = 'none';
}, this)
}

@@ -203,0 +264,0 @@ };

{
"name": "adtech-manager",
"version": "0.0.3",
"version": "0.0.4",
"description": "Adtech-Manager ==============",

@@ -5,0 +5,0 @@ "main": "adtech-manager.js",

@@ -68,4 +68,4 @@ Adtech-Manager

```
<script type="text/javascript" src="//aka-cdn.adtech.de/dt/common/DAC"></script>
<script type="text/javascript" src="/path/to/adtech-manager.js"></script>
<script type="text/javascript" src="//aka-cdn.adtech.de/dt/common/DAC.js"></script>
<script type="text/javascript" src="http://e24.vgc.no/e24-no/production/bower_components/adtech-manager/adtech-manager.js"></script>
<script type="text/javascript">

@@ -101,1 +101,27 @@ var adConfig = {

```
css:
```
.adtech {
padding: 5px 0 0 0;
display: none;
min-height: 1px;
width: 100%;
height: 100%;
}
.adtech:before {
content: "annonse";
font-size: 10px;
color: #555;
display: block;
}
.adtech.hide-lable:before {
content: "";
display: none;
}
.adtech iframe {
display: block;
min-height: 1px;
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc