Thar (2024)


Login to comment

"; $(selector).append(comment_html); $("#comment_text").val(""); add_delete_action(); add_edit_action(); add_reply_action(); add_vote_action(); $("#comment_body_"+data.comment_id).html(data.comment_text); } function add_delete_action() { $(".delete_comment").each(function() { $(this).off("click").on("click", function() { if ($("#edit_form").length) $("#cancel_edit").trigger("click"); $("#modal_delete_ok").data("comment_id",$(this).data("id")); $("#modal_delete_ok").off("click").on("click", function() { var comment_id=$(this).data("comment_id"); $.ajax( { url: "/ui.php?l=us", dataType: "json", type: "POST", data: { form_action: "delete",comment_id: comment_id} }) .then(function (content) { if (content.result==1) { $("#comment_"+content.comment_id).remove(); } else { alert(content.result + content.data); } }, function(xhr, status, error) { alert("STATUS: "+status+" ERROR: "+error); }); }); }); }); } function add_vote_action() { $(".comment_vote_up,.comment_vote_down").each(function() { $(this).off("click").on("click", function() { var comment_id=$(this).data("id"); var vote_class=$(this).attr("class"); var vote=0; if ($(this).hasClass("comment_vote_up")) vote = 1; $.ajax( { url: "/ui.php?l=us", dataType: "json", type: "POST", data: { form_action: "vote",comment_id: comment_id, vote_value: vote} }) .then(function (content) { if (content.result==1) { var vote_value=-1; if (vote==1) vote_value=1; $("#comment_vote_counter_"+content.comment_id).html(($("#comment_vote_counter_"+content.comment_id).html()*1)+vote_value); } else { //alert(content.result + content.data); } }, function(xhr, status, error) { alert("STATUS: "+status+" ERROR: "+error); }); }); }); } function add_edit_action() { $(".edit_comment").each(function() { $(this).off("click").on("click", function() { var comment_id=$(this).data("id"); var comment_text=$("#comment_body_"+comment_id).html(); //console.log(comment_text); if ($("#edit_form").length) $("#cancel_edit").trigger("click"); comment_body=$("#comment_body_"+comment_id).html(); add_edit_form("#comment_body_"+comment_id,comment_text,comment_id); }); }); } function add_reply_action() { $(".reply_to_comment").each(function() { $(this).off("click").on("click", function() { if ($("#edit_form").length) $("#cancel_edit").trigger("click"); var comment_id=$(this).data("id"); $("#comment_actions_"+comment_id).after("

"); add_edit_form("#reply_holder","","",comment_id); }); }); } function saveComment(data, status, selector) { $(selector).html(data.comment_text); $("#comment_form_holder").toggle(); } function saveReply(data, status, reply_id) { $("#comment_form_holder").toggle(); add_comment(data, status, reply_id); if ("#reply_holder") $("#reply_holder").remove(); } function get_comment_text(comment_id, comment_selector) { let return_text=""; $.ajax( { url: "/ui.php?l=us", dataType: "json", type: "POST", async: true, data: {form_action : "get", comment_id: comment_id} }) .then(function (content) { if (content.result==1) { return_text=content.comment_text; $("#comment_text").text(content.comment_text); } else { alert(content.result + content.data); } }, function(xhr, status, error) { alert("STATUS: "+status+" ERROR: "+error); }); return return_text; } function add_edit_form(selector, form_text, comment_id, reply_id) { $("#comment_form_holder").toggle(); var action="edit"; var reply=""; var comment=""; if (reply_id) { action="reply"; comment=""; $("#comment_actions_"+reply_id).toggle(); } else { $("#comment_actions_"+comment_id).toggle(); } if (comment_id>0) { form_text=get_comment_text(comment_id); ///console.log("new"+form_text); } var form_text="

"; $(selector).html(form_text); $("#comment_text").markItUp(mySettings); $("#edit_form").ajaxForm ({ dataType: "json", beforeSubmit: validate, success: function(data, status) { if (reply_id) { $("#edit_form").remove(); $("#comment_actions_"+reply_id).toggle(); saveReply(data, status, reply_id); } else { $("#comment_actions_"+comment_id).toggle(); saveComment(data, status, selector); } $(".comment_save_button").prop("disabled", false); }, error: errormsg }); $("#cancel_edit").on("click", function() { $("#comment_form_holder").toggle(); if (reply_id) { $("#comment_actions_"+reply_id).toggle(); $("#reply_holder").remove(); } else { $("#comment_actions_"+comment_id).toggle(); $(selector).html(comment_body); } add_delete_action(); add_edit_action(); add_reply_action(); }); } function errormsg(data) { //alert("ERROR:" +data.error); console.log(data.error); } function validate(formData, jqForm, options) { var text = $("#comment_text").fieldValue(); $(".comment_save_button").prop("disabled", true); if (text[0]=="") { return false; } else return true; }

Thar (2024)
Top Articles
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 5540

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.