Widget:TimerTest2: Difference between revisions

Jump to navigation Jump to search
Matt Pijoan (talk | contribs)
No edit summary
Matt Pijoan (talk | contribs)
No edit summary
Line 4: Line 4:
mw.loader.using('mediawiki.user',function(){
mw.loader.using('mediawiki.user',function(){
if($.inArray("CMEUser", mw.config.get( 'wgUserGroups' )) != "-1"){
if($.inArray("CMEUser", mw.config.get( 'wgUserGroups' )) != "-1"){
var Obj1 = new (function(){
    var $timer1,
    incrementTime = 100,
    currentTime = 0,
    updateTimer = function() {
        $timer1.html(currentTime);
        currentTime +=incrementTime;
        if(currentTime == 30000){


        }
    },
    init = function(){
        $timer1 = $('#output1');
        Obj1.Timer = $.timer(updateTimer, incrementTime, true);
    };
    this.extPause = function(){
        if(this.isActive){
        $timer1.pause();
        }
}
    this.extPlay = function(){
        if(!this.isActive){
        $timer1.play();
        }
    };
$(init);
});
TimerBin.Obj2 = new (function(){
    var $timer2,
    incrementTime = 100,
    currentTime = 30000,
    updateTimer = function() {
        $timer2.html(currentTime);
        currentTime -= incrementTime;
        if(currentTime === 100){
            Obj1.extPause();
            this.resetTimer();
            alert("Click OK to continue accruing CME Time");
        }
    },
    init = function(){
        $timer2 = $('#output2');
        TimerBin.Obj2.Timer = $.timer(updateTimer, incrementTime, true);
    };
    this.extPlay = function(){
        if(!this.isActive){
        this.Timer.play();
        }
    };
    this.resetTimer = function(){
        currentTime = 30000;
        Obj1.extPlay();
        if(!this.isActive){
        TimerBin.Obj2.extPlay();
        }
    };
$(init);
});
$(document).keypress(function(){window.Obj2.resetTimer();});
$(document).keypress(function(){window.Obj2.resetTimer();});
$(document).click(function(){window.Obj2.resetTimer();});
$(document).click(function(){window.Obj2.resetTimer();});

Revision as of 19:40, 22 April 2014