中国教程网论坛's Archiver

Joasea 发表于 2008-6-9 20:55

奥运会倒计时牌

这是我在别人的网站上看到的,感觉不错。
就拿来大家一块学习一下。


<h3 rel="奥运倒计时牌"><a href="/apps/olympcd/?module_id=27000000009988">奥运倒计时牌</a></h3>
      
      </div>

      <div class="bd">
      <style>
                .ypolympcd{width:100%; background:url([img]http://cn.yimg.com/ncp/app/olymcd/disbg.gif[/img]) center top no-repeat;height:250px; text-align:center;margin:0 auto}
                .ypolympcd .yp-ocwarpper{margin:0 auto; overflow:hidden;position:relative;width:248px;height:250px;}
                .ypolympcd .yp-ocwarpper .yp-oc-act,
                .ypolympcd .yp-ocwarpper .yp-oc-desc{display:block;width:82px; height:21px;overflow:hidden;position:absolute;top:208px;}
                .ypolympcd .yp-ocwarpper .yp-oc-act{background:url([img]http://cn.yimg.com/ncp/app/olymcd/disbt1.gif[/img]) center top no-repeat;left:30px;}
                .ypolympcd .yp-ocwarpper .yp-oc-desc{background:url([img]http://cn.yimg.com/ncp/app/olymcd/disbt1.gif[/img]) center bottom no-repeat;right:30px;}
                .ypolympcd .yp-oc-day,
                .ypolympcd .yp-oc-hour,
                .ypolympcd .yp-oc-min,
                .ypolympcd .yp-oc-sec{position:absolute;height:18px;line-height:18px; font-size:14px;overflow:hidden;font-weight:bold;color:#ff0000;font-family:Arial;top:163px;}
                .ypolympcd .yp-oc-day{left:28px;width:29px;}
                .ypolympcd .yp-oc-hour{left:80px;width:24px;}
                .ypolympcd .yp-oc-min{left:135px;width:24px;}
                .ypolympcd .yp-oc-sec{left:182px;width:24px;}
                .ypolympcd .yp-oc-today{position:absolute;height:32px;line-height:32px; font-size:18px;overflow:hidden;font-weight:bold;color:#000;top:22px;width:197px;left:24px;}
        </style>
        <div class="ypolympcd" id="yp-mod-27000000009988">
                <div class="yp-ocwarpper">
                        <div class="yp-oc-today"></div>
                        <div class="yp-oc-day"></div>
                        <div class="yp-oc-hour"></div>
                        <div class="yp-oc-min"></div>
                        <div class="yp-oc-sec"></div>
                </div>
        </div>
        <script type="text/javascript" src="http://cn.yui.yahooapis.com/2.4.1/build/utilities/utilities.js?_yuiversion=2.4.1"></script>
        <script type="text/javascript">
        (function(){
                YAHOO.namespace('CN.NCP.olymcd');
                YAHOO.CN.NCP.olymcd = function(){
                        var DifferenceHour = -1;
                        var DifferenceMinute = -1;
                        var DifferenceSecond = -1;
                        var diffTime = 0;
                        var Tday = new Date("Aug 8, 2008 20:00:00");
                        var daysms = 24 * 60 * 60 * 1000;
                        var hoursms = 60 * 60 * 1000;
                        var Secondms = 60 * 1000;
                        var microsecond = 1000;
                        var _D = YAHOO.util.Dom;
                        var _MODID = 'yp-mod-27000000009988';
                        var _E = YAHOO.util.Event;
                        var getTime = function(){
                                YAHOO.util.Connect.asyncRequest('post','/common/proxyer?url=http://mall.app.vip.cn3.yahoo.com/olympcd/time.php',{
                               
                                        success : function(o){
                                                var r = eval('('+o.responseText+')');
                                                var clientTime = new Date().getTime();
                                                diffTime = new Date(r.time).getTime()-clientTime;
                                                ocd();
                                        },
                                        failure : function(){
                                                ocd();
                                        }
                                });
                        };
                        function ocd()
                        {
                                if(!_D.inDocument(_MODID)){return;}
                                var newTime = new Date().getTime()+diffTime;
                                var time = new Date(newTime);
                               
                                var tday = time.getDate();   
                                var tmonth = time.getMonth() + 1;
                                var hour = time.getHours();
                                var minute = time.getMinutes();
                                var second = time.getSeconds();
                                var timevalue = ""+((hour > 12) ? hour-12:hour);
                                timevalue +=((minute < 10) ? ":0":":")+minute;
                                timevalue +=((second < 10) ? ":0":":")+second;
                                timevalue +=((hour >12 ) ? " PM":" AM");
                                var convertHour = DifferenceHour;
                                var convertMinute = DifferenceMinute;
                                var convertSecond = DifferenceSecond;
                                var Diffms = Tday.getTime() - time.getTime();
                                DifferenceHour = Math.floor(Diffms / daysms);
                                Diffms -= DifferenceHour * daysms;
                                DifferenceMinute = Math.floor(Diffms / hoursms);
                                Diffms -= DifferenceMinute * hoursms;
                                DifferenceSecond = Math.floor(Diffms / Secondms);
                                Diffms -= DifferenceSecond * Secondms;
                                var dSecs = Math.floor(Diffms / microsecond);
                                if(convertHour != DifferenceHour) _D.getElementsByClassName('yp-oc-day', 'div', _MODID)[0].innerHTML=DifferenceHour;
                                if(convertMinute != DifferenceMinute) _D.getElementsByClassName('yp-oc-hour', 'div', _MODID)[0].innerHTML=DifferenceMinute;
                                if(convertSecond != DifferenceSecond) _D.getElementsByClassName('yp-oc-min', 'div', _MODID)[0].innerHTML=DifferenceSecond;
                                _D.getElementsByClassName('yp-oc-sec', 'div', _MODID)[0].innerHTML=dSecs;
                                _D.getElementsByClassName('yp-oc-today', 'div', _MODID)[0].innerHTML= '今天是2008年'+tmonth+'月'+tday+'日';
                                var ocdtimer = setTimeout(ocd, 1000);
                                if(DifferenceHour == 0 && DifferenceMinute == 0 && DifferenceSecond== 0 && dSecs==0){
                                        clearTimeout(ocdtimer);
                                }
                        }
                        _E.onContentReady(_MODID, getTime);
                };
                YAHOO.util.Event.on(window, 'load', YAHOO.CN.NCP.olymcd);
        })();
        </script>

      </div>

[[i] 本帖最后由 Joasea 于 2008-6-9 21:02 编辑 [/i]]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.