Manyou诚邀开发者加盟 | 常见问题
《站长》俱乐部官方群公布 城市联络员机会多多
立即免费下载 Discuz!7.0.0 正式版
安装升级指南 | 用户手册 | 新手建站学堂
基于.net架构的Discuz!NT2.6正式版发布
Comsenz公司2009年招贤纳士,期待您的加盟
Discuz!收费服务内容及价格
7月重庆、成都、西安三地社区运营实战特训速报名
Discuz!/UCHome 专用官方虚拟主机
牧场新服一起联运:豆浆机免费带回家
基于Discuz!的免费论坛空间5D6D
康盛创想《站长》俱乐部18城市互动之旅报名ing
返回列表 回复 发帖

奥运快讯和金牌榜

演示图:
aoyun.jpg
2008-8-7 20:37


网站演示可看:http://xinr.cn/bbs/thread-3813-1-1.html

右下角自动弹出奥运快讯及金牌榜,每隔10秒读一次数据(自己可以根据自己的实际情况改里面的刷新时间),有奥运快讯和金牌信息自动弹出、30秒后自动收缩(如果想改为不收缩,一直保持着在窗口右下角,可以参考15楼的帖子进行更改,新闻和快讯还是会根据刷新时间自动更新)。

添加非常简单,只需改一个文件即可,卸载只要把该段代码删除即可(放在<!--LIVE NEWS START-->和<!-- LIVE NEWS END -->之间。

将以下代码加到论坛风格文件footer.htm里面(一般应该在templates/default目录下),可以加在<div id="footer">的前面,加好后在后台->工具->更新缓存,把模板缓存更新一下:
  1. <!-- LIVE NEWS START -->
  2. <style>
  3. /* 全局CSS定义 */
  4. h1,h2,h3,h4,h5,h6 {margin:0; padding:0; font-size:12px; font-weight:normal;}
  5. </style>
  6. <div id="f_popup_mask" style="position:absolute;overflow:hidden;display:none;left:0px;top:0px;width:432px; height:150px;">
  7. <div id="f_popup_con"  style="width:432px; height:150px; background:url(http://img1.cache.netease.com/dl/live/bg0717.gif) no-repeat 0 0; ">
  8. <div style="width:268px; float:left; margin:24px 0 0;">
  9. <table width="100%" border="0" cellspacing="0" cellpadding="0" height="68">
  10. <tr><td id="f_popup_title" style="font-size:20px; font-weight:100; font-family:'黑体'; text-align:left; padding:0 10px 0 13px; line-height:140%;">标题</td></tr>
  11. </table>
  12. <h6 style="font-size:12px; color:#FFF6BA; padding:0 10px 0 10px; text-align:right;"><a id="f_popup_infolink" href="http://2008.163.com/" target="_blank">点击查看详细&gt;&gt;</a> <a href="http://2008.163.com/" target="_blank">进入奥运首页&gt;&gt;</a></h6>
  13. </div>
  14. <div style="width:164px; float:right;margin:25px 0 0; height:89px;">
  15. <table id="f_gold_ranking" width="155" border="0" cellspacing="0" cellpadding="1" align="center" style="text-align:center;">
  16.   <tr><td width="71" style="text-align:left;">----</td><td width="21">--</td><td width="21">--</td><td width="21">--</td></tr>
  17.   <tr><td style="text-align:left;">----</td><td>--</td><td>--</td><td>--</td></tr>
  18.   <tr><td style="text-align:left;">----</td><td>--</td><td>--</td><td>--</td></tr>
  19.   <tr><td colspan="4"><a href="http://gold.2008.163.com/" target="_blank"><span style="color:#D81616;">-详细金牌榜-</span></a></td></tr>
  20. </table>
  21. </div>
  22. <!-- 体育 -->
  23. <table width="432" border="0" cellspacing="3" cellpadding="0" style="background:#DB1011; clear:both;">
  24.   <tr>
  25.     <td><a href="http://2008.163.com/"><img src="http://img1.cache.netease.com/cnews/2008/8/4/20080804222416f43cc.jpg" width="426" height="30" alt="" /></a></td>
  26.   </tr>
  27. </table>
  28. </div>
  29. </div>
  30. <script type="text/javascript">
  31. var f_Popup_Enable=true; //是否弹出信息
  32. var f_Live_Data= new Object();
  33. f_Live_Data.dataRequestURL="http://msg.2008.163.com/live.js"; //数据地址
  34. f_Live_Data.refreshTime=10000;//刷新时间,单位毫秒
  35. f_Live_Data.lastMessageID=0;//记录最近一次弹窗ID
  36. f_Live_Data.COOKIE_LASTMSGID_NAME="NTES_PM_LastMsgID";//cookie名
  37. f_Live_Data.getCookieVal=function (offset) {
  38.   var endstr = document.cookie.indexOf (";", offset);
  39.   if (endstr == -1)
  40.   endstr = document.cookie.length;
  41.   return unescape(document.cookie.substring(offset, endstr));
  42. }
  43. f_Live_Data.GetCookie=function (name) {
  44.   var arg = name + "=";
  45.   var alen = arg.length;
  46.   var clen = document.cookie.length;
  47.   var i = 0;
  48.   while (i < clen) {
  49.     var j = i + alen;
  50.     if (document.cookie.substring(i, j) == arg)
  51.       return this.getCookieVal (j);
  52.     i = document.cookie.indexOf(" ", i) + 1;
  53.     if (i == 0)
  54.        break;
  55.   }
  56.   return "";
  57. }
  58. f_Live_Data.SetCookie=function (cookieName,cookieValue,nDays) {
  59. var today = new Date();
  60. var expire = new Date();
  61. if (nDays==null || nDays==0) nDays=1;
  62. expire.setTime(today.getTime() + 3600000*24*nDays);
  63. document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;domain=.163.com;expires="+expire.toGMTString();
  64. }
  65. f_Live_Data.init=function()
  66. {
  67. if(navigator.cookieEnabled){
  68.   f_Popup.init();
  69.   this.lastMessageID = (this.GetCookie(this.COOKIE_LASTMSGID_NAME) && this.GetCookie('NTES_PM_LReqData')) ? parseInt(this.GetCookie(this.COOKIE_LASTMSGID_NAME)) : 0;
  70.   setInterval("f_Live_Data.DoRequest()",this.refreshTime);
  71.   this.DoRequest();
  72. }
  73. }
  74. f_Live_Data.GetCookieCacheData=function()
  75. {
  76. var cdata=this.GetCookie('NTES_PM_LReqData');
  77. var data=new Object();
  78. if(cdata){
  79. var cdataf=cdata.split("|");
  80.   data.lastModify=cdataf[0];
  81.   data.title=cdataf[1];
  82.   data.link=cdataf[2];
  83.   data.goldList=eval(cdataf[3]);
  84. }
  85. return data;
  86. }
  87. f_Live_Data.SetCookieCacheData=function(data)
  88. {
  89. var datastr=data.lastModify+"|"+data.title+"|"+data.link+"|[";
  90. for(var i=0;i<data.goldList.length;i++){
  91.   var rowdata=data.goldList;
  92.   var listStr='{name:"'+rowdata.name+'",id:"'+rowdata.id+'",au:'+rowdata.au+',ag:'+rowdata.ag+',cu:'+rowdata.cu+',ranking:'+rowdata.ranking+'},';
  93.   datastr+=listStr;
  94. }
  95. datastr=datastr.substring(0,datastr.length-1)+"]";
  96. this.SetCookie('NTES_PM_LReqData',datastr);
  97. }
  98. f_Live_Data.DoRequest=function (){
  99. //debug.value+="do request\n";
  100. var ct=this.GetCookie('NTES_PM_ReqTime') ? parseInt(this.GetCookie('NTES_PM_ReqTime')) : 0;
  101. var reqingTime=this.GetCookie('NTES_PM_ReqingTime') ? parseInt(this.GetCookie('NTES_PM_ReqingTime')) : 0;
  102. var t=new Date().getTime();
  103. if(t-ct>=this.refreshTime){//cookie中的cache 已经过期
  104. //debug.value+="cookie cache expire \n";
  105.   if(reqingTime<=0 || t-reqingTime>this.refreshTime)
  106.   {
  107. //debug.value+="没有执行中的请求,发送请求 \n";
  108.    this.sendRequest();
  109.   }else{
  110. //debug.value+="有执行中的请求,等候2秒 \n";
  111.    setTimeout("f_Live_Data.DoRequest()",2000);//有正在执行中的请求,等候2秒再拿数据
  112.   }
  113. }else{//cookie数据没有过期
  114. //debug.value+="cookie cache not expire \n";
  115.   this.onData(this.GetCookieCacheData());
  116. }
  117. }
  118. f_Live_Data.sendRequest=function()
  119. {
  120. //debug.value+="开始请求"+this.dataRequestURL+" \n";
  121. var t=new Date().getTime();
  122. this.SetCookie('NTES_PM_ReqingTime',t);
  123. var obj=document.getElementById('liveDataID');
  124.   if(obj) obj.parentNode.removeChild(obj);
  125.   var newscript=document.createElement("script");
  126.    newscript.type="text/javascript";
  127.    newscript.src=this.dataRequestURL;
  128.    newscript.id="liveDataID";   
  129.   document.getElementsByTagName("head")[0].appendChild(newscript);
  130. }
  131. function f_onLiveDataRequestComplete(data)
  132. {
  133. //debug.value+="从服务器接收到数据 \n";
  134. var t=new Date().getTime();
  135. f_Live_Data.SetCookie('NTES_PM_ReqTime',t);
  136. f_Live_Data.SetCookie('NTES_PM_ReqingTime',0);
  137. f_Live_Data.SetCookieCacheData(data);
  138. f_Live_Data.onData(data);
  139. }
  140. f_Live_Data.parseRanklist=function(list,len)
  141. {
  142. var rankList=new Array();
  143. for(var i=1;i<len;i++) rankList.push(list);
  144. if(list[0].ranking>len){
  145.   rankList.push(list[0]);
  146. }else{
  147.   rankList.push(list[len]);
  148. }
  149. return rankList;
  150. }
  151. f_Live_Data.onData=function(data)
  152. {
  153. ///debug.value+="数据:"+data.lastModify+" \n";
  154. //update ranklist
  155. //填充数据,防止金牌榜数据不全时出现异常。
  156. if(data.goldList.length<5) for(var j=0;j<3;j++) data.goldList.push({name:"-",id:"-",au:'--',ag:'--',cu:'--',ranking:''});
  157. try{
  158.   f_data_updateFunc(data.goldList) //在需要更新数据的地方重新定义此函数。
  159. }
  160. catch(e){}
  161. f_Popup.updateRanklist(this.parseRanklist(data.goldList,3));
  162. // popup when newmsg coming;
  163. var msgid=parseInt(data.lastModify);
  164. if(msgid >this.lastMessageID){
  165.    this.onNewMsgComing(data);
  166.    this.SetCookie(this.COOKIE_LASTMSGID_NAME,msgid);
  167.    this.lastMessageID=msgid;
  168. }
  169. }
  170. f_Live_Data.onNewMsgComing=function (data)
  171. {
  172. //debug.value+="新消息到达"+data.lastModify+" \n";
  173. //新消息到达
  174. //update popup message
  175. var domTitle=document.getElementById('f_popup_title');
  176. var domLink=document.getElementById('f_popup_infolink');
  177. domTitle.innerHTML="<a href='"+data.link+"' target='_blank'>"+data.title+"</a>";
  178. domLink.href=data.link;
  179. //弹出窗口
  180. if(f_Popup_Enable && data.title!='') f_Popup.showMsg();
  181. }
  182. // popup Object
  183. var f_Popup=new Object();
  184. f_Popup.msgShowTime=30000; //弹出信息停留时间
  185. f_Popup.init=function(){
  186.   this.domMask=document.getElementById('f_popup_mask');
  187.   this.domContainor=document.getElementById('f_popup_con');
  188.   this.width=parseInt(this.domContainor.style.width);
  189.   this.height=parseInt(this.domContainor.style.height);
  190.   this.curHeight=0;
  191.   if(document.all && window.attachEvent) window.attachEvent("onscroll",this.onScroll);
  192.    else window.addEventListener("scroll",this.onScroll,false);
  193. }
  194. f_Popup.getRange=function () {
  195.       var top     = document.documentElement.scrollTop;
  196.       var left    = document.documentElement.scrollLeft;
  197.       var height  = document.documentElement.clientHeight;
  198.       var width   = document.documentElement.clientWidth;
  199.       if (top==0 && left==0 && height==0 && width==0) {
  200.         top     = document.body.scrollTop;
  201.         left    = document.body.scrollLeft;
  202.         height  = document.body.clientHeight;
  203.         width   = document.body.clientWidth;
  204.       }
  205.       return  {top:top  ,left:left ,height:height ,width:width } ;
  206. }
  207. f_Popup.onScroll=function(e)
  208. {
  209.   var rng=f_Popup.getRange();
  210.   f_Popup.domMask.style.top=(rng.top+rng.height-f_Popup.height)+"px";
  211.   f_Popup.domMask.style.left=(rng.left+rng.width-f_Popup.width)+"px";
  212. }
  213. f_Popup.showMsg=function(){
  214.   var rng=this.getRange();
  215.   this.domMask.style.left=(rng.left+rng.width-this.width)+"px";
  216.   this.domMask.style.top=rng.top+rng.height+"px";
  217.   this.domMask.style.height="0px";
  218.   this.curHeight=0;
  219.   this.domMask.style.display="block";
  220.   setTimeout("f_Popup.showTween()",20);
  221. }
  222. f_Popup.hideMsg=function(){
  223.   this.domMask.style.display="none";
  224. }
  225. f_Popup.showTween=function(){
  226.   var rng=this.getRange();
  227.   this.curHeight+=(this.height-this.curHeight)/5;
  228.    if(Math.abs(this.height-this.curHeight)<1) {
  229.     this.domMask.style.height=this.height+"px";
  230.     this.domMask.style.top=rng.top+rng.height-this.height+"px";
  231.     setTimeout("f_Popup.hideMsg()",this.msgShowTime);
  232.     return;
  233.    }
  234.    this.domMask.style.height=parseInt(this.curHeight)+"px";
  235.    this.domMask.style.top=rng.top+rng.height-parseInt(this.curHeight)+"px";
  236.   setTimeout("f_Popup.showTween()",20);
  237. }
  238. f_Popup.updateRanklist=function(rankList)
  239. {
  240.   var domRankingTable=document.getElementById("f_gold_ranking");
  241.   var domTrs=domRankingTable.getElementsByTagName('tr');
  242.   for(var i=0;i<rankList.length;i++)
  243.   {
  244.    var rowdata=rankList;
  245.    var tr=domTrs;
  246.    var rowColor=rowdata.name=="中国" ? '#FF0000' : '#000000';
  247.     tr.style.color=rowColor;
  248.    var tds=tr.getElementsByTagName('td');
  249.    tds[0].innerHTML="<a href='http://data.2008.163.com/rank/d,n,1,"+rowdata.id+".html' target='_blank'><span style='color:"+rowColor+"' >"+rowdata.ranking+" "+ rowdata.name+"</span></a>";
  250.    tds[1].innerHTML=rowdata.au;
  251.    tds[2].innerHTML=rowdata.ag;
  252.    tds[3].innerHTML=rowdata.cu;
  253.   }  
  254. }
  255. //var debug;
  256. //if(document.getElementById('debug')) debug=document.getElementById('debug')
  257. // else debug=new Object();
  258. f_Live_Data.init();
  259. </script>
  260. <!-- LIVE NEWS END -->
复制代码
[ 本帖最后由 风幻蓝 于 2008-8-12 10:42 编辑 ]
看起来不错
安装了一下,但是没有反应哦!修改默认风格的footer文件还是任何风格的都可以呢?
修改你正在用的风格文件啊
不行哦,显示不了。
恩, 测试了一下, 显示不了.
忘了说了,改动后,在后台->工具->更新缓存,把模板缓存更新一下。
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
试了怎么不行,骗人的吧~~~~~~
返回列表