// actions : ac - add comment, function postComment() { $('#cmt_message').html(''); var cmt_text = $.trim($('#comment_text').val()); var cmt_cid = $('#cmt_content_id').val(); //var cmt_ctid = $('#cmt_contype_id').val(); var cmt_ctname = $('#cmt_contype_name').val(); var cmt_headline = $('#cmt_headline').val(); var cmt_guid = $('#cmt_guid').val(); var cmt_name = $.trim($('#comment_name').val()); var cmt_email = $.trim($('#comment_email').val()); var loggedstatus = 0; var userid = 'qrst'; var pick = ''; if(cmt_cid == '' || (isNaN(parseInt(cmt_cid)) && cmt_cid!='budget')) { $('#cmt_message').html('Problem capturing comments. Please try after some time.'); $('#cmt_message').attr('class', 'red-error'); return false; } else { $('#cmt_message').attr('class', 'blank-error'); } if(cmt_text == '' || cmt_text=='Your comment') { $('#cmt_message').html('Please enter your comment.'); $('#cmt_message').attr('class', 'red-error'); $('#comment_text').focus(); return false; } else { $('#cmt_message').attr('class', 'blank-error'); } if(_isLogged == "" || _isLogged == null) { if(cmt_name == '' || cmt_name == 'Name') { $('#txt_message').html('Please enter your name.'); $('#txt_message').attr('class', 'red-error'); $('#comment_name').focus(); return false; } else { $('#txt_message').attr('class', 'blank-error'); $('#txt_message').html('Will be displayed'); } if(cmt_email == '' || cmt_email == 'Email') { $('#email_message').html('Please enter your email address.'); $('#email_message').attr('class', 'red-error'); $('#comment_email').focus(); return false; } else { $('#email_message').attr('class', 'blank-error'); $('#email_message').html('Will not be displayed'); } if(!isValidEmail(cmt_email)) { $('#email_message').html('Please enter valid email address.'); $('#email_message').attr('class', 'red-error'); $('#comment_email').focus(); return false; } else { $('#email_message').attr('class', 'blank-error'); $('#email_message').html('Will not be displayed'); } if(document.getElementById("mathans1").innerHTML!=document.getElementById("mathuserans1").value) { $('#sec_message').html('Please enter correct answer.'); $('#sec_message').attr('class', 'red-error'); $('#mathuserans1').focus(); return false; } else { $('#sec_message').attr('class', 'blank-error'); $('#sec_message').html('Please answer this simple math question.'); } } else { cmt_name = _loginUsername; cmt_email = _loginEmail; userid = _isLogged; loggedstatus = 1; } if(_loginImage != '' || _loginImage != null) { pick = _loginImage; } if(cmt_name.toLowerCase().indexOf('tanviahuja dotcom') != -1 || cmt_name.toLowerCase().indexOf('dotcom') != -1 || cmt_name.toLowerCase().indexOf('tanviahuja') != -1 || cmt_name.toLowerCase().indexOf('.com') != -1 || cmt_name.toLowerCase().indexOf('tanvi ahuja') != -1 || cmt_name.toLowerCase().indexOf('dot com') != -1 || cmt_text.toLowerCase().indexOf('tanvi ahuja') != -1 || cmt_text.toLowerCase().indexOf('tanviahuja') != -1 || cmt_text.toLowerCase().indexOf('dot com') != -1) { $('#comment_text').val(''); $('#postcomment').hide(); $('#comment-thanks').show(); return true; } $('#cmt_final_fromname').val(cmt_name); $('#cmt_final_fromaddress').val(cmt_email); $('#cmt_final_location').val(''); $('#cmt_final_message').val(cmt_text); $('#cmt_final_roaltdetails').val(1); $('#cmt_final_extid').val(cmt_cid); $('#cmt_final_userid').val(userid); $('#cmt_final_rchid').val('2147477980'); $('#cmt_final_parentid').val(0); $('#cmt_final_rootid').val(0); $('#cmt_final_aparentid').val(0); $('#cmt_final_loggedstatus').val(loggedstatus); $('#cmt_final_pick').val(pick); $('#cmt_final_article_headline').val(cmt_headline); $('#cmt_final_article_url').val(cmt_guid); $('#cmt_final_article_type').val(cmt_ctname); $('#cmt_message').html(' '); $('#txt_message').html('Will be displayed'); $('#email_message').html('Will not be displayed'); $('#sec_message').html('Please answer this simple math question.'); $('#cmt_final_submit').submit(); // update comment count //updateCommentCount(cmt_cid, cmt_ctid); $('#comment_text').val(''); $('#postcomment').hide(); $('#comment-thanks').show(); return true; } function postReply(event) { var id = event.data.id; var cmt_text = $.trim($('#reply_frm_'+id+' #reply_text').val()); var cmt_pid = $('#cmt_pid_'+id).val(); var cmt_gpid = $('#cmt_gpid_'+id).val(); var cmt_apid = $('#cmt_apid_'+id).val(); var cmt_cid = $('#cmt_content_id').val(); //var cmt_ctid = $('#cmt_contype_id').val(); var cmt_ctname = $('#cmt_contype_name').val(); var cmt_headline = $('#cmt_headline').val(); var cmt_guid = $('#cmt_guid').val(); var cmt_name = $.trim($('#reply_frm_'+id+ ' #reply_name').val()); var cmt_email = $.trim($('#reply_frm_'+id+ ' #reply_email').val()); var loggedstatus = 0; var userid = 'qrst'; var pick = ''; if(cmt_cid == '' || isNaN(parseInt(cmt_cid))) { $('#reply_frm_'+id+ ' #reply_message').html('Problem capturing reply. Please try after some time.'); $('#reply_frm_'+id+ ' #reply_message').attr('class', 'red-error'); } if(cmt_text == '' || cmt_text == 'Your reply') { $('#reply_frm_'+id+ ' #reply_cmt_message').html('Please enter reply.'); $('#reply_frm_'+id+ ' #reply_cmt_message').attr('class', 'red-error'); $('#reply_frm_'+id+' #reply_text').focus(); return false; } else { $('#reply_frm_'+id+ ' #reply_cmt_message').html(' '); $('#reply_frm_'+id+ ' #reply_cmt_message').attr('class', 'blank-error'); } if(_isLogged == "" || _isLogged == null) { if(cmt_name == '' || cmt_name == 'Name') { $('#reply_frm_'+id+ ' #reply_txt_message').html('Please enter name.'); $('#reply_frm_'+id+ ' #reply_txt_message').attr('class', 'red-error'); $('#reply_frm_'+id+ ' #reply_name').focus(); return false; } else { $('#reply_frm_'+id+ ' #reply_txt_message').attr('class', 'blank-error'); $('#reply_frm_'+id+ ' #reply_txt_message').html('Will be displayed'); } if(cmt_email == '' || cmt_email == 'Email') { $('#reply_frm_'+id+ ' #reply_email_message').html('Please enter email.'); $('#reply_frm_'+id+ ' #reply_email_message').attr('class', 'red-error'); $('#reply_frm_'+id+ ' #reply_email').focus(); return false; } else { $('#reply_frm_'+id+ ' #reply_email_message').attr('class', 'blank-error'); $('#reply_frm_'+id+ ' #reply_email_message').html('Will not be displayed'); } if(!isValidEmail(cmt_email)) { $('#reply_frm_'+id+ ' #reply_email_message').html('Please enter valid email.'); $('#reply_frm_'+id+ ' #reply_email_message').attr('class', 'red-error'); $('#reply_frm_'+id+ ' #reply_email').focus(); return false; } else { $('#reply_frm_'+id+ ' #reply_email_message').attr('class', 'blank-error'); $('#reply_frm_'+id+ ' #reply_email_message').html('Will not be displayed'); } if($('#reply_frm_'+id+ ' #mathans2').html() != $('#reply_frm_'+id+ ' #mathuserans2').val()) { $('#reply_frm_'+id+ ' #reply_sec_message').html('Please enter correct answer.'); $('#reply_frm_'+id+ ' #reply_sec_message').attr('class', 'red-error'); $('#reply_frm_'+id+ ' #mathuserans2').focus(); return false; } else { $('#reply_frm_'+id+ ' #reply_sec_message').attr('class', 'blank-error'); $('#reply_frm_'+id+ ' #reply_sec_message').html('Please answer this simple math question.'); } } else { cmt_name = _loginUsername; cmt_email = _loginEmail; userid = _isLogged; loggedstatus = 1; } if(_loginImage != '' || _loginImage != null) { pick = _loginImage; } if(cmt_name.toLowerCase().indexOf('tanviahuja dotcom') != -1 || cmt_name.toLowerCase().indexOf('dotcom') != -1 || cmt_name.toLowerCase().indexOf('tanviahuja') != -1 || cmt_name.toLowerCase().indexOf('.com') != -1 || cmt_name.toLowerCase().indexOf('tanvi ahuja') != -1 || cmt_name.toLowerCase().indexOf('dot com') != -1 || cmt_text.toLowerCase().indexOf('tanvi ahuja') != -1 || cmt_text.toLowerCase().indexOf('tanviahuja') != -1 || cmt_text.toLowerCase().indexOf('dot com') != -1) { $('#reply_frm_'+id+' #reply_text').val(''); $('#reply_frm_'+id+ ' #reply-body').hide(); $('#reply_frm_'+id+ ' #reply-thanks').show(); return true; } $('#cmt_final_fromname').val(cmt_name); $('#cmt_final_fromaddress').val(cmt_email); $('#cmt_final_location').val(''); $('#cmt_final_message').val(cmt_text); $('#cmt_final_roaltdetails').val(1); $('#cmt_final_extid').val(cmt_cid); $('#cmt_final_userid').val(userid); $('#cmt_final_rchid').val('2147477980'); $('#cmt_final_parentid').val(cmt_apid); $('#cmt_final_rootid').val(cmt_gpid); $('#cmt_final_aparentid').val(cmt_pid); $('#cmt_final_loggedstatus').val(loggedstatus); $('#cmt_final_pick').val(pick); $('#cmt_final_article_headline').val(cmt_headline); $('#cmt_final_article_url').val(cmt_guid); $('#cmt_final_article_type').val(cmt_ctname); $('#reply_frm_'+id+ ' #reply_cmt_message').html(' '); $('#reply_frm_'+id+ ' #reply_message').attr('class', 'blank-error'); $('#cmt_final_submit').submit(); //updateCommentCount(cmt_cid, cmt_ctid); $('#reply_frm_'+id+' #reply_text').val(''); $('#reply_frm_'+id+ ' #reply-body').hide(); $('#reply_frm_'+id+ ' #reply-thanks').show(); return true; } function updateCommentCount(cmt_cid, cmt_ctid) { var call_url = '/update_content_cnt.php?c='+cmt_cid+'&ct_id='+cmt_ctid+'&t=c'; $.ajax({ url: call_url, async: true, cache: false, type: 'get', success: function(data, textStatus, jqXHR){ }, error: function(jqXHR, textStatus, errorThrown){ }, beforeSend: function(jqXHR, settings) { }, complete: function(jqXHR, textStatus) { } }); } function tagComment(type, id) { var status = GetColorCookie('__itcmt'+id); if(status==null){ status = ''; } if((status.indexOf('100')!=-1 || status.indexOf('101')!=-1)&&(type=='100' || type=='101')) { alert("You've already voted!"); return false; } else if(status.indexOf('102')!=-1 && type=='102') { alert("You just Recommended this comment!"); return false; } //alert('agree'); var cmt_cid = $('#cmt_content_id').val(); if(cmt_cid == '' || isNaN(parseInt(cmt_cid))) { alert('Problem capturing your action. Please try after some time.'); } var url = 'http://commentapi.indiatimes.com/ratecomment.cms?opinionid='+id+'&typeid='+type+'&rateid=1'; //alert(url); //return false; $('#cmt_tag_submit').attr('action',url); $('#cmt_tag_submit').submit(); var cnt = $('#cnt_'+type+'_'+id).html(); cnt = parseInt(cnt); if(isNaN(cnt)) { cnt = 0; } $('#cnt_'+type+'_'+id).html(cnt+1); setColorCookie('__itcmt'+id,status+"_"+type,1); return true; } function GetColorCookie(name){ var nameEQ = name+"="; var ca = document.cookie.split(';'); for(var i=0;i 0) { $('#allcomments').show(); } else { $('#allcomments').hide(); } $('#postcomment').show(); // hide name, email if(_isLogged != "" && _isLogged != null) { $('#reply-uinfo').hide(); } if (urlStr.indexOf('html#comment') != -1) { var parts = urlStr.split('#'); $('html, body').animate({ scrollTop: $('#'+parts[1]).offset().top }); } }, error: function(jqXHR, textStatus, errorThrown){ //todo - fail }, beforeSend: function(jqXHR, settings) { // todo : before request sent }, complete: function(jqXHR, textStatus) { // todo : after complete request } }); }