From c762ed3209690331efa27e184901b558ae441eec Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Sun, 22 Feb 2015 10:23:19 +0100 Subject: [PATCH] Pubdirecte support --- tarteaucitron.js | 8 ++++++-- tarteaucitron.services.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 1b5616d..28820ed 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -1,4 +1,4 @@ -/*jslint browser: true */ +/*jslint browser: true, evil: true */ // define correct path for files inclusion var scripts = document.getElementsByTagName('script'), @@ -415,6 +415,7 @@ var tarteaucitron = { "use strict"; tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none'); tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none'); + document.location.hash = ''; }, "openAlert": function () { "use strict"; @@ -585,6 +586,7 @@ var tarteaucitron = { "makeAsync": { "buffer": '', "init": function (url, id) { + "use strict"; var savedWrite = document.write, savedWriteln = document.writeln; @@ -595,7 +597,7 @@ var tarteaucitron = { tarteaucitron.makeAsync.buffer += content.concat("\n"); }; - setTimeout(function() { + setTimeout(function () { document.write = savedWrite; document.writeln = savedWriteln; }, 60000); @@ -603,6 +605,7 @@ var tarteaucitron = { tarteaucitron.makeAsync.getAndParse(url, id); }, "getAndParse": function (url, id) { + "use strict"; tarteaucitron.addScript(url, '', function () { document.getElementById(id).innerHTML += tarteaucitron.makeAsync.buffer; tarteaucitron.makeAsync.buffer = ''; @@ -610,6 +613,7 @@ var tarteaucitron = { }); }, "execJS": function forceJsExec(id) { + /* not strict because third party scripts may have errors */ var i, scripts, childId, diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 7a39b4c..7773f5f 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -123,6 +123,7 @@ tarteaucitron.services.criteo = { "needConsent": true, "cookies": [], "js": function () { + "use strict"; document.MAX_ct0 = ''; var criteoUri = '//cas.criteo.com/delivery/ajs.php?', divId = 'criteo_' + tarteaucitron.user.criteoZoneId; @@ -574,6 +575,38 @@ tarteaucitron.services.pinterest = { } }; +// pubdirecte +tarteaucitron.services.pubdirecte = { + "key": "pubdirecte", + "type": "ads", + "name": "Pubdirecte", + "uri": "http://pubdirecte.com/contact.php", + "needConsent": true, + "cookies": [], + "js": function () { + "use strict"; + var pubdirecteUri = '//www.pubdirecte.com/script/banniere.php?', + divId = 'pubdirecte_' + tarteaucitron.user.pubdirecteId; + + if (tarteaucitron.user.pubdirecteId === undefined || document.getElementById(divId) === null) { + return; + } + + pubdirecteUri += 'id=' + tarteaucitron.user.pubdirecteId + '&ref=' + document.getElementById(divId).getAttribute('ref'); + document.getElementById(divId).innerHTML = ''; + tarteaucitron.makeAsync.init(pubdirecteUri, divId); + }, + "fallback": function () { + "use strict"; + var id = 'pubdirecte', + divId = id + '_' + tarteaucitron.user.pubdirecteId; + + if (document.getElementById(divId)) { + document.getElementById(divId).innerHTML = tarteaucitron.engage(id); + } + } +}; + // shareaholic tarteaucitron.services.shareaholic = { "key": "shareaholic",