templates/gate/gate3.html.twig line 1

Open in your IDE?
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>{% block title %}Welcome!{% endblock %}</title>
  6.     <link rel="icon"
  7.           href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>">
  8.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css"
  9.           integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
  10.     <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"
  11.             integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
  12.             crossorigin="anonymous"></script>
  13.     <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"
  14.             integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF"
  15.             crossorigin="anonymous"></script>
  16.     <script>
  17.         window.axeptioSettings = {
  18.             clientId: "66137db6ae83de5e566cfc53",
  19.             cookiesVersion: "first-id sandbox-fr-EU",
  20.         };
  21.         (function (d, s) {
  22.             var t = d.getElementsByTagName(s)[0],
  23.                 e = d.createElement(s);
  24.             e.async = false;
  25.             e.src = "//static.axept.io/tcf/sdk.js";
  26.             e.type = "module";
  27.             t.parentNode.insertBefore(e, t);
  28.         })(document, "script");
  29.     </script>
  30. </head>
  31. <body>
  32. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  33.     <a class="navbar-brand" href="{{ path('app_index') }}">{{ site_name }}</a>
  34.     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
  35.             aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  36.         <span class="navbar-toggler-icon"></span>
  37.     </button>
  38. </nav>
  39. <div class="container">
  40.     <div class="row">
  41.         <div class="col-md-12">
  42.             <h3>First ID (Gate3 - Random UUID Redirect) : <span id="firstid"></span></h3>
  43.         </div>
  44.     </div>
  45.     <div class="row mt-4">
  46.         <div class="col-md-12">
  47.             {% if not hasFirstId %}
  48.                 <button id="redirectButton" class="btn btn-primary">Get First ID</button>
  49.             {% else %}
  50.                 <p>You already have a First ID.</p>
  51.             {% endif %}
  52.         </div>
  53.     </div>
  54.     {% block body %}{% endblock %}
  55. </div>
  56. <script>
  57.     const FIRSTID_VENDOR_ID = 1178;
  58.     function listenForTCFConsent(callback) {
  59.         console.debug('Listening for TCF consent...');
  60.         if (!window.__tcfapi) return;
  61.         window.__tcfapi('addEventListener', 2, (tcData, success) => {
  62.             if (success && tcData.gdprApplies) {
  63.                 if (tcData.vendor.consents[FIRSTID_VENDOR_ID] && tcData.eventStatus === 'useractioncomplete') {
  64.                     console.log('User consented to the flex feature.');
  65.                     callback();
  66.                 } else {
  67.                     console.log('User did not consent to the flex feature.');
  68.                 }
  69.             } else {
  70.                 console.log('__tcfapi failed to load or is not applicable.');
  71.             }
  72.         });
  73.     }
  74.     listenForTCFConsent(window.location.reload)
  75.     function getCookieValueFromCookieName(cookieName) {
  76.         let cookieArr = document.cookie.split(";");
  77.         for (let i = 0; i < cookieArr.length; i++) {
  78.             let cookiePair = cookieArr[i].split("=");
  79.             if (cookieName === cookiePair[0].trim()) {
  80.                 return decodeURIComponent(cookiePair[1]);
  81.             }
  82.         }
  83.         return null;
  84.     }
  85.     function checkFirstidCookie() {
  86.         let firstidCookieValue = getCookieValueFromCookieName("firstid");
  87.         if (firstidCookieValue) {
  88.             console.log(`First ID : ${firstidCookieValue}`)
  89.         } else {
  90.             console.log('No First ID cookie found.')
  91.         }
  92.     }
  93.     function loadFirstIdSdk() {
  94.         var script = document.createElement('script');
  95.         script.src = "https://cdn.preprod.first-id.fr/sdk/loader/loader.min.js";
  96.         script.defer = true;
  97.         document.head.appendChild(script);
  98.         script.onload = function () {
  99.             window.firstId = window.firstId || {
  100.                 callbacks: [],
  101.                 debug: true,
  102.                 cookieName: 'firstid'
  103.             };
  104.             window.firstId.callbacks.push(() => {
  105.                 console.log('FirstID SDK loaded and initialized after user consent.');
  106.             });
  107.             window.firstId.callbacks.push(() => {
  108.                 console.log(FIRSTID.get)
  109.             });
  110.         };
  111.     }
  112.     function checkConsentAndLoadSdk() {
  113.         let consent = getCookieValueFromCookieName('consent');
  114.         if (consent === 'yes') {
  115.             // loadFirstIdSdk();
  116.         }
  117.     }
  118.     checkConsentAndLoadSdk();
  119.     checkFirstidCookie();
  120.     let fid = getCookieValueFromCookieName('firstid')
  121.     if (fid) {
  122.         $('#firstid').text(fid)
  123.     } else {
  124.         $('#firstid').text('No First ID cookie found.')
  125.     }
  126.     document.getElementById('redirectButton')?.addEventListener('click', function() {
  127.         window.location.href = "{{ path('app_gate3_redirect') }}";
  128.     });
  129. </script>
  130. </body>
  131. </html>