{% load i18n %}
function listCommitDetails(url, t) {
    $.modal('<div id="ls-ch"><span class="loading-icon loading-tip"></span></div>', {autoResize:true});
    $('#simplemodal-container').css({'width':'auto', 'height':'auto'});
    $.ajax({
        url: url,
        dataType: 'json',
        cache: false,
        success: function(data) {
            var heading = '<h3 id="dialogTitle">' + "{% trans "Modification Details" %}" + '</h3>';
            var time = '<p class="commit-time">' + t + '</p>';
            var con = '';
            function show(data_, hd) {
                if (data_.length > 0) {
                    con += '<h4>' + hd + '</h4>';
                    con += '<ul>';
                    for (var i = 0, len = data_.length; i < len; i++) {
                        con += '<li>' + data_[i] + '</li>';
                    }
                    con += '</ul>';
                }
            }
            show(data['new'], "{% trans "New files" %}");
            show(data['removed'], "{% trans "Deleted files" %}");
            show(data['renamed'], "{% trans "Renamed or Moved files" %}");
            show(data['modified'], "{% trans "Modified files" %}");
            show(data['newdir'], "{% trans "New directories" %}");
            show(data['deldir'], "{% trans "Deleted directories" %}");
            if (!con) {
                if (data['cmt_desc']) {
                    con = '<p>' + HTMLescape(data['cmt_desc']) + '</p>';
                }
            }
            $('#ls-ch').html(heading + time + con);
            $(window).trigger('resize');
        },
        error: function() {
            $('#ls-ch').html("{% trans "Unknown error." %}");
            setTimeout(function() { $.modal.close(); }, 2500);
        }
    });
}
$('.lsch').on('click', function() {
    listCommitDetails($(this).data('url'), $(this).data('time'));
    return false;
});
