Mình có đoạn js sau:
Đoạn code này cho phép trả lời nhanh nhưng phải f5 mới hiện comment. Còn nhập text vào rồi click "Send" thì nó load mãi không chịu hiện comment. Mình chờ mãi mới thấy box Hỏi đáp hoạt động để gửi thắc mắc. Mong sẽ sớm nhận được sự giúp đỡ :)
P/s: Tks vì đã ghé thăm topic :)
- Code:
$(function () {
$('#quick_reply input[name="post"]').click(function(a){
a.preventDefault();
var g = $("#text_editor_textarea").sceditor('instance').val();
var href = $('a[href*="mode=reply"]').attr("href");
var value = $("#text_editor_textarea").sceditor("instance").val().replace(/\s/g, '').length;
if(10 < value) {
$('<div class="lreply"><br /><img src="http://i35.servimg.com/u/f35/15/64/85/86/ajax-l10.gif"><br><b>Đang cập nhật bình luận của bạn...</b></div>').appendTo(".frm-buttons");
$.post(href, {
"message": g,
"auth[]": $("#quick_reply input[name='auth[]']:last").val(),
"lt": $("#quick_reply input[name='lt']").val(),
"attach_sig": "1",
"post": "Send"
}, function (t) {
if (t.indexOf("Flood") != -1 && $("html").attr("xml:lang") == "vi") {
alert("THÔNG BÁO!!!\nNghi vấn spam, tài khoản của bạn đang được xem xét và có thể bị khóa nếu vẫn comment liên tục trong thời gian ngắn như vậy. Vui lòng comment chậm lại\n(Chờ 60 giây sau để tiếp tục comment.)");
$(".lreply").remove();
} else if (t.indexOf("Flood") != -1 && $("html").attr("xml:lang") != "vi") {
alert("Error!\nYou must wait 60 second before replying");
$(".lreply").remove();
}
if (t.indexOf("A new") != -1 && $("html").attr("xml:lang") == "vi") {
alert("Lỗi!\nĐã có người gửi bài trước bạn.\nBạn phải F5 lại trang để tiếp tục.\nChú ý : Bạn nên copy lại tin nhắn trước khi F5 ");
$(".lreply").remove();
} else if (t.indexOf("A new") != -1 && $("html").attr("xml:lang") != "vi") {
alert("Error!\nSomeone had replied before your post\nYou must refresh the page to continue.\nNotice : You should save or copy your message if you don't want it gone");
$(".lreply").remove();
} else {
var f = $(t).find(".message a:first").attr('href');
f = f.match(/\/(t\d+(p\d+)?)-.+/)[1];
location.href = location.href.replace(/(.+\/)(t\d+(p\d+)?)(-.+)/, "$1" + f + "$4");
$.get(location.href, function (z) {
$("#quick_reply input[name='auth[]']:last").val($(z).find("#quick_reply input[name='auth[]']:last").val());
$("#quick_reply input[name='lt']").val($(z).find("#quick_reply input[name='lt']").val());
$(z).find(".post:last").hide().insertAfter(".post:last").slideDown(400);
});
$("#text_editor_textarea").sceditor('instance').val("");
$(".lreply").remove();
}
});
} else {
if ($("html").attr("xml:lang") == "vi") {
alert("Xin lỗi\nNội dung quá ngắn không thể gửi bài !\nBạn cần nhập thêm " + (10 - value) + " ký tự nữa.");
} else {
alert("Sorry\nThe content is too short to send as post !\nYou must write " + (10 - value) + " characters more.");
}
}
});
});
Đoạn code này cho phép trả lời nhanh nhưng phải f5 mới hiện comment. Còn nhập text vào rồi click "Send" thì nó load mãi không chịu hiện comment. Mình chờ mãi mới thấy box Hỏi đáp hoạt động để gửi thắc mắc. Mong sẽ sớm nhận được sự giúp đỡ :)
P/s: Tks vì đã ghé thăm topic :)