日期:2014-05-16 浏览次数:20704 次
(function($){
var countdown = function(item, config)
{
var seconds = parseInt($(item).attr(config.attribute));
var timer = null;
var doWork = function()
{
if(seconds >= 0)
{
if(typeof(config.callback) == "function")
{
var data = {
total : seconds ,
second : Math.floor(seconds % 60) ,
minute : Math.floor((seconds / 60) % 60) ,
hour : Math.floor((seconds / 3600) % 24) ,
day : Math.floor(seconds / 86400)
};
config.callback.call(item, seconds, data, item);
}
seconds --;
}else{
window.clearInterval(timer);
}
}
timer = window.setInterval(doWork, 1000);
doWork();
};
var main = function()
{
var args = arguments;
var config = { attribute : 'data-seconds', callback : null };
if(args.length =