From 489d37a5b24ba88df813b6a0d743f824fe500c0c Mon Sep 17 00:00:00 2001 From: lucmuller Date: Fri, 29 Jun 2018 11:56:03 +0200 Subject: [PATCH 01/17] Ajout d'un service pour Google On Steroids Voir : https://github.com/CardinalPath/gas --- tarteaucitron.services.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index ba771ea..dfc1151 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1030,6 +1030,38 @@ tarteaucitron.services.gajs = { } }; +// google on steroids +var _gas = _gas || []; +tarteaucitron.services.gas = { + "key": "gas", + "type": "analytic", + "name": "Google Analytics on Steroids", + "uri": "https://github.com/CardinalPath/gas", + "needConsent": true, + "cookies": ['_ga', '_gat', '_gid', '__utma', '__utmb', '__utmc', '__utmt', '__utmz'], + "js": function () { + "use strict"; + _gas.push(['_setAccount', tarteaucitron.user.gasUa]); // REPLACE WITH YOUR GA NUMBER + _gas.push(['_setDomainName', tarteaucitron.parameters.cookieDomain]); // REPLACE WITH YOUR DOMAIN + _gas.push(['_trackPageview']); + _gas.push(['_gasTrackForms']); + _gas.push(['_gasTrackOutboundLinks']); + _gas.push(['_gasTrackMaxScroll']); + _gas.push(['_gasTrackDownloads']); + _gas.push(['_gasTrackVideo']); + _gas.push(['_gasTrackAudio']); + _gas.push(['_gasTrackYoutube', {force: true}]); + _gas.push(['_gasTrackVimeo', {force: true}]); + _gas.push(['_gasTrackMailto']); + + tarteaucitron.addScript('//cdnjs.cloudflare.com/ajax/libs/gas/1.11.0/gas.min.js', 'gas-script', function () { + if (typeof tarteaucitron.user.gasMore === 'function') { + tarteaucitron.user.gasMore(); + } + },'','data-use-dcjs','false'); + } +}; + // google analytics tarteaucitron.services.analytics = { "key": "analytics", @@ -2165,3 +2197,4 @@ tarteaucitron.services.webmecanik = { }); } }; + From 2e8ac445bb7c03000b47bbbb2c38223fc0e3c995 Mon Sep 17 00:00:00 2001 From: guillaumeKoban <40759279+guillaumeKoban@users.noreply.github.com> Date: Mon, 2 Jul 2018 15:10:50 +0200 Subject: [PATCH 02/17] Add Koban service --- README.md | 1 + tarteaucitron.services.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/README.md b/README.md index 75c6b96..a81ba9f 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Bonus: * Marketing Automation & CRM * Mautic * Webmecanik Automation + * Koban * Social network * AddThis diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 03e1955..425f763 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2200,3 +2200,31 @@ tarteaucitron.services.multiplegtag = { } }; +// Koban +tarteaucitron.services.koban = { + "key": "koban", + "type": "analytic", + "name": "Koban", + "uri": "https://koban.cloud/tos", + "needConsent": true, + "cookies": ['kbntrk'], + "js": function () { + "use strict"; + if (tarteaucitron.user.kobanurl === undefined) { + return; + } + if (tarteaucitron.user.kobanapi === undefined) { + return; + } + window.KobanObject = 'kb'; + window.kb = window.kb || function() { + window.kb.q = window.kb.q || []; + window.kb.q.push(arguments); + }; + window.kb.l = new Date(); + kb('reg', tarteaucitron.user.kobanapi); + tarteaucitron.addScript(tarteaucitron.user.kobanurl, '', function() { + }); + } +}; + From 1c917ed62b0aaa31e70fa576bf45e4b5d88b19e4 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Thu, 5 Jul 2018 10:33:59 +0200 Subject: [PATCH 03/17] Added matomo service without merge conflict --- tarteaucitron.services.js | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 03e1955..9ddf7fe 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2200,3 +2200,44 @@ tarteaucitron.services.multiplegtag = { } }; +// matomo + +/* + 1. Set the following variable before the initialization : + + tarteaucitron.user.matomoId = YOUR_SITE_ID_FROM_MATOMO; + tarteaucitron.user.matomoHost = "YOUR_MATOMO_URL"; //eg: https://stat.mydomain.com/ + + 2. Push the service : + + (tarteaucitron.job = tarteaucitron.job || []).push('matomo'); + + 3. HTML + You don't need to add any html code, if the service is autorized, the javascript is added. otherwise no. + */ +tarteaucitron.services.matomo = { + "key": "matomo", + "type": "analytic", + "name": "Matomo (formerly known as Piwik)", + "uri": "https://matomo.org/faq/general/faq_146/", + "needConsent": true, + "cookies": ['_pk_ref', '_pk_cvar', '_pk_id', '_pk_ses', '_pk_hsr', 'piwik_ignore', '_pk_uid'], + "js": function () { + "use strict"; + console.log("matomo"); + if (tarteaucitron.user.matomoId === undefined) { + return; + } + + window._paq = window._paq || []; + window._paq.push(["setSiteId", tarteaucitron.user.matomoId]); + window._paq.push(["setTrackerUrl", tarteaucitron.user.matomoHost + "piwik.php"]); + window._paq.push(["setDoNotTrack", 1]); + window._paq.push(["trackPageView"]); + window._paq.push(["setIgnoreClasses", ["no-tracking", "colorbox"]]); + window._paq.push(["enableLinkTracking"]); + + tarteaucitron.addScript(tarteaucitron.user.matomoHost + 'piwik.js', '', '', true, 'defer', true); + } +}; + From 8168f29e12cf6cc76379cd116d8781a5888146e8 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Sat, 7 Jul 2018 12:04:31 +0200 Subject: [PATCH 04/17] removed console.log --- tarteaucitron.services.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 9ddf7fe..ea1eba1 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2224,7 +2224,6 @@ tarteaucitron.services.matomo = { "cookies": ['_pk_ref', '_pk_cvar', '_pk_id', '_pk_ses', '_pk_hsr', 'piwik_ignore', '_pk_uid'], "js": function () { "use strict"; - console.log("matomo"); if (tarteaucitron.user.matomoId === undefined) { return; } From bbd6cc01b986a6af4b984fafd99cb79130ed546b Mon Sep 17 00:00:00 2001 From: Julien Petit Date: Wed, 11 Jul 2018 17:28:45 +0200 Subject: [PATCH 05/17] Gtag variable should be set in global scope for later use (gtagMore or event calls) --- tarteaucitron.services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index ea1eba1..97b8b00 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1073,7 +1073,7 @@ tarteaucitron.services.gtag = { "use strict"; window.dataLayer = window.dataLayer || []; tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + tarteaucitron.user.gtagUa, '', function () { - function gtag(){dataLayer.push(arguments);} + window.gtag = function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', tarteaucitron.user.gtagUa); From bcef457b24c699d9610b186dd3ed9e30883dfd2f Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Thu, 12 Jul 2018 08:38:04 +0200 Subject: [PATCH 06/17] gtag() scope for multiple gtag ua --- tarteaucitron.services.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 97b8b00..330cb31 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2192,7 +2192,7 @@ tarteaucitron.services.multiplegtag = { tarteaucitron.user.multiplegtagUa.forEach(function(ua) { tarteaucitron.addScript('https://www.googletagmanager.com/gtag/js?id=' + ua, '', function () { - function gtag(){dataLayer.push(arguments);} + window.gtag = function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', ua); }); From 719ebf0fdc3137bd828de389217770cf45475659 Mon Sep 17 00:00:00 2001 From: Yohann bianchi Date: Wed, 18 Jul 2018 15:33:18 +0200 Subject: [PATCH 07/17] =?UTF-8?q?=E2=9C=A8=20Add=20the=20ability=20to=20lo?= =?UTF-8?q?ad=20Google=20Maps=20libraries=20(ie.=20geometry,=20places,=20v?= =?UTF-8?q?isualization,=20drawing)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tarteaucitron.services.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 330cb31..7857a67 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1103,7 +1103,13 @@ tarteaucitron.services.googlemaps = { tarteaucitron.user.mapscallback = 'tac_googlemaps_callback'; } - tarteaucitron.addScript('//maps.googleapis.com/maps/api/js?v=3.exp&key=' + tarteaucitron.user.googlemapsKey + '&callback='+tarteaucitron.user.mapscallback); + // Add Google Maps libraries if any (https://developers.google.com/maps/documentation/javascript/libraries) + var googleMapsLibraries; + if (tarteaucitron.user.googlemapsLibraries) { + googleMapsLibraries = '&libraries=' + tarteaucitron.user.googlemapsLibraries; + } + + tarteaucitron.addScript('//maps.googleapis.com/maps/api/js?v=3.exp&key=' + tarteaucitron.user.googlemapsKey + '&callback='+tarteaucitron.user.mapscallback + googleMapsLibraries); window.tac_googlemaps_callback = function () { tarteaucitron.fallback(['googlemaps-canvas'], function (x) { From c35edea79da580b7e9e9710ff0068d2f0218cb73 Mon Sep 17 00:00:00 2001 From: lucmuller Date: Mon, 23 Jul 2018 10:39:40 +0200 Subject: [PATCH 08/17] Update tarteaucitron.services.js --- tarteaucitron.services.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index c7838b5..4fc6a54 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -711,7 +711,7 @@ tarteaucitron.services.facebook = { "cookies": [], "js": function () { "use strict"; - tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like'], ''); + tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like', 'fb-video'], ''); tarteaucitron.addScript('//connect.facebook.net/' + tarteaucitron.getLocale() + '/sdk.js#xfbml=1&version=v2.0', 'facebook-jssdk'); if (tarteaucitron.isAjax === true) { if (typeof FB !== "undefined") { @@ -722,7 +722,7 @@ tarteaucitron.services.facebook = { "fallback": function () { "use strict"; var id = 'facebook'; - tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like'], tarteaucitron.engage(id)); + tarteaucitron.fallback(['fb-post', 'fb-follow', 'fb-activity', 'fb-send', 'fb-share-button', 'fb-like', 'fb-video'], tarteaucitron.engage(id)); } }; @@ -2230,4 +2230,4 @@ tarteaucitron.services.multiplegtag = { }); }); } -}; \ No newline at end of file +}; From 3dc11107aab0e6777a658623f58c10f14167952f Mon Sep 17 00:00:00 2001 From: lucmuller Date: Mon, 23 Jul 2018 10:46:14 +0200 Subject: [PATCH 09/17] Update tarteaucitron.services.js Suppression de Gogle On Steroids depuis mon master --- tarteaucitron.services.js | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index eb0ffe8..b79a78b 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -1030,38 +1030,6 @@ tarteaucitron.services.gajs = { } }; -// google on steroids -var _gas = _gas || []; -tarteaucitron.services.gas = { - "key": "gas", - "type": "analytic", - "name": "Google Analytics on Steroids", - "uri": "https://github.com/CardinalPath/gas", - "needConsent": true, - "cookies": ['_ga', '_gat', '_gid', '__utma', '__utmb', '__utmc', '__utmt', '__utmz'], - "js": function () { - "use strict"; - _gas.push(['_setAccount', tarteaucitron.user.gasUa]); // REPLACE WITH YOUR GA NUMBER - _gas.push(['_setDomainName', tarteaucitron.parameters.cookieDomain]); // REPLACE WITH YOUR DOMAIN - _gas.push(['_trackPageview']); - _gas.push(['_gasTrackForms']); - _gas.push(['_gasTrackOutboundLinks']); - _gas.push(['_gasTrackMaxScroll']); - _gas.push(['_gasTrackDownloads']); - _gas.push(['_gasTrackVideo']); - _gas.push(['_gasTrackAudio']); - _gas.push(['_gasTrackYoutube', {force: true}]); - _gas.push(['_gasTrackVimeo', {force: true}]); - _gas.push(['_gasTrackMailto']); - - tarteaucitron.addScript('//cdnjs.cloudflare.com/ajax/libs/gas/1.11.0/gas.min.js', 'gas-script', function () { - if (typeof tarteaucitron.user.gasMore === 'function') { - tarteaucitron.user.gasMore(); - } - },'','data-use-dcjs','false'); - } -}; - // google analytics tarteaucitron.services.analytics = { "key": "analytics", @@ -2270,4 +2238,4 @@ tarteaucitron.services.matomo = { tarteaucitron.addScript(tarteaucitron.user.matomoHost + 'piwik.js', '', '', true, 'defer', true); } -}; \ No newline at end of file +}; From 249a00dd7ebdbe53457846999294c44bdd7233e5 Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Wed, 25 Jul 2018 19:59:41 +0200 Subject: [PATCH 10/17] Fix missing braces Thanks @rubycon --- tarteaucitron.services.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 21216f2..de910e4 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2231,6 +2231,9 @@ tarteaucitron.services.koban = { kb('reg', tarteaucitron.user.kobanapi); tarteaucitron.addScript(tarteaucitron.user.kobanurl, '', function() { }); + } +}; + // matomo /* From b1cae8da4f50ce77fcfcd8853a65b05319873be9 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Fri, 27 Jul 2018 10:55:14 +0200 Subject: [PATCH 11/17] added utility function to AddOrUpdate a field on object --- tarteaucitron.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tarteaucitron.js b/tarteaucitron.js index 39de7c1..6596829 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -11,6 +11,20 @@ var scripts = document.getElementsByTagName('script'), tarteaucitronProLoadServices, tarteaucitronNoAdBlocker = false; +/** + Utility function to Add or update the fields of obj1 with the ones in obj2 +*/ +function AddOrUpdate(obj1, obj2){ + for(key in obj2){ + if(obj2[key] instanceof Object){ + obj1[key] = AddOrUpdate(obj1[key], obj2[key]); + }else{ + obj1[key] = obj2[key]; + } + } + return obj1; +} + var tarteaucitron = { "version": 323, "cdn": cdn, From 1d97b3fa956afe95cf8daf5e15f335179d36d87f Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Fri, 27 Jul 2018 10:55:50 +0200 Subject: [PATCH 12/17] Update tarteaucitron.lang with the custom text given --- tarteaucitron.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tarteaucitron.js b/tarteaucitron.js index 6596829..2c1332a 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -223,6 +223,10 @@ var tarteaucitron = { // Step 2: load language and services tarteaucitron.addScript(pathToLang, '', function () { + + if(tarteaucitronCustomText !== undefined){ + tarteaucitron.lang = AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText); + } tarteaucitron.addScript(pathToServices, '', function () { var body = document.body, From a59ee49abba80ffa1ac85a9b4e68e0ffb6ec3295 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Fri, 27 Jul 2018 19:33:31 +0200 Subject: [PATCH 13/17] corrected if undefined variable --- tarteaucitron.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 2c1332a..eee83a4 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -7,6 +7,7 @@ var scripts = document.getElementsByTagName('script'), alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch, tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage, tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire, + tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText, timeExipre = 31536000000, tarteaucitronProLoadServices, tarteaucitronNoAdBlocker = false; @@ -224,7 +225,7 @@ var tarteaucitron = { // Step 2: load language and services tarteaucitron.addScript(pathToLang, '', function () { - if(tarteaucitronCustomText !== undefined){ + if(tarteaucitronCustomText !== ''){ tarteaucitron.lang = AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText); } tarteaucitron.addScript(pathToServices, '', function () { From 1ea7bfa82ab2fca3ca1faacd66b96f39b4e638d4 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Mon, 30 Jul 2018 19:47:12 +0200 Subject: [PATCH 14/17] move utility function in tarteaucitron --- tarteaucitron.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index eee83a4..6669694 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -12,19 +12,7 @@ var scripts = document.getElementsByTagName('script'), tarteaucitronProLoadServices, tarteaucitronNoAdBlocker = false; -/** - Utility function to Add or update the fields of obj1 with the ones in obj2 -*/ -function AddOrUpdate(obj1, obj2){ - for(key in obj2){ - if(obj2[key] instanceof Object){ - obj1[key] = AddOrUpdate(obj1[key], obj2[key]); - }else{ - obj1[key] = obj2[key]; - } - } - return obj1; -} + var tarteaucitron = { "version": 323, @@ -226,7 +214,7 @@ var tarteaucitron = { tarteaucitron.addScript(pathToLang, '', function () { if(tarteaucitronCustomText !== ''){ - tarteaucitron.lang = AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText); + tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText); } tarteaucitron.addScript(pathToServices, '', function () { @@ -1304,5 +1292,18 @@ var tarteaucitron = { } tarteaucitron.cookie.number(); + }, + "AddOrUpdate" : function AddOrUpdate(source, custom){ + /** + Utility function to Add or update the fields of obj1 with the ones in obj2 + */ + for(key in custom){ + if(custom[key] instanceof Object){ + source[key] = AddOrUpdate(source[key], custom[key]); + }else{ + source[key] = custom[key]; + } + } + return source; } }; From b4c14b9ec9180024841c35ab738f240a8c20ed98 Mon Sep 17 00:00:00 2001 From: Ricci Dorian Date: Tue, 31 Jul 2018 09:44:18 +0200 Subject: [PATCH 15/17] corrected call to the method --- tarteaucitron.js | 194 +++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/tarteaucitron.js b/tarteaucitron.js index 6669694..61d14b6 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -30,7 +30,7 @@ var tarteaucitron = { "init": function (params) { "use strict"; var origOpen; - + tarteaucitron.parameters = params; if (alreadyLaunch === 0) { alreadyLaunch = 1; @@ -50,13 +50,13 @@ var tarteaucitron = { if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) { if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') { heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px'; - + if (scrollPos > (screen.height * 2)) { tarteaucitron.userInterface.respondAll(true); } else if (scrollPos > (screen.height / 2)) { document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig; } - + if (tarteaucitron.orientation === 'top') { document.getElementById('tarteaucitronPercentage').style.top = heightPosition; } else { @@ -82,7 +82,7 @@ var tarteaucitron = { tarteaucitron.userInterface.jsSizing('main'); } } - + if (document.getElementById('tarteaucitronCookiesListContainer') !== null) { if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') { tarteaucitron.userInterface.jsSizing('cookie'); @@ -105,7 +105,7 @@ var tarteaucitron = { if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) { if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') { heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px'; - + if (scrollPos > (screen.height * 2)) { tarteaucitron.userInterface.respondAll(true); } else if (scrollPos > (screen.height / 2)) { @@ -136,7 +136,7 @@ var tarteaucitron = { tarteaucitron.userInterface.jsSizing('main'); } } - + if (document.getElementById('tarteaucitronCookiesListContainer') !== null) { if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') { tarteaucitron.userInterface.jsSizing('cookie'); @@ -144,11 +144,11 @@ var tarteaucitron = { } }); } - + if (typeof XMLHttpRequest !== 'undefined') { origOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function () { - + if (window.addEventListener) { this.addEventListener("load", function () { if (typeof tarteaucitronProLoadServices === 'function') { @@ -166,7 +166,7 @@ var tarteaucitron = { setTimeout(tarteaucitronProLoadServices, 1000); } } - + try { origOpen.apply(this, arguments); } catch (err) {} @@ -192,12 +192,12 @@ var tarteaucitron = { "handleBrowserDNTRequest": false }, params = tarteaucitron.parameters; - + // Step 0: get params if (params !== undefined) { tarteaucitron.extend(defaults, params); } - + // global tarteaucitron.orientation = defaults.orientation; tarteaucitron.hashtag = defaults.hashtag; @@ -225,7 +225,7 @@ var tarteaucitron = { orientation = 'Top', cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'], i; - + cat = cat.sort(function (a, b) { if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; } if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; } @@ -277,11 +277,11 @@ var tarteaucitron = { html += ' '; html += ' '; html += ''; - + if (defaults.orientation === 'bottom') { orientation = 'Bottom'; } - + if (defaults.highPrivacy) { html += '
'; html += ' '; @@ -305,7 +305,7 @@ var tarteaucitron = { html += '
'; html += '
'; } - + if (defaults.showAlertSmall === true) { html += '
'; html += '
'; @@ -332,7 +332,7 @@ var tarteaucitron = { } html += '
'; } - + tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () { if (tarteaucitronNoAdBlocker === true || defaults.adblocker === false) { div.id = 'tarteaucitronRoot'; @@ -347,7 +347,7 @@ var tarteaucitron = { } else { tarteaucitron.job = [] } - + tarteaucitron.isAjax = true; tarteaucitron.job.push = function (id) { @@ -370,16 +370,16 @@ var tarteaucitron = { tarteaucitron.launch[id] = false; tarteaucitron.addService(id); }; - + if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') { tarteaucitron.userInterface.openPanel(); } - + tarteaucitron.cookie.number(); setInterval(tarteaucitron.cookie.number, 60000); } }, defaults.adblocker); - + if (defaults.adblocker === true) { setTimeout(function () { if (tarteaucitronNoAdBlocker === false) { @@ -423,7 +423,7 @@ var tarteaucitron = { if (tarteaucitron.added[service.key] !== true) { tarteaucitron.added[service.key] = true; - + html += '
'; html += '
'; html += ' ' + service.name + '
'; @@ -445,13 +445,13 @@ var tarteaucitron = { html += '
'; html += '
'; html += '
'; - + tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block'); - + if (document.getElementById('tarteaucitronServices_' + service.type) !== null) { document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html; } - + tarteaucitron.userInterface.order(service.type); } @@ -460,7 +460,7 @@ var tarteaucitron = { isAllowed = true; tarteaucitron.cookie.create(service.key, true); } - + if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) { if (!isAllowed) { tarteaucitron.cookie.create(service.key, true); @@ -502,7 +502,7 @@ var tarteaucitron = { out = [], obj = {}, s = tarteaucitron.services; - + for (i = 0; i < len; i += 1) { if (!obj[arr[i]]) { obj[arr[i]] = {}; @@ -511,13 +511,13 @@ var tarteaucitron = { } } } - + out = out.sort(function (a, b) { if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; } if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; } return 0; }); - + return out; }, "userInterface": { @@ -533,7 +533,7 @@ var tarteaucitron = { service, key, index = 0; - + for (index = 0; index < tarteaucitron.job.length; index += 1) { service = s[tarteaucitron.job[index]]; key = service.key; @@ -554,16 +554,16 @@ var tarteaucitron = { "respond": function (el, status) { "use strict"; var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), ''); - + // return if same state if (tarteaucitron.state[key] === status) { return; } - + if (status === false && tarteaucitron.launch[key] === true) { tarteaucitron.reloadThePage = true; } - + // if not already launched... launch the service if (status === true) { if (tarteaucitron.launch[key] !== true) { @@ -610,11 +610,11 @@ var tarteaucitron = { nbAllowed += 1; } } - + tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%'); tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%'); tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%'); - + if (nbDenied === 0 && nbPending === 0) { tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark); tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray); @@ -625,16 +625,16 @@ var tarteaucitron = { tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray); tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray); } - + // close the alert if all service have been reviewed if (nbPending === 0) { tarteaucitron.userInterface.closeAlert(); } - + if (tarteaucitron.services[key].cookies.length > 0 && status === false) { tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies); } - + if (status === true) { if (document.getElementById('tacCL' + key) !== null) { document.getElementById('tacCL' + key).innerHTML = '...'; @@ -655,17 +655,17 @@ var tarteaucitron = { }, "closePanel": function () { "use strict"; - + if (document.location.hash === tarteaucitron.hashtag) { document.location.hash = ''; } tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none'); tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none'); - + tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) { elem.style.display = 'none'; }, true); - + if (tarteaucitron.reloadThePage === true) { window.location.reload(); } else { @@ -690,11 +690,11 @@ var tarteaucitron = { "toggleCookiesList": function () { "use strict"; var div = document.getElementById('tarteaucitronCookiesListContainer'); - + if (div === null) { return; } - + if (div.style.display !== 'block') { tarteaucitron.cookie.number(); div.style.display = 'block'; @@ -713,11 +713,11 @@ var tarteaucitron = { "toggle": function (id, closeClass) { "use strict"; var div = document.getElementById(id); - + if (div === null) { return; } - + if (closeClass !== undefined) { tarteaucitron.fallback([closeClass], function (elem) { if (elem.id !== id) { @@ -725,7 +725,7 @@ var tarteaucitron = { } }, true); } - + if (div.style.display !== 'block') { div.style.display = 'block'; } else { @@ -742,9 +742,9 @@ var tarteaucitron = { if (main === null) { return; } - + allDivs = main.childNodes; - + if (typeof Array.prototype.map === 'function') { Array.prototype.map.call(main.children, Object).sort(function (a, b) { if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; } @@ -774,18 +774,18 @@ var tarteaucitron = { paddingBox, alertSmallHeight, cookiesNumberHeight; - + if (type === 'box') { if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) { - + // reset tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px'); - + // calculate alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight; cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight; paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2; - + // apply tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px'); } @@ -799,79 +799,79 @@ var tarteaucitron = { // height of the services list container if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) { - + // reset tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', 'auto'); - + // calculate mainHeight = document.getElementById('tarteaucitron').offsetHeight; closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight; headerHeight = document.getElementById('tarteaucitronMainLineOffset').offsetHeight; - + // apply servicesHeight = (mainHeight - closeButtonHeight - headerHeight + 1); tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', servicesHeight + 'px'); } - + // align the main allow/deny button depending on scrollbar width if (document.getElementById('tarteaucitronScrollbarParent') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) { - + // media query if (e[a + 'Width'] <= 479) { tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px'); } else if (e[a + 'Width'] <= 767) { scrollbarMarginRight = 12; } - + scrollbarWidthParent = document.getElementById('tarteaucitronScrollbarParent').offsetWidth; scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth; tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px'); } - + // center the main panel if (document.getElementById('tarteaucitron') !== null) { - + // media query if (e[a + 'Width'] <= 767) { mainTop = 0; } else { mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21; } - + // correct if (mainTop < 0) { mainTop = 0; } - + if (document.getElementById('tarteaucitronMainLineOffset') !== null) { if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) { mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight; } } - + // apply tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px'); } } else if (type === 'cookie') { - + // put cookies list at bottom if (document.getElementById('tarteaucitronAlertSmall') !== null) { tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px'); } - + // height of cookies list if (document.getElementById('tarteaucitronCookiesListContainer') !== null) { - + // reset tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto'); - + // calculate cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight; cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight; cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight; - + // apply tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px'); } @@ -924,7 +924,7 @@ var tarteaucitron = { "purge": function (arr) { "use strict"; var i; - + for (i = 0; i < arr.length; i += 1) { document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;'; document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';'; @@ -939,7 +939,7 @@ var tarteaucitron = { html = '', i, status = document.cookie.indexOf(key + '=true'); - + if (status >= 0 && nb === 0) { html += tarteaucitron.lang.useNoCookie; } else if (status >= 0) { @@ -954,7 +954,7 @@ var tarteaucitron = { } } } - + if (nbCurrent > 0) { html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie'; if (nbCurrent > 1) { @@ -973,7 +973,7 @@ var tarteaucitron = { } html += '.'; } - + if (document.getElementById('tacCL' + key) !== null) { document.getElementById('tacCL' + key).innerHTML = html; } @@ -1004,7 +1004,7 @@ var tarteaucitron = { regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i, regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn, host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain; - + cookies = cookies.sort(function (a, b) { namea = a.split('=', 1).toString().replace(/ /g, ''); nameb = b.split('=', 1).toString().replace(/ /g, ''); @@ -1014,7 +1014,7 @@ var tarteaucitron = { if (c + a < d + b) { return -1; } return 0; }); - + if (document.cookie !== '') { for (i = 0; i < nb; i += 1) { name = cookies[i].split('=', 1).toString().replace(/ /g, ''); @@ -1045,21 +1045,21 @@ var tarteaucitron = { html += '
'; html += ''; } - + html += '
'; - + if (document.getElementById('tarteaucitronCookiesList') !== null) { document.getElementById('tarteaucitronCookiesList').innerHTML = html; } - + if (document.getElementById('tarteaucitronCookiesNumber') !== null) { document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb; } - + if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) { document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s; } - + for (i = 0; i < tarteaucitron.job.length; i += 1) { tarteaucitron.cookie.checkCount(tarteaucitron.job[i]); } @@ -1068,7 +1068,7 @@ var tarteaucitron = { "getLanguage": function () { "use strict"; if (!navigator) { return 'en'; } - + var availableLanguages = 'cs,en,fr,es,it,de,nl,pt,pl,ru', defaultLanguage = 'en', lang = navigator.language || navigator.browserLanguage || @@ -1080,7 +1080,7 @@ var tarteaucitron = { return tarteaucitronForceLanguage; } } - + if (availableLanguages.indexOf(userLanguage) === -1) { return defaultLanguage; } @@ -1089,11 +1089,11 @@ var tarteaucitron = { "getLocale": function () { "use strict"; if (!navigator) { return 'en_US'; } - + var lang = navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLang || null, userLanguage = lang.substr(0, 2); - + if (userLanguage === 'fr') { return 'fr_FR'; } else if (userLanguage === 'en') { @@ -1116,7 +1116,7 @@ var tarteaucitron = { "use strict"; var script, done = false; - + if (execute === false) { if (typeof callback === 'function') { callback(); @@ -1127,7 +1127,7 @@ var tarteaucitron = { script.id = (id !== undefined) ? id : ''; script.async = true; script.src = url; - + if (attrName !== undefined && attrVal !== undefined) { script.setAttribute(attrName, attrVal); } @@ -1141,7 +1141,7 @@ var tarteaucitron = { } }; } - + document.getElementsByTagName('head')[0].appendChild(script); } }, @@ -1159,12 +1159,12 @@ var tarteaucitron = { document.writeln = function (content) { tarteaucitron.makeAsync.buffer += content.concat("\n"); }; - + setTimeout(function () { document.write = savedWrite; document.writeln = savedWriteln; }, 20000); - + tarteaucitron.makeAsync.getAndParse(url, id); }, "getAndParse": function (url, id) { @@ -1192,7 +1192,7 @@ var tarteaucitron = { if (document.getElementById(id) === null) { return; } - + scripts = document.getElementById(id).getElementsByTagName('script'); for (i = 0; i < scripts.length; i += 1) { type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : ''; @@ -1238,7 +1238,7 @@ var tarteaucitron = { "use strict"; var html = '', r = Math.floor(Math.random() * 100000); - + html += '
'; html += '
'; html += ' ' + tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback; @@ -1247,7 +1247,7 @@ var tarteaucitron = { html += '
'; html += '
'; html += ''; - + return html; }, "extend": function (a, b) { @@ -1276,30 +1276,30 @@ var tarteaucitron = { var div = document.getElementById('tarteaucitronPremium'), timestamp = new Date().getTime(), url = '//opt-out.ferank.eu/premium.php?'; - + if (div === null) { return; } - + url += 'domain=' + tarteaucitron.domain + '&'; url += 'uuid=' + tarteaucitron.uuid + '&'; url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&'; url += '_' + timestamp; - + div.innerHTML = ''; - + tarteaucitron.proTemp = ''; } - + tarteaucitron.cookie.number(); }, - "AddOrUpdate" : function AddOrUpdate(source, custom){ + "AddOrUpdate" : function(source, custom){ /** Utility function to Add or update the fields of obj1 with the ones in obj2 */ for(key in custom){ if(custom[key] instanceof Object){ - source[key] = AddOrUpdate(source[key], custom[key]); + source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]); }else{ source[key] = custom[key]; } From 933ea94c31c7894ce5139920da85f6484d436193 Mon Sep 17 00:00:00 2001 From: Yoram Griguer Date: Tue, 31 Jul 2018 17:56:45 +0200 Subject: [PATCH 16/17] Give the possibility to change cookie's name --- README.md | 1 + tarteaucitron.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a81ba9f..0544792 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ In PHP for example, you can bypass all the script by setting this var `tarteauci