1(function($){window.ProductComments=function(){let uploadedImages=[];$('.scp-submit-comment-button').hide();$(document).off('input','#scp-comment-form textarea[name="comment"]');$(document).on('input','#scp-comment-form textarea[name="comment"]',function(){const hasText=$(this).val().trim().length>0;const $submitBtn=$('#scp-comment-form .scp-submit-comment-button');if(hasText){$submitBtn.fadeIn(150)}else{$submitBtn.fadeOut(150)}});$(document).off('input','.scp-reply-content');$(document).on('input','.scp-reply-content',function(){const hasText=$(this).val().trim().length>0;const $btn=$(this).closest('.scp-reply-box').find('.scp-submit-reply');if(hasText){$btn.fadeIn(150)}else{$btn.fadeOut(150)}});$(document).off("change","#scp-attachments");$(document).off("submit","#scp-comment-form");$(document).off("click",".scp-reply-btn");$(document).off("change",".scp-reply-attachments");$(document).off("click",".scp-submit-reply");$(document).off("click",".scp-toggle-replies");$(document).off("click",".scp-report-btn");$(document).on("change","#scp-attachments",function(e){const files=this.files;if(!files.length)return;uploadedImages=[];$("#scp-upload-preview").html("<p>Uploading...</p>");const product_id=$("#scp-comment-form input[name='product_id']").val();function sendMainUploadRequest(){const formData=new FormData();formData.append("action","scp_upload_comment_attachments");formData.append("nonce",window.nonce_comment);formData.append("product_id",product_id);for(let i=0;i<files.length;i++){formData.append("attachments[]",files[i])} 2$.ajax({url:scp_ajax.ajax_url,type:"POST",data:formData,processData:!1,contentType:!1,success:function(res){if(res.success){uploadedImages=res.data.urls;let html="";uploadedImages.forEach((url)=>{html+=`<img src="${url}" style="max-width:100px; margin:5px;">`});$("#scp-upload-preview").html(html)}else if(res.data?.message){window.handleNotificationError(res.data.message,sendMainUploadRequest)}else{$("#scp-upload-preview").html('<p style="color:red;">Upload failed</p>')}},error:function(xhr){window.handleNotificationError(xhr.responseText,sendMainUploadRequest)},})} 3sendMainUploadRequest()});$(document).on("submit","#scp-comment-form",function(e){e.preventDefault();const textarea=$('textarea[name="comment"]');let comment=textarea.val();const product_id=$('input[name="product_id"]').val();if(uploadedImages.length>0){const imageHTML=uploadedImages.map((url)=>`<p><img src="${url}" style="max-width:100%;"></p>`).join("");comment+="\n\n"+imageHTML} 4function sendMainCommentRequest(){$.post(scp_ajax.ajax_url,{action:"scp_submit_comment",nonce:window.nonce_comment,product_id:product_id,comment:comment,attachments:uploadedImages,}).done(function(res){if(res.success){Swal.fire("â Comment submitted!","","success");if(typeof trackEventLocal==="function"){trackEventLocal("comment")} 5$.post(scp_ajax.ajax_url,{action:"scp_send_comment_email",nonce:window.nonce_comment,user_id:res.data.user_id,product_id:res.data.product_id,comment:res.data.comment,order_id:res.data.order_id||"",parent_id:res.data.parent_id||0,});$.post(scp_ajax.ajax_url,{action:"scp_reload_comments",product_id:product_id,},function(response){if(response.success){$("#scp-comments-wrapper").html(response.data.html);ProductComments()}},);$("#scp-comment-form")[0].reset();$(".scp-submit-comment-button").hide();$("#scp-upload-preview").empty();uploadedImages=[]}else{Swal.fire("â Failed",res.data?.message||"Unknown error","error")}}).fail(function(xhr){window.handleNotificationError(xhr.responseText,sendMainCommentRequest)})} 6sendMainCommentRequest()});$(document).on("click",".scp-reply-btn",function(){const parentId=$(this).data("comment-id");const canAttach=window.scp_can_attach_files;const replyBox=$(` 7 <div class="scp-reply-box" style="margin-top:10px;"> 8 <textarea class="scp-reply-content" placeholder="Add a comment..." required style=" 9 width: 100%; 10 border: none; 11 border-bottom: 1px solid rgba(0, 0, 0, .1); 12 outline: none; 13 background: transparent; 14 resize: none; 15 font-size: 14px; 16 padding: 0; 17 margin: 0; 18 font-family: Helvetica, Arial, sans-serif ; 19 min-height: 80px; 20 overflow: hidden; 21 "></textarea> 22 ${ 23 canAttach 24 ? `<input type="file" class="scp-reply-attachments" multiple accept=".jpg,.jpeg,.png,.gif" style="margin-top:5px;"/><small style="color:#666;">Only JPG,PNG,GIF files are allowed.Max 10MB each.</small><div class="scp-reply-preview" style="margin-top: 5px;"></div>` 25 : "" 26 } 27 <button class="scp-submit-reply" data-parent-id="${parentId}" style="margin-top:5px;">Submit Reply</button> 28 </div> 29 `);$(".scp-reply-box").remove();
29$(this).closest(".comment").append(replyBox);replyBox.find("textarea.scp-reply-content").on("input",function(){this.style.height="auto";this.style.height=this.scrollHeight+"px"})});let replyUploadedImages=[];$(document).on("change",".scp-reply-attachments",function(){const files=this.files;const preview=$(this).siblings(".scp-reply-preview");const product_id=$('input[name="product_id"]').val();const allowedTypes=["image/jpeg","image/png","image/gif"];const maxSize=10*1024*1024;replyUploadedImages=[];preview.html("");for(let file of files){if(!allowedTypes.includes(file.type)){Swal.fire("â Invalid File","Only JPG, PNG, and GIF images are allowed.","error");return} 30if(file.size>maxSize){Swal.fire("â File Too Large","Each image must be under 10MB.","error");return}} 31function sendUploadRequest(){const formData=new FormData();formData.append("action","scp_upload_comment_attachments");formData.append("nonce",window.nonce_comment);formData.append("product_id",product_id);for(let i=0;i<files.length;i++){formData.append("attachments[]",files[i])} 32preview.html("Uploading...");$.ajax({url:scp_ajax.ajax_url,type:"POST",data:formData,processData:!1,contentType:!1,success:function(res){if(res.success){let html="";replyUploadedImages=res.data.urls;replyUploadedImages.forEach((url)=>{html+=`<img src="${url}" style="max-width:70px; margin:5px;">`});preview.html(html)}else if(res.data?.message){window.handleNotificationError(res.data.message,sendUploadRequest)}else{preview.html('<p style="color:red;">Upload failed</p>')}},error:function(xhr){window.handleNotificationError(xhr.responseText,sendUploadRequest)},})} 33sendUploadRequest()});$(document).on("click",".scp-submit-reply",function(){const parentId=$(this).data("parent-id");const content=$(this).siblings(".scp-reply-content").val();const product_id=$('input[name="product_id"]').val();if(!content.trim()){Swal.fire("â ï¸ Warning","Reply cannot be empty.","warning");return} 34function sendReplyRequest(){$.post(scp_ajax.ajax_url,{action:"scp_submit_comment",nonce:window.nonce_comment,product_id:product_id,comment:content,parent_id:parentId,attachments:replyUploadedImages,}).done(function(res){if(res.success){Swal.fire("â Reply submitted!","","success");if(typeof trackEventLocal==="function"){trackEventLocal("comment_reply")} 35$.post(scp_ajax.ajax_url,{action:"scp_send_comment_email",nonce:window.nonce_comment,user_id:res.data.user_id,product_id:res.data.product_id,comment:res.data.comment,order_id:res.data.order_id||"",parent_id:res.data.parent_id||0,});$.post(scp_ajax.ajax_url,{action:"scp_reload_comments",product_id:product_id,},function(response){if(response.success){$("#scp-comments-wrapper").html(response.data.html);ProductComments()}},)}else{Swal.fire("â Failed",res.data?.message||"Unknown error","error")}}).fail(function(xhr){window.handleNotificationError(xhr.responseText,sendReplyRequest)})} 36sendReplyRequest()});$(document).on("click",".scp-toggle-replies",function(){const $btn=$(this);const $comment=$btn.closest(".comment");$comment.find("> ul.children").slideDown(200);$btn.parent().remove()});$(document).on("click",".scp-report-btn",function(){const commentId=$(this).data("comment-id");Swal.fire({title:"Report Comment?",text:"Are you sure you want to report this comment as inappropriate?",icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, report it",}).then((result)=>{if(result.isConfirmed){function sendReportRequest(){$.post(scp_ajax.ajax_url,{action:"scp_report_comment",comment_id:commentId,nonce:window.nonce_comment,}).done(function(response){if(response.success&&typeof trackEventLocal==="function"){trackEventLocal("comment_report")} 37Swal.fire(response.success?"Reported!":"Error",response.data?.message||"Unknown error",response.success?"success":"error",)}).fail(function(xhr){window.handleNotificationError(xhr.responseText,sendReportRequest)})} 38sendReportRequest()}})});$(document).on("input",'textarea[name="comment"]',function(){this.style.height="auto";this.style.height=this.scrollHeight+"px"})};window.loadCommentPageDashboard=function(){let currentFilter="customer";let hasInitialLoad=!1;function loadCommentPage(page=1,filter_type="customer"){$("#simple-comment-table-container").html(` 39 <div class="scp-loading-placeholder"> 40 <div class="scp-spinner"></div> 41 </div> 42 `);$("#simple-comment-pagination").empty();$.post(scp_ajax.ajax_url,{action:"load_simple_comment_page",page:page,filter_type:filter_type,nonce:window.nonce_comment,}).done(function(res){$("#simple-comment-table-container").html(res.table);$("#simple-comment-pagination").html(res.pagination)}).fail(function(xhr){window.handleNotificationError(xhr.responseText,()=>{loadCommentPage(page,filter_type)})})}
43$(document).off("click",".scp-filter-btn");$(document).off("click",".comment-page-btn");$(document).off("click",".scp-mark-resolved");const waitForRender=setInterval(()=>{if($(".scp-filter-btn").length&&!hasInitialLoad){loadCommentPage(1,currentFilter);hasInitialLoad=!0;clearInterval(waitForRender)}},200);$(document).on("click",".scp-filter-btn",function(){currentFilter=$(this).data("type");$(".scp-filter-btn").removeClass("active");$(this).addClass("active");loadCommentPage(1,currentFilter)});$(document).on("click",".comment-page-btn",function(){const page=$(this).data("page");loadCommentPage(page,currentFilter);$("html, body").animate({scrollTop:0},300)});$(document).on("click",".scp-mark-resolved",function(){const commentId=$(this).data("id");$.post(scp_ajax.ajax_url,{action:"scp_mark_resolved",comment_id:commentId,nonce:window.nonce_comment,}).done(function(res){if(res.success){$(`.scp-status[data-id="${commentId}"]`).html('<span style="color:green;">Resolved</span>')}else if(res.data?.message){window.handleNotificationError(res.data.message,()=>{$(`.scp-mark-resolved[data-id="${commentId}"]`).trigger("click")})}}).fail(function(xhr){window.handleNotificationError(xhr.responseText,()=>{$(`.scp-mark-resolved[data-id="${commentId}"]`).trigger("click")})})})}})(jQuery)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.