(global, data)
| 5 | * @param {!Object} data |
| 6 | */ |
| 7 | export function dable(global, data) { |
| 8 | // check required props |
| 9 | validateData(data, ['widgetId']); |
| 10 | |
| 11 | global.dable = |
| 12 | global.dable || |
| 13 | function () { |
| 14 | (global.dable.q = global.dable.q || []).push(arguments); |
| 15 | }; |
| 16 | global.dable( |
| 17 | 'setService', |
| 18 | data['serviceName'] || global.window.context.location.hostname |
| 19 | ); |
| 20 | global.dable( |
| 21 | 'setURL', |
| 22 | global.window.context.canonicalUrl || global.window.context.sourceUrl |
| 23 | ); |
| 24 | global.dable('setRef', global.window.context.referrer); |
| 25 | |
| 26 | const slot = global.document.createElement('div'); |
| 27 | slot.id = '_dbl_' + Math.floor(Math.random() * 100000); |
| 28 | slot.setAttribute('data-widget_id', data['widgetId']); |
| 29 | |
| 30 | const divContainer = global.document.getElementById('c'); |
| 31 | if (divContainer) { |
| 32 | divContainer.appendChild(slot); |
| 33 | } |
| 34 | |
| 35 | const itemId = data['itemId'] || ''; |
| 36 | const channel = data['channel'] || ''; |
| 37 | const articleSection = data['articleSection'] || ''; |
| 38 | const articleSection2 = data['articleSection2'] || ''; |
| 39 | const articleSection3 = data['articleSection3'] || ''; |
| 40 | const orgServiceId = data['orgServiceId'] || ''; |
| 41 | const widgetOpts = {}; |
| 42 | const logOpts = {}; |
| 43 | |
| 44 | if (channel) { |
| 45 | widgetOpts.channel = channel; |
| 46 | } |
| 47 | if (articleSection) { |
| 48 | widgetOpts.category1 = articleSection; |
| 49 | logOpts.category1 = articleSection; |
| 50 | } |
| 51 | if (articleSection2) { |
| 52 | widgetOpts.category2 = articleSection2; |
| 53 | logOpts.category2 = articleSection2; |
| 54 | } |
| 55 | if (articleSection3) { |
| 56 | widgetOpts.category3 = articleSection3; |
| 57 | logOpts.category3 = articleSection3; |
| 58 | } |
| 59 | if (orgServiceId) { |
| 60 | widgetOpts.orgServiceId = orgServiceId; |
| 61 | logOpts.orgServiceId = orgServiceId; |
| 62 | } |
| 63 | |
| 64 | if (itemId) { |
nothing calls this directly
no test coverage detected