
{% load ledger %}
{% load i18n %}
{% load static %}

<script type="application/javascript">
    $('#modalViewCharacterContainer').on('show.bs.modal', function (event) {
        const button = $(event.relatedTarget)
        const ajax_url = button.data('ajax_url');
        const modal = $(this);

        // reactive loader
        modal.find("#modalViewCharacterContent").hide();
        modal.find("#modalViewCharacterLoader").show();

        $("#modalViewCharacterContent").load(
            ajax_url,
            function(response, status, xhr) {
                modal.find("#modalViewCharacterLoader").hide();
                modal.find("#modalViewCharacterContent").show();

                if (xhr.status === 403) {
                    $("#modalViewCharacterContent").html(response);
                }
                // Extract and set the modal title
                const title = $("#modalViewCharacterContent").find("#modal-title").html();
                modal.find(".modal-title").html(title);
                $("#modalViewCharacterContent").find("#modal-title").hide();
            }
        );
    });
</script>

<script>
    // Embed translations in a global JavaScript object
    window.translations = {
        months: [
            "{% trans 'January' %}", "{% trans 'February' %}", "{% trans 'March' %}", "{% trans 'April' %}",
            "{% trans 'May' %}", "{% trans 'June' %}", "{% trans 'July' %}", "{% trans 'August' %}",
            "{% trans 'September' %}", "{% trans 'October' %}", "{% trans 'November' %}", "{% trans 'December' %}"
        ],
        dayText: "{% trans 'Day' %}",
        monthText: "{% trans 'Month' %}"
    };
</script>

<!-- Chart Resources -->
{% ledger_static 'assets/index.js' %}
{% ledger_static 'assets/xy.js' %}
{% ledger_static 'assets/percent.js' %}
{% ledger_static 'assets/flow.js' %}
{% ledger_static 'assets/Animated.js' %}
{% ledger_static 'assets/Dark.js' %}

<!-- Ledger Resources -->
{% ledger_static 'js/charts.js' %}
{% ledger_static 'js/ledger.js' %}
