function Vreview( defaults ){ var profileid = defaults.profileid; var xmlvalue = defaults.xmlvalue; var lim = defaults.limit; var off = defaults.offset; var rowId = defaults.rowId; var parentid = defaults.parentid; var pagetitle = defaults.pagetitle; var multi_star = defaults.multi_star; var enable_rating = defaults.enable_rating; var enable_comment = defaults.enable_comment; var char_limit = defaults.char_limit; var captcha = defaults.captcha; var user = defaults.user; var curr_link = defaults.curr_link; var plgversion = defaults.plgversion; var th = this; //display records start this.displayRecords = function(lim,off) { jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'displayRecords', 'limit':lim, 'offset':off, 'profileid':profileid, 'xmlvalue':xmlvalue, 'rowId':rowId}, async: false, cache: false, beforeSend: function() { jQuery("#loader_message"+rowId).html("").hide(); jQuery('#loader_image'+rowId).show(); }, success: function(data){ if(data.result=="success"){ if(data.noVal){ var emVal = '

'+data.noVal+'

'; jQuery('.no_review'+rowId).html(emVal); } jQuery('#show-review'+rowId).append(data.commentVal); jQuery('#loader_image'+rowId).hide(); } /* var curUrl = window.location.href; if(curUrl.indexOf('limitstart') > 0) { var newLim = off - lim; var newUrl = curUrl.replace("limitstart="+newLim, "limitstart="+off); window.history.pushState({}, null, newUrl); } else { curUrl += ((curUrl.indexOf('?') == -1) ? '?' : '&'); curUrl += "limitstart="+off; //window.location.hash = '?limitstart='+off; window.history.pushState({}, null, curUrl); } */ if(data.countRev) { if (data.revEnd == 1) { var nwUrl = window.location.href; newOff = off + lim; nwUrl = nwUrl.replace("limitstart="+off, "limitstart="+newOff); jQuery("#loader_message"+rowId).html('End of Reviews').show(); } else { var nwUrl = window.location.href; newOff = off + lim; nwUrl = nwUrl.replace("limitstart="+off, "limitstart="+newOff); jQuery("#loader_message"+rowId).html('Load More Data').show(); } } else { jQuery("#loader_message"+rowId).remove(); jQuery("#loader_image"+rowId).remove(); } } }); } //displayrecords end jQuery(document).ready(function() { th.displayRecords(lim, off); jQuery('#loader_message'+rowId).click(function(event) { event.preventDefault(); // if it has no more records no need to fire ajax request var d = jQuery('#loader_message'+rowId).find("a").attr("data-atr"); if (d != "nodata") { off = lim + off; th.displayRecords(lim, off); } }); jQuery('#loadprev'+rowId).click(function(event) { event.preventDefault(); // if it has no more records no need to fire ajax request var d = jQuery('#loadprev'+rowId).find("a").attr("data-atr"); if (d != "nodata") { off = off-lim; jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'displayRecords', 'limit':lim, 'offset':off, 'profileid':profileid, 'xmlvalue':xmlvalue, 'rowId':rowId}, async: false, cache: false, beforeSend: function() { jQuery("#loadprev"+rowId).html("").hide(); jQuery('#loadpre_image'+rowId).show(); }, success: function(data){ if(data.result=="success"){ if(data.noVal){ var emVal = '

'+data.noVal+'

'; jQuery('.no_review'+rowId).html(emVal); } jQuery('#show-review'+rowId).prepend(data.commentVal); jQuery('#loadpre_image'+rowId).hide(); } if (data.revPrev == 1) { jQuery("#loadprev"+rowId).html('Load Previous Data').show(); } else { jQuery("#loadprev"+rowId).remove(); jQuery("#loadpre_image"+rowId).remove(); } } }); } }); }); jQuery(document).ready(function(){ // Check Radio-box jQuery('form[name="adminForm'+rowId+'"] .rating'+rowId+' input:radio').attr('checked', false); jQuery('form[name="adminForm'+rowId+'"] .rating'+rowId+' input').click(function () { jQuery('form[name="adminForm'+rowId+'"] .rating'+rowId+' span').removeClass('checked'); jQuery(this).parent().addClass('checked'); }); }); jQuery(document).ready(function(){ //Check Radio-box jQuery('form[name="adminForm'+rowId+'"] .mrt'+rowId+' input:radio').attr('checked', false); jQuery(document).on('click','form[name="adminForm'+rowId+'"] .mrt'+rowId+' input',function () { jQuery(this).parent().siblings().removeClass('checked'); jQuery(this).parent().addClass('checked'); }); }); //Click Event to Like jQuery(document).on('click','.like'+rowId,function() { var tl = this; th.likePage(tl); }); //Click Event to Dislike jQuery(document).on('click','.dislike'+rowId,function() { var tdl = this; th.dislikePage(tdl); }); //Click Event to Report jQuery(document).on('click','.report'+rowId,function() { var rth = this; th.reportPage(rth); }); //Click Event to Subscribe/Unsubscribe jQuery(document).on('click','#subscribe'+rowId,function() { var sbt = this; th.subscribePage(sbt); }); //Click Event for Comment Like jQuery(document).on('click','.cmlike'+rowId,function() { var cmlthis = this; th.commentLike(cmlthis); }); //Click Event for Comment Dislike jQuery(document).on('click','.cmdislike'+rowId,function() { var cmdlthis = this; th.commentDislike(cmdlthis); }); //Click Event for Comment Report jQuery(document).on('click','.cmreport'+rowId,function() { var cmrpthis = this; th.commentReport(cmrpthis); }); //Clicke event to delete jQuery(document).on('click','.delete-review'+rowId,function() { var dlt = this; th.deleteReview(dlt); }); jQuery('.smilies'+rowId).hide(); jQuery(document).on('click','.smiley'+rowId,function() { jQuery('.smilies'+rowId).toggle(); }); var smileval; var comments; jQuery(document).on('click', '.smile'+rowId ,function(){ smileval = jQuery(this).attr('value'); var cmntTxt = jQuery('form[name="adminForm'+rowId+'"] #comments').val(); var char_length = cmntTxt.length; if(char_limit!=0 && char_length==char_limit) { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text('You have entered excess number of characters'); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); return false; } jQuery('form[name="adminForm'+rowId+'"] #comments').val(cmntTxt+smileval); comments = jQuery('form[name="adminForm'+rowId+'"] #comments').val(); }); jQuery(document).on('click','input ',function() { //jQuery('.smilies'+rowId).hide(); jQuery('.reply-smilies'+rowId).hide(); }); jQuery(document).on('click','textarea',function() { jQuery('.smilies'+rowId).hide(); //jQuery('.reply-smilies'+rowId).hide(); }); if(multi_star==1) { var ratings= new Array(); jQuery('input:radio').change(function(){ var ids = jQuery(this).parent().parent().attr('mrid'); var level = jQuery(this).parent().parent().attr('level'); var counts = jQuery('#counts').attr('value'); //alert(ids); for(var i=0;i0) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } //alert(profileid);alert(th.pagetitle); //return false; jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'like', 'profileid':profileid, 'xmlvalue':xmlvalue, 'pagetitle':pagetitle, 'curr_link':curr_link}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(tl).append(htm); }, complete: function() { jQuery(tl).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ var totalLikes=''+data.totalLike+' '+data.likeTxt+' '; jQuery(tl).html(totalLikes); var totalDislikes=''+data.totalDislike+' '+data.dislikeTxt+' '; jQuery(tl).parent().find('.dislike'+rowId).html(totalDislikes); //alert(data.msg); //jQuery('.like').off(); jQuery(tl).addClass('disabled'); jQuery(tl).parent().find('.dislike'+rowId).removeClass('disabled'); } else if(data.result=="alreadyLiked") { jQuery('.alr-msg'+rowId).css('display','block').text(data.alertMsg); jQuery(tl).addClass('disabled'); setTimeout(function() { jQuery('.alr-msg'+rowId).css('display','none');},3000); //alert(data.alertMsg); } } }); } //Like End //Dislike start this.dislikePage = function(tdl) { if(jQuery('#guest-user'+rowId).length>0) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data:{'option':'com_vreview', 'task':'dislike', 'profileid':profileid,'xmlvalue':xmlvalue, 'pagetitle':pagetitle, 'curr_link':curr_link}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(tdl).append(htm); }, complete: function() { jQuery(tdl).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ var totalLikes=''+data.totalLike+' '+data.likeTxt+' '; jQuery(tdl).parent().find('.like'+rowId).html(totalLikes); var totalDislikes=''+data.totalDislike+' '+data.dislikeTxt+' '; jQuery(tdl).html(totalDislikes); //alert(data.msg); jQuery(tdl).addClass('disabled'); jQuery(tdl).parent().find('.like'+rowId).removeClass('disabled'); } else if(data.result=="alreadyDisliked") { jQuery('.alr-msg'+rowId).css('display','block').text(data.alertMsg); jQuery(tdl).addClass('disabled'); setTimeout(function() { jQuery('.alr-msg'+rowId).css('display','none');},3000); } } }); } //Dislike End //Report Start this.reportPage = function(rth) { if(jQuery('#guest-user'+rowId).length>0) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data:{'option':'com_vreview', 'task':'report', 'profileid':profileid, 'xmlvalue':xmlvalue,'pagetitle':pagetitle, 'curr_link':curr_link}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(rth).append(htm); }, complete: function() { jQuery(rth).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ var totalReports=''+data.totalReport+' '+data.reportTxt+' '; jQuery(rth).html(totalReports); //alert(data.msg); jQuery(rth).addClass('disabled'); } else if(data.result=="alreadyReport") { jQuery('.alr-msg'+rowId).css('display','block').text(data.alertMsg); jQuery(rth).addClass('disabled'); setTimeout(function() { jQuery('.alr-msg'+rowId).css('display','none');},3000); } } }); } //Report End // Subscribe Start this.subscribePage = function(sbt) { if(jQuery('#guest-user'+rowId).length>0) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } jQuery.ajax({ //url:'index.php', type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'subscribe', 'profileid':profileid, 'xmlvalue':xmlvalue}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(sbt).append(htm); }, complete: function() { jQuery(sbt).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ if(data.subscribeVal==1) { var subscribe = ''+data.subText+''; //alert(data.subMsg); } else { var subscribe = ''+data.subText+''; //alert(data.subMsg); } jQuery('#subscribe'+rowId).html(subscribe); } } }); } // Subscribe End //Delete Start this.deleteReview = function(dlt) { var reviewid = jQuery(dlt).attr('drid'); var commentid = jQuery(dlt).attr('dcid'); jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'delete', 'reviewid':reviewid, 'commentid':commentid, 'profileid':profileid, 'xmlvalue':xmlvalue}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(dlt).append(htm); }, complete: function() { jQuery(dlt).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ jQuery(dlt).parent().parent().remove(); jQuery('.disable').removeClass('disable'); jQuery('.smiley'+rowId).removeClass('disabled'); jQuery('.submitreview'+rowId).removeClass('disabled'); jQuery('form[name="adminForm'+rowId+'"] #comments').prop('disabled', false); //alert( data.msg); } } }); } //Delete End //Edit Start this.editReview = function(thiseditClass) { var eid = jQuery(thiseditClass).attr('eid'); rvId = jQuery(thiseditClass).attr('erid'); cmId = jQuery(thiseditClass).attr('cmid'); jQuery.ajax({ //url:'index.php', type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'editReview', 'rvId':rvId, 'cmId':cmId}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(thiseditClass).append(htm); }, complete: function() { jQuery(thiseditClass).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ jQuery('html,body').stop().animate({scrollTop: jQuery(jQuery('#adminForm'+rowId)).offset().top }, 1000); jQuery('.disable').removeClass('disable'); jQuery('.smiley'+rowId).removeClass('disabled'); jQuery('.submitreview'+rowId).removeClass('disabled'); jQuery('form[name="adminForm'+rowId+'"] #comments').prop('disabled', false); if(char_limit!=0) { var max_length = 'maxlength='+char_limit+''; } else { var max_length = 'maxlength=""'; } var inptext = ''; jQuery('.cmnt'+rowId).html(inptext); } } }); } //Edit End //Submit Review Start this.submitReview = function(submitClass) { if((jQuery('#guest-user'+rowId).length>0) && (!jQuery('#guest-user'+rowId).hasClass('guest-user'+rowId))) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } if(jQuery('.guest-form'+rowId).length>0) { var emailReg = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); if(jQuery('form[name="adminForm'+rowId+'"] #name').val()=='') { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text('Please Enter Your Name'); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); return false; } if(jQuery('form[name="adminForm'+rowId+'"] #email').val()=='') { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text('PLease Enter Your Email Id'); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); return false; } var email = jQuery('form[name="adminForm'+rowId+'"] #email').val(); var name = jQuery('form[name="adminForm'+rowId+'"] #name').val(); var valid = emailReg.test(email); if(!valid) { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text('PLease Enter Valid Email Id'); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); return false; } } else { var email = ''; var name = ''; } //jQuery('.smilies'+rowId).hide(); if(rvId) { var rId = rvId; } else { var rId = ''; } if(cmId) { var cmd = cmId; } else { var cmd = ''; } var challengeField = jQuery("input#recaptcha_challenge_field").val(); if(plgversion==1.0) { var recaptcha_response_field = jQuery("input#recaptcha_response_field").val(); } else if(plgversion==2.0) { var recaptcha_response_field = jQuery("textarea#g-recaptcha-response").val(); } if(enable_comment==1) { var char_length = jQuery('form[name="adminForm'+rowId+'"] #comments').val().length; } if(char_limit!=0 && char_length>char_limit) { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text('You have entered excess number of characters'); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert('You have entered excess number of characters'); return false; } if(enable_rating==1 && multi_star==1) { if(ratings.length>0) { var rating = ratings; }else { var rating = ''; } } else if(enable_rating==1) { if(ratings) { var rating = ratings; }else { var rating = ''; } } else { var rating = ''; } //alert(rating); /*if(comments) { var comment = comments; }else { var comment = jQuery('form[name="adminForm'+rowId+'"] #comments').val(); }*/ var comment = jQuery('form[name="adminForm'+rowId+'"] #comments').val(); if(enable_rating==1) { if(rId=='' && rating=='') { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text('Please give your review before submitting.'); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert('Please give your review before submitting'); return false; } } else { if(comment=='') { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text('Please Enter Your Comment'); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert('Please Enter Your Comment'); return false; } } jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'review', 'profileid':profileid, 'parentid':parentid, 'xmlvalue':xmlvalue, 'comment':comment, 'rating':rating, 'pagetitle':pagetitle, 'rid':rId, 'cmd':cmd, 'recaptcha_response_field':recaptcha_response_field, 'recaptcha_challenge_field':challengeField, 'name':name, 'email':email, 'rowId':rowId, 'curr_link':curr_link, 'plgversion':plgversion }, async: false, cache: false, beforeSend: function() { jQuery(".loadingbox").show(); }, complete: function() { jQuery(".loadingbox").hide(); }, success: function(data){ if(data.result=="success"){ if(data.cmd=="") { jQuery('#show-review'+rowId).prepend(data.commentVal); } else { jQuery(thiseditClass).parent().parent().html(data.commentVal); } jQuery('form[name="adminForm'+rowId+'"] #comments').val(''); jQuery('form[name="adminForm'+rowId+'"] #name').val(''); jQuery('form[name="adminForm'+rowId+'"] #email').val(''); jQuery('.mrt'+rowId+' input').parent().siblings().removeClass('checked'); jQuery('.rating'+rowId+' span').removeClass('checked'); cmId = ''; rvId = ''; comments = ''; var avg_ttl = ''; jQuery('form[name="adminForm'+rowId+'"] .avg-stars').html(avg_ttl); jQuery('.no_review'+rowId).remove(); if(data.subVal==0 || data.subVal==null) { var subscribe = ''+data.subsTxt+''; jQuery('#sub'+rowId).html(subscribe); } else { var subscribe = ''+data.subsTxt+''; jQuery('#sub').html(subscribe); } /*if(data.enbl_rating==0 && data.reviewLim==data.revCount && user!=0) { jQuery("#comments").prop('disabled', true); jQuery('.smiley').addClass('disabled'); jQuery('.submitreview ').addClass('disabled'); alert(''); }*/ if(data.enbl_rating==1 && user!=0) { var htm='
'; jQuery('.mrt'+rowId).append(htm); jQuery('.rating'+rowId).append(htm); jQuery('form[name="adminForm'+rowId+'"] #comments').prop('disabled', true); jQuery('.smiley'+rowId).addClass('disabled'); jQuery('.submitreview'+rowId).addClass('disabled'); } if(captcha==1 && enable_rating==1 && plgversion==1.0) { Recaptcha.reload(); } jQuery('.msg'+rowId).addClass('succ-msg').css('display','block').text(data.succMsg); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert( data.succMsg ); if(data.mod_msg){ jQuery('.mod-msg'+rowId).css('display','block').text(data.mod_msg); setTimeout(function() { jQuery('.mod-msg'+rowId).css('display','none');},3000); //alert(data.mod_msg); } } else if(data.result=="captcha") { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text(data.capErr); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert( data.capErr ); if(plgversion==1.0) { Recaptcha.reload(); } }else if(data.result=="censor") { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text(data.censorErr); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert(data.censorErr); } else if(data.result=="emailErr") { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text(data.emailError); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert(data.emailError); } else if(data.result=="reviewLimit") { jQuery('form[name="adminForm'+rowId+'"] #comments').val(''); jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text(data.limErr); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert(data.limErr); } else if(data.result=="charLimit") { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text(data.charLimTxt); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert(data.charLimTxt); } else if(data.result=="reviewExist") { jQuery('.msg'+rowId).addClass('error-msg').css('display','block').text(data.revExistTxt); setTimeout(function() { jQuery('.msg'+rowId).css('display','none');},3000); //alert( data.revExistTxt ); } //location.reload(); } }); } //Submit Review End var smileval; var replies=''; jQuery(document).on('click','.reply-smile'+rowId,function(){ var rsd = this; jQuery(this).parent().parent().parent().css('display','inline-block'); smileval = jQuery(this).attr('value'); var replyText = jQuery(this).parent().parent().parent().find('input').val(); var char_length = jQuery(this).parent().parent().parent().find('input').val().length; if(char_limit!=0 && char_length==char_limit) { jQuery(this).parent().parent().parent().parent().find("span.r-msg").addClass('r-err-msg').css('display','block').text('You have entered excess number of characters'); setTimeout(function() { jQuery(rsd).parent().parent().parent().parent().find("span.r-msg").css("display","none");},3000); //alert('You have entered excess number of characters'); return false; } jQuery(this).parent().parent().parent().find('input').val(replyText+smileval); replies = jQuery(this).parent().parent().parent().find('input').val(); }); this.submitReply = function(thisClass) { var ids = jQuery(thisClass).attr('rrid'); if((jQuery('#guest-user'+rowId).length>0) && (!jQuery('#guest-user'+rowId).hasClass('guest-user'+rowId))) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } jQuery(thisClass).parent().next("div").find(".rep").toggle(); jQuery(thisClass).parent().next("div").find('input').keypress(function(event){ var that = this; var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ th.sendReply(that,thisClass); } }); jQuery(thisClass).parent().next("div").find('span.send-reply').click(function(event){ var that = jQuery(this).prev('input[name="title"]'); jQuery(that).parent().next('div.reply-smilies').css('display','none'); th.sendReply(that,thisClass); }); } this.sendReply=function(that,thisClass){ //var reply = jQuery('#'+inputid+'').val(); var commentid = jQuery(that).attr('commentid'); var reply = jQuery(that).val(); if(reply=='') { jQuery(that).parent().parent().parent().find("span.r-msg").addClass('r-err-msg').css('display','block').text('Please Enter Your Comment'); setTimeout(function() { jQuery(that).parent().parent().parent().find("span.r-msg").css('display','none');},3000); return false; } var char_length = jQuery(that).val().length; if(char_limit!=0 && char_length>char_limit) { jQuery(that).parent().parent().parent().find("span.r-msg").addClass('r-err-msg').css('display','block').text('You have entered excess number of characters'); setTimeout(function() { jQuery(that).parent().parent().parent().find("span.r-msg").css('display','none');},3000); return false; } jQuery.ajax({ //url:"index.php", type: "POST", dataType:"json", data: {'option':'com_vreview', 'task':'reply', 'reply':reply, 'commentid':commentid, 'profileid':profileid, 'xmlvalue':xmlvalue, 'curr_link':curr_link}, async: false, cache: false, beforeSend: function() { jQuery(that).parent().parent().parent().parent().find('.reply-loader').show(); }, complete: function() { jQuery(that).parent().parent().parent().parent().find('.reply-loader').hide(); }, success: function(data){ if(data.result=="success") { if(data.show_reply_time==1){ var reptime = ''+data.reply_time+''; } else { var reptime = ''; } if(jQuery(thisClass).parent().parent().find('.review-panel-replies').find('span.rtext'+rowId).hasClass('open')) { var openClass = "open"; } else { var openClass = ""; } var countRep = ''+data.countReply+' '+data.repTxt+''; jQuery(thisClass).parent().parent().find('.review-panel-replies').html(countRep); var reply='
'+data.username+''+''+data.replies+''+reptime+'
'; if(jQuery(thisClass).parent().parent().find('.review-panel-replies').find('span.rtext'+rowId).hasClass('open')) { jQuery(that).parent().parent().parent().next('div.review-rep').prepend(reply); } //jQuery('#show-review').html(data.commentVal); jQuery(that).val(''); replies=''; jQuery(that).parent().parent().parent().find("span.r-msg").addClass('r-succ-msg').css('display','block').text(data.repSucc); setTimeout(function() { jQuery(that).parent().parent().parent().find("span.r-msg").css('display','none');},3000); //alert(data.repSucc); //location.reload(); } else if(data.result=="censor") { jQuery(that).parent().parent().parent().find("span.r-msg").addClass('r-err-msg').css('display','block').text(data.censorErr); setTimeout(function() { jQuery(that).parent().parent().parent().find("span.r-msg").css('display','none');},3000); //alert(data.censorErr); } else if(data.result=="charRepLimit") { jQuery(that).parent().parent().parent().find("span.r-msg").addClass('r-err-msg').css('display','block').text(data.charRepLimitTxt); setTimeout(function() { jQuery(that).parent().parent().parent().find("span.r-msg").css('display','none');},3000); //alert(data.charRepLimitTxt); } else if(data.result=="commentLimit") { jQuery(thisClass).parent().next("div").find('input').val(''); jQuery(that).parent().parent().parent().find("span.r-msg").addClass('r-err-msg').css('display','block').text(data.commentLimitTxt); setTimeout(function() { jQuery(that).parent().parent().parent().find("span.r-msg").css('display','none');},3000); //alert (data.commentLimitTxt); } } }); }; var thisrtext; var limits; var offsets; jQuery(document).on('click','.rtext'+rowId,function() { if(jQuery(this).hasClass('open')) { jQuery(this).parent().parent().parent().find('.review-rep').toggle(); return false; } limits = lim; offsets = 0; jQuery(this).parent().parent().parent().find('.review-rep'+rowId).css('display','block'); var commentid = jQuery(this).attr('ccid'); thisrtext = this; th.displayReply(limits, offsets, commentid, thisrtext); }); jQuery(document).on('click','.loader_reply_message'+rowId,function() { // if it has no more records no need to fire ajax request var commentid = jQuery(this).attr('ccid'); var d = jQuery(this).find("button").attr("data-atr"); if (d != "nodata") { offsets = limits + offsets; th.displayReply(limits, offsets, commentid, thisrtext); } }); this.displayReply = function(lim, off, cmd, thr) { jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'displayReply', 'limit':lim, 'offset':off, 'commentid':cmd, 'profileid':profileid}, async: false, cache: false, beforeSend: function() { jQuery(thr).parent().parent().parent().find(".loader_reply_message"+rowId).html("").hide(); jQuery(thr).parent().parent().parent().find(".loader_reply_image"+rowId).show(); }, success: function(data){ if(data.result=="success"){ //jQuery(thr).parent().parent().parent().find('.review-rep').css('display','block'); jQuery(thr).parent().parent().parent().find('.review-rep'+rowId).prepend(data.replyVal); jQuery(thr).parent().parent().parent().find(".loader_reply_image"+rowId).hide(); if (data.replyVal == "") { jQuery(thr).parent().parent().parent().find(".loader_reply_message"+rowId).html('').show() } else { jQuery(thr).parent().parent().parent().find(".loader_reply_message"+rowId).html('').show(); } jQuery(thr).addClass('open'); } } }); } jQuery('.reply-smilies'+rowId).hide(); jQuery(document).on('click','.reply-smiley'+rowId,function() { jQuery(this).parent().next("div").toggle(); }); this.commentLike = function(cmlthis) { var reviewid = jQuery(cmlthis).attr('rid'); var commentid = jQuery(cmlthis).attr('cid'); if(jQuery('#guest-user'+rowId).length>0) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'commentLike', 'reviewid':reviewid, 'commentid':commentid, 'profileid':profileid, 'curr_link':curr_link}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(cmlthis).append(htm); }, complete: function() { jQuery(cmlthis).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ var likecount=''+data.countLike+' '+data.likeTxt+' '; jQuery(cmlthis).html(likecount); var dislikecount=''+data.countDislike+' '+data.dislikeTxt+' '; jQuery(cmlthis).parent().parent().find(".cmdislike"+rowId).html(dislikecount); //alert( data.msg ); jQuery(cmlthis).addClass('disabled'); jQuery(cmlthis).parent().parent().find(".cmdislike"+rowId).removeClass('disabled'); } } }); } this.commentDislike = function(cmdlthis) { var reviewid = jQuery(cmdlthis).attr('rid'); var commentid = jQuery(cmdlthis).attr('cid'); if(jQuery('#guest-user'+rowId).length>0) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'commentDislike', 'reviewid':reviewid, 'commentid':commentid, 'profileid':profileid, 'curr_link':curr_link}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(cmdlthis).append(htm); }, complete: function() { jQuery(cmdlthis).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ var dislikecount=''+data.countDislike+' '+data.dislikeTxt+' '; jQuery(cmdlthis).html(dislikecount); var likecount=''+data.countLike+' '+data.likeTxt+' '; jQuery(cmdlthis).parent().parent().find(".cmlike"+rowId).html(likecount); //alert( data.msg ); jQuery(cmdlthis).addClass('disabled'); jQuery(cmdlthis).parent().parent().find(".cmlike"+rowId).removeClass('disabled'); } } }); } this.commentReport = function(cmrpthis) { var reviewid = jQuery(cmrpthis).attr('rid'); var commentid = jQuery(cmrpthis).attr('cid'); if(jQuery('#guest-user'+rowId).length>0) { jQuery( "#dialog"+rowId ).dialog( "open" ); return false; } jQuery.ajax({ //url:"index.php", type: "POST", dataType:"JSON", data: {'option':'com_vreview', 'task':'commentReport', 'reviewid':reviewid, 'commentid':commentid, 'profileid':profileid, 'xmlvalue':xmlvalue, 'curr_link':curr_link}, async: false, cache: false, beforeSend: function() { var htm = ''; jQuery(cmrpthis).append(htm); }, complete: function() { jQuery(cmrpthis).find('span.like-load').remove(); }, success: function(data){ if(data.result=="success"){ var reportcount=''+data.countReport+' '+data.reportTxt+' '; jQuery(cmrpthis).html(reportcount); //alert( data.msg ); jQuery(cmrpthis).addClass('disabled'); } } }); } }