Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added new ad network vlyby (#30205)
* initial setup * added correct cdn links and added prop for observer * updated readme * added missing comma * removed unused code and fixed linter errors * fixed vlyby readme linter issues * initial setup email added rebase * added correct cdn links and added prop for observer * updated readme * added missing comma * removed unused code and fixed linter errors * fixed vlyby readme linter issues * added allowed_data * fixed prettier error * fixed types * type check err fix * fixed getdata * removed unnecessary global pass down * pass down global fix * fixed missing param * reverted last 2 commits Co-authored-by: Martin Schwager <mschwager@notebooksbilliger.de> Co-authored-by: Martin <martin@samcube.de>
- Loading branch information
1 parent
23a38c4
commit 80f913d
Showing
6 changed files
with
136 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
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,74 @@ | ||
/** | ||
* Copyright 2016 The AMP HTML Authors. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS-IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/* eslint-disable require-jsdoc */ | ||
import {validateData} from '../3p/3p'; | ||
|
||
/** | ||
* @param {!Window} global | ||
* @param {!Object} data | ||
*/ | ||
export function vlyby(global, data) { | ||
/*eslint "google-camelcase/google-camelcase": 0*/ | ||
global._vlyby_amp = { | ||
allowed_data: ['publisherid', 'placementid', 'pubref'], | ||
mandatory_data: ['publisherid', 'placementid'], | ||
data: { | ||
pubref: '', | ||
publisherid: '', | ||
placementid: '', | ||
...data, | ||
}, | ||
}; | ||
|
||
validateData(data, global._vlyby_amp.mandatory_data); | ||
|
||
const rand = Math.round(Math.random() * 100000000); | ||
|
||
// install observation on entering/leaving the view | ||
global.context.observeIntersection(function (changes) { | ||
/** @type {!Array} */ (changes).forEach(function (c) { | ||
if (global._vlyby_amp) { | ||
global._vlyby_amp.rects = c; | ||
} | ||
}); | ||
}); | ||
|
||
//create Container | ||
const containerId = 'qad' + rand; | ||
createContainer(global, containerId); | ||
|
||
//create Script | ||
createScript(global, containerId); | ||
|
||
function createScript(global, id) { | ||
const s = global.document.createElement('script'); | ||
const referrer = data['pubref'] || global.context.canonicalUrl; | ||
|
||
s.setAttribute('type', 'text/javascript'); | ||
s.setAttribute('async', 'true'); | ||
s.setAttribute('src', '//amp.vlyby.com/qad/qad-outer2.js'); | ||
s.setAttribute('data-PubId', data['publisherid']); | ||
s.setAttribute('data-PlacementId', data['placementid']); | ||
s.setAttribute('data-DivId', id); | ||
s.setAttribute('data-PubRef', referrer); | ||
global.document.getElementById('c').appendChild(s); | ||
} | ||
function createContainer(global, id) { | ||
const d = global.document.createElement('div'); | ||
d.id = id; | ||
global.document.getElementById('c').appendChild(d); | ||
} | ||
} |
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,43 @@ | ||
<!--- | ||
Copyright 2016 The AMP HTML Authors. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS-IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
# vlyby | ||
|
||
## Example | ||
|
||
```html | ||
<amp-embed | ||
width="300" | ||
height="250" | ||
type="vlyby" | ||
layout="responsive" | ||
heights="250px" | ||
data-publisherid="f363eb2b75459b34592cc4" | ||
data-placementid="default" | ||
data-pubref="test.amp.com" | ||
> | ||
</amp-embed> | ||
``` | ||
|
||
## Configuration | ||
|
||
Supported parameters: | ||
|
||
All parameters are mandatory, only `data-pubref` is optional. | ||
|
||
- `data-publisherid` (String, non-empty) | ||
- `data-placementid` (String, non-empty) | ||
- `data-pubref` (String) |
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