tarteaucitron.js 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641
  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": 20200501,
  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) || (!service.needConsent)),
  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,oc,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 === 'oc') {
  1248. return 'oc_FR';
  1249. } else if (userLanguage === 'pt') {
  1250. return 'pt_PT';
  1251. } else if (userLanguage === 'nl') {
  1252. return 'nl_NL';
  1253. } else if (userLanguage === 'el') {
  1254. return 'el_EL';
  1255. } else {
  1256. return 'en_US';
  1257. }
  1258. },
  1259. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1260. "use strict";
  1261. var script,
  1262. done = false;
  1263. if (execute === false) {
  1264. if (typeof callback === 'function') {
  1265. callback();
  1266. }
  1267. } else {
  1268. script = document.createElement('script');
  1269. script.type = 'text/javascript';
  1270. script.id = (id !== undefined) ? id : '';
  1271. script.async = true;
  1272. script.src = url;
  1273. if (attrName !== undefined && attrVal !== undefined) {
  1274. script.setAttribute(attrName, attrVal);
  1275. }
  1276. if (typeof callback === 'function') {
  1277. if ( !tarteaucitron.parameters.useExternalJs ) {
  1278. script.onreadystatechange = script.onload = function () {
  1279. var state = script.readyState;
  1280. if (!done && (!state || /loaded|complete/.test(state))) {
  1281. done = true;
  1282. callback();
  1283. }
  1284. };
  1285. } else {
  1286. callback();
  1287. }
  1288. }
  1289. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1290. document.getElementsByTagName('head')[0].appendChild(script);
  1291. }
  1292. }
  1293. },
  1294. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1295. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1296. },
  1297. "makeAsync": {
  1298. "antiGhost": 0,
  1299. "buffer": '',
  1300. "init": function (url, id) {
  1301. "use strict";
  1302. var savedWrite = document.write,
  1303. savedWriteln = document.writeln;
  1304. document.write = function (content) {
  1305. tarteaucitron.makeAsync.buffer += content;
  1306. };
  1307. document.writeln = function (content) {
  1308. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1309. };
  1310. setTimeout(function () {
  1311. document.write = savedWrite;
  1312. document.writeln = savedWriteln;
  1313. }, 20000);
  1314. tarteaucitron.makeAsync.getAndParse(url, id);
  1315. },
  1316. "getAndParse": function (url, id) {
  1317. "use strict";
  1318. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1319. tarteaucitron.makeAsync.antiGhost = 0;
  1320. return;
  1321. }
  1322. tarteaucitron.makeAsync.antiGhost += 1;
  1323. tarteaucitron.addInternalScript(url, '', function () {
  1324. if (document.getElementById(id) !== null) {
  1325. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1326. tarteaucitron.makeAsync.buffer = '';
  1327. tarteaucitron.makeAsync.execJS(id);
  1328. }
  1329. });
  1330. },
  1331. "execJS": function (id) {
  1332. /* not strict because third party scripts may have errors */
  1333. var i,
  1334. scripts,
  1335. childId,
  1336. type;
  1337. if (document.getElementById(id) === null) {
  1338. return;
  1339. }
  1340. scripts = document.getElementById(id).getElementsByTagName('script');
  1341. for (i = 0; i < scripts.length; i += 1) {
  1342. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1343. if (type === '') {
  1344. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1345. }
  1346. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1347. childId = id + Math.floor(Math.random() * 99999999999);
  1348. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1349. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1350. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1351. eval(scripts[i].innerHTML);
  1352. }
  1353. }
  1354. }
  1355. },
  1356. "fallback": function (matchClass, content, noInner) {
  1357. "use strict";
  1358. var elems = document.getElementsByTagName('*'),
  1359. i,
  1360. index = 0;
  1361. for (i in elems) {
  1362. if (elems[i] !== undefined) {
  1363. for (index = 0; index < matchClass.length; index += 1) {
  1364. if ((' ' + elems[i].className + ' ')
  1365. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1366. if (typeof content === 'function') {
  1367. if (noInner === true) {
  1368. content(elems[i]);
  1369. } else {
  1370. elems[i].innerHTML = content(elems[i]);
  1371. }
  1372. } else {
  1373. elems[i].innerHTML = content;
  1374. }
  1375. }
  1376. }
  1377. }
  1378. }
  1379. },
  1380. "engage": function (id) {
  1381. "use strict";
  1382. var html = '',
  1383. r = Math.floor(Math.random() * 100000),
  1384. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1385. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1386. engage = tarteaucitron.lang['engage-' + id];
  1387. }
  1388. html += '<div class="tac_activate">';
  1389. html += ' <div class="tac_float">';
  1390. html += ' ' + engage;
  1391. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1392. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1393. html += ' </button>';
  1394. html += ' </div>';
  1395. html += '</div>';
  1396. return html;
  1397. },
  1398. "extend": function (a, b) {
  1399. "use strict";
  1400. var prop;
  1401. for (prop in b) {
  1402. if (b.hasOwnProperty(prop)) {
  1403. a[prop] = b[prop];
  1404. }
  1405. }
  1406. },
  1407. "proTemp": '',
  1408. "proTimer": function () {
  1409. "use strict";
  1410. setTimeout(tarteaucitron.proPing, 500);
  1411. },
  1412. "pro": function (list) {
  1413. "use strict";
  1414. tarteaucitron.proTemp += list;
  1415. clearTimeout(tarteaucitron.proTimer);
  1416. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1417. },
  1418. "proPing": function () {
  1419. "use strict";
  1420. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1421. var div = document.getElementById('tarteaucitronPremium'),
  1422. timestamp = new Date().getTime(),
  1423. url = 'https://tarteaucitron.io/log/?';
  1424. if (div === null) {
  1425. return;
  1426. }
  1427. url += 'account=' + tarteaucitron.uuid + '&';
  1428. url += 'domain=' + tarteaucitron.domain + '&';
  1429. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1430. url += '_time=' + timestamp;
  1431. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1432. tarteaucitron.proTemp = '';
  1433. }
  1434. tarteaucitron.cookie.number();
  1435. },
  1436. "AddOrUpdate" : function(source, custom){
  1437. /**
  1438. Utility function to Add or update the fields of obj1 with the ones in obj2
  1439. */
  1440. for(key in custom){
  1441. if(custom[key] instanceof Object){
  1442. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1443. }else{
  1444. source[key] = custom[key];
  1445. }
  1446. }
  1447. return source;
  1448. },
  1449. "getElemWidth": function(elem) {
  1450. return elem.getAttribute('width') || elem.clientWidth;
  1451. },
  1452. "getElemHeight": function(elem) {
  1453. return elem.getAttribute('height') || elem.clientHeight;
  1454. }
  1455. };