(global, data)
| 5 | * @param {!Object} data |
| 6 | */ |
| 7 | export function affinity(global, data) { |
| 8 | validateData( |
| 9 | data, |
| 10 | ['width', 'height', 'adtype', ['adslot', 'slot']], |
| 11 | [ |
| 12 | 'affLayout', |
| 13 | 'multiSize', |
| 14 | 'affSticky', |
| 15 | 'affTitle', |
| 16 | 'affJson', |
| 17 | 'affRtcConfig', |
| 18 | 'jsontargeting', |
| 19 | 'extras', |
| 20 | ] |
| 21 | ); |
| 22 | |
| 23 | const runV1 = function (g, d) { |
| 24 | if (false === g.isInitCalled) { |
| 25 | g.isInitCalled = true; |
| 26 | loadScript(g, gGPT, () => { |
| 27 | loadScript(g, affCDN + '/amp/v2022/amp.js', () => { |
| 28 | (function () { |
| 29 | window.affinity.initAMP(g, d); |
| 30 | })(); |
| 31 | }); |
| 32 | }); |
| 33 | } |
| 34 | }, |
| 35 | O2s = Object.prototype.toString, |
| 36 | isObject = function (val) { |
| 37 | return '[object Object]' == O2s.call(val); |
| 38 | }, |
| 39 | chkIsvalidContext = function (mixContext) { |
| 40 | if ('string' == typeof mixContext) { |
| 41 | try { |
| 42 | mixContext = JSON.parse(mixContext); |
| 43 | } catch (e) { |
| 44 | return false; |
| 45 | } |
| 46 | } |
| 47 | if (isObject(mixContext) && mixContext.sourceUrl) { |
| 48 | return true; |
| 49 | } |
| 50 | return false; |
| 51 | }, |
| 52 | getAmpContext = function () { |
| 53 | if (chkIsvalidContext(W.context)) { |
| 54 | return W.context; |
| 55 | } |
| 56 | if (chkIsvalidContext(W.AMP_CONTEXT_DATA)) { |
| 57 | return W.AMP_CONTEXT_DATA; |
| 58 | } |
| 59 | |
| 60 | return undefined; |
| 61 | }, |
| 62 | jsonParse = function (strJson) { |
| 63 | let ret = null; |
| 64 | try { |
nothing calls this directly
no test coverage detected