Open janwinkler opened 1 year ago
The stub example is incorrect (the function __gpp_stub still returns the values instead of calling the callback).
Corrected function:
window.__gpp_stub = function () { var b = arguments; __gpp.queue = __gpp.queue || []; if (!b.length) { return __gpp.queue; } var cmd = b[0]; var clb = b.length > 1 ? b[1] : null; var par = b.length > 2 ? b[2] : null; var result = null; if (cmd === 'ping') { result = { gppVersion: '1.1', // must be “Version.Subversion”, current: “1.1” cmpStatus: 'stub', // possible values: stub, loading, loaded, error cmpDisplayStatus: 'hidden', // possible values: hidden, visible, disabled supportedAPIs: ['2:tcfeuv2', '5:tcfcav1', '6:uspv1'], // list of supported APIs signalStatus : 'not ready', cmpId: 31, // IAB assigned CMP ID, may be 0 during stub/loading sectionList: [], applicableSections: [-1], //or 0 or ID set by publisher gppString: '' }; } else if (cmd === 'addEventListener') { __gpp.events = __gpp.events || []; if (!('lastId' in __gpp)) { __gpp.lastId = 0; } __gpp.lastId++; var lnr = __gpp.lastId; __gpp.events.push({ 'id': lnr, 'callback': clb, 'parameter': par }); result = { eventName: 'listenerRegistered', listenerId: lnr, // Registered ID of the listener data: true, // positive signal pingData: { gppVersion: '1.1', cmpStatus: 'stub', signalStatus : 'not ready', cmpDisplayStatus: 'hidden', supportedAPIs: ['2:tcfeuv2', '5:tcfcav1', '9:usva', '7:usnat'], cmpId: 31, sectionList: [], applicableSections: [-1], //or 0 or ID set by publisher gppString: '' } }; } else if (cmd === 'removeEventListener') { var success = false; __gpp.events = __gpp.events || []; for (var i = 0; i < __gpp.events.length; i++) { if (__gpp.events[i].id == par) { __gpp.events[i].splice(i, 1); success = true; break; } } result = { eventName: 'listenerRemoved', listenerId: par, // Registered ID of the listener data: success, // status info pingData: { gppVersion: '1.1', cmpStatus: 'stub', signalStatus : 'not ready', cmpDisplayStatus: 'hidden', supportedAPIs: ['2:tcfeuv2', '5:tcfcav1', '9:usva', '7:usnat'], cmpId: 31, sectionList: [], applicableSections: [-1], //or 0 or ID set by publisher gppString: '' } }; } //queue all other commands else { __gpp.queue.push([].slice.apply(b)); } if(result !== null && typeof(clb) === 'function') { clb(result, true); } };
@janwinkler do you mind opening a PR to correct this?
The stub example is incorrect (the function __gpp_stub still returns the values instead of calling the callback).
Corrected function: