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
 
(48 intermediate revisions by the same user not shown)
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"){
window.Obj1 = new (function(){
var Obj1 = new (function(){
     var $timer1,
     var $timer1,
     incrementTime = 100,
     incrementTime = 100,
Line 25: Line 25:
     init = function(){
     init = function(){
         $timer1 = $('#output1');
         $timer1 = $('#output1');
         this.Timer = $.timer(updateTimer, incrementTime, true);
         window.Timer1 = $.timer(updateTimer, incrementTime, true);
    };
    this.pause = function(){
        window.Timer1.pause().once();
     };
     };
     this.play = function(){
     this.play = function(){
         if(!this.Timer.isActive){
         if(!this.Timer.isActive){
         this.play().once();
         window.Timer1.play().once();
         }
         }
     };
     };
$(init);
$(init);
});
});
window.Obj2 = new (function(){
var Obj2 = new (function(){
     var $timer2,
     var $timer2,
     incrementTime = 100,
     incrementTime = 100,
     currentTime = 30000,
     currentTime = 120000,
     updateTimer = function() {
     updateTimer = function() {
         $timer2.html(currentTime);
         $timer2.html(currentTime);
         currentTime -=incrementTime;
         currentTime -=incrementTime;
         if(currentTime === 100){
         if(currentTime === 100){
             window.Obj1.pause();
             window.Timer1.pause();
             alert("Click OK to continue accruing CME Time");
             alert("Click OK to continue accruing CME Time");
             window.Obj2.Timer.pause().once();
             window.Timer2.pause().once();
             currentTime = 30000;
             currentTime = 5000;
         }
         }
     },
     },
     init = function(){
     init = function(){
         $timer2 = $('#output2');
         $timer2 = $('#output2');
         this.Timer = $.timer(updateTimer, incrementTime, true);
         window.Timer2 = $.timer(updateTimer, incrementTime, true);
     };
     };
     this.resetTimer = function(){
     this.resetTimer = function(){
         currentTime = 30000;
         currentTime = 120000;
         if(!this.isActive){
         if(!window.Timer2.isActive){
         Obj2.play();
         window.Timer2.play().once();
         }
         }
         Obj1.play();
         window.Timer1.play();
     }
     }
$(init);
$(init);
});
});
$(document).keypress(function(){window.Obj2.resetTimer();});
$(document).keypress(function(){Obj2.resetTimer();});
$(document).click(function(){window.Obj2.resetTimer();});
$(document).click(function(){Obj2.resetTimer();});
$(document).mousemove(function(){window.Obj2.resetTimer();});
$(document).mousemove(function(){Obj2.resetTimer();});
$(document).scroll(function(){window.Obj2.resetTimer();});
$(document).scroll(function(){Obj2.resetTimer();});
}
}
});
});
});
});
</script>
</script>
<span id="output1"></span><br />
<span id="output1"></span><br />
<span id="output2"></span>
<span id="output2"></span>
</includeonly>
</includeonly>

Latest revision as of 18:26, 24 April 2014