window.showSuccessMsg=function(message,timerArg){ var timer=3000; if(timerArg){ timer=timerArg; } $('.successMessage').text(message); $('.successMessage').show(); window._popUpTimerId=setTimeout(function(){ $('.successMessage').hide(); //_closePopUp(); },timer) } window.showErrorMsg = function(message,timerArg){ var timer=3000; if(timerArg){ timer=timerArg; } $('[data-plugin="comment-error"]').text(message); // $('.successMessage').text(message); $('[data-plugin="comment-error"]').show(); setTimeout(function(){ $('[data-plugin="comment-error"]').hide(); //_closePopUp(); },timer) } var travelcomments_module = (function(){ function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i 0){ makeCommentComp(msid,obj,false); } }); } setUpvoteAttr(); } function makeCommentComp(msid,obj,isLoggedUserComment,popUpObj){ var cmtobj = {}; var ele = ''; cmtobj.parentid = obj._id; cmtobj.parentthumb = (obj.PIU!=null && obj.PIU!='null') ? obj.PIU : 'http://mytimes.jeetwin-gaming.com/image/thumb/2/7105055'; cmtobj.parentname = obj.A_D_N; cmtobj.parentts = obj.C_D; cmtobj.parentrating = obj.U_R; //cmtobj.parentcomment = obj.C_T.replace(/(<|<)br\s*\/*(>|>)/g,' '); cmtobj.parentcomment = $("
").html(obj.C_T).text(); cmtobj.parentupvote = (obj.AC_A_C!=undefined && obj.AC_A_C!=null) ? obj.AC_A_C : 0; cmtobj.parentdownvote = (obj.AC_D_C!=undefined && obj.AC_D_C!=null) ? obj.AC_D_C : 0; cmtobj.user_reward_point_info = (obj.user_reward_point_info!=undefined && obj.user_reward_point_info!=null) ? obj.user_reward_point_info : 0; cmtobj.user_reward = obj.user_reward; cmtobj.userprofile = obj.user_detail ? ((obj.user_detail.D_N_U!=undefined && obj.user_detail.D_N_U!=null) ? obj.user_detail.D_N_U : obj.user_detail._id) : []; isLoggedUserComment = isLoggedUserComment ? isLoggedUserComment : (obj.user_detail && obj.user_detail.uid ? obj.user_detail.uid == ssoid : false); if(typeof (obj.CHILD)!="undefined"){ cmtobj.childs = obj.CHILD; } ele = ele + makeCommentsUI(cmtobj,isLoggedUserComment); if(popUpObj && popUpObj.popUpListComp){ if($("#comment-section-"+msid) && $("#comment-section-"+msid).find('[data-plugin="commentsdata"]')){ $("#comment-section-"+msid).find('[data-plugin="commentsdata"]').append(ele); } }else{ $("#commentmodule"+msid).find('[data-plugin="commentsdata"]').append(ele); } } function setUpvoteAttr(){ var storedids = JSON.parse(localStorage.getItem("upvotedids")); if(storedids!=null){ storedids.forEach(function(id){ $('[data-plugin="up-vote"][comment-id="'+id+'"]').attr('upvoted',true); $('[data-plugin="down-vote"][comment-id="'+id+'"]').attr('upvoted',true); $('[data-plugin="flag"][comment-id="'+id+'"]').attr('upvoted',true); }); } var storedids1 = JSON.parse(localStorage.getItem("downvotedids")); if(storedids1!=null){ storedids1.forEach(function(id){ $('[data-plugin="up-vote"][comment-id="'+id+'"]').attr('downvoted',true); $('[data-plugin="down-vote"][comment-id="'+id+'"]').attr('downvoted',true); $('[data-plugin="flag"][comment-id="'+id+'"]').attr('downvoted',true); }); } var storedids2 = JSON.parse(localStorage.getItem("flaggedids")); if(storedids2!=null){ storedids2.forEach(function(id){ $('[data-plugin="up-vote"][comment-id="'+id+'"]').attr('flagged',true); $('[data-plugin="down-vote"][comment-id="'+id+'"]').attr('flagged',true); $('[data-plugin="flag"][comment-id="'+id+'"]').attr('flagged',true); $('[data-plugin="flag"][comment-id="'+id+'"]').text('Flagged'); }); } var storedids3 = JSON.parse(localStorage.getItem("followedids")); if(storedids3!=null){ storedids3.forEach(function(id){ $('[data-plugin="user-follow"][followid="'+id+'"]').addClass('active'); $('[data-plugin="user-follow"][followid="'+id+'"]').text('Followed'); }); } } function makeCommentsUI(cmtobj,isLoggedUserComment){ if(typeof(cmtobj)!='undefined'){ var commentPnlClass = isLoggedUserComment ? ' yourCommentPanel' : ''; if(typeof(cmtobj.childs)!='undefined'){ var childele = makeChildsOfParentComment(cmtobj.childs); } else{ var childele = ''; } var commentele = '
'+ '
'+ '
'+ '
'+ '
'+ '

'+cmtobj.parentname+''; if(isLoggedUserComment){ commentele += 'Your Comment'; } if(cmtobj.user_reward && cmtobj.user_reward){ commentele += ''+cmtobj.user_reward.statusPoints+''; } commentele += ''+cmtobj.parentts+'

'; if(cmtobj.parentcomment.length > 135) { commentele += '

'+cmtobj.parentcomment.substring(0,135)+'... Read More

'; } else { commentele += '

'+cmtobj.parentcomment+'

'; } commentele +='
'+ 'Reply'+ ''+ 'Flag

Find this comment offensive?

Choose your reason below and click on the Submit button. This will alert our moderators to take action

Reason for reporting:
  • Foul language
  • Defamatory
  • Inciting hatred against a certain community
  • Out of context/Spam
  • Others
CloseReport This!
'+ ''+cmtobj.parentupvote+''+ 'Up'+ ''+cmtobj.parentdownvote+''+ 'Down'+ ''+ '
'+ '
'+ '
'+ ''+childele+ '
'; return commentele; } else{ return ''; } } function makeChildsOfParentComment(child){ var ele = ''; child.forEach(function(obj){ var cmtobj = {}; cmtobj.parentid = obj._id; cmtobj.parentthumb = (obj.PIU!=null && obj.PIU!='null') ? obj.PIU : 'http://mytimes.jeetwin-gaming.com/image/thumb/2/7105055'; cmtobj.parentname = obj.A_D_N; cmtobj.parentts = obj.C_D; cmtobj.parentrating = obj.U_R; // cmtobj.parentcomment = obj.C_T.replace(/(<|<)br\s*\/*(>|>)/g,' '); cmtobj.parentcomment = $("
").html(obj.C_T).text(); cmtobj.parentupvote = (obj.AC_A_C!=undefined && obj.AC_A_C!=null) ? obj.AC_A_C : 0; cmtobj.parentdownvote = (obj.AC_D_C!=undefined && obj.AC_D_C!=null) ? obj.AC_D_C : 0; cmtobj.level1parent = obj.O_D_N; cmtobj.user_reward_point_info = (obj.user_reward_point_info!=undefined && obj.user_reward_point_info!=null) ? obj.user_reward_point_info : 0; cmtobj.userprofile = obj.user_detail ? ((obj.user_detail.D_N_U!=undefined && obj.user_detail.D_N_U!=null) ? obj.user_detail.D_N_U : obj.user_detail._id) : []; if(typeof (obj.CHILD)!="undefined"){ cmtobj.childs = obj.CHILD; } ele = ele + makeCommentsChildUI(cmtobj); }); return ele; } function makeCommentsChildUI(cmtobj){ if(typeof(cmtobj)!='undefined'){ if(typeof(cmtobj.childs)!='undefined'){ var childele = makeChildsOfParentComment(cmtobj.childs); } else{ var childele = ''; } var cele = '
'+ '
'+ '
'+ '
'+ '
'+ '

'+cmtobj.parentname+''+cmtobj.level1parent+''+cmtobj.parentts+'

'; if(cmtobj.parentcomment.length > 125) { cele += '

'+cmtobj.parentcomment.substring(0,125)+'... Read More

'; } else { cele += '

'+cmtobj.parentcomment+'

'; } cele +='
'+ 'Reply'+ ''+ 'Flag'+ ''+cmtobj.parentupvote+''+ 'Up'+ ''+cmtobj.parentdownvote+''+ 'Down'+ ''+ '

Find this comment offensive?

Choose your reason below and click on the Submit button. This will alert our moderators to take action

Reason for reporting:
  • Foul language
  • Defamatory
  • Inciting hatred against a certain community
  • Out of context/Spam
  • Others
CloseReport This!
'+ '
'+ '
'+ '
'+ ''+ '
'; return (cele + childele); } else{ return ''; } } function renderCommentList(data,msid){ // alert('render comment list fro ::'+msid); var parseData = JSON.parse(data); var cmtdatalength = parseData.length-1; if(parseData[0] && parseData[0].userCommentThread && parseData[0].userCommentThread.length){ makeCommentComp(msid,parseData[0].userCommentThread[0],true,{popUpListComp:true}); }else{ parseData.forEach(function(obj,index){ if(index>0){ makeCommentComp(msid,obj,false,{popUpListComp:true}); } }); } } function isCommmentUrl(str){ var url_pattern = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-]*)?\??(?:[\-\+=&;%@\.\w]*)#?(?:[\.\!\/\\\w]*))?)/g; return url_pattern.test( str ); } function validateComment(_obj){ var promise = new Promise(function(resolve,reject){ var comment = _obj.commentText ? _obj.commentText : ''; var obj_comment = { fromname : (_obj.validNonLoggedData && _obj.validNonLoggedData.name) ? _obj.validNonLoggedData.name : globaluser.getFullName(), fromaddress : (_obj.validNonLoggedData && _obj.validNonLoggedData.email) ? _obj.validNonLoggedData.email : globaluser.getEmail(), userid : (typeof globaluser!="undefined" && globaluser!=null && globaluser.getUid()) ? globaluser.getUid() : (_obj.validNonLoggedIn ? 'qrst' : 'qrst'), location : (_obj.validNonLoggedData && _obj.validNonLoggedData.location) ? _obj.validNonLoggedData.location : globaluser.getCITY(), //imageUrl : globaluser.getThumb(), imageUrl : (typeof globaluser!="undefined" && globaluser!=null && globaluser.getThumb()) ? globaluser.getThumb() :'', loggedstatus : _obj.validNonLoggedIn ? 0 : 1, message : comment, roaltdetails : 1, ArticleID : _obj.msid, msid : _obj.msid, parentid : _obj.commentid ? _obj.commentid : 0, rootid : _obj.commentid ? _obj.commentid : 0, url : window.location.href, configid : 41083278, pcode : 'happytrips', // verifyuser } if(_obj.validNonLoggedIn){ obj_comment.verifyuser = 1; } $.ajax({ url : "/travel/validatecomment.cms", data: obj_comment, type : 'POST' }).done(function(data){ if(data == ''){ resolve('success'); }else{ resolve(data); } resolve(data); }).fail(function(err){ reject(err); }); }); return promise; } function getcommentsDataAPI(msid,commentcurrpage,sorttype){ //var url = "/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=CreationDate&order=asc&size=25&lastdeenid=123&after=true&pagenum=1&withReward=true" var apistr = ""; switch(sorttype){ case "oldest": apistr = "/travel/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=CreationDate&order=desc&size=25&lastdeenid=123&after=true&pagenum="+commentcurrpage+"&withReward=true"; break; case "agree": apistr = "/travel/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&commenttype=agree&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=AgreeCount&order=desc&size=25&lastdeenid=123&after=true&pagenum="+commentcurrpage+"&withReward=true"; break; case "disagree": apistr = "/travel/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&commenttype=disagree&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=DisagreeCount&order=desc&size=25&lastdeenid=123&after=true&pagenum="+commentcurrpage+"&withReward=true"; break; case "discussed": apistr = "/travel/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&commenttype=mostdiscussed&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=discussed&order=desc&size=25&lastdeenid=123&after=true&pagenum="+commentcurrpage+"&withReward=true"; break; case "newest" : apistr = "/travel/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=CreationDate&order=asc&size=25&lastdeenid=123&after=true&pagenum="+commentcurrpage+"&withReward=true"; break; default : apistr = "/travel/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=CreationDate&order=asc&size=25&lastdeenid=123&after=true&pagenum="+commentcurrpage+"&withReward=true"; break; } return apistr; } return { constants:{ _currentObj : false, appkey:'Travel', pcode:'happytrips', commentcurrpage:1 }, user:null, lsarray : [], lsarraydv : [], lsarrayfollow : [], lsarrayfollow : [], postComment : function(_obj){ if(_obj && _obj.msid){ var loginState='logout'; if(window.globaluser || _obj.validNonLoggedIn){ loginState='Login'; var comment = _obj.commentText ? _obj.commentText : ''; if($.trim(comment) !=""){ if($('#comment-section-'+_obj.msid+ ' .noresult_box ').is(":visible")){ $('#comment-section-'+_obj.msid+ ' .noresult_box ').remove();} if(isCommmentUrl(comment)){ if(_obj.reply){ if($('[data-plugin="comment-level-1"][comment-id="'+_obj.commentid+'"]').length>0){ if($('[data-plugin="comment-level-1"][comment-id="'+_obj.commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-1"][comment-id="'+_obj.commentid+'"]').find(".error").html("You can't post this review as it contains URL."); }else{ $('[data-plugin="comment-level-1"][comment-id="'+_obj.commentid+'"]').append("You can't post this review as it contains URL."); } }else if($('[data-plugin="comment-level-2"][comment-id="'+_obj.commentid_obj.commentid+'"]').length>0){ if($('[data-plugin="comment-level-2"][comment-id="'+_obj.commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-2"][comment-id="'+_obj.commentid+'"]').find(".error").html("You can't post this review as it contains URL."); }else{ $('[data-plugin="comment-level-2"][comment-id="'+_obj.commentid+'"]').append("You can't post this review as it contains URL."); } } }else{ // comment-section-+ if($('#comment-section-'+_obj.msid).children(".error").length > 0){ $('#comment-section-'+_obj.msid).children(".error").html("You can't post this review as it contains URL."); }else{ // $('#comment-section-'+msid+' [data-plugin="comment-level-1"]:first').before(justnowele) showErrorMsg("You can't post this review as it contains URL.") // $('#comment-section-'+_obj.msid+' [data-plugin="comment-error"]').html("You can't post this review as it contains URL."); // $('#comment-section-'+_obj.msid+' [data-plugin="comment-level-1"]:first').before("You can't post this review as it contains URL."); } } return false; } // _obj.commentText = comment; validateComment(_obj).then(function(response){ if(response){ var obj_comment = { fromname : (_obj.validNonLoggedData && _obj.validNonLoggedData.name) ? _obj.validNonLoggedData.name : globaluser.getFullName(), fromaddress : (_obj.validNonLoggedData && _obj.validNonLoggedData.email) ? _obj.validNonLoggedData.email : globaluser.getEmail(), // userid : globaluser.getUid(), //userid : (typeof globaluser!="undefined" && globaluser!=null && globaluser.getEmail()) ? globaluser.getEmail() : (_obj.validNonLoggedIn ? 'qrst' : 'qrst'), userid : (typeof globaluser!="undefined" && globaluser!=null && globaluser.getUid()) ? globaluser.getUid() : (_obj.validNonLoggedIn ? 'qrst' : 'qrst'), location : (_obj.validNonLoggedData && _obj.validNonLoggedData.location) ? _obj.validNonLoggedData.location : globaluser.getCITY(), imageUrl : (typeof globaluser!="undefined" && globaluser!=null && globaluser.getThumb()) ? globaluser.getThumb() :'', loggedstatus : _obj.validNonLoggedIn ? 0 : 1, message : comment, roaltdetails : 1, ArticleID : _obj.msid, msid : _obj.msid, parentid : _obj.commentid ? _obj.commentid : 0, rootid : _obj.commentid ? _obj.commentid : 0, url : window.location.href, configid : 41083278, pcode : 'happytrips', redirectionurl: window.location.href, processRedirectionUrl : false } if(_obj.validNonLoggedIn){ obj_comment.verifyuser = 1 } // hit post comment api // postro $.ajax({ url : "/travel/postro.cms", data: obj_comment, type : 'POST' }).done(function(data){ console.log(data); $('[data-plugin="travel-comment-post"]').removeClass('active'); var commentid = _obj.commentid; var msid = _obj.msid; var userImage = (typeof globaluser != 'undefined' && globaluser && globaluser.getThumb()) ? globaluser.getThumb() : 'http://static.toiimg.com/photo/29251859.cms'; var userName = (typeof globaluser != 'undefined' && globaluser && globaluser.getFullName()) ? globaluser.getFullName() : (_obj.validNonLoggedData && _obj.validNonLoggedData.name) ; if(data=='abusivelanguage'){ if(_obj.reply){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").html('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); }else{ $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').append('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } }else if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").html('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); }else{ $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').append('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } } }else{ // comment-section-+ if($('#comment-section-'+msid).children(".error").length > 0){ $('#comment-section-'+msid).children(".error").html('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); }else{ $('#comment-section-'+msid).children(".errornew").html('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } showErrorMsg('Abusive language'); $('[data-plugin="comment-textarea"]').val(""); $('[data-plugin="comment-input"]').val(""); $('[data-plugin="comment-input-remaining"]').text("3000") } return; } if(data=='duplicatecontent'){ if(_obj.reply){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").html('Duplicate Content'); }else{ $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').append('Duplicate Content'); } }else if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").html('Duplicate Content'); }else{ $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').append('Duplicate Content'); } } }else{ var containerDiv = $('[data-msid="'+msid+'"]'); if($('#comment-section-'+msid).children(".error").length > 0){ $('#comment-section-'+msid).children(".error").html('Duplicate Content'); }else{ showErrorMsg('Duplicate Content'); $('[data-plugin="comment-textarea"]').val(""); $('[data-plugin="comment-input"]').val(""); $('[data-plugin="comment-input-remaining"]').text("3000") } } return; } if(_obj.reply){ showSuccessMsg('Thank you for replying,Your Reply has been successfully submitted.'); }else{ showSuccessMsg('Thank you for commenting, Your comment has been successfully submitted.'); } if(_obj.commentText.length > 135){ if(_obj.reply){ var justnowele = '

'+userName+'Your CommentJust Now

'+_obj.commentText.substring(0,135)+'... Read More

'; }else{ var justnowele = '

'+userName+'Your CommentJust Now

'+_obj.commentText.substring(0,135)+'... Read More

'; } }else{ if(_obj.reply){ var justnowele = '

'+globaluser.getFullName()+'Your CommentJust Now

'+_obj.commentText+'

'; }else{ var justnowele = '

'+userName+'Your CommentJust Now

'+_obj.commentText+'

'; } } if(_obj.reply){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").remove(); } $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').append(justnowele); $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".userItemsCon").addClass("subcomment_box"); }else if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").length > 0){ $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").remove(); } $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').append(justnowele); $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".userItemsCon").addClass("subcomment_box"); } }else{ var containerDiv = $('[data-msid="'+msid+'"]'); if($('[data-plugin="comment-level-1"]:first').find(".error").length > 0){ $('[data-plugin="comment-level-1"]:first').find(".error").remove(); } if(containerDiv.find('[data-plugin="comment-level-1"]:first').length > 0){ // $('[data-plugin="comment-level-1"]:first').before(justnowele); $('#commentmodule'+msid+' [data-plugin="comment-level-1"]:first').before(justnowele); $('#comment-section-'+msid+' [data-plugin="comment-level-1"]:first').before(justnowele); $('[data-plugin="comment-level-1"]:first').prev().addClass("yourCommentPanel"); }else{ var containerDiv = $('[data-msid="'+msid+'"]'); containerDiv.find('[data-plugin="commentsdata"]').append(justnowele); } containerDiv.find('.noresult_box').hide(); } $('[data-plugin="comment-textarea"]').val(""); $('[data-plugin="comment-input"]').val(""); $('[data-plugin="comment-input-remaining"]').text("3000") var platform = 'WEB'; if(window.matchMedia("(max-width: 768px)").matches) { platform = 'WAP'; } var temp = tempname === 'photostory' ? 'Photostory' : 'Articleshow'; ga('send', 'event', temp + '_comments_' + platform, 'Submit', window.location.href , '' , {'nonInteraction': 1}); if(_obj.callback){ _obj.callback(); } // alert('comment posted'); }).fail(function(err){ // alert('error occured') }) } }).catch(function(err){ // alert('some error while posting comment'); console.log("err:",err); }); // alert('hitting api to post comment'); } }else{ _obj.validNonLoggedData = {}; _obj.validNonLoggedIn = false; if(_obj.reply){ var inputName = _obj._ref.parents('[data-plugin="reply-'+_obj.commentid+'"]').find('[data-plugin="get-user-name"]').val(); var inputEmail = _obj._ref.parents('[data-plugin="reply-'+_obj.commentid+'"]').find('[data-plugin="get-user-email"]').val(); var inputLocation = _obj._ref.parents('[data-plugin="reply-'+_obj.commentid+'"]').find('[data-plugin="get-user-location"]').val(); var inputCapcha = _obj._ref.parents('[data-plugin="reply-'+_obj.commentid+'"]').find('[data-plugin="get-user-captcha"]').val(); var setCaptchVal = _obj._ref.parents('[data-plugin="reply-'+_obj.commentid+'"]').find('[data-plugin="set-user-captcha"]').text(); }else{ var inputName = $('#comment-section-'+_obj.msid+' [data-plugin="get-user-name"]').val(); var inputEmail = $('#comment-section-'+_obj.msid+' [data-plugin="get-user-email"]').val(); var inputLocation = $('#comment-section-'+_obj.msid+' [data-plugin="get-user-location"]').val(); var inputCapcha = $('#comment-section-'+_obj.msid+' [data-plugin="get-user-captcha"]').val(); var setCaptchVal = $('#comment-section-'+_obj.msid+' [data-plugin="set-user-captcha"]').text(); } if(!inputName || !inputEmail || !inputLocation || !inputCapcha){ if(!inputName){ alert('Please enter your name.'); }else if(!inputEmail){ alert('Please enter your email address.'); }else if(!inputLocation){ alert('Please enter your location.'); } else if(!inputCapcha){ alert('Please enter captcha value.'); } return; }else{ if(!eval(setCaptchVal + "=" + inputCapcha)){ alert('Please enter a valid captcha value.'); return; } // require('tiljs/is') _obj.validNonLoggedIn = true; _obj.validNonLoggedData = { name:inputName, email:inputEmail, location:inputLocation } travelcomments_module.postComment(_obj); } // ask to login // require('tiljs/login').login(function(user){ // if(user){ // // alert('user found') // console.log('user=>'+user); // travelcomments_module.postComment(_obj); // } // }); } } }, loadCommentsOnLayerPer : function(msid){ ssoid = (typeof ssoid!='undefined' && ssoid!=null) ? ssoid : ''; $.ajax({ url : "http://myt.jeetwin-gaming.com/mytimes/getFeed/Activity?msid="+msid+"&appkey=Travel&sortcriteria=CreationDate&order=asc&size=1&pagenum=1&showMyComment=true&uuId="+ssoid, cache: true, success: function(data) { if(data.length > 0){ makeCommentsObj(JSON.stringify(data),msid); $("#commentmodule"+msid).find('[data-plugin="moviedetailcomments"] .wht_seeall').show(); }else{ $("#commentmodule"+msid).find('[data-plugin="moviedetailcomments"] .wht_seeall').hide(); } } }); if(msid && $('#comment-section-'+msid) && $('#comment-section-'+msid+' [data-plugin="set-user-captcha"]')){ $('#comment-section-'+msid+' [data-plugin="set-user-captcha"]').text(Math.floor((Math.random()*10)) +"+" +Math.floor((Math.random()*10)) +"=") } }, commentUpVote : function(id){ //var url = "/ratecomment_new.cms?opinionid="+id+"&typeid=100&rateid=0"; var url = 'http://myt.jeetwin-gaming.com/mytimes/addActivity?appKey=Travel&parentCommentId='+id+'&activityType=Agreed&baseEntityType=ARTICLE&objectType=A&url='+window.location.href; var ajaxresult = ajaxGet(url); ajaxresult.done(function(data){ }); ajaxresult.always(function(data){ travelcomments_module.lsarray.push(id); localStorage.setItem('upvotedids',JSON.stringify(travelcomments_module.lsarray)); $('[data-plugin="up-vote"][comment-id="'+id+'"]').attr('upvoted',true); $('[data-plugin="down-vote"][comment-id="'+id+'"]').attr('upvoted',true); $('[data-plugin="flag"][comment-id="'+id+'"]').attr('upvoted',true); }); }, commentDownVote : function(id){ //var url = "/ratecomment_new.cms?opinionid="+id+"&typeid=101&rateid=0"; var url = 'http://myt.jeetwin-gaming.com/mytimes/addActivity?appKey=Travel&parentCommentId='+id+'&activityType=Disagreed&baseEntityType=ARTICLE&objectType=A&url='+window.location.href; var ajaxresult = ajaxGet(url); ajaxresult.done(function(data){ }); ajaxresult.always(function(data){ travelcomments_module.lsarraydv.push(id); localStorage.setItem('downvotedids',JSON.stringify(travelcomments_module.lsarraydv)); $('[data-plugin="up-vote"][comment-id="'+id+'"]').attr('downvoted',true); $('[data-plugin="down-vote"][comment-id="'+id+'"]').attr('downvoted',true); $('[data-plugin="flag"][comment-id="'+id+'"]').attr('downvoted',true); }); }, commentFlag : function(user,id,msid,lengthval,showalert){ var url = '/offensive/mark?ofusername='+user.getFullName()+'&ofreason=NONE&ofcommenteroid='+id+'&ofcommenthostid=83&ofcommentchannelid=-2128958273&ofcommentid='+msid+'&ofuserisloggedin=1&ofuserssoid='+user.getEmail()+'&ofuseremail='+user.getEmail(); var lengthva = lengthval; var alertstat = showalert; var ajaxresult = ajaxGet(url); ajaxresult.done(function(data){ }); ajaxresult.always(function(data){ if(lengthva > 0){ if(alertstat){ $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").show(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt").show(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt .redtxt:last").html("Please enter a reason!!"); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt .redtxt:last").show(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".msg_txt").hide(); } else{ if(typeof lsarrayf != 'undefined'){ lsarrayf.push(id); localStorage.setItem('flaggedids',JSON.stringify(lsarrayf)); } $('[data-plugin="up-vote"][comment-id="'+id+'"]').attr('flagged',true); $('[data-plugin="down-vote"][comment-id="'+id+'"]').attr('flagged',true); $('[data-plugin="flag"][comment-id="'+id+'"]').attr('flagged',true); $('[data-plugin="flag"][comment-id="'+id+'"]').text('Flagged'); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt").hide(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".msg_txt").show(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt .redtxt:last").hide(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").show(); } }else{ $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").show(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt").show(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt .redtxt:last").html("Please select a reason!!"); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".default_txt .redtxt:last").show(); $('[data-plugin="flag"][comment-id="'+id+'"]').next(".flag_box").find(".msg_txt").hide(); } }); }, followFlag : function(user,id){ var url = 'http://myt.jeetwin-gaming.com/mytimes/followuser?callback=jQuery1110043275776963275825_1512042757854&userId='+user.getId()+'&fromMyTimes=true'; var ajaxresult = ajaxGet(url); ajaxresult.done(function(data){ }); ajaxresult.always(function(data){ lsarrayfollow.push(id); localStorage.setItem('followedids',JSON.stringify(lsarrayfollow)); $('[data-plugin="user-follow"][followid="'+id+'"]').addClass('active'); $('[data-plugin="user-follow"][followid="'+id+'"]').text('Followed'); }); }, postcomment : function(user,rating,commentid,commenttxt,reply,msid){ if($.trim(commenttxt) !=""){ var commentObj = $("#commentmodule"+msid) var as_comments={}; as_comments.fromname = user.getFullName(); as_comments.fromaddress = user.getEmail(); as_comments.userid = user.getUid(); as_comments.location = user.getCITY(); as_comments.imageUrl = user.getThumb(); as_comments.loggedstatus = 1; as_comments.message = commenttxt; as_comments.roaltdetails = 1; as_comments.articleid = msid; as_comments.msid = msid; as_comments.parentid = commentid; as_comments.rootid = commentid; as_comments.url = window.location.href; as_comments.configid = 41083278; as_comments.medium = 'WEB'; as_comments.redirectionurl = window.location.href if(rating>=1){ as_comments.urs = rating * 2; } as_comments.rotype = 0; as_comments.pcode = "TOI"; $.ajax({ url : "/toiignorevp/postro2.cms", data: as_comments, type : 'POST' }).done(function(data){ if(data=='abusivelanguage'){ if(reply){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").length > 0) { $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").html('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } else { $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').append('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } } else if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").length > 0) { $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").html('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } else { $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').append('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } } } else{ if($(commentObj).find('[data-plugin="commentsdata"]').children(".error").length > 0) { $(commentObj).find('[data-plugin="commentsdata"]').children(".error").html('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } else { $(commentObj).find('[data-plugin="comment-level-1"]:first').before('Refrain from posting comments that are obscene, defamatory or inflammatory, and do not indulge in personal attacks, name calling or inciting hatred against any community. Help us delete comments that do not follow these guidelines by marking them offensive. Lets work together to keep the conversation civil.'); } } return; } if(data=='duplicatecontent'){ if(reply){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").length > 0) { $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").html('Duplicate Content'); } else { $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').append('Duplicate Content'); } } else if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").length > 0) { $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").html('Duplicate Content'); } else { $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').append('Duplicate Content'); } } } else{ if($(commentObj).find('[data-plugin="commentsdata"]').children(".error").length > 0) { $(commentObj).find('[data-plugin="commentsdata"]').children(".error").html('Duplicate Content'); } else { $(commentObj).find('[data-plugin="comment-level-1"]:first').before('Duplicate Content'); } } return; } if(reply){ commonlibmethods.popupshow('Thank you for replying','Your Reply has been successfully submitted'); } else { commonlibmethods.popupshow('Thank you for commenting this article','Your Comment has been successfully submitted'); } $('.characterlimit').html('3000 characters left'); if(commenttxt.length > 135) { if(reply) { var justnowele = '

