tarteaucitron.js 77 KB

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