找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 46|回复: 3

求各位帮忙扒一段JS代码。

[复制链接]

29

主题

1006

回帖

2223

积分

金牌会员

积分
2223
发表于 2018-1-2 14:49:50 | 显示全部楼层 |阅读模式
想要www.iqshw.com/qqnews/2018/0102/139044.html中如下图所示的这段倒计时代码,可惜自己菜鸟一枚,哪位大佬帮帮忙,不胜感激。



回复

使用道具 举报

14

主题

687

回帖

1472

积分

金牌会员

积分
1472
发表于 2018-1-2 15:48:21 | 显示全部楼层
jQuery Countdown
回复

使用道具 举报

24

主题

283

回帖

698

积分

高级会员

积分
698
发表于 2018-1-2 16:47:20 | 显示全部楼层
[ol]
  • https://www.iqshw.com/skin/iqshwcomm_v2014/js/plugin/jquery.countdown.min.js[/ol]复制代码
  • 回复

    使用道具 举报

    24

    主题

    283

    回帖

    698

    积分

    高级会员

    积分
    698
    发表于 2018-1-2 16:51:00 | 显示全部楼层
    [ol][*]/*
    [*] * jQuery Countdown - v1.2.4
    [*] * http://github.com/kemar/jquery.countdown
    [*] * Licensed MIT
    [*] */
    [*](function($,g,i,j){"use strict";var k='countDown';var l={css_class:'countdown',only_show_days:false,always_show_days:false,with_labels:true,with_seconds:true,with_separators:true,label_dd:'days',label_hh:'hours',label_mm:'minutes',label_ss:'seconds',separator:':',separator_days:',',timeElement:''};function CountDown(a,b){this.element=$(a);this.options=$.extend({},l,b);this._defaults=l;this._name=k;this.init()}$.extend(CountDown.prototype,{init:function(){if(this.element.children().length){return}if(this.element.attr('datetime')){this.endDate=this.parseEndDate(this.element.attr('datetime'))}if(this.endDate===j){this.endDate=this.parseEndDate(this.element.text())}if(this.endDate===j){return}if(this.element.is('time')){this.timeElement=this.element}else{this.timeElement=$(this.options.timeElement);this.element.html(this.timeElement)}this.markup();this.setTimeoutDelay=this.sToMs(1);this.daysVisible=true;this.timeElement.bind('time.elapsed',this.options.onTimeElapsed);this.doCountDown()},parseEndDate:function(a){var d;d=this.parseDuration(a);if(d instanceof Date){return d}d=this.parseDateTime(a);if(d instanceof Date){return d}d=this.parseHumanReadableDuration(a);if(d instanceof Date){return d}d=Date.parse(a);if(!isNaN(d)){return new Date(d)}},parseDuration:function(a){var b=a.match(/^P(?:(\d+)D)?T?(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)(?:\.(\d{1,3}))?S)?$/);if(b){var d,dd,hh,mm,ss,ms;dd=b[1]?this.dToMs(b[1]):0;hh=b[2]?this.hToMs(b[2]):0;mm=b[3]?this.mToMs(b[3]):0;ss=b[4]?this.sToMs(b[4]):0;ms=b[5]?parseInt(b[5],10):0;d=new Date();d.setTime(d.getTime()+dd+hh+mm+ss+ms);return d}},parseDateTime:function(a){var b=a.match(/^(\d{4,})-(\d{2})-(\d{2})[T\s](\d{2}):(\d{2})(?:\:(\d{2}))?(?:\.(\d{1,3}))?([Z\+\-\:\d]+)?$/);if(b){var c=b[8]?b[8].match(/^([\+\-])?(\d{2}):?(\d{2})$/):j;var e=0;if(c){e=this.hToMs(c[2])+this.mToMs(c[3]);e=(c[1]==='-')?e:-e}var d,yy,mo,dd,hh,mm,ss,ms;yy=b[1];mo=b[2]-1;dd=b[3];hh=b[4]||0;mm=b[5]||0;ss=b[6]||0;ms=b[7]||0;d=new Date(Date.UTC(yy,mo,dd,hh,mm,ss,ms));d.setTime(d.getTime()+e);return d}},parseHumanReadableDuration:function(a){var b=a.match(/^(?:(\d+).+\s)?(\d+)[h:]\s?(\d+)[m:]?\s?(\d+)?[s]?(?:\.(\d{1,3}))?$/);if(b){var d,dd,hh,mm,ss,ms;d=new Date();dd=b[1]?this.dToMs(b[1]):0;hh=b[2]?this.hToMs(b[2]):0;mm=b[3]?this.mToMs(b[3]):0;ss=b[4]?this.sToMs(b[4]):0;ms=b[5]?parseInt(b[5],10):0;d.setTime(d.getTime()+dd+hh+mm+ss+ms);return d}},sToMs:function(s){return parseInt(s,10)*1000},mToMs:function(m){return parseInt(m,10)*60*1000},hToMs:function(h){return parseInt(h,10)*60*60*1000},dToMs:function(d){return parseInt(d,10)*24*60*60*1000},msToS:function(a){return parseInt((a/1000)%60,10)},msToM:function(a){return parseInt((a/1000/60)%60,10)},msToH:function(a){return parseInt((a/1000/60/60)%24,10)},msToD:function(a){return parseInt((a/1000/60/60/24),10)},markup:function(){var a=['','','',this.options.label_dd,'','','',this.options.separator_days,'','','','','',this.options.label_hh,'','','',this.options.separator,'','','','','',this.options.label_mm,'','','',this.options.separator,'','','','','',this.options.label_ss,'',''];this.timeElement.html(a.join(''));if(!this.options.with_labels){this.timeElement.find('.label').remove()}if(!this.options.with_separators){this.timeElement.find('.separator').remove()}if(!this.options.with_seconds){this.timeElement.find('.item-ss').remove();this.timeElement.find('.separator').last().remove()}this.item_dd=this.timeElement.find('.item-dd');this.separator_dd=this.timeElement.find('.separator-dd');this.remaining_dd=this.timeElement.find('.dd');this.remaining_hh1=this.timeElement.find('.hh-1');this.remaining_hh2=this.timeElement.find('.hh-2');this.remaining_mm1=this.timeElement.find('.mm-1');this.remaining_mm2=this.timeElement.find('.mm-2');this.remaining_ss1=this.timeElement.find('.ss-1');this.remaining_ss2=this.timeElement.find('.ss-2');this.timeElement.addClass(this.options.css_class)},doCountDown:function(){var a=this.endDate.getTime()-new Date().getTime();var b=this.msToS(a);var c=this.msToM(a);var d=this.msToH(a);var e=this.msToD(a);if(a复制代码
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-4-20 03:53 , Processed in 0.018141 second(s), 4 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表