tarteaucitron.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. /*jslint browser: true, evil: true */
  2. // define correct path for files inclusion
  3. var scripts = document.getElementsByTagName('script'),
  4. path = scripts[scripts.length - 1].src.split('?')[0],
  5. cdn = path.split('/').slice(0, -1).join('/') + '/',
  6. alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
  7. tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
  8. tarteaucitronProLoadServices,
  9. tarteaucitronNoAdBlocker = false;
  10. var tarteaucitron = {
  11. "version": 206,
  12. "cdn": cdn,
  13. "user": {},
  14. "lang": {},
  15. "services": {},
  16. "added": [],
  17. "idprocessed": [],
  18. "state": [],
  19. "launch": [],
  20. "parameters": {},
  21. "isAjax": false,
  22. "reloadThePage": false,
  23. "init": function (params) {
  24. "use strict";
  25. var origOpen;
  26. tarteaucitron.parameters = params;
  27. if (alreadyLaunch === 0) {
  28. alreadyLaunch = 1;
  29. if (window.addEventListener) {
  30. window.addEventListener("load", function () {
  31. tarteaucitron.load();
  32. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  33. elem.addEventListener("click", function () {
  34. tarteaucitron.userInterface.openPanel();
  35. }, false);
  36. }, true);
  37. }, false);
  38. window.addEventListener("keydown", function (evt) {
  39. if (evt.keyCode === 27) {
  40. tarteaucitron.userInterface.closePanel();
  41. }
  42. }, false);
  43. window.addEventListener("hashchange", function () {
  44. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  45. tarteaucitron.userInterface.openPanel();
  46. }
  47. }, false);
  48. window.addEventListener("resize", function () {
  49. if (document.getElementById('tarteaucitron') !== null) {
  50. if (document.getElementById('tarteaucitron').style.display === 'block') {
  51. tarteaucitron.userInterface.jsSizing('main');
  52. }
  53. }
  54. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  55. if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
  56. tarteaucitron.userInterface.jsSizing('cookie');
  57. }
  58. }
  59. }, false);
  60. } else {
  61. window.attachEvent("onload", function () {
  62. tarteaucitron.load();
  63. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  64. elem.attachEvent("onclick", function () {
  65. tarteaucitron.userInterface.openPanel();
  66. });
  67. }, true);
  68. });
  69. window.attachEvent("onkeydown", function (evt) {
  70. if (evt.keyCode === 27) {
  71. tarteaucitron.userInterface.closePanel();
  72. }
  73. });
  74. window.attachEvent("onhashchange", function () {
  75. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  76. tarteaucitron.userInterface.openPanel();
  77. }
  78. });
  79. window.attachEvent("onresize", function () {
  80. if (document.getElementById('tarteaucitron') !== null) {
  81. if (document.getElementById('tarteaucitron').style.display === 'block') {
  82. tarteaucitron.userInterface.jsSizing('main');
  83. }
  84. }
  85. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  86. if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
  87. tarteaucitron.userInterface.jsSizing('cookie');
  88. }
  89. }
  90. });
  91. }
  92. if (typeof XMLHttpRequest !== 'undefined') {
  93. origOpen = XMLHttpRequest.prototype.open;
  94. XMLHttpRequest.prototype.open = function () {
  95. if (window.addEventListener) {
  96. this.addEventListener("load", function () {
  97. if (typeof tarteaucitronProLoadServices === 'function') {
  98. tarteaucitronProLoadServices();
  99. }
  100. }, false);
  101. } else if (typeof this.attachEvent !== 'undefined') {
  102. this.attachEvent("onload", function () {
  103. if (typeof tarteaucitronProLoadServices === 'function') {
  104. tarteaucitronProLoadServices();
  105. }
  106. });
  107. } else {
  108. if (typeof tarteaucitronProLoadServices === 'function') {
  109. setTimeout(tarteaucitronProLoadServices, 1000);
  110. }
  111. }
  112. try {
  113. origOpen.apply(this, arguments);
  114. } catch (err) {}
  115. };
  116. }
  117. }
  118. },
  119. "load": function () {
  120. "use strict";
  121. var cdn = tarteaucitron.cdn,
  122. language = tarteaucitron.getLanguage(),
  123. pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js?v=' + tarteaucitron.version,
  124. pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
  125. linkElement = document.createElement('link'),
  126. defaults = {
  127. "adblocker": false,
  128. "hashtag": '#tarteaucitron',
  129. "highPrivacy": false,
  130. "orientation": "top",
  131. "removeCredit": false,
  132. "showAlertSmall": true,
  133. "cookieslist": true
  134. },
  135. params = tarteaucitron.parameters;
  136. // Step 0: get params
  137. if (params !== undefined) {
  138. tarteaucitron.extend(defaults, params);
  139. }
  140. // global
  141. tarteaucitron.hashtag = defaults.hashtag;
  142. tarteaucitron.highPrivacy = defaults.highPrivacy;
  143. // Step 1: load css
  144. linkElement.rel = 'stylesheet';
  145. linkElement.type = 'text/css';
  146. linkElement.href = cdn + 'css/tarteaucitron.css?v=' + tarteaucitron.version;
  147. document.getElementsByTagName('head')[0].appendChild(linkElement);
  148. // Step 2: load language and services
  149. tarteaucitron.addScript(pathToLang, '', function () {
  150. tarteaucitron.addScript(pathToServices, '', function () {
  151. var body = document.body,
  152. div = document.createElement('div'),
  153. html = '',
  154. index,
  155. orientation = 'Top',
  156. cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video'],
  157. i;
  158. cat = cat.sort(function (a, b) {
  159. if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
  160. if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
  161. return 0;
  162. });
  163. // Step 3: prepare the html
  164. html += '<div id="tarteaucitronPremium"></div>';
  165. html += '<div id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();"></div>';
  166. html += '<div id="tarteaucitron">';
  167. html += ' <div id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
  168. html += ' ' + tarteaucitron.lang.close;
  169. html += ' </div>';
  170. html += ' <div id="tarteaucitronServices">';
  171. html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
  172. html += ' <div class="tarteaucitronName">';
  173. html += ' <b><a href="#" onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronInfo\', \'tarteaucitronInfoBox\');return false">&#10011;</a> ' + tarteaucitron.lang.all + '</b>';
  174. html += ' </div>';
  175. html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
  176. html += ' <div id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
  177. html += ' &#10003; ' + tarteaucitron.lang.allow;
  178. html += ' </div> ';
  179. html += ' <div id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  180. html += ' &#10007; ' + tarteaucitron.lang.deny;
  181. html += ' </div>';
  182. html += ' </div>';
  183. html += ' </div>';
  184. html += ' <div id="tarteaucitronInfo" class="tarteaucitronInfoBox">';
  185. html += ' ' + tarteaucitron.lang.disclaimer;
  186. if (defaults.removeCredit === false) {
  187. html += ' <br/><br/>';
  188. html += ' <a href="https://opt-out.ferank.eu/" rel="nofollow" target="_blank">' + tarteaucitron.lang.credit + '</a>';
  189. }
  190. html += ' </div>';
  191. html += ' <div class="tarteaucitronBorder" id="tarteaucitronScrollbarParent">';
  192. html += ' <div class="clear"></div>';
  193. for (i = 0; i < cat.length; i += 1) {
  194. html += ' <div id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
  195. html += ' <div class="tarteaucitronTitle">';
  196. html += ' <a href="#" onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronDetails' + cat[i] + '\', \'tarteaucitronInfoBox\');return false">&#10011;</a> ' + tarteaucitron.lang[cat[i]].title;
  197. html += ' </div>';
  198. html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
  199. html += ' ' + tarteaucitron.lang[cat[i]].details;
  200. html += ' </div>';
  201. html += ' </div>';
  202. html += ' <div id="tarteaucitronServices_' + cat[i] + '"></div>';
  203. }
  204. html += ' <div class="tarteaucitronHidden" id="tarteaucitronScrollbarChild" style="height:20px;display:block"></div>';
  205. html += ' </div>';
  206. html += ' </div>';
  207. html += '</div>';
  208. if (defaults.orientation === 'bottom') {
  209. orientation = 'Bottom';
  210. }
  211. if (defaults.highPrivacy) {
  212. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  213. html += ' <span id="tarteaucitronDisclaimerAlert">';
  214. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  215. html += ' </span>';
  216. html += ' <span id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.openPanel();">';
  217. html += ' ' + tarteaucitron.lang.personalize;
  218. html += ' </span>';
  219. html += '</div>';
  220. } else {
  221. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  222. html += ' <span id="tarteaucitronDisclaimerAlert">';
  223. html += ' ' + tarteaucitron.lang.alertBig;
  224. html += ' </span>';
  225. html += ' <span id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
  226. html += ' &#10003; ' + tarteaucitron.lang.acceptAll;
  227. html += ' </span>';
  228. html += ' <span id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
  229. html += ' ' + tarteaucitron.lang.personalize;
  230. html += ' </span>';
  231. html += '</div>';
  232. }
  233. if (defaults.showAlertSmall === true) {
  234. html += '<div id="tarteaucitronAlertSmall">';
  235. html += ' <div id="tarteaucitronManager" onclick="tarteaucitron.userInterface.openPanel();">';
  236. html += ' ' + tarteaucitron.lang.alertSmall;
  237. html += ' <div id="tarteaucitronDot">';
  238. html += ' <span id="tarteaucitronDotGreen"></span>';
  239. html += ' <span id="tarteaucitronDotYellow"></span>';
  240. html += ' <span id="tarteaucitronDotRed"></span>';
  241. html += ' </div>';
  242. if (defaults.cookieslist === true) {
  243. html += ' </div><!-- @whitespace';
  244. html += ' --><div id="tarteaucitronCookiesNumber" onclick="tarteaucitron.userInterface.toggleCookiesList();">0</div>';
  245. html += ' <div id="tarteaucitronCookiesListContainer">';
  246. html += ' <div id="tarteaucitronClosePanelCookie" onclick="tarteaucitron.userInterface.closePanel();">';
  247. html += ' ' + tarteaucitron.lang.close;
  248. html += ' </div>';
  249. html += ' <div class="tarteaucitronCookiesListMain" id="tarteaucitronCookiesTitle">';
  250. html += ' <b id="tarteaucitronCookiesNumberBis">0 cookie</b>';
  251. html += ' </div>';
  252. html += ' <div id="tarteaucitronCookiesList"></div>';
  253. html += ' </div>';
  254. } else {
  255. html += ' </div>';
  256. }
  257. html += '</div>';
  258. }
  259. tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
  260. if (tarteaucitronNoAdBlocker === true || defaults.adblocker === false) {
  261. div.id = 'tarteaucitronRoot';
  262. body.appendChild(div, body);
  263. div.innerHTML = html;
  264. if (tarteaucitron.job !== undefined) {
  265. tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
  266. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  267. tarteaucitron.addService(tarteaucitron.job[index]);
  268. }
  269. }
  270. tarteaucitron.isAjax = true;
  271. tarteaucitron.job.push = function (id) {
  272. // ie <9 hack
  273. if (typeof tarteaucitron.job.indexOf === 'undefined') {
  274. tarteaucitron.job.indexOf = function (obj, start) {
  275. var i,
  276. j = this.length;
  277. for (i = (start || 0); i < j; i += 1) {
  278. if (this[i] === obj) { return i; }
  279. }
  280. return -1;
  281. };
  282. }
  283. if (tarteaucitron.job.indexOf(id) === -1) {
  284. Array.prototype.push.call(this, id);
  285. }
  286. tarteaucitron.launch[id] = false;
  287. tarteaucitron.addService(id);
  288. };
  289. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  290. tarteaucitron.userInterface.openPanel();
  291. }
  292. tarteaucitron.cookie.number();
  293. setInterval(tarteaucitron.cookie.number, 60000);
  294. }
  295. }, defaults.adblocker);
  296. if (defaults.adblocker === true) {
  297. setTimeout(function () {
  298. if (tarteaucitronNoAdBlocker === false) {
  299. html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '" style="display:block">';
  300. html += ' <span id="tarteaucitronDisclaimerAlert">';
  301. html += ' ' + tarteaucitron.lang.adblock + '<br/>';
  302. html += ' <b>' + tarteaucitron.lang.adblock_call + '</b>';
  303. html += ' </span>';
  304. html += ' <span id="tarteaucitronPersonalize" onclick="location.reload();">';
  305. html += ' ' + tarteaucitron.lang.reload;
  306. html += ' </span>';
  307. html += '</div>';
  308. html += '<div id="tarteaucitronPremium"></div>';
  309. div.id = 'tarteaucitronRoot';
  310. body.appendChild(div, body);
  311. div.innerHTML = html;
  312. tarteaucitron.pro('!adblocker=true');
  313. } else {
  314. tarteaucitron.pro('!adblocker=false');
  315. }
  316. }, 1500);
  317. }
  318. });
  319. });
  320. },
  321. "addService": function (serviceId) {
  322. "use strict";
  323. var html = '',
  324. s = tarteaucitron.services,
  325. service = s[serviceId],
  326. cookie = tarteaucitron.cookie.read(),
  327. hostname = document.location.hostname,
  328. hostRef = document.referrer.split('/')[2],
  329. isNavigating = (hostRef === hostname) ? true : false,
  330. isAutostart = (!service.needConsent) ? true : false,
  331. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0) ? true : false,
  332. isDenied = (cookie.indexOf(service.key + '=false') >= 0) ? true : false,
  333. isAllowed = (cookie.indexOf(service.key + '=true') >= 0) ? true : false,
  334. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0) ? true : false;
  335. if (tarteaucitron.added[service.key] !== true) {
  336. tarteaucitron.added[service.key] = true;
  337. html += '<div id="' + service.key + 'Line" class="tarteaucitronLine">';
  338. html += ' <div class="tarteaucitronName">';
  339. html += ' <b>' + service.name + '</b><br/>';
  340. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  341. html += ' <a href="https://opt-out.ferank.eu/service/' + service.key + '/" target="_blank">';
  342. html += ' ' + tarteaucitron.lang.more;
  343. html += ' </a>';
  344. html += ' - ';
  345. html += ' <a href="' + service.uri + '" target="_blank">';
  346. html += ' ' + tarteaucitron.lang.source;
  347. html += ' </a>';
  348. html += ' </div>';
  349. html += ' <div class="tarteaucitronAsk">';
  350. html += ' <div id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
  351. html += ' &#10003; ' + tarteaucitron.lang.allow;
  352. html += ' </div> ';
  353. html += ' <div id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
  354. html += ' &#10007; ' + tarteaucitron.lang.deny;
  355. html += ' </div>';
  356. html += ' </div>';
  357. html += '</div>';
  358. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  359. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  360. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  361. }
  362. tarteaucitron.userInterface.order(service.type);
  363. }
  364. // allow by default for non EU
  365. if (isResponded === false && tarteaucitron.user.bypass === true) {
  366. isAllowed = true;
  367. tarteaucitron.cookie.create(service.key, true);
  368. }
  369. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  370. if (!isAllowed) {
  371. tarteaucitron.cookie.create(service.key, true);
  372. }
  373. if (tarteaucitron.launch[service.key] !== true) {
  374. tarteaucitron.launch[service.key] = true;
  375. service.js();
  376. }
  377. tarteaucitron.state[service.key] = true;
  378. tarteaucitron.userInterface.color(service.key, true);
  379. } else if (isDenied) {
  380. if (typeof service.fallback === 'function') {
  381. service.fallback();
  382. }
  383. tarteaucitron.state[service.key] = false;
  384. tarteaucitron.userInterface.color(service.key, false);
  385. } else if (!isResponded) {
  386. tarteaucitron.cookie.create(service.key, 'wait');
  387. if (typeof service.fallback === 'function') {
  388. service.fallback();
  389. }
  390. tarteaucitron.userInterface.color(service.key, 'wait');
  391. tarteaucitron.userInterface.openAlert();
  392. }
  393. tarteaucitron.cookie.checkCount(service.key);
  394. },
  395. "cleanArray": function cleanArray(arr) {
  396. "use strict";
  397. var i,
  398. len = arr.length,
  399. out = [],
  400. obj = {},
  401. s = tarteaucitron.services;
  402. for (i = 0; i < len; i += 1) {
  403. if (!obj[arr[i]]) {
  404. obj[arr[i]] = {};
  405. if (tarteaucitron.services[arr[i]] !== undefined) {
  406. out.push(arr[i]);
  407. }
  408. }
  409. }
  410. out = out.sort(function (a, b) {
  411. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  412. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  413. return 0;
  414. });
  415. return out;
  416. },
  417. "userInterface": {
  418. "css": function (id, property, value) {
  419. "use strict";
  420. if (document.getElementById(id) !== null) {
  421. document.getElementById(id).style[property] = value;
  422. }
  423. },
  424. "respondAll": function (status) {
  425. "use strict";
  426. var s = tarteaucitron.services,
  427. service,
  428. key,
  429. index = 0;
  430. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  431. service = s[tarteaucitron.job[index]];
  432. key = service.key;
  433. if (tarteaucitron.state[key] !== status) {
  434. if (status === false && tarteaucitron.launch[key] === true) {
  435. tarteaucitron.reloadThePage = true;
  436. }
  437. if (tarteaucitron.launch[key] !== true && status === true) {
  438. tarteaucitron.launch[key] = true;
  439. tarteaucitron.services[key].js();
  440. }
  441. tarteaucitron.state[key] = status;
  442. tarteaucitron.cookie.create(key, status);
  443. tarteaucitron.userInterface.color(key, status);
  444. }
  445. }
  446. },
  447. "respond": function (el, status) {
  448. "use strict";
  449. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  450. // return if same state
  451. if (tarteaucitron.state[key] === status) {
  452. return;
  453. }
  454. if (status === false && tarteaucitron.launch[key] === true) {
  455. tarteaucitron.reloadThePage = true;
  456. }
  457. // if not already launched... launch the service
  458. if (status === true) {
  459. if (tarteaucitron.launch[key] !== true) {
  460. tarteaucitron.launch[key] = true;
  461. tarteaucitron.services[key].js();
  462. }
  463. }
  464. tarteaucitron.state[key] = status;
  465. tarteaucitron.cookie.create(key, status);
  466. tarteaucitron.userInterface.color(key, status);
  467. },
  468. "color": function (key, status) {
  469. "use strict";
  470. var gray = '#808080',
  471. greenDark = '#1B870B',
  472. greenLight = '#E6FFE2',
  473. redDark = '#9C1A1A',
  474. redLight = '#FFE2E2',
  475. yellowDark = '#FBDA26',
  476. c = 'tarteaucitron',
  477. nbDenied = 0,
  478. nbPending = 0,
  479. nbAllowed = 0,
  480. sum = tarteaucitron.job.length,
  481. index;
  482. if (status === true) {
  483. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + greenDark);
  484. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', greenDark);
  485. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', gray);
  486. } else if (status === false) {
  487. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + redDark);
  488. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', gray);
  489. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', redDark);
  490. }
  491. // check if all services are allowed
  492. for (index = 0; index < sum; index += 1) {
  493. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  494. nbDenied += 1;
  495. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  496. nbPending += 1;
  497. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  498. nbAllowed += 1;
  499. }
  500. }
  501. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  502. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  503. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  504. if (nbDenied === 0 && nbPending === 0) {
  505. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark);
  506. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  507. } else if (nbAllowed === 0 && nbPending === 0) {
  508. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  509. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
  510. } else {
  511. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  512. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  513. }
  514. // close the alert if all service have been reviewed
  515. if (nbPending === 0) {
  516. tarteaucitron.userInterface.closeAlert();
  517. }
  518. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  519. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  520. }
  521. if (status === true) {
  522. if (document.getElementById('tacCL' + key) !== null) {
  523. document.getElementById('tacCL' + key).innerHTML = '...';
  524. }
  525. setTimeout(function () {
  526. tarteaucitron.cookie.checkCount(key);
  527. }, 2500);
  528. } else {
  529. tarteaucitron.cookie.checkCount(key);
  530. }
  531. },
  532. "openPanel": function () {
  533. "use strict";
  534. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  535. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  536. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  537. tarteaucitron.userInterface.jsSizing('main');
  538. },
  539. "closePanel": function () {
  540. "use strict";
  541. if (document.location.hash === tarteaucitron.hashtag) {
  542. document.location.hash = '';
  543. }
  544. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  545. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  546. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  547. elem.style.display = 'none';
  548. }, true);
  549. if (tarteaucitron.reloadThePage === true) {
  550. window.location.reload();
  551. } else {
  552. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  553. }
  554. },
  555. "openAlert": function () {
  556. "use strict";
  557. var c = 'tarteaucitron';
  558. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  559. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  560. },
  561. "closeAlert": function () {
  562. "use strict";
  563. var c = 'tarteaucitron';
  564. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  565. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  566. tarteaucitron.userInterface.jsSizing('box');
  567. },
  568. "toggleCookiesList": function () {
  569. "use strict";
  570. var div = document.getElementById('tarteaucitronCookiesListContainer');
  571. if (div === null) {
  572. return;
  573. }
  574. if (div.style.display !== 'block') {
  575. tarteaucitron.cookie.number();
  576. div.style.display = 'block';
  577. tarteaucitron.userInterface.jsSizing('cookie');
  578. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  579. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  580. } else {
  581. div.style.display = 'none';
  582. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  583. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  584. }
  585. },
  586. "toggle": function (id, closeClass) {
  587. "use strict";
  588. var div = document.getElementById(id);
  589. if (div === null) {
  590. return;
  591. }
  592. if (closeClass !== undefined) {
  593. tarteaucitron.fallback([closeClass], function (elem) {
  594. if (elem.id !== id) {
  595. elem.style.display = 'none';
  596. }
  597. }, true);
  598. }
  599. if (div.style.display !== 'block') {
  600. div.style.display = 'block';
  601. } else {
  602. div.style.display = 'none';
  603. }
  604. },
  605. "order": function (id) {
  606. "use strict";
  607. var main = document.getElementById('tarteaucitronServices_' + id),
  608. allDivs = main.childNodes,
  609. store = [],
  610. i;
  611. if (main === null) {
  612. return;
  613. }
  614. if (typeof Array.prototype.map === 'function') {
  615. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  616. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  617. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  618. return 0;
  619. }).forEach(function (element) {
  620. main.appendChild(element);
  621. });
  622. }
  623. },
  624. "jsSizing": function (type) {
  625. "use strict";
  626. var scrollbarMarginRight = 10,
  627. scrollbarWidthParent,
  628. scrollbarWidthChild,
  629. servicesHeight,
  630. e = window,
  631. a = 'inner',
  632. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  633. mainTop,
  634. mainHeight,
  635. closeButtonHeight,
  636. headerHeight,
  637. cookiesListHeight,
  638. cookiesCloseHeight,
  639. cookiesTitleHeight,
  640. paddingBox,
  641. alertSmallHeight,
  642. cookiesNumberHeight;
  643. if (type === 'box') {
  644. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  645. // reset
  646. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  647. // calculate
  648. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  649. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  650. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  651. // apply
  652. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  653. }
  654. } else if (type === 'main') {
  655. // get the real window width for media query
  656. if (window.innerWidth === undefined) {
  657. a = 'client';
  658. e = document.documentElement || document.body;
  659. }
  660. // height of the services list container
  661. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  662. // reset
  663. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', 'auto');
  664. // calculate
  665. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  666. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  667. headerHeight = document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  668. // apply
  669. servicesHeight = (mainHeight - closeButtonHeight - headerHeight + 1);
  670. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', servicesHeight + 'px');
  671. }
  672. // align the main allow/deny button depending on scrollbar width
  673. if (document.getElementById('tarteaucitronScrollbarParent') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  674. // media query
  675. if (e[a + 'Width'] <= 479) {
  676. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  677. } else if (e[a + 'Width'] <= 767) {
  678. scrollbarMarginRight = 12;
  679. }
  680. scrollbarWidthParent = document.getElementById('tarteaucitronScrollbarParent').offsetWidth;
  681. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  682. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  683. }
  684. // center the main panel
  685. if (document.getElementById('tarteaucitron') !== null) {
  686. // media query
  687. if (e[a + 'Width'] <= 767) {
  688. mainTop = 0;
  689. } else {
  690. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  691. }
  692. // correct
  693. if (mainTop < 0) {
  694. mainTop = 0;
  695. }
  696. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  697. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  698. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  699. }
  700. }
  701. // apply
  702. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  703. }
  704. } else if (type === 'cookie') {
  705. // put cookies list at bottom
  706. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  707. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  708. }
  709. // height of cookies list
  710. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  711. // reset
  712. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  713. // calculate
  714. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  715. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  716. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  717. // apply
  718. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  719. }
  720. }
  721. }
  722. },
  723. "cookie": {
  724. "owner": {},
  725. "create": function (key, status) {
  726. "use strict";
  727. var d = new Date(),
  728. time = d.getTime(),
  729. expireTime = time + 31536000000, // 365 days
  730. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  731. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  732. value = 'tarteaucitron=' + cookie + '!' + key + '=' + status;
  733. if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
  734. tarteaucitron.pro('!' + key + '=' + status);
  735. }
  736. d.setTime(expireTime);
  737. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;';
  738. },
  739. "read": function () {
  740. "use strict";
  741. var nameEQ = "tarteaucitron=",
  742. ca = document.cookie.split(';'),
  743. i,
  744. c;
  745. for (i = 0; i < ca.length; i += 1) {
  746. c = ca[i];
  747. while (c.charAt(0) === ' ') {
  748. c = c.substring(1, c.length);
  749. }
  750. if (c.indexOf(nameEQ) === 0) {
  751. return c.substring(nameEQ.length, c.length);
  752. }
  753. }
  754. return '';
  755. },
  756. "purge": function (arr) {
  757. "use strict";
  758. var i;
  759. for (i = 0; i < arr.length; i += 1) {
  760. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  761. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  762. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  763. }
  764. },
  765. "checkCount": function (key) {
  766. "use strict";
  767. var arr = tarteaucitron.services[key].cookies,
  768. nb = arr.length,
  769. nbCurrent = 0,
  770. html = '',
  771. i,
  772. status = document.cookie.indexOf(key + '=true');
  773. if (status >= 0 && nb === 0) {
  774. html += tarteaucitron.lang.useNoCookie;
  775. } else if (status >= 0) {
  776. for (i = 0; i < nb; i += 1) {
  777. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  778. nbCurrent += 1;
  779. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  780. tarteaucitron.cookie.owner[arr[i]] = [];
  781. }
  782. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  783. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  784. }
  785. }
  786. }
  787. if (nbCurrent > 0) {
  788. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  789. if (nbCurrent > 1) {
  790. html += 's';
  791. }
  792. html += '.';
  793. } else {
  794. html += tarteaucitron.lang.useNoCookie;
  795. }
  796. } else if (nb === 0) {
  797. html = tarteaucitron.lang.noCookie;
  798. } else {
  799. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  800. if (nb > 1) {
  801. html += 's';
  802. }
  803. html += '.';
  804. }
  805. if (document.getElementById('tacCL' + key) !== null) {
  806. document.getElementById('tacCL' + key).innerHTML = html;
  807. }
  808. },
  809. "crossIndexOf": function (arr, match) {
  810. "use strict";
  811. var i;
  812. for (i = 0; i < arr.length; i += 1) {
  813. if (arr[i] === match) {
  814. return true;
  815. }
  816. }
  817. return false;
  818. },
  819. "number": function () {
  820. "use strict";
  821. var cookies = document.cookie.split(';'),
  822. nb = (document.cookie !== '') ? cookies.length : 0,
  823. html = '',
  824. i,
  825. name,
  826. namea,
  827. nameb,
  828. c,
  829. d,
  830. s = (nb > 1) ? 's' : '',
  831. savedname,
  832. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  833. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  834. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  835. cookies = cookies.sort(function (a, b) {
  836. namea = a.split('=', 1).toString().replace(/ /g, '');
  837. nameb = b.split('=', 1).toString().replace(/ /g, '');
  838. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  839. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  840. if (c + a > d + b) { return 1; }
  841. if (c + a < d + b) { return -1; }
  842. return 0;
  843. });
  844. if (document.cookie !== '') {
  845. for (i = 0; i < nb; i += 1) {
  846. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  847. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  848. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  849. html += '<div class="tarteaucitronHidden">';
  850. html += ' <div class="tarteaucitronTitle">';
  851. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  852. html += ' </div>';
  853. html += '</div>';
  854. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  855. savedname = host;
  856. html += '<div class="tarteaucitronHidden">';
  857. html += ' <div class="tarteaucitronTitle">';
  858. html += ' ' + host;
  859. html += ' </div>';
  860. html += '</div>';
  861. }
  862. html += '<div class="tarteaucitronCookiesListMain">';
  863. html += ' <div class="tarteaucitronCookiesListLeft"><a href="#" onclick="tarteaucitron.cookie.purge([\'' + cookies[i].split('=', 1) + '\']);tarteaucitron.cookie.number();tarteaucitron.userInterface.jsSizing(\'cookie\');return false"><b>&times;</b></a> <b>' + name + '</b>';
  864. html += ' </div>';
  865. html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
  866. html += '</div>';
  867. }
  868. } else {
  869. html += '<div class="tarteaucitronCookiesListMain">';
  870. html += ' <div class="tarteaucitronCookiesListLeft"><b>-</b></div>';
  871. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  872. html += '</div>';
  873. }
  874. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  875. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  876. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  877. }
  878. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  879. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  880. }
  881. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  882. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  883. }
  884. }
  885. },
  886. "getLanguage": function () {
  887. "use strict";
  888. if (!navigator) { return 'en'; }
  889. var availableLanguages = 'en,fr,es,it,de,pt,pl',
  890. defaultLanguage = 'en',
  891. lang = navigator.language || navigator.browserLanguage ||
  892. navigator.systemLanguage || navigator.userLang || null,
  893. userLanguage = lang.substr(0, 2);
  894. if (tarteaucitronForceLanguage !== '') {
  895. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  896. return tarteaucitronForceLanguage;
  897. }
  898. }
  899. if (availableLanguages.indexOf(userLanguage) === -1) {
  900. return defaultLanguage;
  901. }
  902. return userLanguage;
  903. },
  904. "getLocale": function () {
  905. "use strict";
  906. if (!navigator) { return 'en_US'; }
  907. var lang = navigator.language || navigator.browserLanguage ||
  908. navigator.systemLanguage || navigator.userLang || null,
  909. userLanguage = lang.substr(0, 2);
  910. if (userLanguage === 'fr') {
  911. return 'fr_FR';
  912. } else if (userLanguage === 'en') {
  913. return 'en_US';
  914. } else if (userLanguage === 'de') {
  915. return 'de_DE';
  916. } else if (userLanguage === 'es') {
  917. return 'es_ES';
  918. } else if (userLanguage === 'it') {
  919. return 'it_IT';
  920. } else if (userLanguage === 'pt') {
  921. return 'pt_PT';
  922. } else {
  923. return 'en_US';
  924. }
  925. },
  926. "addScript": function (url, id, callback, execute) {
  927. "use strict";
  928. var script,
  929. done = false;
  930. if (execute === false) {
  931. if (typeof callback === 'function') {
  932. callback();
  933. }
  934. } else {
  935. script = document.createElement('script');
  936. script.type = 'text/javascript';
  937. script.id = (id !== undefined) ? id : '';
  938. script.async = true;
  939. script.src = url;
  940. if (typeof callback === 'function') {
  941. script.onreadystatechange = script.onload = function () {
  942. var state = script.readyState;
  943. if (!done && (!state || /loaded|complete/.test(state))) {
  944. done = true;
  945. callback();
  946. }
  947. };
  948. }
  949. document.getElementsByTagName('head')[0].appendChild(script);
  950. }
  951. },
  952. "makeAsync": {
  953. "antiGhost": 0,
  954. "buffer": '',
  955. "init": function (url, id) {
  956. "use strict";
  957. var savedWrite = document.write,
  958. savedWriteln = document.writeln;
  959. document.write = function (content) {
  960. tarteaucitron.makeAsync.buffer += content;
  961. };
  962. document.writeln = function (content) {
  963. tarteaucitron.makeAsync.buffer += content.concat("\n");
  964. };
  965. setTimeout(function () {
  966. document.write = savedWrite;
  967. document.writeln = savedWriteln;
  968. }, 20000);
  969. tarteaucitron.makeAsync.getAndParse(url, id);
  970. },
  971. "getAndParse": function (url, id) {
  972. "use strict";
  973. if (tarteaucitron.makeAsync.antiGhost > 9) {
  974. tarteaucitron.makeAsync.antiGhost = 0;
  975. return;
  976. }
  977. tarteaucitron.makeAsync.antiGhost += 1;
  978. tarteaucitron.addScript(url, '', function () {
  979. if (document.getElementById(id) !== null) {
  980. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  981. tarteaucitron.makeAsync.buffer = '';
  982. tarteaucitron.makeAsync.execJS(id);
  983. }
  984. });
  985. },
  986. "execJS": function (id) {
  987. /* not strict because third party scripts may have errors */
  988. var i,
  989. scripts,
  990. childId,
  991. type;
  992. if (document.getElementById(id) === null) {
  993. return;
  994. }
  995. scripts = document.getElementById(id).getElementsByTagName('script');
  996. for (i = 0; i < scripts.length; i += 1) {
  997. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  998. if (type === '') {
  999. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1000. }
  1001. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1002. childId = id + Math.floor(Math.random() * 99999999999);
  1003. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1004. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1005. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1006. eval(scripts[i].innerHTML);
  1007. }
  1008. }
  1009. }
  1010. },
  1011. "fallback": function (matchClass, content, noInner) {
  1012. "use strict";
  1013. var elems = document.getElementsByTagName('*'),
  1014. i,
  1015. index = 0;
  1016. for (i in elems) {
  1017. if (elems[i] !== undefined) {
  1018. for (index = 0; index < matchClass.length; index += 1) {
  1019. if ((' ' + elems[i].className + ' ')
  1020. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1021. if (typeof content === 'function') {
  1022. if (noInner === true) {
  1023. content(elems[i]);
  1024. } else {
  1025. elems[i].innerHTML = content(elems[i]);
  1026. }
  1027. } else {
  1028. elems[i].innerHTML = content;
  1029. }
  1030. }
  1031. }
  1032. }
  1033. }
  1034. },
  1035. "engage": function (id) {
  1036. "use strict";
  1037. var html = '',
  1038. r = Math.floor(Math.random() * 100000);
  1039. html += '<div class="tac_activate">';
  1040. html += ' <div class="tac_float">';
  1041. html += ' <b>' + tarteaucitron.services[id].name + '</b> ' + tarteaucitron.lang.fallback;
  1042. html += ' <div class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1043. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1044. html += ' </div>';
  1045. html += ' </div>';
  1046. html += '</div>';
  1047. return html;
  1048. },
  1049. "extend": function (a, b) {
  1050. "use strict";
  1051. var prop;
  1052. for (prop in b) {
  1053. if (b.hasOwnProperty(prop)) {
  1054. a[prop] = b[prop];
  1055. }
  1056. }
  1057. },
  1058. "proTemp": '',
  1059. "proTimer": function () {
  1060. "use strict";
  1061. setTimeout(tarteaucitron.proPing, 1000);
  1062. },
  1063. "pro": function (list) {
  1064. "use strict";
  1065. tarteaucitron.proTemp += list;
  1066. clearTimeout(tarteaucitron.proTimer);
  1067. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
  1068. },
  1069. "proPing": function () {
  1070. "use strict";
  1071. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1072. var div = document.getElementById('tarteaucitronPremium'),
  1073. timestamp = new Date().getTime(),
  1074. url = '//opt-out.ferank.eu/premium.php?';
  1075. if (div === null) {
  1076. return;
  1077. }
  1078. url += 'domain=' + tarteaucitron.domain + '&';
  1079. url += 'uuid=' + tarteaucitron.uuid + '&';
  1080. url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1081. url += '_' + timestamp;
  1082. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1083. tarteaucitron.proTemp = '';
  1084. }
  1085. tarteaucitron.cookie.number();
  1086. }
  1087. };