tarteaucitron.js 81 KB

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