templates/gate/gate.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.     {# Axeptio TCF API #}
  17.     <script>
  18.         window.axeptioSettings = {
  19.             clientId: "66137db6ae83de5e566cfc53",
  20.             cookiesVersion: "first-id sandbox-fr-EU",
  21.         };
  22.         (function (d, s) {
  23.             var t = d.getElementsByTagName(s)[0],
  24.                 e = d.createElement(s);
  25.             e.async = false;
  26.             e.src = "//static.axept.io/tcf/sdk.js";
  27.             e.type = "module";
  28.             t.parentNode.insertBefore(e, t);
  29.         })(document, "script");
  30.     </script>
  31.     {# End Axeptio TCF API #}
  32. </head>
  33. <body>
  34. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  35.     <a class="navbar-brand" href="{{ path('app_index') }}">{{ site_name }}</a>
  36.     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
  37.             aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  38.         <span class="navbar-toggler-icon"></span>
  39.     </button>
  40. </nav>
  41. <div class="container">
  42.     <div class="row">
  43.         <div class="col-md-12">
  44.             <h3>First ID : <span id="firstid"></span></h3>
  45.         </div>
  46.     </div>
  47.     <div class="row mt-4">
  48.         <div class="col-md-12">
  49.             {% if not hasFirstId %}
  50.                 <button id="redirectButton" class="btn btn-primary">Get First ID</button>
  51.             {% else %}
  52.                 <p>You already have a First ID.</p>
  53.             {% endif %}
  54.         </div>
  55.     </div>
  56.     {% block body %}{% endblock %}
  57. </div>
  58. <script>
  59.     const FIRSTID_VENDOR_ID = 1178;
  60.     function listenForTCFConsent(callback) {
  61.         console.debug('Listening for TCF consent...');
  62.         if (!window.__tcfapi) return;
  63.         window.__tcfapi('addEventListener', 2, (tcData, success) => {
  64.             if (success && tcData.gdprApplies) {
  65.                 if (tcData.vendor.consents[FIRSTID_VENDOR_ID] && tcData.eventStatus === 'useractioncomplete') {
  66.                     console.log('User consented to the flex feature.');
  67.                     callback();
  68.                 } else {
  69.                     console.log('User did not consent to the flex feature.');
  70.                 }
  71.             } else {
  72.                 console.log('__tcfapi failed to load or is not applicable.');
  73.             }
  74.         });
  75.     }
  76.     listenForTCFConsent(window.location.reload)
  77.     function getCookieValueFromCookieName(cookieName) {
  78.         let cookieArr = document.cookie.split(";");
  79.         for (let i = 0; i < cookieArr.length; i++) {
  80.             let cookiePair = cookieArr[i].split("=");
  81.             if (cookieName === cookiePair[0].trim()) {
  82.                 return decodeURIComponent(cookiePair[1]);
  83.             }
  84.         }
  85.         return null;
  86.     }
  87.     function checkFirstidCookie() {
  88.         let firstidCookieValue = getCookieValueFromCookieName("firstid");
  89.         if (firstidCookieValue) {
  90.             console.log(`First ID : ${firstidCookieValue}`)
  91.         } else {
  92.             console.log('No First ID cookie found.')
  93.         }
  94.     }
  95.     function loadFirstIdSdk() {
  96.         var script = document.createElement('script');
  97.         script.src = "https://cdn.preprod.first-id.fr/sdk/loader/loader.min.js";
  98.         script.defer = true;
  99.         document.head.appendChild(script);
  100.         script.onload = function () {
  101.             window.firstId = window.firstId || {
  102.                 callbacks: [],
  103.                 debug: true,
  104.                 cookieName: 'firstid'
  105.             };
  106.             window.firstId.callbacks.push(() => {
  107.                 console.log('FirstID SDK loaded and initialized after user consent.');
  108.             });
  109.             window.firstId.callbacks.push(() => {
  110.                 console.log(FIRSTID.get)
  111.             });
  112.         };
  113.     }
  114.     function checkConsentAndLoadSdk() {
  115.         let consent = getCookieValueFromCookieName('consent');
  116.         if (consent === 'yes') {
  117.             // loadFirstIdSdk();
  118.         }
  119.     }
  120.     checkConsentAndLoadSdk();
  121.     checkFirstidCookie();
  122.     // loadFirstIdSdk()
  123.     let fid = getCookieValueFromCookieName('firstid')
  124.     if (fid) {
  125.         $('#firstid').text(fid)
  126.     } else {
  127.         $('#firstid').text('No First ID cookie found.')
  128.     }
  129.     document.getElementById('redirectButton').addEventListener('click', function() {
  130.         window.location.href = "{{ path('app_gate_redirect') }}";
  131.     });
  132. </script>
  133. </body>
  134. </html>