Skip to content

Commit

Permalink
MoMAGIC Ad Network - Vendor Registration (#39963)
Browse files Browse the repository at this point in the history
* MoMAGIC Ad Network - Vendor Registration

* Fix lint and compilation

---------

Co-authored-by: mmprebid <[email protected]>
  • Loading branch information
powerivq and mmprebid authored Apr 26, 2024
1 parent 199d1b3 commit 4ecaad6
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 3p/vendors/momagic.js
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;
5 changes: 5 additions & 0 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,11 @@ const adConfig = jsonConfiguration({
preconnect: ['https://player1.mixpo.com', 'https://player2.mixpo.com'],
},

'momagic': {
prefetch: 'https://securepubads.g.doubleclick.net/tag/js/gpt.js',
preconnect: ['https://amp.truereach.co.in/'],
},

'monetizer101': {
renderStartImplemented: true,
},
Expand Down
3 changes: 3 additions & 0 deletions ads/ads.extern.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ data.local;
data.enablemraid;
data.jsplayer;

// momagic
window.momagicAmpInit;

// nativo.js
var PostRelease;
PostRelease.Start;
Expand Down
62 changes: 62 additions & 0 deletions ads/vendors/momagic.js
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);
}
31 changes: 31 additions & 0 deletions ads/vendors/momagic.md
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`
10 changes: 10 additions & 0 deletions examples/amp-ad/ads.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
<option>microad</option>
<option>miximedia</option>
<option>mixpo</option>
<option>momagic</option>
<option>monetizer101</option>
<option>mox</option>
<option>my6sense</option>
Expand Down Expand Up @@ -1381,6 +1382,15 @@ <h2>Mixpo</h2>
<amp-ad width="300" height="250" type="mixpo" data-guid="b0caf856-fd92-4adb-aaec-e91948c9ffc8" data-subdomain="www">
</amp-ad>

<h2>Momagic</h2>
<amp-ad
width="480"
height="600"
type="momagic"
data-container="adSlot1"
data-publisher="01023642-aca4-b601-6a54-0006df0000dc">
</amp-ad>

<h2>Monetizer101</h2>
<amp-ad width="auto" height="176" layout="fixed-height" type="monetizer101" data-widget="price-comparison"
data-config='{"shopId": 1, "priceMin": 500, "nameKeywords": "iphone"}'>
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/amp-ad.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati
- [MicroAd](../../ads/vendors/microad.md)
- [MixiMedia](../../ads/vendors/miximedia.md)
- [Mixpo](../../ads/vendors/mixpo.md)
- [Momagic](../../ads/vendors/momagic.md)
- [Monetizer101](../../ads/vendors/monetizer101.md)
- [mox](../../ads/vendors/mox.md)
- [my6Sense](../../ads/vendors/my6sense.md)
Expand Down

0 comments on commit 4ecaad6

Please sign in to comment.