Browse Source

Pubdirecte support

Amauri CHAMPEAUX 10 years ago
parent
commit
c762ed3209
2 changed files with 39 additions and 2 deletions
  1. 6 2
      tarteaucitron.js
  2. 33 0
      tarteaucitron.services.js

+ 6 - 2
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,

+ 33 - 0
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",