1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-15 16:04:01 +00:00
seahub/templates/snippets/events_js.html

58 lines
2.2 KiB
HTML

{% include 'snippets/list_commit_detail.html' %}
$('.event-item').each(function(index) {
if (index > 0 && $(this).children('.pic').attr('data') == $(this).prev().children('.pic').attr('data')) {
$(this).children('.pic').addClass('hide');
}
});
$('#events').removeClass('hide');
// 查看加密 repo 的详情时, 先为其设置密码
var cur_event;
$('a.lsch-encrypted').click(function() {
if ($(this).attr('password_set') == 'true') {
list_commit_change($(this));
} else {
cur_event = $(this);
$('#repo-set-password-form input[name="repo_id"]').val($(this).attr('repo_id'));
$('#repo-set-password-form .repo-name').html($(this).attr('repo_name'));
$('#repo-set-password-form').modal({appendTo:'#main'});
}
return false;
});
$('#repo-set-password-form .submit').click(function() {
var input_password = $('#repo-set-password-form input[name="password"]');
var repo_id = $('#repo-set-password-form input[name="repo_id"]').val();
var password = input_password.val();
if (!password) {
apply_form_error('repo-set-password-form', "密码不能为空");
} else {
apply_form_error('repo-set-password-form', '');
$.ajax({
url: '{% url repo_set_password %}',
type: 'POST',
dataType: 'json',
cache: 'false',
beforeSend: prepareCSRFToken,
data: {
repo_id: repo_id,
password: password,
username: '{{request.user.username}}'
},
success: function(data) {
if (data['success']) {
$.modal.close();
$('a.lsch-encrypted[repo_id="' + repo_id + '"]').attr('password_set', 'true');
list_commit_change(cur_event);
} else {
input_password.val('');
apply_form_error('repo-set-password-form', data['error']);
}
},
error: function(data, textStatus, jqXHR) {
apply_form_error('repo-set-password-form', '访问网站出错');
}
});
}
return false;
});