笙默考试管理系统-MyExamTest--calculagraph

笙默考试管理系统-MyExamTest--calculagra1

目录

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

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

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

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

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

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

/**

 * Created with jing.zhao2013

 * Date: 14-3-21

 * Time: 下午4:05

 */

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

function Calculagraph(opt){

    if(!opt) opt={};

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

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

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

    this.time=Math.abs(this.time);

    this.timer=null;

    var self=this;

    var format=function(t){

        var m=60;

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

        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;

};

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

    if(self.dom){

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

    }

    this.fun=function(){

        self.time++;

        if(self.dom){

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

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

        }

        if(self.fn){

            self.fn();

        }

    };

}

Calculagraph.prototype.stop=function(){

    var self = this;

    clearInterval(self.timer);

};

Calculagraph.prototype.start=function(){

    var self = this;

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

};

/**

 * Created with jing.zhao2013

 * Date: 14-3-21

 * Time: 下午4:05

 */

function Calculagraph(opt){

    if(!opt) opt={};

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

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

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

    this.time=Math.abs(this.time);

    this.timer=null;

    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(self.dom){

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

    }

    this.fun=function(){

        self.time++;

        if(self.dom){

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

        }

        if(self.fn){

            self.fn();

        }

    };

}

Calculagraph.prototype.stop=function(){

    var self = this;

    clearInterval(self.timer);

};

Calculagraph.prototype.start=function(){

    var self = this;

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

};

你可能感兴趣的:(笙默考试管理系统,javascript,前端,开发语言)