-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adagio*: add adagioUtils.js, remove duplicated code (#11849)
- Loading branch information
Showing
3 changed files
with
38 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
canAccessWindowTop, | ||
generateUUID, | ||
getWindowSelf, | ||
getWindowTop, | ||
isSafeFrameWindow | ||
} from '../../src/utils.js'; | ||
|
||
/** | ||
* Returns the best Window object to use with ADAGIO. | ||
* @returns {Window} window.top or window.self object | ||
*/ | ||
export function getBestWindowForAdagio() { | ||
return (canAccessWindowTop()) ? getWindowTop() : getWindowSelf(); | ||
} | ||
|
||
/** | ||
* Returns the window.ADAGIO global object used to store Adagio data. | ||
* This object is created in window.top if possible, otherwise in window.self. | ||
*/ | ||
export const _ADAGIO = (function() { | ||
const w = getBestWindowForAdagio(); | ||
|
||
w.ADAGIO = w.ADAGIO || {}; | ||
w.ADAGIO.pageviewId = w.ADAGIO.pageviewId || generateUUID(); | ||
w.ADAGIO.adUnits = w.ADAGIO.adUnits || {}; | ||
w.ADAGIO.pbjsAdUnits = w.ADAGIO.pbjsAdUnits || []; | ||
w.ADAGIO.queue = w.ADAGIO.queue || []; | ||
w.ADAGIO.versions = w.ADAGIO.versions || {}; | ||
w.ADAGIO.versions.pbjs = '$prebid.version$'; | ||
w.ADAGIO.windows = w.ADAGIO.windows || []; | ||
w.ADAGIO.isSafeFrameWindow = isSafeFrameWindow(); | ||
|
||
return w.ADAGIO; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters