Rough Opal (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, token: security_token} }) .then(function (content) { if (content.result==1) { $("#comment_"+content.comment_id).remove(); } else { alert(content.error); } }, 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 (vote_class=="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, token: security_token} }) .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(); 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(); $(".comment_text.markItUpEditor").text(""); } function saveReply(data, status, reply_id) { $("#comment_form_holder").toggle(); add_comment(data, status, reply_id); if ("#reply_holder") $("#reply_holder").remove(); $(".comment_text.markItUpEditor").text(""); } function get_comment_text(comment_id) { var comment_text=""; $.ajax( { url: "/ui.php?l=us", dataType: "json", type: "POST", async: true, data: {form_action : "get", comment_id: comment_id, token: security_token} }) .then(function (content) { if (content.result==1) { //comment_text=content.comment_text; $("#edit_text, .comment_text").text(content.comment_text); } else { $("#cancel_edit").click(); alert(content.error); } }, function(xhr, status, error) { alert("STATUS: "+status+" ERROR: "+error); }); return comment_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); } 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); } $(".comment_text.markItUpEditor").text(""); 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; }

Rough Opal (2024)

References

Top Articles
Latest Posts
Article information

Author: Prof. An Powlowski

Last Updated:

Views: 5331

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Prof. An Powlowski

Birthday: 1992-09-29

Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

Phone: +26417467956738

Job: District Marketing Strategist

Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.