-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MoMAGIC Ad Network - Vendor Registration (#39963)
* MoMAGIC Ad Network - Vendor Registration * Fix lint and compilation --------- Co-authored-by: mmprebid <[email protected]>
- Loading branch information
Showing
7 changed files
with
124 additions
and
0 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,12 @@ | ||
// src/polyfills.js must be the first import. | ||
import '#3p/polyfills'; | ||
|
||
import {register} from '#3p/3p'; | ||
import {draw3p, init} from '#3p/integration-lib'; | ||
|
||
import {momagic} from '#ads/vendors/momagic'; | ||
|
||
init(window); | ||
register('momagic', momagic); | ||
|
||
window.draw3p = draw3p; |
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
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,62 @@ | ||
import {validateData} from '#3p/3p'; | ||
|
||
/** | ||
* @param {!Window} global | ||
* @param {!Object} data | ||
*/ | ||
export function momagic(global, data) { | ||
validateData(data, ['publisher', 'container'], ['format', 'url', 'extras']); | ||
|
||
const scriptRoot = document.createElement('div'); | ||
scriptRoot.id = data.container; | ||
|
||
document.body.appendChild(scriptRoot); | ||
|
||
let url = ''; | ||
|
||
if (data.format) { | ||
url = | ||
`https://amp.truereach.co.in/publisher/${encodeURIComponent(data.publisher)}/${encodeURIComponent(data.format)}/` + | ||
`truereachAdRender.js?t=` + | ||
Math.floor(Date.now() / 36e5); | ||
} else { | ||
url = | ||
`https://amp.truereach.co.in/publisher/${encodeURIComponent(data.publisher)}/` + | ||
`truereachAdRender.js?t=` + | ||
Math.floor(Date.now() / 36e5); | ||
} | ||
|
||
// Path to Script | ||
const pathtoscript = data.url ? data.url : url; | ||
loadScriptNew(pathtoscript, function () { | ||
global.momagicAmpInit(data); | ||
}); | ||
} | ||
|
||
/** | ||
* Load the script asynchronously | ||
* @param {string} url | ||
* @param {!Function} callback | ||
*/ | ||
function loadScriptNew(url, callback) { | ||
const script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
if (script.readyState) { | ||
// only required for IE <9 | ||
script.onreadystatechange = function () { | ||
if (script.readyState === 'loaded' || script.readyState === 'complete') { | ||
script.onreadystatechange = null; | ||
callback(); | ||
} | ||
}; | ||
} else { | ||
//Others | ||
script.onload = function () { | ||
callback(); | ||
}; | ||
} | ||
script.id = 'interactive_js_ampcode'; | ||
script.defer = true; | ||
script.src = url; | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
} |
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,31 @@ | ||
# Momagic | ||
|
||
## Example | ||
|
||
### Basic | ||
|
||
```html | ||
<amp-ad | ||
width="300" | ||
height="600" | ||
type="momagic" | ||
data-container="slotId" | ||
data-publisher="publisherId" | ||
> | ||
</amp-ad> | ||
``` | ||
|
||
## Configuration | ||
|
||
For details on the configuration semantics, please contact the ad network or refer to their documentation. | ||
|
||
### Required parameters | ||
|
||
- `data-publisher` | ||
- `data-container` | ||
|
||
|
||
### Optional parameters | ||
- `data-format` | ||
- `data-url` | ||
- `data-extras` |
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