(function(n){n.fn.extend({WebCarsNewsVote:function(t){var r={Version:1,VoteId:0};return t&&jQuery.extend(r,t),this.each(function(){r.VoteId=this.id?this.id.replace(/[^\d]+/,""):0;if(r.VoteId>0){var s='
',o='网友调查 共有人参加
- 感谢您的参与,您可以在24小时后进行再次投票,谢谢!
',h='',t=jQuery(this);function e(){n.ajax({type:"POST",contentType:"application/json",url:"/WS/WebCarsVote.asmx/GetVote",data:"{voteId : "+r.VoteId+"}",dataType:"json",error:function(){alert("获取投票时失败,请稍后重试!")},success:function(n){var e,r;if(u(n.d.VoteId))i(n);else{t.append(s);while(/ /.test(n.d.VoteContent))n.d.VoteContent=n.d.VoteContent.replace(" ","");t.find("h6").text(n.d.VoteContent),e=1;for(r in n.d.Items)t.find("ul").append(''+e+(n.d.Items[r].VoteItem.indexOf("、")>=0?"":" ")+n.d.Items[r].VoteItem+""),e++;n.d.ShowColumns==2&&t.find("div.newsDiaochaContent").attr("class","newsDiaochaContents"),f(n.d.VoteId)}}})}function u(n){var t=GetCookie("Vote"+n+r.Version);return t!=null&&t!=""?!0:!1}function i(i){var u,e,f,r;t.append(o);while(/ /.test(i.d.VoteContent))i.d.VoteContent=i.d.VoteContent.replace(" ","");t.find("div.newsDiaochaContent>ul>li:first").text(i.d.VoteContent),u=0;for(r in i.d.Items)u+=i.d.Items[r].VoteCount;n("h5",t).find("font").text(i.d.VoteCount),e=1;for(r in i.d.Items)f=u==0?"0":Math.round(i.d.Items[r].VoteCount*1/u*100),t.find("table").append(''+e+(i.d.Items[r].VoteItem.indexOf("、")>=0?"":" ")+i.d.Items[r].VoteItem+' | '+f+'% | '+i.d.Items[r].VoteCount+" |
"),e++}function f(u){t.find("img").click(function(){var f="";if(t.find("input[name='voteItem']:checked").size()<=0)return alert("未选择任何项!"),!1;t.find("input[name='voteItem']:checked").each(function(){f+=this.value+","}),f=f.replace(/\,$/g,""),n.ajax({type:"POST",contentType:"application/json",url:"/WS/WebCarsVote.asmx/AddVote",data:"{voteId : "+u+', voteItemId : "'+f+'"}',dataType:"json",error:function(){alert("投票时失败,请稍后重试!")},success:function(n){t.empty();var f=new Date;f.setDate(f.getDate()+1),SetCookie("Vote"+u+r.Version,1,f,"/",".webcars.com.cn"),i(n)}})})}e()}})}})})(jQuery);