mirror of
https://github.com/go-gitea/gitea
synced 2024-11-09 11:31:34 +01:00
2add8fe9be
* Frontend refactor, PascalCase to camelCase, remove unused code * fix
40 lines
993 B
JavaScript
40 lines
993 B
JavaScript
const {csrfToken} = window.config;
|
|
|
|
export function initWebHookEditor() {
|
|
if ($('.new.webhook').length === 0) {
|
|
return;
|
|
}
|
|
|
|
$('.events.checkbox input').on('change', function () {
|
|
if ($(this).is(':checked')) {
|
|
$('.events.fields').show();
|
|
}
|
|
});
|
|
$('.non-events.checkbox input').on('change', function () {
|
|
if ($(this).is(':checked')) {
|
|
$('.events.fields').hide();
|
|
}
|
|
});
|
|
|
|
const updateContentType = function () {
|
|
const visible = $('#http_method').val() === 'POST';
|
|
$('#content_type').parent().parent()[visible ? 'show' : 'hide']();
|
|
};
|
|
updateContentType();
|
|
$('#http_method').on('change', () => {
|
|
updateContentType();
|
|
});
|
|
|
|
// Test delivery
|
|
$('#test-delivery').on('click', function () {
|
|
const $this = $(this);
|
|
$this.addClass('loading disabled');
|
|
$.post($this.data('link'), {
|
|
_csrf: csrfToken
|
|
}).done(
|
|
setTimeout(() => {
|
|
window.location.href = $this.data('redirect');
|
|
}, 5000)
|
|
);
|
|
});
|
|
}
|