'+user.getFullName()+'Your CommentJust Now

'+commenttxt.substring(0,135)+'... Read More

'; } else { var justnowele = '

'+user.getFullName()+'Your CommentJust Now

'+commenttxt.substring(0,135)+'... Read More

'; } } else { if(reply) { var justnowele = '

'+user.getFullName()+'Your CommentJust Now

'+commenttxt+'

'; } else { var justnowele = '

'+user.getFullName()+'Your CommentJust Now

'+commenttxt+'

'; } } if(reply){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").length > 0) { $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".error").remove(); } $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').append(justnowele); $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').addClass("yourCommentPanel"); $('[data-plugin="comment-level-1"][comment-id="'+commentid+'"]').find(".userItemsCon").addClass("subcomment_box"); } else if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').length>0){ if($('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").length > 0) { $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".error").remove(); } $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').append(justnowele); $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').addClass("yourCommentPanel"); $('[data-plugin="comment-level-2"][comment-id="'+commentid+'"]').find(".userItemsCon").addClass("subcomment_box"); } } else{ if($(commentObj).find('[data-plugin="comment-level-1"]:first').find(".error").length > 0) { $(commentObj).find('[data-plugin="comment-level-1"]:first').find(".error").remove(); } if($(commentObj).find('[data-plugin="comment-level-1"]:first').length > 0) { $(commentObj).find('[data-plugin="comment-level-1"]:first').before(justnowele); $(commentObj).find('[data-plugin="comment-level-1"]:first').prev().addClass("yourCommentPanel"); } else { $(commentObj).find('[data-plugin="commentsdata"]:first').append(justnowele); $(commentObj).find('[data-plugin="commentsdata"]:first').addClass("yourCommentPanel"); } } $(commentObj).find('[data-plugin="comment-textarea"]').val("") }); } }, getCommentCount : function(msid) { var cmntcallapi = ""; cmntcallapi = $.ajax({ type: "GET", url: "http://myt.jeetwin-gaming.com/mytimes/sharedEntity?msids=" + msid + "&appKey=Travel", dataType: "jsonp", cache: false }); cmntcallapi.done(function(data) { data = data && data.length > 0 ? data : [{A_U_I : msid}]; $.each(data, function(i) { var _commentLabelObj = $('[data-cmntmsid=' + data[i].A_U_I + ']').find("[data-val='cmnt_block_shw'] .cmnt_cnt_bbl"); var _commentTextObj = $('[data-cmntmsid=' + data[i].A_U_I + ']').find('[data-plugin="commenttext"]'); var _commentCountObj = $("#comment-section-" + data[i].A_U_I + " [data-plugin='comment-count-new']"); var _commentNocommentObj = $('[data-cmntmsid=' + data[i].A_U_I + ']').find("[data-id='userreviewslayer']"); var _commentAllcommentObj = $('[data-cmntmsid=' + data[i].A_U_I + ']').find(".readcmt"); var _cmt_c = data[i].cmt_c ? data[i].cmt_c : 0; if(_cmt_c === 0){ _commentNocommentObj.show(); } else{ _commentAllcommentObj.show(); } _commentLabelObj.text("("+_cmt_c+")"); _commentCountObj.text(_cmt_c); _commentTextObj.text(_cmt_c); }) }); }, lazyloadCommentsOnDemand : function(msid,commentcurrpage,sorttype){ var commentsDataObj = $('#comment-section-'+msid+ ' [data-plugin="commentsdata"]'); commentsDataObj.html(''); $('#comment-section-'+msid+ ' .moreloader').show(); var url = getcommentsDataAPI(msid,1,sorttype) // var url = "/commentsdata.cms?msid="+msid+"&curpg=1&pcode="+travelcomments_module.constants.pcode+"&appkey="+travelcomments_module.constants.appkey+"&sortcriteria=CreationDate&order=asc&size=25&lastdeenid=123&after=true&pagenum=1&withReward=true" var ajaxresult = ajaxGet(url); ajaxresult.done(function(data){ $('#comment-section-'+msid+ ' .moreloader').hide(); var noResultHtml = '
Sorry! There are no comments yet.
'; if(data==""){ commentsDataObj.html(noResultHtml); }else{ if(JSON.parse(data).length > 0){ var totalcomments = JSON.parse(data)[0].totalcount; var commentspages = Math.ceil(totalcomments/25); renderCommentList(data,msid) }else{ commentsDataObj.html(noResultHtml); } if(ssoid != undefined && ssoid !="" && globaluser != undefined && globaluser !=""){ $('#comment-section-'+msid+ ' [data-plugin="comment-user-follow_wrapper"]').show(); }else{ $('#comment-section-'+msid+ ' [data-plugin="comment-user-follow_wrapper"]').hide(); } setUpvoteAttr(); } }); } } }()) require(["tiljs/login", "tiljs/event"], function(login,event) { event.subscribe("user.status", function(user) { // alert('user status changed'); if(user){ window.globaluser = user; }else{ // travelcomments_module.user = null; window.globaluser = null; } console.log("global user set"); }); }); $(document).ready(function() { var lastScrollTop = 0; var ui_mod = false; if(typeof tempname !="undefined" && (tempname == "photostory" || tempname=="ttarticleshow")){ var _msid = ''; if(tempname == "photostory"){ _msid = msid; }else if(tempname=="ttarticleshow"){ _msid = msidnew; } travelcomments_module.loadCommentsOnLayerPer(_msid); travelcomments_module.getCommentCount(_msid); } // alert('initiate comments module'); $("body").on("click", '[data-plugin="invokecomments"]', function(e){ var _this = $(this); var platform = 'WEB'; if(window.matchMedia("(max-width: 768px)").matches) { platform = 'WAP'; } var temp = tempname === 'photostory' ? 'Photostory' : 'Articleshow'; ga('send', 'event', temp + '_comments_' + platform, 'click', window.location.href , '' , {'nonInteraction': 1}); travelcomments_module.constants._currentObj = _this; var _label = (_this.hasClass("readcmt")?"ReadAll-Comments":"Add-Comment"); var _commentObj = _this.closest(".travel_comment"); var msid = _commentObj.data("cmntmsid"); $('#comment-section-' + _commentObj.data("cmntmsid")).addClass('slideleft'); $('[data-plugin="commentoverlay"]').addClass('cmt_slide_overlay'); $('body').addClass('bodyhidden'); if (_commentObj.data("cmntstatus")) { _commentObj.data('cmntstatus', false); } if (_this.attr('id') === "cmnt_new") { setTimeout(function() { $('#comment-section-' + _commentObj.data("cmntmsid") + ' [data-plugin="comment-input"]').focus(); }, 10); } else { // $(window).scrollTop($("#comment-section-" + _commentObj.data('cmntmsid')).offset().top - 100); setTimeout(function() { $('#comment-section-' + _commentObj.data("cmntmsid") + ' [data-plugin="comment-input"]').focus(); }, 10); } travelcomments_module.getCommentCount(msid); var commentcurrpage = 1; var sorttype = 'newest'; travelcomments_module.lazyloadCommentsOnDemand(msid,commentcurrpage,sorttype); // var platform = 'WEB'; // if(window.matchMedia("(max-width: 768px)").matches) { // platform = 'WAP'; // } // var template = $('.travel_comment').getAttribute('data-template'); // if(_label == "ReadAll-Comments"){ // ga("send", "event", +template'_readcomment|WEB','click'); // }else if(_label == "Add-Comment"){ // ga("send", "event", +template'_comment|WEB','click'); // } }); $("body").on("click", '[data-plugin="closecomments"]', function(e){ e.preventDefault(); var Obj = $(this).closest(".comment-section"); var msid = Obj.data('csmsid'); $('#comment-section-' + msid).removeClass('slideleft'); $('[data-plugin="commentoverlay"]').removeClass('cmt_slide_overlay'); $("body").removeClass('bodyhidden'); }); $("body").on("click", ".readmorecmt", function(e){ $(this).parents(".readmorecmt").hide(); $(this).parents(".readmorecmt").siblings(".readlesscmt").fadeIn(300); }); $("body").on("click", ".readlesscmt", function(e){ $(this).parents(".readlesscmt").hide(); $(this).parents(".readlesscmt").siblings(".readmorecmt").fadeIn(300); }); $("body").on('click','[data-plugin="travel-comment-post"]',function(){ var _thisObj = $(this); if(!$(this).hasClass('active')){ return false; } var commentid = _thisObj.attr('comment-id'); var msid = _thisObj.attr('data-msid'); var comment = _thisObj.parents('[data-plugin="comment-form-login"]').siblings('[data-plugin="comment-textarea"]').val(); var _obj = { msid:msid, // update this msid after work, commentid:commentid, commentText:comment, reply:false }; travelcomments_module.postComment(_obj); // var contentmsid = (tempname=="recipeshow") ? recipemsid : window.msid; }); $("body").on('change','#travel_comment_sort',function(){ // travelcomments_module.constants.commentcurrpage = 1; var commentcurrpage = 1; var _msid = $(this).attr('data-csmsid'); travelcomments_module.lazyloadCommentsOnDemand(_msid,commentcurrpage,$(this).val()); }) $("body").on('click','[data-plugin="flag"]',function(){ var _thisObj = $(this); $(".flag_box").hide(); var flagid = _thisObj.attr('comment-id'); if(_thisObj.attr('upvoted')=="true"){ $('.rerror[comment-id="'+flagid+'"]').text('You cannot agree and mark the same comment Offensive'); $('.rerror[comment-id="'+flagid+'"]').show(); return; } if(_thisObj.attr('downvoted')=="true"){ $('.rerror[comment-id="'+flagid+'"]').text('You cannot disagree and flag the same comment'); $('.rerror[comment-id="'+flagid+'"]').show(); return; } if(_thisObj.attr('flagged')=="true"){ $('.rerror[comment-id="'+flagid+'"]').text('You have already flagged this comment'); $('.rerror[comment-id="'+flagid+'"]').show(); return; } _thisObj.siblings(".flag_box").show(); }); $("body").on('click','.flagbox_close',function(){ $(".flag_box").hide(); }); $("body").on('click','[data-plugin="flag-report"]',function(){ var _thisObj = $(this); _thisObj.parents(".flag_boxIn").find("[data-plugin='comment-flag-error']").hide(); var _textBoxObj = _thisObj.parents(".flag_boxIn").find("textarea"); var msid = _thisObj.parents("[data-cmntmsid]").attr('data-cmntmsid'); var flagid =_thisObj.parents("[comment-id]").attr('comment-id'); var reason = null; reason = _thisObj.parents(".flag_boxIn").find("input:checked").val(); if(!reason){ _thisObj.parents(".flag_boxIn").find("[data-plugin='comment-flag-error']").show(); }else{ if (reason == "Others") { var reasonVal = _textBoxObj.val(); var showalert = (_textBoxObj.is(":visible") && ((_textBoxObj.val() == "") || (_textBoxObj.val() == "Write a reason for reporting..."))) ? true : false if (showalert) { _thisObj.parents(".flag_boxIn").find("[data-plugin='comment-flag-error']").show(); return; } reason = "Others: " + reasonVal; } if (reason) { if(window.globaluser){ _thisObj.parents(".flag_boxIn").find("[data-plugin='comment-flag-error']").hide(); travelcomments_module.commentFlag(window.globaluser,flagid,msid,_thisObj.parents(".flag_boxIn").find("input:checked").length,); }else{ // ask to login require('tiljs/login').login(function(user){ if(user){ window.globaluser = user; travelcomments_module.commentFlag(window.globaluser,flagid,msid,_thisObj.parents(".flag_boxIn").find("input:checked").length,); } }) } } } }); $("body").on('click','input[name="rd"]',function(e){ var _thisObj = $(this); var _thisParentLiObj = _thisObj.parents("li"); var _thisFlagBoxObj = _thisObj.parents(".flag_boxIn"); var _thisTextArea = _thisParentLiObj.siblings('li[class="textarea"]').find("textarea"); (_thisParentLiObj.attr("class") == "others") ? _thisTextArea.show() : _thisTextArea.hide(); if(_thisParentLiObj.attr("class") != "others"){ _thisFlagBoxObj.find(".redtxt:last").hide(); } }); $("body").on('click','[data-plugin="reply"]',function(){ var _thisObj = $(this); _thisObj.addClass('ractive'); var commentid = _thisObj.attr('comment-id'); $('.replybox').hide(); $(this).parents(".usercommentItems ").find('[data-plugin="reply-'+commentid+'"]').show(); //$('[data-plugin="reply-'+commentid+'"]').show(); }); $("body").on('click','[data-plugin="reply-cancel"]',function(){ $('.replybox').hide(); // $(".error").remove(); $('.replybox textarea').val(''); }); $("body").on('click','[data-plugin="reply-submit"]',function(){ var _thisObj = $(this); var commentid = _thisObj.attr('comment-id'); var contentmsid = _thisObj.parents("[data-cmntmsid]").attr('data-cmntmsid'); // var comment = $('[data-plugin="reply-'+commentid+'"] textarea').val().trim(); var comment = _thisObj.parents('[data-plugin="reply-'+commentid+'"]').find('textarea').val() if(comment!='' && comment!='Write your comment here...'){ var _obj = { msid:contentmsid, // update this msid after work, commentid:commentid, commentText:comment, reply:true, _ref:_thisObj, callback:function(){ //alert('replied successfully') } }; if(window.globaluser){ // $('[data-plugin="reply-'+commentid+'"]').find('[data-plugin="reply-cancel"]').click(); travelcomments_module.postComment(_obj); setTimeout(function(){ $('[data-plugin="reply-'+commentid+'"]').find('[data-plugin="reply-cancel"]')[0].click(); },2000) }else{ require('tiljs/login').login(function(user){ travelcomments_module.postComment(_obj); setTimeout(function(){ $('[data-plugin="reply-'+commentid+'"]').find('[data-plugin="reply-cancel"]')[0].click(); },2000) }); } } }); $("body").on('click','[data-plugin="up-vote"]',function(){ var _thisObj = $(this); var commentid = _thisObj.attr('comment-id'); if(_thisObj.attr('downvoted')=="true"){ $('.rerror[comment-id="'+commentid+'"]').text('You cannot agree and disagree with the same comment'); $('.rerror[comment-id="'+commentid+'"]').show(); return; } if(_thisObj.attr('upvoted')=="true"){ $('.rerror[comment-id="'+commentid+'"]').text('You have already agreed with this comment'); $('.rerror[comment-id="'+commentid+'"]').show(); return; } // _thisObj.prev().text(parseInt(_thisObj.prev().text())+1); $('[data-plugin="up-vote"][comment-id="'+commentid+'"]').prev().text('1'); travelcomments_module.commentUpVote(commentid); }); $("body").on('click','[data-plugin="down-vote"]',function(){ var _thisObj = $(this); var commentid = _thisObj.attr('comment-id'); if(_thisObj.attr('upvoted')=="true"){ $('.rerror[comment-id="'+commentid+'"]').text('You cannot agree and disagree with the same comment'); $('.rerror[comment-id="'+commentid+'"]').show(); return; } if(_thisObj.attr('downvoted')=="true"){ $('.rerror[comment-id="'+commentid+'"]').text('You have already disagreed with this comment'); $('.rerror[comment-id="'+commentid+'"]').show(); return; } // _thisObj.prev().text(parseInt(_thisObj.prev().text())+1); $('[data-plugin="down-vote"][comment-id="'+commentid+'"]').prev().text('1'); travelcomments_module.commentDownVote(commentid); }); $("body").on('keyup','[data-plugin="comment-textarea"]',function(){ var _thisObj = $(this); var msid = _thisObj.parents("[data-cmntmsid]").attr('data-cmntmsid'); if($(this).attr('data-replybox') == "yes"){ var postBtn = _thisObj.parents('.replybox ').find('[data-plugin="reply-submit"]'); }else{ var postBtn = $('#comment-section-'+msid+' [data-plugin="travel-comment-post"]') } if($(this).val() && $(this).val()!=''){ if(postBtn && !postBtn.hasClass('active')){ postBtn.addClass('active'); } // comment-section-80881929 $('#comment-section-'+msid+' [data-plugin="obscenecmt"]').show(); //_thisObj.parents('[data-plugin="obscenecmt"]').show(); // data-plugin="obscenecmt" }else{ if(postBtn && postBtn.hasClass('active')){ postBtn.removeClass('active'); } } }); $("body").on('click','[data-plugin="comment-google-post"], [data-plugin="comment-facebook-post"], [data-plugin="comment-email-post"]',function(){ var _thisObj = $(this); var msid = _thisObj.parents("[data-cmntmsid]").attr('data-cmntmsid'); if($(this).attr('data-replybox') == "yes"){ var commentId = $(this).attr('comment-id'); var postBtnActive = _thisObj.parents("[data-plugin='reply-"+commentId+"']").find('[data-plugin="reply-submit"]').hasClass('active') }else{ var postBtnActive = $('#comment-section-'+msid+' [data-plugin="travel-comment-post"]').hasClass('active') } if(!postBtnActive){ alert('You cannot post this comment as it is a blank comment'); return; }else{ var loginType = _thisObj.attr('data-plugin'); var callback = function(user){ window.globaluser = user; var commentid = _thisObj.attr('comment-id'); var comment = _thisObj.parents('[data-plugin="comment-form-login"]').siblings('[data-plugin="comment-textarea"]').val(); var _obj = { msid:msid, // update this msid after work, commentid:commentid, commentText:comment, reply:(_thisObj.attr('data-replybox') == "yes") ? true : false }; travelcomments_module.postComment(_obj); } if(loginType == "comment-facebook-post"){ require('tiljs/login').loginWithFacebook(callback); } else if(loginType == "comment-google-post"){ require('tiljs/login').loginWithGoogle(callback); }else if(loginType == "comment-email-post"){ require('tiljs/login').login(callback); } } }) $(window).on("scroll", function() { // if(!ui_mod){ // require(["tiljs/ui"],function(ui){ // ui_mod = ui; // }) // } // if(ui_mod){ // var st = $(this).scrollTop(); // // Down scroll // var status = (st > lastScrollTop) ? true : false; // var commentbox = $('.travel_comment'); // $.each(commentbox,function(index,elm){ // if(ui_mod.inView(elm) && elm.getAttribute('gasent') != "true" && elm.style.display != 'none'){ // elm.setAttribute('gasent', true); // vat tName = elm.getAttribute('data-template') // ga('send', 'event', tName+'_readcomment|WEB','view'); // ga('send', 'event', tName+'_comment|WEB','view'); // } // }) // } var commentbox = $('.travel_comment'); // $.each(commentbox,function(index,elem){ // if ($(window).scrollTop() + window.innerHeight >= $(elem).offset().top + $(elem).height() && elem.getAttribute("gasent") != "true") { // var platform = 'WEB'; // if(window.matchMedia("(max-width: 768px)").matches) { // platform = 'WAP'; // } // if(ga != null && ga != undefined) // { // elem.setAttribute("gasent", true); // var tName = elem.getAttribute('data-template') // ga("send", "event", tName+'_readcomment|'+platform,'view'); // ga("send", "event", tName+'_comment|'+platform,'view'); // } // } // }) }) }) // alert('comment js added');