<script>
    {% comment %}
     This script removes extra fields from API forms on GET method. 
      - https://stackoverflow.com/questions/5904437/
      - https://stackoverflow.com/questions/46834539/
{% endcomment %}
    $(function() {
        var form = $('form')[0];
        $(form).submit(function() {
            $('input, select').each(function() {
                if ($(this).val().length === 0) {
                    $(this).prop('disabled', true);
                    $(this).next().prop('disabled', true);
                }
            });
        });
    });
</script>
{# Extra javascript that enables copy-to-clipboard for a given element #}
<script>
    function copyTextById(id2copy) {
        var copyText = document.getElementById(id2copy);
        navigator.clipboard.writeText(copyText.innerHTML);
    }
</script>
<script>refresh_select2()</script>
<script>
    {# to enable bootstrap tooltips #}
    const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
    const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
    {# to enable bootstrap popovers #}
    const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]');
    const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl));
</script>
