/* * jquery.yycountdown plugin * * Copyright (c) 2014 YYengine Yuji Yamabata * Dual licensed under the MIT and GPL licenses. * http://docs.jquery.com/License */ ;(function(b){b.fn.yycountdown=function(f){var a=b.extend({startDateTime:new Date,endDateTime:"2020/07/24 00:00:00",diffDateTime:0,unit:{d:"day",h:"hour",m:"min",s:"sec"},complete:null,node:{d:null,h:null,m:null,s:null},self:null,timerId:null},f);a.self=b(this);(function(){"Date"!==typeof a.complete&&(a.startDateTimeObj=new Date(a.startDateTime));a.endDateTimeObj=new Date(a.endDateTime);a.diffDateTime=Math.floor((a.endDateTimeObj-a.startDateTimeObj)/1E3);var g=b("
").addClass("yycountdown-box"), c=b("").addClass("yyc-day"),d=b("").addClass("yyc-hou"),e=b("").addClass("yyc-min"),f=b("").addClass("yyc-sec"),h=b("").addClass("yyc-day-text"),k=b("").addClass("yyc-hou-text"),l=b("").addClass("yyc-min-text"),m=b("").addClass("yyc-sec-text");h.html(a.unit.d);k.html(a.unit.h);l.html(a.unit.m);m.html(a.unit.s);g.append(c).append(h).append(d).append(k).append(e).append(l).append(f).append(m);a.self.append(g);a.node.d=a.self.find(".yyc-day"); a.node.h=a.self.find(".yyc-hou");a.node.m=a.self.find(".yyc-min");a.node.s=a.self.find(".yyc-sec")})();a.timerId=setInterval(function(){var b=--a.diffDateTime,c=Math.floor(b/86400),d=Math.floor((b-86400*c)/3600),e=Math.floor((b-86400*c-3600*d)/60),b=Math.floor(b-86400*c-3600*d-60*e);a.node.d.html(c);a.node.h.html(("0"+d).slice(-2));a.node.m.html(("0"+e).slice(-2));a.node.s.html(("0"+b).slice(-2));0>=a.diffDateTime&&(clearInterval(a.timerId),"function"===typeof a.complete&&a.complete(a.self))},1E3)}})(jQuery);