gdpr.js 59 KB

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