1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-22 16:56:57 +00:00
seahub/templates/snippets/events_js.html
llj 50db057172 improved file_edit(submit, filetype judge etc) and repo_decrypt of events
* enable submit after edit a file in an encrypted repo for more than 1 hour
* added file type judgement, edit-tip etc
2012-12-24 20:30:39 +08:00

99 lines
3.6 KiB
HTML

{% load i18n %}
function reqEvents(start) {
$('#events-loading').removeClass('hide');
$.ajax({
url:'{{SITE_ROOT}}events/?start=' + start{% if org %} + '&org_id={{ org.org_id }}'{% endif %},
dataType: 'json',
cache: false,
success: function(data) {
$('#events').append(data['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');
}
});
if (start == 0) {
$('#events').removeClass('hide');
}
$('#events-loading').addClass('hide');
if (data['more']) {
$('#events-more').data('start', start + 10).removeClass('hide');
} else {
$('#events-more').addClass('hide');
}
// 查看加密 repo 的详情时, 先为其设置密码
$('a.lsch-encrypted').click(function() {
if ($(this).data('passwordset')) {
list_commit_change($(this));
} else {
$('#repo-decrypt-form input[name="repo_id"]').val($(this).data('repoid'));
$('#repo-decrypt-form .op-target').html($(this).data('reponame'));
$('#repo-decrypt-form').data('cur_event', $(this)).modal({appendTo:'#main'});
}
return false;
});
$('.lsch').click(function() {
list_commit_change($(this));
return false;
});
},
error: function() {
var str = '{% trans "Unknown error." %}';
if ($('#events-more').hasClass('hide')) {
str += '{% trans "Please refresh the page later." %}';
} else {
str += '{% trans "Please try again later." %}';
}
$('#events-error').html(str).removeClass('hide');
}
});
}
reqEvents(0);
$('#events-more').click(function() {
$(this).addClass('hide');
reqEvents($(this).data('start'));
});
{% include 'snippets/list_commit_detail.html' %}
$('#repo-decrypt-form .submit').click(function() {
var input_password = $('#repo-decrypt-form input[name="password"]');
var repo_id = $('#repo-decrypt-form input[name="repo_id"]').val();
var password = input_password.val();
if (!password) {
apply_form_error('repo-decrypt-form', '{% trans "Password is required." %}');
} else {
apply_form_error('repo-decrypt-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[data-repoid="' + repo_id + '"]').attr('data-passwordset', true);
list_commit_change($('#repo-decrypt-form').data('cur_event'));
} else {
input_password.val('');
apply_form_error('repo-decrypt-form', data['error']);
}
},
error: function(data, textStatus, jqXHR) {
apply_form_error('repo-decrypt-form', '{% trans "Unknown error." %}');
}
});
}
return false;
});