{% extends "admin/settings.html" %}
{% load djblets_js djblets_utils i18n %}

{% block scripts-post %}
{{block.super}}
<script type="text/javascript">
    var CACHE_LOCATION_FIELD_MAP = {{form.CACHE_LOCATION_FIELD_MAP|json_dumps:2}};

    function updateAuthFormDisplay() {
        var selection = $("#id_cache_type").get(0),
            cache_type = selection.options[selection.selectedIndex].value,
            location_field = CACHE_LOCATION_FIELD_MAP[cache_type];

        _.each(CACHE_LOCATION_FIELD_MAP, function(field) {
            $('#row-' + field).hide();
        });

        if (location_field) {
            $('#row-' + location_field).show();
        }
    }

    $(document).ready(function() {
        $("#id_cache_type")
            .change(updateAuthFormDisplay)
            .triggerHandler("change");
    });
</script>
{% endblock %}
