Members

(constant) texts

Returns default texts for PayOkay modal

Methods

addAzureExport()

Saves segments to cookies for later use (Azure/Piano export)


addElement(name, container, attributesopt) → {HTMLElement}

Shortens DOM element adding

Parameters
Name Type Attributes Description
name string

Tag name

container HTMLElement

Parent element

attributes Object <optional>

HTML attributes

Returns

Created element

Type: 
HTMLElement

addIframe(element, attributes, callbackopt) → {HTMLIFrameElement}

Adds iframe for creative rendering

Parameters
Name Type Attributes Description
element HTMLElement

Parent element

attributes Object

HTML attributes for iframe

callback function <optional>

Callback function after loading

Returns

Created iframe element

Type: 
HTMLIFrameElement

addPixel(url)

Adds 1px image for tracking

Parameters
Name Type Description
url string

Tracking pixel URL


addStyle(doc, css) → {HTMLElement}

Adds custom CSS style to document

Parameters
Name Type Description
doc Document

Document object

css string

CSS code

Returns

Created style element

Type: 
HTMLElement

addTCFStub()

Adds TCF stub for GDPR (official Didomi implementation)


awaitDOM() → {Promise}

Waits for DOM to be loaded

Returns

Promise that resolves after DOM is loaded

Type: 
Promise

b64DecodeUnicode(str) → {string}

Decodes UTF-8 Base64 string

Parameters
Name Type Description
str string

Base64 string

Returns

Decoded string

Type: 
string

clamp(val, min, max) → {number}

Limits value between min and max (inclusive)

Parameters
Name Type Description
val number

Value to limit

min number

Minimum value

max number

Maximum value

Returns

Limited value

Type: 
number

clone(source) → {*}

Creates deep copy of object using JSON

Parameters
Name Type Description
source *

Source object

Returns

Copy of object

Type: 
*

cpexError(message, error) → {Error}

Shows console error with common prefix and creates Error object

Parameters
Name Type Description
message string

Error message

error Error | string

Error object or error text

Returns

Error object with cause

Type: 
Error

cpexLog()

Shows console log only when debug mode is enabled


cpexLogHeadline(text)

Shows console log in large font

Parameters
Name Type Description
text string

Text to display


cpexWarn()

Shows console warning with common prefix


cropText(text, maxLength) → {string}

Crops text and adds ellipsis

Parameters
Name Type Description
text string

Text to crop

maxLength number

Maximum length

Returns

Cropped text

Type: 
string

decorateLog(args) → {Array}

Decorates log arguments with timing information

Parameters
Name Type Description
args *

Arguments for logging

Returns

Decorated arguments

Type: 
Array

deepMerge(target, source) → {Object|boolean}

Deep merges two objects

Parameters
Name Type Description
target Object

Target object

source Object

Source object

Returns

Merged object or false on error

Type: 
Object | boolean

displayMetaData(elementId, creativeMetaData)

Shows visual debug "tags" on banners

Parameters
Name Type Description
elementId string

Ad element ID

creativeMetaData Object

Ad metadata


enrichVast(url) → {string}

Adds GDPR parameters to VAST URL (TODO: implement)

Parameters
Name Type Description
url string

VAST URL

Returns

Modified URL

Type: 
string

fillIframeDoc(doc, creative)

Inserts creative into iframe document

Parameters
Name Type Description
doc Document

Iframe document

creative string

Creative HTML code


fillNativeTemplate(native, html, configopt) → {string}

DEPRECATED. Fills HTML template from Native ad data

Parameters
Name Type Attributes Description
native Object

Native ad data

html string

HTML template

config Object <optional>

Configuration

Returns

Filled template

Type: 
string

fillOrtbNativeTemplate(native, html, configopt) → {string}

Fills HTML template from Prebid Native ad data

Parameters
Name Type Attributes Description
native Object

Prebid Native ad data

html string

HTML template

config Object <optional>

Configuration

Returns

Filled template

Type: 
string

gamGetElementByPath(adUnitPath) → {Object|undefined}

Returns googletag slot by its adUnit path in GAM

Parameters
Name Type Description
adUnitPath string

Ad unit path in GAM

Returns

Google tag slot object

Type: 
Object | undefined

getConsent() → {Promise.<string>}

