2019-07-31 04:24:50 +02:00
|
|
|
---
|
|
|
|
layout: null
|
|
|
|
---
|
|
|
|
|
|
|
|
(function ($) {
|
|
|
|
var $comments = $('.js-comments');
|
|
|
|
|
|
|
|
$('#new_comment').submit(function () {
|
|
|
|
var form = this;
|
|
|
|
|
|
|
|
$(form).addClass('disabled');
|
|
|
|
|
|
|
|
{% assign sm = site.staticman -%}
|
2021-02-04 17:28:36 +01:00
|
|
|
var endpoint = '{{ sm.endpoint }}';
|
2019-07-31 04:24:50 +02:00
|
|
|
var repository = '{{ sm.repository }}';
|
|
|
|
var branch = '{{ sm.branch }}';
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: $(this).attr('method'),
|
|
|
|
url: endpoint + repository + '/' + branch + '/comments',
|
|
|
|
data: $(this).serialize(),
|
|
|
|
contentType: 'application/x-www-form-urlencoded',
|
|
|
|
success: function (data) {
|
2020-07-13 07:09:27 +02:00
|
|
|
$('#comment-form-submit').addClass('d-none');
|
|
|
|
$('#comment-form-submitted').removeClass('d-none');
|
|
|
|
$('.page__comments-form .js-notice').removeClass('alert-danger');
|
|
|
|
$('.page__comments-form .js-notice').addClass('alert-success');
|
2019-07-31 04:24:50 +02:00
|
|
|
showAlert('success');
|
|
|
|
},
|
|
|
|
error: function (err) {
|
|
|
|
console.log(err);
|
2020-07-13 07:09:27 +02:00
|
|
|
$('#comment-form-submitted').addClass('d-none');
|
|
|
|
$('#comment-form-submit').removeClass('d-none');
|
|
|
|
$('.page__comments-form .js-notice').removeClass('alert-success');
|
|
|
|
$('.page__comments-form .js-notice').addClass('alert-danger');
|
2019-07-31 04:24:50 +02:00
|
|
|
showAlert('failure');
|
|
|
|
$(form).removeClass('disabled');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
function showAlert(message) {
|
2020-07-13 07:09:27 +02:00
|
|
|
$('.page__comments-form .js-notice').removeClass('d-none');
|
2019-07-31 04:24:50 +02:00
|
|
|
if (message == 'success') {
|
2020-07-13 07:09:27 +02:00
|
|
|
$('.page__comments-form .js-notice-text-success').removeClass('d-none');
|
|
|
|
$('.page__comments-form .js-notice-text-failure').addClass('d-none');
|
2019-07-31 04:24:50 +02:00
|
|
|
} else {
|
2020-07-13 07:09:27 +02:00
|
|
|
$('.page__comments-form .js-notice-text-success').addClass('d-none');
|
|
|
|
$('.page__comments-form .js-notice-text-failure').removeClass('d-none');
|
2019-07-31 04:24:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})(jQuery);
|