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 1: Line 1:
<includeonly>
<includeonly>
<script type='text/javascript' src="http://www.wikidoc.org/includes/raty/jquery.timer.js"></script>
<script type='text/javascript'>
<script type='text/javascript'>
$.getScript( 'http://ec2-50-19-198-137.compute-1.amazonaws.com/includes/raty/jquery.timer.js',function(){
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 window.Obj1 = new (function(){
     var $timer1,
     var $timer1,
     incrementTime = 100,
     incrementTime = 100,
Line 18: Line 18:
                 activity: window.location.pathname.substring(11,window.location.pathname.length),
                 activity: window.location.pathname.substring(11,window.location.pathname.length),
             } ).done ( function ( data ) {
             } ).done ( function ( data ) {
                alert("Triggered");
                 console.log( data );
                 console.log( data );
             } );
             } );
Line 38: Line 37:
$(init);
$(init);
});
});
var Obj2 = new (function(){
var window.Obj2 = new (function(){
     var $timer2,
     var $timer2,
     incrementTime = 100,
     incrementTime = 100,
     currentTime = 120000,
     currentTime = 30000,
     updateTimer = function() {
     updateTimer = function() {
         $timer2.html(currentTime);
         $timer2.html(currentTime);
         currentTime -=incrementTime;
         currentTime -=incrementTime;
         if(currentTime === 100){
         if(currentTime === 100){
             Obj1.pause();
             window.Obj1.pause();
             alert("Click OK to continue accruing CME Time");
             alert("Click OK to continue accruing CME Time");
             Obj2.Timer.pause().once();
             window.Obj2.Timer.pause().once();
             currentTime = 5000;
             currentTime = 30000;
         }
         }
     },
     },
     init = function(){
     init = function(){
         $timer2 = $('#output2');
         $timer2 = $('#output2');
         Obj2.Timer = $.timer(updateTimer, incrementTime, true);
         window.Obj2.Timer = $.timer(updateTimer, incrementTime, true);
     };
     };
     this.resetTimer = function(){
     this.resetTimer = function(){
         currentTime = 120000;
         currentTime = 30000;
         if(!this.Timer.isActive){
         if(!this.Timer.isActive){
         this.Timer.play().once();
         this.Timer.play().once();
Line 65: Line 64:
$(init);
$(init);
});
});
$(document).keypress(function(){Obj2.resetTimer();});
$(document).keypress(function(){window.Obj2.resetTimer();});
$(document).click(function(){Obj2.resetTimer();});
$(document).click(function(){window.Obj2.resetTimer();});
$(document).mousemove(function(){Obj2.resetTimer();});
$(document).mousemove(function(){window.Obj2.resetTimer();});
$(document).scroll(function(){Obj2.resetTimer();});
$(document).scroll(function(){window.Obj2.resetTimer();});
}
}
});
});
});
</script>
</script>
<span id="output2"></span>
<span id="output2"></span>
</includeonly>
</includeonly>

Revision as of 16:29, 22 April 2014