templates/base.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.     {# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
  17.     {#
  18.     {% block stylesheets %}
  19.         {{ encore_entry_link_tags('app') }}
  20.     {% endblock %}
  21.     {% block javascripts %}
  22.         {{ encore_entry_script_tags('app') }}
  23.     {% endblock %}
  24.     #}
  25.     {# Axeptio TCF API #}
  26. {#    <script rel="preconnect" src="//static.axept.io/tcf/sdk.js"></script>#}
  27. {#    <script>#}
  28. {#        window.axeptioSettings = {#}
  29. {#            clientId: "66137db6ae83de5e566cfc53",#}
  30. {#            cookiesVersion: "first-id sandbox-fr-EU",#}
  31. {#        };#}
  32. {#        (function (d, s) {#}
  33. {#            var t = d.getElementsByTagName(s)[0],#}
  34. {#                e = d.createElement(s);#}
  35. {#            e.async = true;#}
  36. {#            e.async = true;#}
  37. {#            e.src = "//static.axept.io/tcf/sdk.js";#}
  38. {#            e.type = "module";#}
  39. {#            t.parentNode.insertBefore(e, t);#}
  40. {#        })(document, "script");#}
  41. {#    </script>#}
  42.     {# End Axeptio TCF API #}
  43. </head>
  44. <body>
  45. <nav class="navbar navbar-expand-lg navbar-light bg-light">
  46.     <a class="navbar-brand" href="{{ path('app_index') }}">{{ site_name }}</a>
  47.     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
  48.             aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  49.         <span class="navbar-toggler-icon"></span>
  50.     </button>
  51. </nav>
  52. <div class="container">
  53.     <div class="row">
  54.         <div class="col-md-12">
  55.             <h3>First ID : <span id="firstid"></span></h3>
  56.         </div>
  57.     </div>
  58.     {% block body %}{% endblock %}
  59. </div>
  60. </body>
  61. <script>
  62.     // Define a constant for the FirstID vendor ID (1178)
  63.     // const FIRSTID_VENDOR_ID = 1178;
  64.     //
  65.     // // This function listens for user consent via the TCF API
  66.     // function listenForTCFConsent(callback) {
  67.     //     // Output to console that the system is now listening for TCF consent
  68.     //     console.debug('Listening for TCF consent...');
  69.     //
  70.     //     // Check if the TCF API (__tcfapi) is present on the window object
  71.     //     if (!window.__tcfapi)
  72.     //         return;  // Exit if TCF API is not found
  73.     //
  74.     //     // Register an event listener to receive updates when consent is given through the TCF API
  75.     //     window.__tcfapi('addEventListener', 2, (tcData, success) => {
  76.     //         // Check if the API call was successful and GDPR applies
  77.     //         if (success && tcData.gdprApplies) {
  78.     //             // Check if the user has given consent for the specific vendor ID
  79.     //             if (tcData.vendor.consents[FIRSTID_VENDOR_ID] && tcData.eventStatus === 'useractioncomplete') {
  80.     //                 console.log('User consented to the flex feature.');
  81.     //                 // TODO: Set cookie ??
  82.     //                 callback();  // Execute the callback function if consent is given
  83.     //             } else {
  84.     //                 console.log('User did not consent to the flex feature.');
  85.     //             }
  86.     //         } else {
  87.     //             console.log('__tcfapi failed to load or is not applicable.');
  88.     //         }
  89.     //     });
  90.     // }
  91.     // Call the listenForTCFConsent function with a callback function that reloads the page
  92.     // listenForTCFConsent(window.location.reload)
  93.     function getCookieValueFromCookieName(cookieName) {
  94.         let cookieArr = document.cookie.split(";");
  95.         console.log(cookieArr)
  96.         for (let i = 0; i < cookieArr.length; i++) {
  97.             let cookiePair = cookieArr[i].split("=");
  98.             if (cookieName === cookiePair[0].trim()) {
  99.                 return decodeURIComponent(cookiePair[1]);
  100.             }
  101.         }
  102.         return null;
  103.     }
  104.     function checkFirstidCookie() {
  105.         let firstidCookieValue = getCookieValueFromCookieName("firstid");
  106.         if (firstidCookieValue) {
  107.             console.log(`First ID : ${firstidCookieValue}`)
  108.         } else {
  109.             console.log('No First ID cookie find.')
  110.         }
  111.     }
  112.     // function setCookie(cName, cValue, expDays) {
  113.     //     let date = new Date();
  114.     //     date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
  115.     //     const expires = "expires=" + date.toUTCString();
  116.     //     document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
  117.     // }
  118.     // function getFirstidIfNeeded() {
  119.     //     let consentCookie = getCookieValueFromCookieName('consent');
  120.     //     let firstidCookieValue = getCookieValueFromCookieName("firstid");
  121.     //
  122.     //     if (consentCookie === 'yes' && !firstidCookieValue) {
  123.     //         let currentLocation = window.location.href;
  124.     //         let currentLocationBase64 = btoa(currentLocation);
  125.     //         window.location = `https://gate2.preprod.first-id.fr?redirectUrl=${currentLocationBase64}`;
  126.     //     }
  127.     // }
  128.     // function createFirstidCookieIfNeeded() {
  129.     //     let params = new URLSearchParams(window.location.search);
  130.     //     let firstidCookieValue = getCookieValueFromCookieName("firstid");
  131.     //
  132.     //     if (params.has('firstId') && !firstidCookieValue) {
  133.     //         setCookie('firstid', params.get('firstId'), 180);
  134.     //         console.log(`cookie first id is set with value ${params.get('firstId')}`)
  135.     //     }
  136.     // }
  137.     // function loadFirstIdSdk() {
  138.     //     var script = document.createElement('script');
  139.     //     script.src = "https://cdn.preprod.first-id.fr/sdk/loader/loader.min.js";
  140.     //     script.defer = true;
  141.     //     document.head.appendChild(script);
  142.     //
  143.     //     script.onload = function () {
  144.     //         window.firstId = window.firstId || {
  145.     //             callbacks: [],
  146.     //             debug: true,
  147.     //             cookieName: 'firstid'
  148.     //         };
  149.     //
  150.     //         window.firstId.callbacks.push(() => {
  151.     //             console.log('FirstID SDK loaded and initialized after user consent.');
  152.     //             // Additional FirstID SDK logic here
  153.     //         });
  154.     //
  155.     //         window.firstId.callbacks.push(() => {
  156.     //             console.log(FIRSTID.get)
  157.     //         });
  158.     //     };
  159.     // }
  160.     // function checkConsentAndLoadSdk() {
  161.     //     // Check if consent cookie is set, if so, load the SDK
  162.     //     let consent = getCookieValueFromCookieName('consent');
  163.     //     if (consent === 'yes') {
  164.     //         loadFirstIdSdk();
  165.     //     }
  166.     // }
  167.     // checkConsentAndLoadSdk();
  168.     checkFirstidCookie();
  169.     //createFirstidCookieIfNeeded();
  170.     //getFirstidIfNeeded();
  171.     // loadFirstIdSdk();
  172.     let fid = getCookieValueFromCookieName('firstid')
  173.     if (fid) {
  174.         $('#firstid').text(fid)
  175.     } else {
  176.         $('#firstid').text('No First ID cookie find.')
  177.     }
  178. </script>
  179. </html>