@folklore/ads
Advanced tools
Comparing version 0.0.39 to 0.0.40
@@ -279,8 +279,12 @@ 'use strict'; | ||
class AdsManager extends EventEmitter__default["default"] { | ||
static index = 0; | ||
static createAdId() { | ||
const newId = `div-gpt-ad-${new Date().getTime()}-${Math.round(Math.random() * (Math.random() * 1000))}-${AdsManager.index}`; | ||
AdsManager.index += 1; | ||
return newId; | ||
} | ||
// static index = 0; | ||
// static createAdId() { | ||
// const newId = `div-gpt-ad-${new Date().getTime()}-${Math.round( | ||
// Math.random() * (Math.random() * 1000), | ||
// )}-${AdsManager.index}`; | ||
// AdsManager.index += 1; | ||
// return newId; | ||
// } | ||
static getArticleTargeting(article) { | ||
@@ -350,2 +354,3 @@ if (article === null) { | ||
this.slots = []; | ||
this.index = 0; | ||
if (this.options.autoInit) { | ||
@@ -355,2 +360,10 @@ this.init(); | ||
} | ||
createAdId() { | ||
// const newId = `div-gpt-ad-${new Date().getTime()}-${Math.round( | ||
// Math.random() * (Math.random() * 1000), | ||
// )}-${this.index}`; | ||
const newId = `div-gpt-ad-${this.index}`; | ||
this.index += 1; | ||
return newId; | ||
} | ||
onGPTReady() { | ||
@@ -484,3 +497,3 @@ const { | ||
} = opts; | ||
const id = providedId || AdsManager.createAdId(); | ||
const id = providedId || this.createAdId(); | ||
debug('Creating slot #%s(%s)...', id, path); | ||
@@ -487,0 +500,0 @@ const slot = new AdSlot(id, path, size, { |
@@ -261,8 +261,12 @@ import PropTypes from 'prop-types'; | ||
class AdsManager extends EventEmitter { | ||
static index = 0; | ||
static createAdId() { | ||
const newId = `div-gpt-ad-${new Date().getTime()}-${Math.round(Math.random() * (Math.random() * 1000))}-${AdsManager.index}`; | ||
AdsManager.index += 1; | ||
return newId; | ||
} | ||
// static index = 0; | ||
// static createAdId() { | ||
// const newId = `div-gpt-ad-${new Date().getTime()}-${Math.round( | ||
// Math.random() * (Math.random() * 1000), | ||
// )}-${AdsManager.index}`; | ||
// AdsManager.index += 1; | ||
// return newId; | ||
// } | ||
static getArticleTargeting(article) { | ||
@@ -332,2 +336,3 @@ if (article === null) { | ||
this.slots = []; | ||
this.index = 0; | ||
if (this.options.autoInit) { | ||
@@ -337,2 +342,10 @@ this.init(); | ||
} | ||
createAdId() { | ||
// const newId = `div-gpt-ad-${new Date().getTime()}-${Math.round( | ||
// Math.random() * (Math.random() * 1000), | ||
// )}-${this.index}`; | ||
const newId = `div-gpt-ad-${this.index}`; | ||
this.index += 1; | ||
return newId; | ||
} | ||
onGPTReady() { | ||
@@ -466,3 +479,3 @@ const { | ||
} = opts; | ||
const id = providedId || AdsManager.createAdId(); | ||
const id = providedId || this.createAdId(); | ||
debug('Creating slot #%s(%s)...', id, path); | ||
@@ -469,0 +482,0 @@ const slot = new AdSlot(id, path, size, { |
{ | ||
"name": "@folklore/ads", | ||
"version": "0.0.39", | ||
"version": "0.0.40", | ||
"description": "Ads library", | ||
@@ -53,3 +53,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "6a3484815046ba47850ba5d71e5eee9afe4adeb4", | ||
"gitHead": "9b792452940372423d526d0fb10d3f427b7ebe1c", | ||
"dependencies": { | ||
@@ -56,0 +56,0 @@ "@folklore/hooks": "^0.0.44", |
73866
2349