笙默考试管理系统---countop

本文介绍了笙默考试管理系统中的CountDown组件,用于创建倒计时功能,支持自定义总秒数、回调函数以及自动或手动启动/停止计时。
摘要由CSDN通过智能技术生成

笙默考试管理系统---countop

目录

笙默考试管理系统---countop

一、 笙默考试管理系统-MyExamTest----countop

二、 笙默考试管理系统-MyExamTest----countop

三、 笙默考试管理系统-MyExamTest----countop

四、 笙默考试管理系统-MyExamTest----countop

五、 笙默考试管理系统-MyExamTest----countop

  • 笙默考试管理系统-MyExamTest----countop

* Created with jing.zhao2013

 * Date: 14-3-13

 * Time: 下午4:50

 */

function CountDown(opt){

    if(!opt) opt={};

    this.dom = opt["dom"]?opt["dom"]:null;

    this.totalSecond=opt["totalSecond"]?opt["totalSecond"]:0;

this.fn=opt["fn"]?opt["fn"]:null;

    this.auto=opt["auto"]?opt["auto"]:false;

    this.zeroFn=opt["zeroFn"]?opt["zeroFn"]:null;

    this.lowerFn=opt["lowerFn"]?opt["lowerFn"]:null;

    this.timer=null;

    this.started=false;

    if(!this.dom) {

        alert("请设置正确的参数");

        return false;

}

  • 笙默考试管理系统-MyExamTest----countop

    var self=this;

    var format=function(t){

        var m=60;

        var min=parseInt(t/m);

        var sec=t-min*m;

        var minute=(min<10)?"0"+min:min;

        var second=(sec<10)?"0"+sec:sec;

        return minute+":"+second;

    };

    if(this.totalSecond<0){

     clearInterval(self.timer);

        self.lowerFn();

        return;

}

  • 笙默考试管理系统-MyExamTest----countop

    self.dom.innerHTML=format(self.totalSecond);

    this.fun=function(){

        self.totalSecond++;

        self.dom.innerHTML=format(self.totalSecond);

        

        var now = new Date();

      

        if(self.fn){

            self.fn();

        }

    };

    if(self.auto){

     if(self.started) return false;

    

     var isOpenTiming = $("#isOpenTiming").attr("checked");

    

     if(isOpenTiming=="checked"){

        this.timer=setInterval(self.fun,1000);

        self.started = true;

     }else {

     return false;

     }

    }

}

CountDown.prototype.stop=function(){

    var self = this;

    self.started = false;

    clearInterval(self.timer);

};

  • 笙默考试管理系统-MyExamTest----countop

CountDown.prototype.start=function(){

var isOpenTiming = $("#isOpenTiming").attr("checked");

    var self = this;

    if(self.started) return false;

    

    if(isOpenTiming=="checked"){

     self.started = true;

     this.timer=setInterval(self.fun,1000);

    }

};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

N201871643

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值