        <div id="mymodal" class="modal" tabindex="-1">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">INFORMATION</h4>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <iframe id="framemodal" frameborder=0 width="100%" height="600px"></iframe>
                    </div>
                </div>
            </div>
        </div>

        <div id="modalinfo" class="modal" tabindex="-1">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">INFORMATION</h4>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div id="modalinfotext"></div>
                    </div>
                </div>
            </div>
        </div>



        

        <script>
            {% if websocket_activate %}
                function subscribe(channeltype,channelkey,userkey) {
                    console.log("== SUBSCRIBE "+channeltype+"-"+channelkey+" with userkey "+userkey);
                    conn.send(JSON.stringify({
                        command: "subscribe",
                        log: "subscribe",
                        channel: channeltype+"-"+channelkey,
                        channeltype: channeltype,
                        channelkey: channelkey,
                        userkey: userkey
                    }));
                }

                function sendMessage(msg) {
                    json=JSON.stringify(msg);
                    console.log("== SEND MSG = "+json);
                    conn.send(json);
                }
            {% endif %}   

            function iformat(icon) {
                return $('<span><i class="' + icon.id + '"></i> ' + icon.text + '</span>');
            }
            $('.select2-icon').select2({
                width: "100%",
                placeholder: 'choisir un icône',
                allowClear: true,                
                templateSelection: iformat,
                templateResult: iformat,
                formatResult: iformat,
                allowHtml: true,
                escapeMarkup: function(m) {
                    return m;
                }
            })


            function seeUser(id) {
                {% if app.user %}
                    $("#mymodal").find(".modal-title").html("FICHE UTILISATEUR");
                    var url="{{ path('app_core_user_view',{id:'xx'}) }}";
                    url=url.replace('xx',id);

                    $("#mymodal").find("#framemodal").attr("src",url);
                    $("#mymodal").modal("show");
                {% endif %}
            }   

            function inIframe () {
                try {
                    return window.self !== window.top;
                } catch (e) {
                    return true;
                }
            } 
            function switchHeader(flag) {
                {% if app.user %}
                $.ajax({
                    method: "POST",
                    url: "{{ path('app_core_user_preference') }}",
                    data: {
                        id:0,
                        key:'fguserheader',
                        value: flag
                    },
                    success: function() {
                        location.reload();
                    }            
                });
                {% endif %}                
            }

            // Cacher afficher le menu des widgets 
            $( ".widget").hover(function() {
                if($(this).children(".widgetmenu").length) {
                    var widthwidget=$(this).width();
                    var widthtitle=$(this).children(".widgetheader").children(".title").width()+$(this).children(".widgetheader").children("img").width();
                    var widthmenu=$(this).children(".widgetmenu").width();

                    if(widthtitle+widthmenu+10>widthwidget) $(this).children(".widgetheader").children(".title").hide();

                    $(this).children(".widgetmenu").show();
                }
            });

            $( ".widget" ).mouseleave(function() {
                $(this).children(".widgetmenu").hide();
                $(this).children(".widgetheader").children(".title").show();
            });

            $( ".grid-item-content").hover(function() {
                $(this).children(".item-heart").show();
                $(this).children(".item-delete").show();
                $(this).children(".item-restaure").show();
                $(this).children(".item-update").show();
                $(this).children(".item-preview").show();
            });

            $( ".grid-item-content" ).mouseleave(function() {
                $(this).children(".item-heart").hide();
                $(this).children(".item-delete").hide();
                $(this).children(".item-restaure").hide();
                $(this).children(".item-update").hide();
                $(this).children(".item-preview").hide();
            });

            $(".navbar-toggle").mouseup(function() {
                setTimeout(function() {
                    resize();
                }, 50);                
                
            });

            
            function resize() {
                var heightbody = $('html').height();
                var heightheader = ($('.header').height()&&$('.header').is(":visible")?$('.header').height():0);
                var heightlittleheader = ($('.littleheader').height()&&$('.littleheader').is(":visible")?$('.littleheader').height():0);
                var heightmenu = ($('#menu').height()&&$('#menu').is(":visible")?$('#menu').height():0);
                
                var heightframe = heightbody-heightheader-heightlittleheader-heightmenu-1;

                $("#page-wrapper").css("min-height",heightframe);

                $(".pageframe").each(function(){
                    $(this).height(heightframe);
                });
            }        


            $(window).resize(function() {
                resize();
            });

            $(document).ready(function() {
                $(".js-datepicker").datepicker({
                    format: "dd/mm/yyyy",
                    language: "fr"
                });

                $('.select2simple').select2();

                $('.select2ajax').select2({
                    ajax: {
                        processResults: function (data) {
                            return {
                                results: data
                            };
                        }                    
                    }
                });

                $('.select2').each(function() {
                    if($(this).attr('data-init')) {
                        $(this).val(2);
                    }
                });

                // Dans une iframe on enlève des élèment
                if(inIframe()) {
                    $("nav").remove();
                    $("body").removeClass("body");
                    $("body").addClass("simple");
                    $("#page-wrapper").css("margin","0px");
                    $("#page-wrapper").css("border-left","none");
                }

                // Resize des dom
                resize();
            });    

            function EnvoleClickSondes(dom,title, service) {
                const url = "/sondepiwik/sonde.php";
                const app = "{{alias}}";
                const lienUrl = dom[0].href; 
                const urlsonde = `${url}?appli=${encodeURIComponent(title)}&route=${encodeURIComponent(lienUrl)}&rubrique=${encodeURIComponent(service)}`;

                fetch(urlsonde)
                    .then(response => {
                        if (!response.ok) {
                            throw new Error(`Erreur HTTP! Statut: ${response.status} pour ${urlsonde}`);
                        }
                        console.log(`Sonde envoyée avec succès à : ${urlsonde}`);
                    })
                    .catch(error => {
                        console.error("Échec de l'appel de l'urlsonde:", error);
                    });
            }   
        </script>
