templates/flex/flex.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.     <script>
  7.     </script>
  8.     <link rel="icon"
  9.           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>">
  10.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css"
  11.           integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
  12.     <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"
  13.             integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
  14.             crossorigin="anonymous"></script>
  15.     <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"
  16.             integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF"
  17.             crossorigin="anonymous"></script>
  18.     {# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
  19.     {#
  20.     {% block stylesheets %}
  21.         {{ encore_entry_link_tags('app') }}
  22.     {% endblock %}
  23.     {% block javascripts %}
  24.         {{ encore_entry_script_tags('app') }}
  25.     {% endblock %}
  26.     #}
  27.     {# Axeptio TCF API #}
  28.     <script>
  29.         window.axeptioSettings = {
  30.             clientId: "66137db6ae83de5e566cfc53",
  31.             cookiesVersion: "first-id sandbox-fr-EU",
  32.         };
  33.         (function (d, s) {
  34.             var t = d.getElementsByTagName(s)[0],
  35.                 e = d.createElement(s);
  36.             e.async = false;
  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.     <div class="row mt-4">
  59.         <div class="col-md-12">
  60.             <h4>DeviceId:</h4>
  61.             <input type="text" id="deviceIdInput" class="mb-2 form-control" disabled>
  62.             <button id="generateDeviceId" class="btn btn-secondary">Get device id</button>
  63.         </div>
  64.     </div>
  65.     {% block body %}{% endblock %}
  66. </div>
  67. </body>
  68. <script>
  69.     function getCookieValueFromCookieName(cookieName) {
  70.         let cookieArr = document.cookie.split(";");
  71.         for (let i = 0; i < cookieArr.length; i++) {
  72.             let cookiePair = cookieArr[i].split("=");
  73.             if (cookieName === cookiePair[0].trim()) {
  74.                 return decodeURIComponent(cookiePair[1]);
  75.             }
  76.         }
  77.         return null;
  78.     }
  79.     function loadFirstIdSdk() {
  80.         console.time("sdk:callback");
  81.         console.time("sdk:event");
  82.         var script = document.createElement('script');
  83.         script.src = "https://cdn.preprod.first-id.fr/sdk/loader/loader-latest-flex.js?id=1234567890";
  84.         script.defer = true;
  85.         document.head.appendChild(script);
  86.         script.onload = function () {
  87.             window.firstId = window.firstId || {
  88.                 callbacks: [],
  89.                 debug: true,
  90.                 cookieName: 'firstid',
  91.                 firstIdFlexFeature: true,
  92.             };
  93.             window.firstId.callbacks.push(() => {
  94.                 console.log('FirstID SDK loaded and initialized after user consent.');
  95.                 console.timeEnd("sdk:callback");
  96.                 // Additional FirstID SDK logic here
  97.             });
  98.             window.firstId.callbacks.push(() => {
  99.                 console.log(FIRSTID.get)
  100.             });
  101.             // FirstIdSdk().init();
  102.         };
  103.     }
  104.     loadFirstIdSdk();
  105.     let interval = undefined
  106.     function updateFid() {
  107.         let fid = getCookieValueFromCookieName('firstid')
  108.         if (fid) {
  109.             if (interval) {
  110.                 clearInterval(interval)
  111.             }
  112.             $('#firstid').text(fid)
  113.         } else {
  114.             $('#firstid').text('No First ID cookie find.')
  115.         }
  116.     }
  117.     interval = setInterval(updateFid, 1000)
  118.     document.addEventListener('firstId:new', (event) => console.log('New first id:', event.detail));
  119.     document.addEventListener('firstId:initialized', (event) => {
  120.         console.log('First id initialized:', event.detail)
  121.         console.timeEnd("sdk:event");
  122.     });
  123.     document.getElementById('generateDeviceId').addEventListener('click', function() {
  124.         if(!window.FIRSTID) {
  125.             console.error('FirstID SDK not loaded yet.');
  126.             return;
  127.         }
  128.         if(!window.FIRSTID.getDeviceId) {
  129.             console.error('FirstID SDK does not have getDeviceId method.');
  130.             return;
  131.         }
  132.         FIRSTID.getDeviceId()
  133.             .then(id => {
  134.                 document.getElementById('deviceIdInput').value = id;
  135.             })
  136.             .catch(error => {
  137.                 console.error('Error:', error);
  138.             });
  139.     });
  140. </script>
  141. </html>