Browse Source

Making id uniq

Amauri CHAMPEAUX 10 years ago
parent
commit
1615ede70d
2 changed files with 17 additions and 12 deletions
  1. 2 2
      tarteaucitron.js
  2. 15 10
      tarteaucitron.services.js

+ 2 - 2
tarteaucitron.js

@@ -382,14 +382,14 @@ var tarteaucitron = {
             }
         }
     },
-    "engage": function (id) {
+    "engage": function (id, r) {
         "use strict";
         var html = '';
         
         html += '<div class="tac_activate">';
         html += '   <div class="tac_float">';
         html += '      <b>' + id + '</b> ' + tarteaucitron.lang.fallback + '<br/>';
-        html += '      <div class="tarteaucitronAllow" id="tacEngage' + id + '">';
+        html += '      <div class="tarteaucitronAllow" id="tacEngage' + id + r + '">';
         html += '          ' + tarteaucitron.lang.allow;
         html += '       </div>';
         html += '   </div>';

+ 15 - 10
tarteaucitron.services.js

@@ -17,10 +17,11 @@ tarteaucitron.services.disqus = {
     },
     "fallback": function () {
         "use strict";
-        var id = 'disqus';
+        var id = 'disqus',
+            r = Math.floor(Math.random() * 100000);
         
         document.getElementById('disqus_thread').innerHTML = tarteaucitron.engage(id);
-        document.getElementById('tacEngage' + id).onclick = function () {
+        document.getElementById('tacEngage' + id + r).onclick = function () {
             tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true);
         };
     }
@@ -49,12 +50,13 @@ tarteaucitron.services.sharethis = {
     "fallback": function () {
         "use strict";
         var cookies = ['__unam'],
-            id = 'sharethis';
+            id = 'sharethis',
+            r = Math.floor(Math.random() * 100000);
         
         tarteaucitron.cookie.purge(cookies);
         
         tarteaucitron.fallback(['tacSharethis'], tarteaucitron.engage(id));
-        document.getElementById('tacEngage' + id).onclick = function () {
+        document.getElementById('tacEngage' + id + r).onclick = function () {
             tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true);
         };
     }
@@ -83,12 +85,13 @@ tarteaucitron.services.shareaholic = {
     "fallback": function () {
         "use strict";
         var cookies = ['__utma', '__utmb', '__utmc', '__utmz'],
-            id = 'shareaholic';
+            id = 'shareaholic',
+            r = Math.floor(Math.random() * 100000);
         
         tarteaucitron.cookie.purge(cookies);
         
         tarteaucitron.fallback(['shareaholic-canvas'], tarteaucitron.engage(id));
-        document.getElementById('tacEngage' + id).onclick = function () {
+        document.getElementById('tacEngage' + id + r).onclick = function () {
             tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true);
         };
     }
@@ -112,12 +115,13 @@ tarteaucitron.services.addthis = {
     "fallback": function () {
         "use strict";
         var cookies = ['__atuvc'],
-            id = 'addthis';
+            id = 'addthis',
+            r = Math.floor(Math.random() * 100000);
         
         tarteaucitron.cookie.purge(cookies);
         
         tarteaucitron.fallback(['addthis_sharing_toolbox'], tarteaucitron.engage(id));
-        document.getElementById('tacEngage' + id).onclick = function () {
+        document.getElementById('tacEngage' + id + r).onclick = function () {
             tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true);
         };
     }
@@ -171,10 +175,11 @@ tarteaucitron.services.adsense = {
     },
     "fallback": function () {
         "use strict";
-        var id = 'adsense';
+        var id = 'adsense',
+            r = Math.floor(Math.random() * 100000);
         
         tarteaucitron.fallback(['adsbygoogle'], tarteaucitron.engage(id));
-        document.getElementById('tacEngage' + id).onclick = function () {
+        document.getElementById('tacEngage' + id + r).onclick = function () {
             tarteaucitron.userInterface.respond(document.getElementById(id + 'Allowed'), true);
         };
     }