tarteaucitron.js 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. /*jslint browser: true, evil: true */
  2. var scripts = document.getElementsByTagName('script'),
  3. path = scripts[scripts.length - 1].src.split('?')[0],
  4. tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
  5. cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
  6. alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
  7. tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
  8. tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
  9. tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
  10. // tarteaucitronExpireInDay: true for day(s) value - false for hour(s) value
  11. tarteaucitronExpireInDay = (tarteaucitronExpireInDay === undefined || typeof tarteaucitronExpireInDay !== "boolean") ? true : tarteaucitronExpireInDay,
  12. timeExpire = 31536000000,
  13. tarteaucitronProLoadServices,
  14. tarteaucitronNoAdBlocker = false;
  15. var tarteaucitron = {
  16. "version": 20200114,
  17. "cdn": cdn,
  18. "user": {},
  19. "lang": {},
  20. "services": {},
  21. "added": [],
  22. "idprocessed": [],
  23. "state": [],
  24. "launch": [],
  25. "parameters": {},
  26. "isAjax": false,
  27. "reloadThePage": false,
  28. "events": {
  29. "init": function () {},
  30. "load": function () {},
  31. },
  32. "init": function (params) {
  33. "use strict";
  34. var origOpen;
  35. tarteaucitron.parameters = params;
  36. if (alreadyLaunch === 0) {
  37. alreadyLaunch = 1;
  38. if (window.addEventListener) {
  39. window.addEventListener("load", function () {
  40. tarteaucitron.initEvents.loadEvent(false);
  41. }, false);
  42. window.addEventListener("scroll", function () {
  43. tarteaucitron.initEvents.scrollEvent();
  44. }, false);
  45. window.addEventListener("keydown", function (evt) {
  46. tarteaucitron.initEvents.keydownEvent(false, evt);
  47. }, false);
  48. window.addEventListener("hashchange", function () {
  49. tarteaucitron.initEvents.hashchangeEvent();
  50. }, false);
  51. window.addEventListener("resize", function () {
  52. tarteaucitron.initEvents.resizeEvent();
  53. }, false);
  54. } else {
  55. window.attachEvent("onload", function () {
  56. tarteaucitron.initEvents.loadEvent(true);
  57. });
  58. window.attachEvent("onscroll", function () {
  59. tarteaucitron.initEvents.scrollEvent();
  60. });
  61. window.attachEvent("onkeydown", function (evt) {
  62. tarteaucitron.initEvents.keydownEvent(true, evt);
  63. });
  64. window.attachEvent("onhashchange", function () {
  65. tarteaucitron.initEvents.hashchangeEvent();
  66. });
  67. window.attachEvent("onresize", function () {
  68. tarteaucitron.initEvents.resizeEvent();
  69. });
  70. }
  71. if (typeof XMLHttpRequest !== 'undefined') {
  72. origOpen = XMLHttpRequest.prototype.open;
  73. XMLHttpRequest.prototype.open = function () {
  74. if (window.addEventListener) {
  75. this.addEventListener("load", function () {
  76. if (typeof tarteaucitronProLoadServices === 'function') {
  77. tarteaucitronProLoadServices();
  78. }
  79. }, false);
  80. } else if (typeof this.attachEvent !== 'undefined') {
  81. this.attachEvent("onload", function () {
  82. if (typeof tarteaucitronProLoadServices === 'function') {
  83. tarteaucitronProLoadServices();
  84. }
  85. });
  86. } else {
  87. if (typeof tarteaucitronProLoadServices === 'function') {
  88. setTimeout(tarteaucitronProLoadServices, 1000);
  89. }
  90. }
  91. try {
  92. origOpen.apply(this, arguments);
  93. } catch (err) {}
  94. };
  95. }
  96. }
  97. if(tarteaucitron.events.init) {
  98. tarteaucitron.events.init();
  99. }
  100. },
  101. "initEvents": {
  102. "loadEvent": function (isOldBrowser) {
  103. tarteaucitron.load();
  104. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  105. if (isOldBrowser) {
  106. elem.attachEvent("onclick", function (event) {
  107. tarteaucitron.userInterface.openPanel();
  108. event.preventDefault();
  109. });
  110. } else {
  111. elem.addEventListener("click", function (event) {
  112. tarteaucitron.userInterface.openPanel();
  113. event.preventDefault();
  114. }, false);
  115. }
  116. }, true);
  117. },
  118. "keydownEvent": function (isOldBrowser, evt) {
  119. if (evt.keyCode === 27) {
  120. tarteaucitron.userInterface.closePanel();
  121. }
  122. if (isOldBrowser) {
  123. if ( evt.keyCode === 9 && focusableEls.indexOf(evt.target) >= 0) {
  124. if ( evt.shiftKey ) /* shift + tab */ {
  125. if (document.activeElement === firstFocusableEl) {
  126. lastFocusableEl.focus();
  127. evt.preventDefault();
  128. }
  129. } else /* tab */ {
  130. if (document.activeElement === lastFocusableEl) {
  131. firstFocusableEl.focus();
  132. evt.preventDefault();
  133. }
  134. }
  135. }
  136. }
  137. },
  138. "hashchangeEvent": function () {
  139. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  140. tarteaucitron.userInterface.openPanel();
  141. }
  142. },
  143. "resizeEvent": function () {
  144. var tacElem = document.getElementById('tarteaucitron');
  145. var tacCookieContainer = document.getElementById('tarteaucitronCookiesListContainer');
  146. if (tacElem && tacElem.style.display === 'block') {
  147. tarteaucitron.userInterface.jsSizing('main');
  148. }
  149. if (tacCookieContainer && tacCookieContainer.style.display === 'block') {
  150. tarteaucitron.userInterface.jsSizing('cookie');
  151. }
  152. },
  153. "scrollEvent": function () {
  154. var scrollPos = window.pageYOffset || document.documentElement.scrollTop;
  155. var heightPosition;
  156. var tacPercentage = document.getElementById('tarteaucitronPercentage');
  157. var tacAlertBig = document.getElementById('tarteaucitronAlertBig');
  158. if (tacAlertBig && !tarteaucitron.highPrivacy) {
  159. if (tacAlertBig.style.display === 'block') {
  160. heightPosition = tacAlertBig.offsetHeight + 'px';
  161. if (scrollPos > (screen.height * 2)) {
  162. tarteaucitron.userInterface.respondAll(true);
  163. } else if (scrollPos > (screen.height / 2)) {
  164. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  165. }
  166. if (tacPercentage) {
  167. if (tarteaucitron.orientation === 'top') {
  168. tacPercentage.style.top = heightPosition;
  169. } else {
  170. tacPercentage.style.bottom = heightPosition;
  171. }
  172. tacPercentage.style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  173. }
  174. }
  175. }
  176. },
  177. },
  178. "load": function () {
  179. "use strict";
  180. var cdn = tarteaucitron.cdn,
  181. language = tarteaucitron.getLanguage(),
  182. pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js?v=' + tarteaucitron.version,
  183. pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
  184. linkElement = document.createElement('link'),
  185. defaults = {
  186. "adblocker": false,
  187. "hashtag": '#tarteaucitron',
  188. "cookieName": 'tarteaucitron',
  189. "highPrivacy": true,
  190. "orientation": "middle",
  191. "bodyPosition": "bottom",
  192. "removeCredit": false,
  193. "showAlertSmall": true,
  194. "cookieslist": true,
  195. "handleBrowserDNTRequest": false,
  196. "AcceptAllCta" : true,
  197. "moreInfoLink": true,
  198. "privacyUrl": "",
  199. "useExternalCss": false,
  200. "useExternalJs": false
  201. },
  202. params = tarteaucitron.parameters;
  203. // Don't show the middle bar if we are on the privacy policy page
  204. if (window.location.href == tarteaucitron.parameters.privacyUrl && tarteaucitron.parameters.orientation == "middle") {
  205. tarteaucitron.parameters.orientation = "bottom";
  206. }
  207. // Step -1
  208. if (typeof tarteaucitronCustomPremium !== 'undefined') {
  209. tarteaucitronCustomPremium();
  210. }
  211. // Step 0: get params
  212. if (params !== undefined) {
  213. for (var k in defaults) {
  214. if(!tarteaucitron.parameters.hasOwnProperty(k)) {
  215. tarteaucitron.parameters[k] = defaults[k];
  216. }
  217. }
  218. }
  219. // global
  220. tarteaucitron.orientation = tarteaucitron.parameters.orientation;
  221. tarteaucitron.hashtag = tarteaucitron.parameters.hashtag;
  222. tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy;
  223. tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest;
  224. // Step 1: load css
  225. if ( !tarteaucitron.parameters.useExternalCss ) {
  226. linkElement.rel = 'stylesheet';
  227. linkElement.type = 'text/css';
  228. linkElement.href = cdn + 'css/tarteaucitron.css?v=' + tarteaucitron.version;
  229. document.getElementsByTagName('head')[0].appendChild(linkElement);
  230. }
  231. // Step 2: load language and services
  232. tarteaucitron.addInternalScript(pathToLang, '', function () {
  233. if(tarteaucitronCustomText !== ''){
  234. tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
  235. }
  236. tarteaucitron.addInternalScript(pathToServices, '', function () {
  237. // css for new middle bar
  238. if (tarteaucitron.orientation === 'middle') {
  239. var customThemeMiddle = document.createElement('style'),
  240. cssRuleMiddle = 'div#tarteaucitronRoot.tarteaucitronBeforeVisible:before {content: \'\';position: fixed;width: 100%;height: 100%;background: white;top: 0;left: 0;z-index: 999;opacity: 0.5;}div#tarteaucitronAlertBig:before {content: \'' + tarteaucitron.lang.middleBarHead + '\';font-size: 50px;}body #tarteaucitronRoot div#tarteaucitronAlertBig {width: 60%;min-width: 285px;height: auto;margin: auto;left: 50%;top: 50%;transform: translate(-50%, -50%);box-shadow: 0 0 9000px #000;border-radius: 20px;padding: 50px 0;}span#tarteaucitronDisclaimerAlert {padding: 0 30px;}#tarteaucitronRoot span#tarteaucitronDisclaimerAlert {margin: 50px 0;display: block;text-align: center;font-size: 21px;}';
  241. customThemeMiddle.type = 'text/css';
  242. if (customThemeMiddle.styleSheet) {
  243. customThemeMiddle.styleSheet.cssText = cssRuleMiddle;
  244. } else {
  245. customThemeMiddle.appendChild(document.createTextNode(cssRuleMiddle));
  246. }
  247. document.getElementsByTagName('head')[0].appendChild(customThemeMiddle);
  248. }
  249. var body = document.body,
  250. div = document.createElement('div'),
  251. html = '',
  252. index,
  253. orientation = 'Top',
  254. cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'],
  255. i;
  256. cat = cat.sort(function (a, b) {
  257. if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
  258. if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
  259. return 0;
  260. });
  261. // Step 3: prepare the html
  262. html += '<div id="tarteaucitronPremium"></div>';
  263. html += '<button type="button" id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();" aria-label="' + tarteaucitron.lang.close + '"></button>';
  264. html += '<div id="tarteaucitron" role="dialog" aria-labelledby="dialogTitle">';
  265. html += ' <button type="button" id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
  266. html += ' ' + tarteaucitron.lang.close;
  267. html += ' </button>';
  268. html += ' <div id="tarteaucitronServices">';
  269. html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
  270. html += ' <span class="tarteaucitronH1" role="heading" aria-level="1" id="dialogTitle">'+ tarteaucitron.lang.title + '</span>';
  271. html += ' <div id="tarteaucitronInfo">';
  272. html += ' ' + tarteaucitron.lang.disclaimer;
  273. if (tarteaucitron.parameters.privacyUrl !== "") {
  274. html += ' <br/><br/>';
  275. html += ' <button type="button" id="tarteaucitronPrivacyUrlDialog" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  276. html += ' ' + tarteaucitron.lang.privacyUrl;
  277. html += ' </button>';
  278. }
  279. html += ' </div>';
  280. html += ' <div class="tarteaucitronName">';
  281. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2">' + tarteaucitron.lang.all + '</span>';
  282. html += ' </div>';
  283. html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
  284. html += ' <button type="button" id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
  285. html += ' &#10003; ' + tarteaucitron.lang.allowAll;
  286. html += ' </button> ';
  287. html += ' <button type="button" id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  288. html += ' &#10007; ' + tarteaucitron.lang.denyAll;
  289. html += ' </button>';
  290. html += ' </div>';
  291. html += ' </div>';
  292. html += ' <div class="tarteaucitronBorder">';
  293. html += ' <div class="clear"></div><ul>';
  294. for (i = 0; i < cat.length; i += 1) {
  295. html += ' <li id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
  296. html += ' <div class="tarteaucitronTitle">';
  297. html += ' <button type="button" onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronDetails' + cat[i] + '\', \'tarteaucitronInfoBox\');return false">&#10011; ' + tarteaucitron.lang[cat[i]].title + '</button>';
  298. html += ' </div>';
  299. html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
  300. html += ' ' + tarteaucitron.lang[cat[i]].details;
  301. html += ' </div>';
  302. html += ' <ul id="tarteaucitronServices_' + cat[i] + '"></ul></li>';
  303. }
  304. html += ' <li id="tarteaucitronNoServicesTitle" class="tarteaucitronLine">' + tarteaucitron.lang.noServices + '</li>';
  305. html += ' </ul>';
  306. html += ' <div class="tarteaucitronHidden" id="tarteaucitronScrollbarChild" style="height:20px;display:block"></div>';
  307. if (tarteaucitron.parameters.removeCredit === false) {
  308. html += ' <a class="tarteaucitronSelfLink" href="https://tarteaucitron.io/" rel="nofollow noreferrer noopener" target="_blank" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '">🍋 ' + tarteaucitron.lang.credit + '</a>';
  309. }
  310. html += ' </div>';
  311. html += ' </div>';
  312. html += '</div>';
  313. if (tarteaucitron.parameters.orientation === 'bottom') {
  314. orientation = 'Bottom';
  315. }
  316. if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) {
  317. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  318. //html += '<div class="tarteaucitronAlertBigWrapper">';
  319. html += ' <span id="tarteaucitronDisclaimerAlert">';
  320. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  321. html += ' </span>';
  322. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  323. html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.openPanel();">';
  324. html += ' ' + tarteaucitron.lang.personalize;
  325. html += ' </button>';
  326. if (tarteaucitron.parameters.privacyUrl !== "") {
  327. html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  328. html += ' ' + tarteaucitron.lang.privacyUrl;
  329. html += ' </button>';
  330. }
  331. //html += ' </span>';
  332. //html += '</div>';
  333. html += '</div>';
  334. } else {
  335. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  336. //html += '<div class="tarteaucitronAlertBigWrapper">';
  337. html += ' <span id="tarteaucitronDisclaimerAlert">';
  338. if (tarteaucitron.parameters.highPrivacy) {
  339. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  340. } else {
  341. html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig;
  342. }
  343. html += ' </span>';
  344. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  345. html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
  346. html += ' &#10003; ' + tarteaucitron.lang.acceptAll;
  347. html += ' </button>';
  348. if (tarteaucitron.parameters.orientation === 'middle') {
  349. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  350. html += ' &#10007; ' + tarteaucitron.lang.denyAll;
  351. html += ' </button>';
  352. html += ' <br/><br/>';
  353. }
  354. html += ' <button type="button" id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
  355. html += ' ' + tarteaucitron.lang.personalize;
  356. html += ' </button>';
  357. if (tarteaucitron.parameters.privacyUrl !== "") {
  358. html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  359. html += ' ' + tarteaucitron.lang.privacyUrl;
  360. html += ' </button>';
  361. }
  362. //html += ' </span>';
  363. //html += '</div>';
  364. html += '</div>';
  365. html += '<div id="tarteaucitronPercentage"></div>';
  366. }
  367. if (tarteaucitron.parameters.showAlertSmall === true) {
  368. html += '<div id="tarteaucitronAlertSmall" class="tarteaucitronAlertSmall' + orientation + '">';
  369. html += ' <button type="button" id="tarteaucitronManager" onclick="tarteaucitron.userInterface.openPanel();">';
  370. html += ' ' + tarteaucitron.lang.alertSmall;
  371. html += ' <span id="tarteaucitronDot">';
  372. html += ' <span id="tarteaucitronDotGreen"></span>';
  373. html += ' <span id="tarteaucitronDotYellow"></span>';
  374. html += ' <span id="tarteaucitronDotRed"></span>';
  375. html += ' </span>';
  376. if (tarteaucitron.parameters.cookieslist === true) {
  377. html += ' </button><!-- @whitespace';
  378. html += ' --><button type="button" id="tarteaucitronCookiesNumber" onclick="tarteaucitron.userInterface.toggleCookiesList();">0</button>';
  379. html += ' <div id="tarteaucitronCookiesListContainer">';
  380. html += ' <button type="button" id="tarteaucitronClosePanelCookie" onclick="tarteaucitron.userInterface.closePanel();">';
  381. html += ' ' + tarteaucitron.lang.close;
  382. html += ' </button>';
  383. html += ' <div class="tarteaucitronCookiesListMain" id="tarteaucitronCookiesTitle">';
  384. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2" id="tarteaucitronCookiesNumberBis">0 cookie</span>';
  385. html += ' </div>';
  386. html += ' <div id="tarteaucitronCookiesList"></div>';
  387. html += ' </div>';
  388. } else {
  389. html += ' </div>';
  390. }
  391. html += '</div>';
  392. }
  393. tarteaucitron.addInternalScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
  394. if (tarteaucitronNoAdBlocker === true || tarteaucitron.parameters.adblocker === false) {
  395. // create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
  396. /*var wrapper = document.createElement('div');
  397. wrapper.id = "contentWrapper";
  398. while (document.body.firstChild)
  399. {
  400. wrapper.appendChild(document.body.firstChild);
  401. }
  402. // Append the wrapper to the body
  403. document.body.appendChild(wrapper);*/
  404. div.id = 'tarteaucitronRoot';
  405. if (tarteaucitron.parameters.bodyPosition === 'top') {
  406. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  407. var bodyFirstChild = body.firstChild;
  408. body.insertBefore(div, bodyFirstChild);
  409. }
  410. else {
  411. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  412. body.appendChild(div, body);
  413. }
  414. div.innerHTML = html;
  415. //ie compatibility
  416. var tacRootAvailableEvent;
  417. if(typeof(Event) === 'function') {
  418. tacRootAvailableEvent = new Event("tac.root_available");
  419. }else{
  420. tacRootAvailableEvent = document.createEvent('Event');
  421. tacRootAvailableEvent.initEvent("tac.root_available", true, true);
  422. }
  423. //end ie compatibility
  424. window.dispatchEvent(tacRootAvailableEvent);
  425. if (tarteaucitron.job !== undefined) {
  426. tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
  427. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  428. tarteaucitron.addService(tarteaucitron.job[index]);
  429. }
  430. } else {
  431. tarteaucitron.job = []
  432. }
  433. tarteaucitron.isAjax = true;
  434. tarteaucitron.job.push = function (id) {
  435. // ie <9 hack
  436. if (typeof tarteaucitron.job.indexOf === 'undefined') {
  437. tarteaucitron.job.indexOf = function (obj, start) {
  438. var i,
  439. j = this.length;
  440. for (i = (start || 0); i < j; i += 1) {
  441. if (this[i] === obj) { return i; }
  442. }
  443. return -1;
  444. };
  445. }
  446. if (tarteaucitron.job.indexOf(id) === -1) {
  447. Array.prototype.push.call(this, id);
  448. }
  449. tarteaucitron.launch[id] = false;
  450. tarteaucitron.addService(id);
  451. };
  452. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  453. tarteaucitron.userInterface.openPanel();
  454. }
  455. tarteaucitron.cookie.number();
  456. setInterval(tarteaucitron.cookie.number, 60000);
  457. }
  458. }, tarteaucitron.parameters.adblocker);
  459. if (tarteaucitron.parameters.adblocker === true) {
  460. setTimeout(function () {
  461. if (tarteaucitronNoAdBlocker === false) {
  462. html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '" style="display:block" role="alert" aria-live="polite">';
  463. html += ' <p id="tarteaucitronDisclaimerAlert">';
  464. html += ' ' + tarteaucitron.lang.adblock + '<br/>';
  465. html += ' <strong>' + tarteaucitron.lang.adblock_call + '</strong>';
  466. html += ' </p>';
  467. html += ' <button type="button" class="tarteaucitronCTAButton" onclick="location.reload();">';
  468. html += ' ' + tarteaucitron.lang.reload;
  469. html += ' </button>';
  470. html += '</div>';
  471. html += '<div id="tarteaucitronPremium"></div>';
  472. div.id = 'tarteaucitronRoot';
  473. if (tarteaucitron.parameters.bodyPosition === 'top') {
  474. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  475. var bodyFirstChild = body.firstChild;
  476. body.insertBefore(div, bodyFirstChild);
  477. }
  478. else {
  479. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  480. body.appendChild(div, body);
  481. }
  482. div.innerHTML = html;
  483. }
  484. }, 1500);
  485. }
  486. });
  487. });
  488. if(tarteaucitron.events.load) {
  489. tarteaucitron.events.load();
  490. }
  491. },
  492. "addService": function (serviceId) {
  493. "use strict";
  494. var html = '',
  495. s = tarteaucitron.services,
  496. service = s[serviceId],
  497. cookie = tarteaucitron.cookie.read(),
  498. hostname = document.location.hostname,
  499. hostRef = document.referrer.split('/')[2],
  500. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
  501. isAutostart = (!service.needConsent),
  502. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
  503. isDenied = (cookie.indexOf(service.key + '=false') >= 0),
  504. isAllowed = (cookie.indexOf(service.key + '=true') >= 0),
  505. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
  506. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1");
  507. if (tarteaucitron.added[service.key] !== true) {
  508. tarteaucitron.added[service.key] = true;
  509. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  510. html += ' <div class="tarteaucitronName">';
  511. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + '</span>';
  512. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  513. if (tarteaucitron.parameters.moreInfoLink == true) {
  514. var link = 'https://tarteaucitron.io/service/' + service.key + '/';
  515. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  516. link = service.readmoreLink;
  517. }
  518. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  519. link = tarteaucitron.parameters.readmoreLink;
  520. }
  521. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
  522. html += ' ' + tarteaucitron.lang.more;
  523. html += ' </a>';
  524. html += ' - ';
  525. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '">';
  526. html += ' ' + tarteaucitron.lang.source;
  527. html += ' </a>';
  528. }
  529. html += ' </div>';
  530. html += ' <div class="tarteaucitronAsk">';
  531. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
  532. html += ' &#10003; ' + tarteaucitron.lang.allow;
  533. html += ' </button> ';
  534. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
  535. html += ' &#10007; ' + tarteaucitron.lang.deny;
  536. html += ' </button>';
  537. html += ' </div>';
  538. html += '</li>';
  539. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  540. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  541. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  542. }
  543. tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
  544. tarteaucitron.userInterface.order(service.type);
  545. }
  546. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  547. // allow by default for non EU
  548. if (isResponded === false && tarteaucitron.user.bypass === true) {
  549. isAllowed = true;
  550. tarteaucitron.cookie.create(service.key, true);
  551. }
  552. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  553. if (!isAllowed) {
  554. tarteaucitron.cookie.create(service.key, true);
  555. }
  556. if (tarteaucitron.launch[service.key] !== true) {
  557. tarteaucitron.launch[service.key] = true;
  558. service.js();
  559. tarteaucitron.sendEvent(service.key + '_loaded');
  560. }
  561. tarteaucitron.state[service.key] = true;
  562. tarteaucitron.userInterface.color(service.key, true);
  563. } else if (isDenied) {
  564. if (typeof service.fallback === 'function') {
  565. service.fallback();
  566. }
  567. tarteaucitron.state[service.key] = false;
  568. tarteaucitron.userInterface.color(service.key, false);
  569. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  570. tarteaucitron.cookie.create(service.key, 'false');
  571. if (typeof service.fallback === 'function') {
  572. service.fallback();
  573. }
  574. tarteaucitron.state[service.key] = false;
  575. tarteaucitron.userInterface.color(service.key, false);
  576. } else if (!isResponded) {
  577. tarteaucitron.cookie.create(service.key, 'wait');
  578. if (typeof service.fallback === 'function') {
  579. service.fallback();
  580. }
  581. tarteaucitron.userInterface.color(service.key, 'wait');
  582. tarteaucitron.userInterface.openAlert();
  583. }
  584. tarteaucitron.cookie.checkCount(service.key);
  585. tarteaucitron.sendEvent(service.key + '_added')
  586. },
  587. "sendEvent" : function(event_key) {
  588. if(event_key !== undefined) {
  589. //ie compatibility
  590. var send_event_item;
  591. if(typeof(Event) === 'function') {
  592. send_event_item = new Event(event_key);
  593. }else{
  594. send_event_item = document.createEvent('Event');
  595. send_event_item.initEvent(event_key, true, true);
  596. }
  597. //end ie compatibility
  598. document.dispatchEvent(send_event_item);
  599. }
  600. },
  601. "cleanArray": function cleanArray(arr) {
  602. "use strict";
  603. var i,
  604. len = arr.length,
  605. out = [],
  606. obj = {},
  607. s = tarteaucitron.services;
  608. for (i = 0; i < len; i += 1) {
  609. if (!obj[arr[i]]) {
  610. obj[arr[i]] = {};
  611. if (tarteaucitron.services[arr[i]] !== undefined) {
  612. out.push(arr[i]);
  613. }
  614. }
  615. }
  616. out = out.sort(function (a, b) {
  617. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  618. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  619. return 0;
  620. });
  621. return out;
  622. },
  623. "userInterface": {
  624. "css": function (id, property, value) {
  625. "use strict";
  626. if (document.getElementById(id) !== null) {
  627. document.getElementById(id).style[property] = value;
  628. }
  629. },
  630. "addClass": function (id, className) {
  631. "use strict";
  632. if (document.getElementById(id) !== null) {
  633. document.getElementById(id).classList.add(className);
  634. }
  635. },
  636. "removeClass": function (id, className) {
  637. "use strict";
  638. if (document.getElementById(id) !== null) {
  639. document.getElementById(id).classList.remove(className);
  640. }
  641. },
  642. "respondAll": function (status) {
  643. "use strict";
  644. var s = tarteaucitron.services,
  645. service,
  646. key,
  647. index = 0;
  648. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  649. service = s[tarteaucitron.job[index]];
  650. key = service.key;
  651. if (tarteaucitron.state[key] !== status) {
  652. if (status === false && tarteaucitron.launch[key] === true) {
  653. tarteaucitron.reloadThePage = true;
  654. }
  655. if (tarteaucitron.launch[key] !== true && status === true) {
  656. tarteaucitron.pro('!' + key + '=engage');
  657. tarteaucitron.launch[key] = true;
  658. tarteaucitron.services[key].js();
  659. }
  660. tarteaucitron.state[key] = status;
  661. tarteaucitron.cookie.create(key, status);
  662. tarteaucitron.userInterface.color(key, status);
  663. }
  664. }
  665. },
  666. "respond": function (el, status) {
  667. "use strict";
  668. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  669. // return if same state
  670. if (tarteaucitron.state[key] === status) {
  671. return;
  672. }
  673. if (status === false && tarteaucitron.launch[key] === true) {
  674. tarteaucitron.reloadThePage = true;
  675. }
  676. // if not already launched... launch the service
  677. if (status === true) {
  678. if (tarteaucitron.launch[key] !== true) {
  679. tarteaucitron.pro('!' + key + '=engage');
  680. tarteaucitron.launch[key] = true;
  681. tarteaucitron.sendEvent(key + '_loaded');
  682. tarteaucitron.services[key].js();
  683. }
  684. }
  685. tarteaucitron.state[key] = status;
  686. tarteaucitron.cookie.create(key, status);
  687. tarteaucitron.userInterface.color(key, status);
  688. },
  689. "color": function (key, status) {
  690. "use strict";
  691. var c = 'tarteaucitron',
  692. nbDenied = 0,
  693. nbPending = 0,
  694. nbAllowed = 0,
  695. sum = tarteaucitron.job.length,
  696. index;
  697. if (status === true) {
  698. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  699. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  700. } else if (status === false) {
  701. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  702. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  703. }
  704. // check if all services are allowed
  705. for (index = 0; index < sum; index += 1) {
  706. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  707. nbDenied += 1;
  708. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  709. nbPending += 1;
  710. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  711. nbAllowed += 1;
  712. }
  713. }
  714. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  715. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  716. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  717. if (nbDenied === 0 && nbPending === 0) {
  718. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  719. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  720. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  721. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  722. } else if (nbAllowed === 0 && nbPending === 0) {
  723. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  724. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  725. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  726. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  727. } else {
  728. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  729. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  730. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  731. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  732. }
  733. // close the alert if all service have been reviewed
  734. if (nbPending === 0) {
  735. tarteaucitron.userInterface.closeAlert();
  736. }
  737. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  738. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  739. }
  740. if (status === true) {
  741. if (document.getElementById('tacCL' + key) !== null) {
  742. document.getElementById('tacCL' + key).innerHTML = '...';
  743. }
  744. setTimeout(function () {
  745. tarteaucitron.cookie.checkCount(key);
  746. }, 2500);
  747. } else {
  748. tarteaucitron.cookie.checkCount(key);
  749. }
  750. },
  751. "openPanel": function () {
  752. "use strict";
  753. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  754. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  755. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  756. document.getElementById('tarteaucitronClosePanel').focus();
  757. document.getElementsByTagName('body')[0].classList.add('modal-open');
  758. tarteaucitron.userInterface.focusTrap();
  759. tarteaucitron.userInterface.jsSizing('main');
  760. //ie compatibility
  761. var tacOpenPanelEvent;
  762. if(typeof(Event) === 'function') {
  763. tacOpenPanelEvent = new Event("tac.open_panel");
  764. }else{
  765. tacOpenPanelEvent = document.createEvent('Event');
  766. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  767. }
  768. //end ie compatibility
  769. window.dispatchEvent(tacOpenPanelEvent);
  770. },
  771. "closePanel": function () {
  772. "use strict";
  773. if (document.location.hash === tarteaucitron.hashtag) {
  774. if (window.history) {
  775. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  776. } else {
  777. document.location.hash = '';
  778. }
  779. }
  780. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  781. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  782. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  783. elem.style.display = 'none';
  784. }, true);
  785. if (tarteaucitron.reloadThePage === true) {
  786. window.location.reload();
  787. } else {
  788. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  789. }
  790. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  791. document.getElementById('tarteaucitronCloseAlert').focus();
  792. }
  793. document.getElementsByTagName('body')[0].classList.remove('modal-open');
  794. //ie compatibility
  795. var tacClosePanelEvent;
  796. if(typeof(Event) === 'function') {
  797. tacClosePanelEvent = new Event("tac.close_panel");
  798. }else{
  799. tacClosePanelEvent = document.createEvent('Event');
  800. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  801. }
  802. //end ie compatibility
  803. window.dispatchEvent(tacClosePanelEvent);
  804. },
  805. "focusTrap": function() {
  806. "use strict";
  807. var focusableEls,
  808. firstFocusableEl,
  809. lastFocusableEl,
  810. filtered;
  811. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  812. filtered = [];
  813. // get only visible items
  814. for (var i = 0, max = focusableEls.length; i < max; i++) {
  815. if (focusableEls[i].offsetHeight > 0) {
  816. filtered.push(focusableEls[i]);
  817. }
  818. }
  819. firstFocusableEl = filtered[0];
  820. lastFocusableEl = filtered[filtered.length - 1];
  821. //loop focus inside tarteaucitron
  822. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  823. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  824. if ( evt.shiftKey ) /* shift + tab */ {
  825. if (document.activeElement === firstFocusableEl) {
  826. lastFocusableEl.focus();
  827. evt.preventDefault();
  828. }
  829. } else /* tab */ {
  830. if (document.activeElement === lastFocusableEl) {
  831. firstFocusableEl.focus();
  832. evt.preventDefault();
  833. }
  834. }
  835. }
  836. })
  837. },
  838. "openAlert": function () {
  839. "use strict";
  840. var c = 'tarteaucitron';
  841. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  842. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  843. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  844. tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
  845. //ie compatibility
  846. var tacOpenAlertEvent;
  847. if(typeof(Event) === 'function') {
  848. tacOpenAlertEvent = new Event("tac.open_alert");
  849. }else{
  850. tacOpenAlertEvent = document.createEvent('Event');
  851. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  852. }
  853. //end ie compatibility
  854. window.dispatchEvent(tacOpenAlertEvent);
  855. },
  856. "closeAlert": function () {
  857. "use strict";
  858. var c = 'tarteaucitron';
  859. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  860. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  861. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  862. tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
  863. tarteaucitron.userInterface.jsSizing('box');
  864. //ie compatibility
  865. var tacCloseAlertEvent;
  866. if(typeof(Event) === 'function') {
  867. tacCloseAlertEvent = new Event("tac.close_alert");
  868. }else{
  869. tacCloseAlertEvent = document.createEvent('Event');
  870. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  871. }
  872. //end ie compatibility
  873. window.dispatchEvent(tacCloseAlertEvent);
  874. },
  875. "toggleCookiesList": function () {
  876. "use strict";
  877. var div = document.getElementById('tarteaucitronCookiesListContainer');
  878. if (div === null) {
  879. return;
  880. }
  881. if (div.style.display !== 'block') {
  882. tarteaucitron.cookie.number();
  883. div.style.display = 'block';
  884. tarteaucitron.userInterface.jsSizing('cookie');
  885. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  886. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  887. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  888. elem.style.display = 'none';
  889. }, true);
  890. } else {
  891. div.style.display = 'none';
  892. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  893. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  894. }
  895. },
  896. "toggle": function (id, closeClass) {
  897. "use strict";
  898. var div = document.getElementById(id);
  899. if (div === null) {
  900. return;
  901. }
  902. if (closeClass !== undefined) {
  903. tarteaucitron.fallback([closeClass], function (elem) {
  904. if (elem.id !== id) {
  905. elem.style.display = 'none';
  906. }
  907. }, true);
  908. }
  909. if (div.style.display !== 'block') {
  910. div.style.display = 'block';
  911. } else {
  912. div.style.display = 'none';
  913. }
  914. },
  915. "order": function (id) {
  916. "use strict";
  917. var main = document.getElementById('tarteaucitronServices_' + id),
  918. allDivs,
  919. store = [],
  920. i;
  921. if (main === null) {
  922. return;
  923. }
  924. allDivs = main.childNodes;
  925. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  926. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  927. //var mainChildren = Array.from(main.children);
  928. //mainChildren.sort(function (a, b) {
  929. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  930. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  931. return 0;
  932. }).forEach(function (element) {
  933. main.appendChild(element);
  934. });
  935. }
  936. },
  937. "jsSizing": function (type) {
  938. "use strict";
  939. var scrollbarMarginRight = 10,
  940. scrollbarWidthParent,
  941. scrollbarWidthChild,
  942. servicesHeight,
  943. e = window,
  944. a = 'inner',
  945. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  946. mainTop,
  947. mainHeight,
  948. closeButtonHeight,
  949. headerHeight,
  950. cookiesListHeight,
  951. cookiesCloseHeight,
  952. cookiesTitleHeight,
  953. paddingBox,
  954. alertSmallHeight,
  955. cookiesNumberHeight;
  956. if (type === 'box') {
  957. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  958. // reset
  959. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  960. // calculate
  961. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  962. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  963. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  964. // apply
  965. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  966. }
  967. } else if (type === 'main') {
  968. // get the real window width for media query
  969. if (window.innerWidth === undefined) {
  970. a = 'client';
  971. e = document.documentElement || document.body;
  972. }
  973. // height of the services list container
  974. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  975. // reset
  976. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  977. // calculate
  978. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  979. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  980. // apply
  981. servicesHeight = (mainHeight - closeButtonHeight + 2);
  982. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  983. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  984. }
  985. // align the main allow/deny button depending on scrollbar width
  986. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  987. // media query
  988. if (e[a + 'Width'] <= 479) {
  989. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  990. } else if (e[a + 'Width'] <= 767) {
  991. scrollbarMarginRight = 12;
  992. }
  993. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  994. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  995. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  996. }
  997. // center the main panel
  998. if (document.getElementById('tarteaucitron') !== null) {
  999. // media query
  1000. if (e[a + 'Width'] <= 767) {
  1001. mainTop = 0;
  1002. } else {
  1003. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  1004. }
  1005. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1006. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  1007. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  1008. }
  1009. }
  1010. // correct
  1011. if (mainTop < 0) {
  1012. mainTop = 0;
  1013. }
  1014. // apply
  1015. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  1016. }
  1017. } else if (type === 'cookie') {
  1018. // put cookies list at bottom
  1019. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  1020. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  1021. }
  1022. // height of cookies list
  1023. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  1024. // reset
  1025. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  1026. // calculate
  1027. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  1028. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  1029. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  1030. // apply
  1031. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  1032. }
  1033. }
  1034. }
  1035. },
  1036. "cookie": {
  1037. "owner": {},
  1038. "create": function (key, status) {
  1039. "use strict";
  1040. if (tarteaucitronForceExpire !== '') {
  1041. // The number of day(s)/hour(s) can't be higher than 1 year
  1042. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1043. if (tarteaucitronExpireInDay) {
  1044. // Multiplication to tranform the number of days to milliseconds
  1045. timeExpire = tarteaucitronForceExpire * 86400000;
  1046. } else {
  1047. // Multiplication to tranform the number of hours to milliseconds
  1048. timeExpire = tarteaucitronForceExpire * 3600000;
  1049. }
  1050. }
  1051. }
  1052. var d = new Date(),
  1053. time = d.getTime(),
  1054. expireTime = time + timeExpire, // 365 days
  1055. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1056. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1057. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1058. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
  1059. d.setTime(expireTime);
  1060. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
  1061. },
  1062. "read": function () {
  1063. "use strict";
  1064. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1065. ca = document.cookie.split(';'),
  1066. i,
  1067. c;
  1068. for (i = 0; i < ca.length; i += 1) {
  1069. c = ca[i];
  1070. while (c.charAt(0) === ' ') {
  1071. c = c.substring(1, c.length);
  1072. }
  1073. if (c.indexOf(nameEQ) === 0) {
  1074. return c.substring(nameEQ.length, c.length);
  1075. }
  1076. }
  1077. return '';
  1078. },
  1079. "purge": function (arr) {
  1080. "use strict";
  1081. var i;
  1082. for (i = 0; i < arr.length; i += 1) {
  1083. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1084. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1085. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1086. }
  1087. },
  1088. "checkCount": function (key) {
  1089. "use strict";
  1090. var arr = tarteaucitron.services[key].cookies,
  1091. nb = arr.length,
  1092. nbCurrent = 0,
  1093. html = '',
  1094. i,
  1095. status = document.cookie.indexOf(key + '=true');
  1096. if (status >= 0 && nb === 0) {
  1097. html += tarteaucitron.lang.useNoCookie;
  1098. } else if (status >= 0) {
  1099. for (i = 0; i < nb; i += 1) {
  1100. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1101. nbCurrent += 1;
  1102. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1103. tarteaucitron.cookie.owner[arr[i]] = [];
  1104. }
  1105. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1106. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1107. }
  1108. }
  1109. }
  1110. if (nbCurrent > 0) {
  1111. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1112. if (nbCurrent > 1) {
  1113. html += 's';
  1114. }
  1115. html += '.';
  1116. } else {
  1117. html += tarteaucitron.lang.useNoCookie;
  1118. }
  1119. } else if (nb === 0) {
  1120. html = tarteaucitron.lang.noCookie;
  1121. } else {
  1122. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1123. if (nb > 1) {
  1124. html += 's';
  1125. }
  1126. html += '.';
  1127. }
  1128. if (document.getElementById('tacCL' + key) !== null) {
  1129. document.getElementById('tacCL' + key).innerHTML = html;
  1130. }
  1131. },
  1132. "crossIndexOf": function (arr, match) {
  1133. "use strict";
  1134. var i;
  1135. for (i = 0; i < arr.length; i += 1) {
  1136. if (arr[i] === match) {
  1137. return true;
  1138. }
  1139. }
  1140. return false;
  1141. },
  1142. "number": function () {
  1143. "use strict";
  1144. var cookies = document.cookie.split(';'),
  1145. nb = (document.cookie !== '') ? cookies.length : 0,
  1146. html = '',
  1147. i,
  1148. name,
  1149. namea,
  1150. nameb,
  1151. c,
  1152. d,
  1153. s = (nb > 1) ? 's' : '',
  1154. savedname,
  1155. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1156. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1157. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1158. cookies = cookies.sort(function (a, b) {
  1159. namea = a.split('=', 1).toString().replace(/ /g, '');
  1160. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1161. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1162. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1163. if (c + a > d + b) { return 1; }
  1164. if (c + a < d + b) { return -1; }
  1165. return 0;
  1166. });
  1167. if (document.cookie !== '') {
  1168. for (i = 0; i < nb; i += 1) {
  1169. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1170. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1171. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1172. html += '<div class="tarteaucitronHidden">';
  1173. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1174. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1175. html += ' </span>';
  1176. html += '</div><ul class="cookie-list">';
  1177. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1178. savedname = host;
  1179. html += '<div class="tarteaucitronHidden">';
  1180. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1181. html += ' ' + host;
  1182. html += ' </span>';
  1183. html += '</div><ul class="cookie-list">';
  1184. }
  1185. html += '<li class="tarteaucitronCookiesListMain">';
  1186. html += ' <div class="tarteaucitronCookiesListLeft"><button type="button" onclick="tarteaucitron.cookie.purge([\'' + cookies[i].split('=', 1) + '\']);tarteaucitron.cookie.number();tarteaucitron.userInterface.jsSizing(\'cookie\');return false"><strong>&times;</strong></button> <strong>' + name + '</strong>';
  1187. html += ' </div>';
  1188. html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
  1189. html += '</li>';
  1190. }
  1191. html += '</ul>';
  1192. } else {
  1193. html += '<div class="tarteaucitronCookiesListMain">';
  1194. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1195. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1196. html += '</div>';
  1197. }
  1198. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  1199. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1200. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1201. }
  1202. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1203. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1204. }
  1205. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1206. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1207. }
  1208. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1209. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1210. }
  1211. }
  1212. },
  1213. "getLanguage": function () {
  1214. "use strict";
  1215. var availableLanguages = 'bg,cn,cs,da,de,el,en,es,fi,fr,hu,it,ja,nl,pl,pt,ro,ru,sk,tr',
  1216. defaultLanguage = 'en';
  1217. if (tarteaucitronForceLanguage !== '') {
  1218. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1219. return tarteaucitronForceLanguage;
  1220. }
  1221. }
  1222. if (!navigator) { return 'en'; }
  1223. var lang = navigator.language || navigator.browserLanguage ||
  1224. navigator.systemLanguage || navigator.userLang || null,
  1225. userLanguage = lang ? lang.substr(0, 2) : null;
  1226. if (availableLanguages.indexOf(userLanguage) === -1) {
  1227. return defaultLanguage;
  1228. }
  1229. return userLanguage;
  1230. },
  1231. "getLocale": function () {
  1232. "use strict";
  1233. if (!navigator) { return 'en_US'; }
  1234. var lang = navigator.language || navigator.browserLanguage ||
  1235. navigator.systemLanguage || navigator.userLang || null,
  1236. userLanguage = lang ? lang.substr(0, 2) : null;
  1237. if (userLanguage === 'fr') {
  1238. return 'fr_FR';
  1239. } else if (userLanguage === 'en') {
  1240. return 'en_US';
  1241. } else if (userLanguage === 'de') {
  1242. return 'de_DE';
  1243. } else if (userLanguage === 'es') {
  1244. return 'es_ES';
  1245. } else if (userLanguage === 'it') {
  1246. return 'it_IT';
  1247. } else if (userLanguage === 'pt') {
  1248. return 'pt_PT';
  1249. } else if (userLanguage === 'nl') {
  1250. return 'nl_NL';
  1251. } else if (userLanguage === 'el') {
  1252. return 'el_EL';
  1253. } else {
  1254. return 'en_US';
  1255. }
  1256. },
  1257. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1258. "use strict";
  1259. var script,
  1260. done = false;
  1261. if (execute === false) {
  1262. if (typeof callback === 'function') {
  1263. callback();
  1264. }
  1265. } else {
  1266. script = document.createElement('script');
  1267. script.type = 'text/javascript';
  1268. script.id = (id !== undefined) ? id : '';
  1269. script.async = true;
  1270. script.src = url;
  1271. if (attrName !== undefined && attrVal !== undefined) {
  1272. script.setAttribute(attrName, attrVal);
  1273. }
  1274. if (typeof callback === 'function') {
  1275. if ( !tarteaucitron.parameters.useExternalJs ) {
  1276. script.onreadystatechange = script.onload = function () {
  1277. var state = script.readyState;
  1278. if (!done && (!state || /loaded|complete/.test(state))) {
  1279. done = true;
  1280. callback();
  1281. }
  1282. };
  1283. } else {
  1284. callback();
  1285. }
  1286. }
  1287. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1288. document.getElementsByTagName('head')[0].appendChild(script);
  1289. }
  1290. }
  1291. },
  1292. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1293. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1294. },
  1295. "makeAsync": {
  1296. "antiGhost": 0,
  1297. "buffer": '',
  1298. "init": function (url, id) {
  1299. "use strict";
  1300. var savedWrite = document.write,
  1301. savedWriteln = document.writeln;
  1302. document.write = function (content) {
  1303. tarteaucitron.makeAsync.buffer += content;
  1304. };
  1305. document.writeln = function (content) {
  1306. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1307. };
  1308. setTimeout(function () {
  1309. document.write = savedWrite;
  1310. document.writeln = savedWriteln;
  1311. }, 20000);
  1312. tarteaucitron.makeAsync.getAndParse(url, id);
  1313. },
  1314. "getAndParse": function (url, id) {
  1315. "use strict";
  1316. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1317. tarteaucitron.makeAsync.antiGhost = 0;
  1318. return;
  1319. }
  1320. tarteaucitron.makeAsync.antiGhost += 1;
  1321. tarteaucitron.addInternalScript(url, '', function () {
  1322. if (document.getElementById(id) !== null) {
  1323. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1324. tarteaucitron.makeAsync.buffer = '';
  1325. tarteaucitron.makeAsync.execJS(id);
  1326. }
  1327. });
  1328. },
  1329. "execJS": function (id) {
  1330. /* not strict because third party scripts may have errors */
  1331. var i,
  1332. scripts,
  1333. childId,
  1334. type;
  1335. if (document.getElementById(id) === null) {
  1336. return;
  1337. }
  1338. scripts = document.getElementById(id).getElementsByTagName('script');
  1339. for (i = 0; i < scripts.length; i += 1) {
  1340. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1341. if (type === '') {
  1342. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1343. }
  1344. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1345. childId = id + Math.floor(Math.random() * 99999999999);
  1346. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1347. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1348. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1349. eval(scripts[i].innerHTML);
  1350. }
  1351. }
  1352. }
  1353. },
  1354. "fallback": function (matchClass, content, noInner) {
  1355. "use strict";
  1356. var elems = document.getElementsByTagName('*'),
  1357. i,
  1358. index = 0;
  1359. for (i in elems) {
  1360. if (elems[i] !== undefined) {
  1361. for (index = 0; index < matchClass.length; index += 1) {
  1362. if ((' ' + elems[i].className + ' ')
  1363. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1364. if (typeof content === 'function') {
  1365. if (noInner === true) {
  1366. content(elems[i]);
  1367. } else {
  1368. elems[i].innerHTML = content(elems[i]);
  1369. }
  1370. } else {
  1371. elems[i].innerHTML = content;
  1372. }
  1373. }
  1374. }
  1375. }
  1376. }
  1377. },
  1378. "engage": function (id) {
  1379. "use strict";
  1380. var html = '',
  1381. r = Math.floor(Math.random() * 100000),
  1382. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1383. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1384. engage = tarteaucitron.lang['engage-' + id];
  1385. }
  1386. html += '<div class="tac_activate">';
  1387. html += ' <div class="tac_float">';
  1388. html += ' ' + engage;
  1389. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1390. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1391. html += ' </button>';
  1392. html += ' </div>';
  1393. html += '</div>';
  1394. return html;
  1395. },
  1396. "extend": function (a, b) {
  1397. "use strict";
  1398. var prop;
  1399. for (prop in b) {
  1400. if (b.hasOwnProperty(prop)) {
  1401. a[prop] = b[prop];
  1402. }
  1403. }
  1404. },
  1405. "proTemp": '',
  1406. "proTimer": function () {
  1407. "use strict";
  1408. setTimeout(tarteaucitron.proPing, 500);
  1409. },
  1410. "pro": function (list) {
  1411. "use strict";
  1412. tarteaucitron.proTemp += list;
  1413. clearTimeout(tarteaucitron.proTimer);
  1414. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1415. },
  1416. "proPing": function () {
  1417. "use strict";
  1418. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1419. var div = document.getElementById('tarteaucitronPremium'),
  1420. timestamp = new Date().getTime(),
  1421. url = 'https://tarteaucitron.io/log/?';
  1422. if (div === null) {
  1423. return;
  1424. }
  1425. url += 'account=' + tarteaucitron.uuid + '&';
  1426. url += 'domain=' + tarteaucitron.domain + '&';
  1427. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1428. url += '_time=' + timestamp;
  1429. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1430. tarteaucitron.proTemp = '';
  1431. }
  1432. tarteaucitron.cookie.number();
  1433. },
  1434. "AddOrUpdate" : function(source, custom){
  1435. /**
  1436. Utility function to Add or update the fields of obj1 with the ones in obj2
  1437. */
  1438. for(key in custom){
  1439. if(custom[key] instanceof Object){
  1440. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1441. }else{
  1442. source[key] = custom[key];
  1443. }
  1444. }
  1445. return source;
  1446. },
  1447. "getElemWidth": function(elem) {
  1448. return elem.getAttribute('width') || elem.clientWidth;
  1449. },
  1450. "getElemHeight": function(elem) {
  1451. return elem.getAttribute('height') || elem.clientHeight;
  1452. }
  1453. };