Gets GDPR consent string from CMP

Returns

TC string

Type: 
Promise.<string>

getCookie(name) → {string|null}

Reads a cookie by name

Parameters
Name Type Description
name string

Cookie name

Returns

Cookie value or null

Type: 
string | null

getId5PartnerData(ip) → {Promise.<string>}

Returns custom user identification info for ID5

Parameters
Name Type Description
ip Object

Object with IP address

Returns

Base64 encoded data

Type: 
Promise.<string>

getIpAddress() → {Promise.<Object>}

Gets user's IP address

Returns

Object with IP address (ip4 or ip6)

Type: 
Promise.<Object>

getPackage() → {Object}

Returns the main cpexPackage object instance

Returns

cpexPackage instance

Type: 
Object

getRandomInt(a, b) → {number}

Returns random integer in range (inclusive)

Parameters
Name Type Description
a number

Minimum value

b number

Maximum value

Returns

Random number

Type: 
number

getThirdPartyCookieSupport() → {Promise.<number>}

Detects third-party cookie support in browser

Returns

1 if supported, 0 otherwise

Type: 
Promise.<number>

hasAdblock(prebidPath) → {Promise.<boolean>}

Tests for adblock presence using AJAX request

Parameters
Name Type Description
prebidPath string

Path to Prebid file

Returns

True if adblock is active

Type: 
Promise.<boolean>

hideAdContent(element)

Hides ad content (used e.g. on error)

Parameters
Name Type Description
element string

Element ID


isAdsObject(obj) → {boolean}

Checks if object contains ads structure

Parameters
Name Type Description
obj *

Object to check

Returns

True if it has correct structure

Type: 
boolean

isDOMObject(obj) → {boolean}

Checks if object is a DOM element

Parameters
Name Type Description
obj *

Object to check

Returns

True if it's a DOM element

Type: 
boolean

isFilledArray(arr) → {boolean}

Checks if variable is an array with content

Parameters
Name Type Description
arr *

Variable to check

Returns

True if it's a non-empty array

Type: 
boolean

isMobile() → {boolean}

Returns whether browser is on mobile device

Returns

True for mobile device

Type: 
boolean

isObject(obj) → {boolean}

Checks if variable is an object (not null or array)

Parameters
Name Type Description
obj *

Variable to check

Returns

True if it's an object

Type: 
boolean

isPrebidLoaded() → {boolean}

Checks if Prebid is loaded

Returns

True if Prebid is loaded

Type: 
boolean

loadScript(doc, url, name, typeopt) → {Promise}

Loads script or link asynchronously

Parameters
Name Type Attributes Default Description
doc Document

Document object

url string

URL of file to load

name string

Name for identification

type string <optional> 'script'

Element type (script or link)

Returns

Promise that resolves after loading

Type: 
Promise

regexGetFirstComment(text) → {string|undefined}

Extracts first HTML comment from text using regex

Parameters
Name Type Description
text string

Text to search

Returns

Comment content or undefined

Type: 
string | undefined

regexGetValue(text, keyword) → {string|undefined}

Extracts keyword value from text using regex

Parameters
Name Type Description
text string

Text to search

keyword string

Keyword to search for

Returns

Found value or undefined

Type: 
string | undefined

replaceTemplateLiteral(str, obj) → {string}

Manual template literal replacement

Parameters
Name Type Description
str string

Template with variables ${var}

obj Object

Object with variable values

Returns

Filled template

Type: 
string

setCookie(name, duration, valueopt, domainopt)

Sets a cookie

Parameters
Name Type Attributes Default Description
name string

Cookie name

duration number

Duration in seconds

value string <optional> 'true'

Cookie value

domain string <optional>

Domain for cookie


ssspCallback(ad, sssp)

Callback for SSSP ad server (Seznam.cz)

Parameters
Name Type Description
ad Object

Ad object

sssp Object

SSSP instance


ssspInfoCallback(ad, sssp)

Info callback for SSSP ad server (Seznam.cz)

Parameters
Name Type Description
ad Object

Ad object

sssp Object

SSSP instance


style() → {string}

Returns CSS styles for PayOkay modal

Returns

CSS code

Type: 
string

triggerTracking(data)

Fires tracking pixels for given data

Parameters
Name Type Description
data Object

Data with tracking URLs