var huifutemplate = "
"; var numobj = "", origText = '请输入您的评论', _editor_setbackground = false,CURRENT_LIKE,CURRENT_PAGE,CURRENT_MODE,isiframe,vcodeimgsrc = '/newscomment/Vcode?',voteaumurl = '/newscomment/Voteup?',biaoqingtemplate = ''; function execRE(re, rp, content) { oReg = new RegExp(re, 'ig'); r = content.replace(oReg, rp); return r; } // var newsKEC = { params : {}, init : function(options){ //id,keydown,keyup,blur,focus,mode,resizeMode if (!Fn.obj(options.id)) return false; this.params = { id : '', resizeMode : 0, filterMode : true, allowPreviewEmoticons : false, allowUpload : false, items : [], newlineTag : 'br', afterFocus : function(){newsKEC.toFocus(options.id)}, afterBlur : function(){newsKEC.toBlur(options.id)}, afterKeyup : function(){newsKEC.toKeyup(options.id)}, //afterKeydown : function(){newsKEC.toKeydown(options.id)}, mode : 1 //window 1 = onunload, 0 = onload } Object.extend(this.params, options); KE.show(this.params, this.params.mode); }, toKeyup : function(o){ }, toFocus : function(o){ if (!Fn.isUndefined(o)){ if(KE.text(o) == origText){ KE.util.setFullHtml(o, ' '); } } if (_editor_setbackground){ if(KE.text(o) == "" && KE.html(o).indexOf('img')<0){ //KE.util.setFullHtml(o,''); var num = Fn.Browser.google ? 0 : 0 KE.util.getIframeDoc(KE.g[o].iframe).body.style['background'] = 'url(http://img1.2345.com/duoteimg/images/ke-setbg-focus.gif) no-repeat 0 '+num+'px'; }else{ KE.util.getIframeDoc(KE.g[o].iframe).body.style['background'] = 'none'; } } }, toBlur : function(o){ if(origText){ if(KE.text(o) == "" && KE.html(o).indexOf('img')<0){ KE.util.setFullHtml(o, origText); }else if(KE.text(o) == origText){ KE.util.setFullHtml(o, ' '); } else { //KE.util.setFullHtml(o, KE.html(o).replace(/$/i,'')); } } if (_editor_setbackground){ if(KE.text(o) == "" && KE.html(o).indexOf('img')<0){ KE.util.setFullHtml(o,' '); var num = Fx.Browser.google ? 0 : 0 KE.util.getIframeDoc(KE.g[o].iframe).body.style['background']='url(http://img1.2345.com/duoteimg/images/ke-setbg-blur.gif) no-repeat 0 '+num+'px'; }else{ KE.util.getIframeDoc(KE.g[o].iframe).body.style['background']='none'; } } }, toKeydown : function(o){ if (origText){ if(KE.text(o) == origText){ KE.util.setFullHtml(o,' '); }else if(KE.html(o) == ""){ alert(KE.html(o)) KE.util.setFullHtml(o, newsKEC.getOrgi(o)); } } if (_editor_setbackground){ KE.util.getIframeDoc(KE.g[o].iframe).body.style['background']='none'; } newsKEC.updateNum(o); }, updateNum : function(o){ if (Fn.obj('num'))Fn('num').html("字数:"+ KE.text(o).length+"/500"); }, getOrgi : function(o){ return ''+origText+'' } }; // 闪烁动画 var Comment = { iframeDoc : null, getFaceLen : function(o){ Fx.regExps.init(//g,o); re = Fx.regExps.Match() return re.length }, //评论框的定位以及闪烁(id,次数) commentFocus : function(id,num){ this.iframeDoc = KE.util.getIframeDoc(KE.g[id].iframe); Comment.notice(num,150); KE.focus(id); }, //框闪烁 normal : function(times,intvalnum){ if(this.iframeDoc!=null){ this.iframeDoc.body.style['backgroundColor']='#FFF'; this.iframeDoc.body.style['opacity']=null; if(times<0) { return; } times=times-1; setTimeout("Comment.notice("+times+")",200); } }, notice : function(times,intvalnum){ if(this.iframeDoc!=null){ this.iframeDoc.body.style['backgroundColor']='#f9a0a0'; this.iframeDoc.body.style['opacity']=0.5; times=times-1; setTimeout("Comment.notice2("+times+")",200); } }, notice2 : function(times,intvalnum){ if(this.iframeDoc!=null){ this.iframeDoc.body.style['backgroundColor']='#F6CECE'; this.iframeDoc.body.style['opacity']=0.5; setTimeout("Comment.normal("+times+")",200); } } }; var newsComment = { isvote : [], param : {}, istimeout : [], timer : [], init : function(){ this.editorTips(); this.regList() }, //判断是否因此提示 editorTips : function() { if(Fn.cookie('comment.is_editor_tips')) { Fn('ping_tishi_div').hide(); Fn(Fn.NAME('c.rebox','div')[0]).css({'padding':'10px 0 0 0'}); } }, // 所有评论框复原 resetplform:function($filter){ $("a[name='c.reply']").each(function(sn){ if ($filter != sn) { if (sn > 0) { if ($(this).text() == '收起回复') { KE.util.setFullHtml('tocomment'+sn, origText); $(this).next('div.comment').hide().find("input[name='imgcode']").val(''); $(this).text('回复'); } } else { KE.util.setFullHtml('tocomment0', origText); $('#tocomment0').parents('form').find("input[name='imgcode']").val(''); $('#tocomment0').parents('form').find('a.changeBtn').trigger('click'); } } }); }, /*初始化绑定*/ initbindQuest:function() { // $(".changeBtn").die().live('click',function(e){ common.stopBubble(e,1); $(this).prev("img").attr('src', vcodeimgsrc+'&t='+Math.random()); }); // 刷新 $("a[name='c.refresh']").click(function(e){ common.stopBubble(e,1); common.v['fall'].toInsert(true); }); // ajax $("a[name='c.voteup']").die().live('click',function(e){ common.stopBubble(e,1); var cid = $(this).parent().attr('cid'),_sl = this,$timekey = "voteaum_voteup_"+cid; if (_self.istimeout[$timekey] || Fn.cookie($timekey)!='' && Fn.cookie($timekey)!='undefined' ){ common.showanimate(e,'你已经顶过了~','error'); return false; } _self.timeout($timekey,0,1); // 20分钟 $.ajax({ type: 'get', url: voteaumurl+'&zxId='+CURRENT_SOFTID+'&tocommentid='+cid+'&type=voteup', success: function(data) { data = common.getjson(data); if (data.code) { common.showanimate(e,data.code,'error'); } else { $(_sl).text(parseInt($(_sl).text())+1).css('background-position','0px -96px'); common.showanimate(e,'赞+1'); } } }); }); // 滚动到评论框 $("a[name='a.too.comment']").click(function(e){ common.stopBubble(e,1); common.scrolltoobj('div.tb_a'); Comment.commentFocus('tocomment0',6); }); }, regareplySN:function(){ //li dom 在变,sn 编号也在变 $("a[name='c.reply']").each(function(i){ $(this).attr({'sn':i}); var cid = $(this).parent().attr('cid'); if (cid) { $(this).next("div.comment").find("textarea[name='c.tocomment']").attr({'id':'tocomment'+i}); } else { $("textarea[name='c.tocomment']").eq(0).attr({'id':'tocomment0'}); } }); }, regList : function(){ _self = this; this.param['rebox'] = Fn.NAME('c.rebox','div'); this.param['tocomment'] = Fn.NAME('c.tocomment','textarea'); this.param['reform'] = Fn.NAME('c.reform','form'); _self.regareplySN(); _self.initbindQuest(); // 回复框 重点 $("a[name='c.reply']").die().live('click',function(event){ common.stopBubble(event,1); var sn = Fn(this).attr('sn'), isfirst = '',cid = $(this).parent().attr('cid'); _self.resetplform(sn); if (!_self.param['rebox.loaded'+sn]){ if (sn > 0) $(huifutemplate).insertAfter($(this)); var $container = sn > 0 ? $(this).parent().find('form') : $(this).parents('form'); $container.find("a[name='c.cmtbtn']").attr({'sn':sn}).click(function(e){ common.stopBubble(e,1); _self.valid($(this).attr('sn')); }); if (cid) { $(this).next("div.comment").find("input[name='pid']").val(cid); $(this).next("div.comment").find("textarea[name='c.tocomment']").attr({'id':'tocomment'+sn}); } else { $("textarea[name='c.tocomment']").eq(0).attr({'id':'tocomment'+sn}); } newsKEC.init({id:'tocomment'+sn}); _self.param['rebox.loaded'+sn] = true; // form onsubmit $container.submit(function(){ $(this).find("a[name='c.cmtbtn']").trigger('click'); return false; }); // 表情部分 if ($container.find("a[name='c.face']").find("div[name='c.facelink']").length == 0) { $(biaoqingtemplate).find('img').each(function(){ $(this).click(function(){ _self.setFace(this.src, 'tocomment'+sn); }); }).parents("div[name='c.facelink']").insertAfter($container.find("a[name='c.face']")); } $container.find("a[name='c.face']").click(function(e){common.stopBubble(e,1);}); $container.find("a[name='c.face']").parent().hover( function(e) { $(this).find("div[name='c.facelink']").show(); }, function(e) { $(this).find("div[name='c.facelink']").hide(); } ); } if (Fn(this).html() == '回复') { Fn(this).addClass('replya_blod').html('收起回复'); $(this).next("div.comment").show(); // 验证码触发 if (cid) { $(this).next("div.comment").find("a.changeBtn").trigger('click'); } else { $("a.changeBtn").eq(0).trigger('click'); } } else { Fn(this).removeClass('replya_blod').html('回复'); $(this).next("div.comment").slideUp(10); } }); $("a[name='c.reply']").eq(0).trigger('click'); }, setFace : function(src, o){ var face = /([a-z0-9]{1,})+\.gif/.exec(src); if (!face[1]) face[1] = src; var o = o ? o : 'tocomment' var m = Fn(o); /*if (typeof origText!='undefined' && o == 'tocomment'){ m.click() }*/ var v = ''; var len = KE.count(o); var facelen = this.getFaceLen(KE.html(o)); if (facelen >= 3) { common.afteranimate({elem: $('#'+o).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'最多输入三个表情',massage:'error'}); return false; } if (len < 500 | facelen<3){ this.edInsert(o,v); if (Fn.Browser.chrome || Fn.Browser.google || Fn.Browser.firefox) this.edInsert(o,' ') }else{ return false; } if (Fn.obj('num'))Fn('num').html("字数:"+ KE.count(o)+"/500"); setTimeout(function(){newsKEC.toKeydown(o);}, 10); }, getFaceLen : function(o){ Fn.regExps.init(//gi,o); re = Fn.regExps.Match(); return re.length; }, shareTo : function(t,m){ if (!this.param['issharetowindow']) return; this.param['issharetowindow'] = false; var url = ''; switch(t){ default : locat = document.location.href; url = "http://v.t.sina.com.cn/share/share.php?title="+m+" - 在多特软件站对"+Fn('softname').text()+"的评论&url="+escape(document.location.href); target = "vivi"; sFeatures = "scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes"; break; } if (url){ _win = window.open(url,'sharetowindow',sFeatures); setTimeout(function(){_win.focus()},2000) } }, edInsert : function(o,v){ _self = this; KE.focus(o); setTimeout(function(){ KE.insertHtml(o, v); if (Fn.Browser.chrome || Fn.Browser.google || Fn.Browser.firefox){ KE.insertHtml(o,' '); KE.focus(o,'end'); } },10); }, timeout : function(key,t,times){ var _self = this; if(times == 'undefined'|| !times) times = 1; if (t){ this.istimeout[key] = false; clearTimeout(this.timer[key]); Fn.cookie(key,'',-2); } else { this.istimeout[key] = true Fn.cookie(key,new Date().getTime(), 0.02) this.timer[key] = setTimeout(function(){ _self.timeout(key,1)},times*1000*60) } }, toFocus : function(o){ var o = o?o:'tocomment' var m = Fx.obj(o); Fx.obj('tolinkcomment').focus() setTimeout(function(){KE.focus(o,'end')},10); }, reply : function(id){ if(!id) id='' POPdlg.show(); Fn('quote2').val(id) }, valid : function(t){ if (this.istimeout['myposttime_'+CURRENT_SOFTID] || Fn.cookie('myposttime_'+CURRENT_SOFTID)!='' && Fn.cookie('myposttime_'+CURRENT_SOFTID)!='undefined' ){ common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'水也不是这么灌的,请您休息一分钟再发表评论!',massage:'error'}); return false; } var t = t ? t : ''; var len = KE.count('tocomment'+t); var content = execRE("]*>", "", KE.html('tocomment'+t)); content = content.htmlTrim(); this.tt = t; if (!Fn.isUndefined(origText)){ if (KE.text('tocomment'+t) == origText){ if (t > 0) { Comment.commentFocus('tocomment'+t,2); } else { common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'评论内容长度为5~500个字!',massage:'error'}); KE.focus('tocomment'+t); } return false; } } if (/^([0-9 \r\n]+)$/.test(content)){ common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'一连串数字是什么意思呢,还是说点实在的吧!',massage:'error'}); KE.focus('tocomment'+t); return false; } if (len<5 || len>500){ common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'评论内容长度为5~500个字!',massage:'error'}); KE.util.focus('tocomment'+t); return false; } if (KE.text('tocomment'+t).length<5){ if (content.indexOf('img')>=0 && KE.text('tocomment'+t).trim().length <= 0){ common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'纯表情会让人误以为您是表情帝,还是说点实在的吧!',massage:'error'}); }else{ common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'评论内容长度为5~500个字!',massage:'error'}); } KE.focus('tocomment'+t); return false; } var facelen = this.getFaceLen(content); if (facelen>3){ common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'最多输入三个表情,请删除一些表情!',massage:'error'}); return false; } Fn('tocomment'+t).value(content); var $form = $('#tocomment'+t).parents('form'),$ercode = $.trim($form.find("input[name='imgcode']").val()); // 继续验证 if($ercode.length != 4) { common.afteranimate({elem:$('#tocomment'+t).parents('form').find('span.captcha_right a.changeBtn').parent(),html:'请输入完整的验证码!',massage:'error'}); $form.find("input[name='imgcode']").focus(); return false; } if ($form.find("a[name='c.cmtbtn']").hasClass('pubing')) return false; $form.find("a[name='c.cmtbtn']").text('发布中..').addClass('pubing'); if(t){ this.param['cmtsn'] = t; this.param['cmtsn'] = t; $.ajax({ type: 'post', dataType: 'text', url: $form.attr('action')+'&zxId='+CURRENT_SOFTID+'&sn='+t, data: $form.serialize(), success: function(data) { $form.find("a[name='c.cmtbtn']").text('评论').removeClass('pubing'); data = common.getjson(data); if (data.code ==0 ) { _self.timeout('myposttime_'+CURRENT_SOFTID); if (data.data.pid) { $(data.data.html).insertBefore("ul.comment_lists li div[cid='"+data.data.pid+"']"); }else{ $('ul.comment_lists').prepend(data.data.html); common.scrolltoobj('ul.comment_lists',-50); } _self.resetplform(); } else { if (data.code) { alert(data.msg); } if (data.code === 102) { $form.find("a.changeBtn").trigger('click'); } } } }); } else { document.comForm.submit(); } return true; } };