Siria: i bombardamenti ripresi dall’aviazione russa
“);
voting.append( “”);
commentItems.append(voting);
commentItem.append(commentItems);
list.append(commentItem);
}
});
setup_comment_vote();
})
.fail(function (jqxhr, textStatus, error) {
var err = textStatus + “, ” + error;
if (console.log) {
console.log( “Request Failed: ” + err );
}
});
}
$ (function () {
var isSignedIn = false;
var isCaptchaEnabled = false;
var isBanned = false;
countComments().done(function() {
if (pagesCount > 1) {
for (var i = 2; i ” + i + “”);
$ (“.v3_news-comments-pager-numbers”, container).append(pageLink);
}
$ (‘.v3_news-comments-pager-numbers’, container).on(“click”,”a”, function(event){
event.preventDefault();
var prevPage = parseInt($ (this).attr(‘href’).substring(1));
loadComments(prevPage * pageSize, pageSize, true);
});
$ (‘.v3_news-comments-nav-pager-prev’, container).click(function(event) {
event.preventDefault();
loadComments((page – 2) * pageSize, pageSize, true);
});
$ (‘.v3_news-comments-nav-pager-next’, container).click(function(event) {
event.preventDefault();
loadComments(page * pageSize, pageSize, true);
});
}
else {
$ (‘.v3_news-comments-nav-pager’, container).hide();
}
});
loadComments(0,pageSize,true);
$ .when(Atex.api.userService.isLogged()).then(function(data) {
isSignedIn = data.logged;
if (isSignedIn) {
if (isCaptchaEnabled) {
$ (“.g-recaptcha”, container).hide();
}
isBanned = data.userData.bannedFromComments === true;
} else if (isCaptchaEnabled) {
$ (“.g-recaptcha”, container).show();
}
if (isBanned) {
$ (“#text_comment”, container).attr(“placeholder”, “Non ti è consentito inserire commenti…”);
}
else if (isCaptchaEnabled || isSignedIn) {
$ (“#text_comment”, container).attr(“placeholder”, “Scrivi qui il tuo commento e premi Invia”);
$ (“#comment_form > fieldset”, container).prop(“disabled”, false);
autosize($ (‘#text_comment’));
} else if (!isSignedIn) {
$ (“#text_comment”, container).attr(“placeholder”, “Scrivi qui il tuo commento e premi Invia”);
$ (“#comment_form > fieldset”, container).prop(“disabled”, false);
autosize($ (‘#text_comment’));
}
});
$ (“#comment_form”).submit(function(event) {
event.preventDefault();
var form = $ (this);
$ .when(Atex.api.userService.isLogged()).then(function(data) {
var isLogged = data.logged;
if (!isLogged && !isCaptchaEnabled) {
$ (‘#right-align .v4_header-login’).click();
} else {
$ (“#comment_error”).hide();
var url = form.attr(“action”);
var recaptcha_response;
if (isCaptchaEnabled) {
recaptcha_response = grecaptcha.getResponse();
}
var comment = $ (“#text_comment”).val();
if (!comment) {
$ (“#comment_error”).text(“Per favore inserire il commento…”).show();
return;
}
if (isCaptchaEnabled && !isSignedIn && !recaptcha_response) {
$ (“#comment_error”).text(“Per favore inserisci il captcha…”).show();
return;
}
if (isBanned) {
$ (“#comment_error”).text(“Non ti è consentito inserire commenti…”).show();
return;
}
$ .ajax({
url: url,
type: “POST”,
dataType: “json”,
contentType: “text/plain; charset=utf-8”,
headers: {“X-Recaptcha-Response” : recaptcha_response},
data: comment
})
.done(function (data) {
var ta = document.querySelector(‘#text_comment’);
var evt = document.createEvent(‘Event’);
evt.initEvent(‘autosize.update’, true, false);
if(data.status == ‘PENDING’) {
$ (“.pending”).show();
$ (“#text_comment”).val(”);
ta.dispatchEvent(evt);
} else {
$ (“.pending”).hide();
countComments().done(function() {
var currentPages = $ (‘.v3_news-comments-pager-numbers > a’).size();
if (currentPages ” + (currentPages + 1) + “”);
$ (“.v3_news-comments-pager-numbers”).append(pageLink);
}
loadComments(0, pageSize, true).done(function () {
ta.dispatchEvent(evt);
});
});
}
})
.fail(function (jqxhr, textStatus, error) {
var err = textStatus + “, ” + error;
if (console.log) {
console.log(“Request Failed: ” + err);
}
$ (“#comment_error”).text(“Si è verificato un errore. Si prega di riprovare più tardi…”).show();
})
.always(function() {
if (isCaptchaEnabled) {
grecaptcha.reset();
}
});
} // if
}); // isLogged()
});
});
})(jQuery);
Discussion about this post