{% load sri %}
{% load i18n %}

{% include 'ledger/bundles/table-css.html' %}
{% sri_static 'ledger/css/planetary.css' %}

{% include 'ledger/partials/modal/modal.html' with name="ViewFactory" %}
{% include 'ledger/partials/modal/modal.html' with name="ViewExtractor" %}

{% include 'ledger/partials/modal/switchalarm_confirm.html' %}
{% sri_static 'ledger/js/modal/modal-system.js' %}

<script type="application/javascript">
    setupModal('#modalViewFactoryContainer', 'ajax_factory', '#modalViewFactoryContent', '#modalViewFactoryLoader');
    setupModal('#modalViewExtractorContainer', 'ajax_extractor', '#modalViewExtractorContent', '#modalViewExtractorLoader');
</script>

{% include 'bundles/datatables-js-bs5.html' %}

<script type="application/javascript">
    // Extract the 'main' parameter from the current URL
    const urlParams = new URLSearchParams(window.location.search);
    const singleViewParms = urlParams.get('single');

	let planetarySettings = {
        planetaryUrl: '{% url "ledger:api:get_planetarydetails" character_id=character_id planet_id=0 %}',
        viewFactoryUrl: '{% url "ledger:api:get_factory_info" character_id=1337 planet_id=1337 %}',
        viewExtractorUrl: '{% url "ledger:api:get_extractor_info" character_id=1337 planet_id=1337 %}',
        viewSwitchAlarmUrl: '{% url "ledger:switch_alarm" %}',
		csrfToken: '{% csrf_token %}',
		switchAlarmText: '{% translate "Are you sure to Switch Notification" %}',
        switchAlarm: '{% translate "Switch Notification" %}',
        alarmActivated: '{% translate "Notification Activated" %}',
        alarmDeactivated: '{% translate "Notification Deactivated" %}',
        characterPk: '{{ character_id }}',
        updateInterval: '{{ update_interval }}',
	};

    if (singleViewParms !== "true") {
        document.getElementById('turn-all-notification').classList.remove('d-none');
    }

    // Construct the planetaryUrl with the 'main' parameter
    if (singleViewParms) {
        planetarySettings.planetaryUrl += '?single=' + singleViewParms;
    }
</script>

{% sri_static 'ledger/js/planetary-confirm.js' %}
{% sri_static 'ledger/js/planetary.js' %}
