templates/front/layouts/partials/javascript.html.twig line 1

Open in your IDE?
  1. {% block javascripts %}
  2.     {{ encore_entry_script_tags('app') }}
  3.     <script src="{{ asset('assets/front/js/bootstrap.bundle.js') }}"></script>
  4. {#    <script src="{{ asset('assets/front/js/bootstrap.js') }}"></script>#}
  5.     <script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script>
  6.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/trumbowyg.min.js') }}"></script>
  7.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/langs/fr.min.js') }}"></script>
  8.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/plugins/emoji/trumbowyg.emoji.js') }}"></script>
  9.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/emoji/trumbowyg.emoji.min.js') }}"></script>
  10.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/fontsize/trumbowyg.fontsize.min.js') }}"></script>
  11.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/history/trumbowyg.history.min.js') }}"></script>
  12.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/indent/trumbowyg.indent.min.js') }}"></script>
  13.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/insertaudio/trumbowyg.insertaudio.min.js') }}"></script>
  14.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/lineheight/trumbowyg.lineheight.min.js') }}"></script>
  15.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/noembed/trumbowyg.noembed.min.js') }}"></script>
  16.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/upload/trumbowyg.upload.min.js') }}"></script>
  17.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/cleanpaste/trumbowyg.cleanpaste.min.js') }}"></script>
  18.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/pasteimage/trumbowyg.pasteimage.min.js') }}"></script>
  19.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/pasteembed/trumbowyg.pasteembed.min.js') }}"></script>
  20.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/fontfamily/trumbowyg.fontfamily.min.js') }}"></script>
  21.     <script src="{{ asset('assets/front/vendor/trumbowyg-main/dist/plugins/colors/trumbowyg.colors.min.js') }}"></script>
  22.     <script src="{{ asset('assets/front/vendor/owlcarousel/dist/owl.carousel.min.js') }}"></script>
  23.     <script src="{{ asset('assets/front/vendor/bootstrap-datetimepicker/js/bootstrap-datepicker.js') }}"></script>
  24.     <script src="{{ asset('assets/front/vendor/jquery-mousewheel/jquery.mousewheel.min.js') }}"></script>
  25.     <script src="{{ asset('assets/front/vendor/select2/dist/js/select2.full.min.js') }}"></script>
  26.     <script src="{{ asset('assets/front/vendor/select2/dist/js/i18n/fr.js') }}"></script>
  27.     <script src="{{ asset('assets/front/vendor/datetimepicker/build/jquery.datetimepicker.full.min.js') }}"></script>
  28.     <script src="{{ asset('assets/front/init/init-owl-carousel.js') }}"></script>
  29.     <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
  30.     {# <script src="{{ asset('assets/front/init/contact.js') }}"></script> #}
  31.     <script src="{{ asset('assets/front/vendor/jquery-ui/jquery-ui.js') }}"></script>
  32.     <!--<script src="{{ asset('assets/front/vendor/aos/aos.js') }}"></script>
  33.     <script>
  34.         AOS.init();
  35.     </script>-->
  36.     <script src="{{ asset('assets/front/vendor/cropperjs/dist/cropper.js') }}"></script>
  37.     <script src="{{ asset('assets/front/vendor/jquery-cropper/dist/jquery-cropper.js') }}"></script>
  38.     <script src="{{ asset('assets/front/vendor/video-js/video.min.js') }}"></script>
  39.     <script src="{{ asset('assets/front/vendor/wizard.js') }}"></script>
  40. {#    <script src="https://cdn.jsdelivr.net/gh/AdrianVillamayor/Wizard-JS@1.8/src/wizard.min.js" integrity="sha256-vVk0T+7qGD5K2sLJywOcqKmnJerAFRaOI1FWJNH3YYg=" crossorigin="anonymous"></script>#}
  41.     <script src="{{ asset('assets/front/init/flatpickr.js') }}"></script>
  42.     <script src="{{ asset('assets/front/vendor/jquery.mousedirection.js') }}"></script>
  43.     {# <script src="{{ asset('assets/front/init/countDown.js') }}"></script> #}
  44.     <script src="{{ asset('assets/front/vendor/fullcalendar/dist/index.global.js') }}"></script>
  45.     <script src="{{ asset('assets/front/vendor/color-thief/dist/color-thief.umd.js') }}"></script>
  46.     <script src="{{ asset('assets/front/vendor/evento/evo-calendar/js/evo-calendar.js') }}"></script>
  47. {#    <script src="https://cdn.jsdelivr.net/npm/evo-calendar@1.1.2/evo-calendar/js/evo-calendar.min.js"></script>#}
  48.     <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  49.     <script src="{{ asset('assets/front/vendor/eventjs/dist/jquery.bs.calendar.js') }}"></script>
  50.     <script src="{{ asset('assets/front/js/pdf.js') }}"></script>
  51.     <script src="{{ asset('assets/front/vendor/jquery-toaster/jquery.toaster.js') }}"></script>
  52.     <script src="{{ asset('assets/front/vendor/tel-input/build/js/intlTelInput-jquery.js') }}"></script>
  53.     <script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>
  54.     <script type="module" >
  55.         import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.23.0/firebase-app.js'
  56.         import { getMessaging, getToken, onMessage, deleteToken } from 'https://www.gstatic.com/firebasejs/9.23.0/firebase-messaging.js'
  57.         const originalFetch = window.fetch;
  58.         window.responseInterceptor = async (response) => {
  59.             if (response.url.includes("/config/firebase")) {
  60.                 console.log("interceptor")
  61.                 if (response.ok) {
  62.                     {% if app.request.cookies.get('firebase_config_iv') and app.request.cookies.get('firebase_config_data') %}
  63.                         {% set decryptedData = decrypt(app.request.cookies.get('firebase_config_iv'), app.request.cookies.get('firebase_config_data')) %}
  64.                         const decryptedData = '{{ decryptedData }}'
  65.                         const jsonString = decryptedData.replace(/&quot;/g, '"')
  66.                         response.json = async () => JSON.parse(jsonString);
  67.                     {% endif %}
  68.                 }
  69.                 console.log("end of interceptor")
  70.             }
  71.             return response;
  72.         }
  73.         window.fetch = async (...args) => {
  74.             let response = await originalFetch(...args);
  75.             response = await responseInterceptor(response); // Await here ensures the interception completes
  76.             return response;
  77.         };
  78.         async function fetchFirebaseConfigRequest() {
  79.             const response = await window.fetch('/config/firebase');
  80.             if (!response.ok) {
  81.                 throw new Error('Failed to fetch configuration');
  82.             }
  83.             return await response.json();
  84.         }
  85.         const firebaseResponse = await fetchFirebaseConfigRequest();
  86.         const firebaseConfig = {
  87.             apiKey: firebaseResponse.apiKey,
  88.             authDomain: firebaseResponse.authDomain,
  89.             projectId: firebaseResponse.projectId,
  90.             storageBucket: firebaseResponse.storageBucket,
  91.             messagingSenderId: firebaseResponse.messagingSenderId,
  92.             appId: firebaseResponse.appId,
  93.             measurementId: firebaseResponse.measurementId
  94.         };
  95.         // Initialize Firebase
  96.         const app = initializeApp(firebaseConfig);
  97.         const vapidKey = firebaseResponse.vapidKey;
  98.         let messaging = getMessaging(app);
  99.         function deleteFirebaseToken() {
  100.             deleteToken(messaging, { vapidKey: vapidKey }).then(() => {
  101.                 console.log('Token deleted.');
  102.             }).catch((err) => {
  103.                 console.log('Unable to delete token. ', err);
  104.             });
  105.         }
  106.         onMessage(messaging, (payload) => {
  107.             console.log('Message received. ', payload);
  108.         });
  109.         Notification.requestPermission().then((permission) => {
  110.             if (permission === 'granted') {
  111.                 console.log('Notification permission granted.');
  112.             } else {
  113.                 console.log('Unable to get permission to notify.');
  114.             }
  115.         });
  116.         async function getOrRegisterServiceWorker(){
  117.             if ('serviceWorker' in navigator) {
  118.                 const serviceWorker = await window.navigator.serviceWorker
  119.                     .getRegistration('/firebase-cofina-notification-scope');
  120.                 if (serviceWorker) return serviceWorker;
  121.                 return window.navigator.serviceWorker.register('/firebase-messaging-sw.js', {
  122.                     scope: '/firebase-cofina-notification-scope',
  123.                 });
  124.             }
  125.             throw new Error('The browser doesn`t support service worker.');
  126.         }
  127.         function registerFirebaseToken(token){
  128.             const firebaseToken = localStorage.getItem("firebaseToken")
  129.             const firebaseTokenIsUsed = localStorage.getItem("firebaseTokenIsUsed")
  130.             if(firebaseTokenIsUsed !== undefined && firebaseTokenIsUsed && firebaseToken !== undefined &&firebaseToken == token){
  131.                 console.log("Cofina Notifications")
  132.             }else{
  133.                 localStorage.setItem("firebaseToken", token)
  134.                 localStorage.setItem("firebaseTokenIsUsed", false)
  135.             }
  136.         }
  137.         getOrRegisterServiceWorker().then(serviceWorkerRegistration => {
  138.             getToken(messaging, { vapidKey: vapidKey, serviceWorkerRegistration }).then((currentToken) => {
  139.                 if (currentToken) {
  140.                     registerFirebaseToken(currentToken)
  141.                 } else {
  142.                     console.log('No registration token available. Request permission to generate one.');
  143.                 }
  144.             }).catch((err) => {
  145.                 console.log('An error occurred while retrieving token. ', err);
  146.             });
  147.         })
  148.     </script>
  149.     <script src="{{ asset('assets/front/init/main.js') }}"></script>
  150.     {# <script src="{{ asset('assets/front/init/profileButton.js') }}"></script> #}
  151. {% endblock %}