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
 
(97 intermediate revisions by the same user not shown)
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(){
if($.inArray("CMEUser", mw.config.get( 'wgUserGroups' )) != "-1"){
var Obj1 = new (function(){
var Obj1 = new (function(){
     var $timer1,
     var $timer1,
Line 9: Line 11:
         $timer1.html(currentTime);
         $timer1.html(currentTime);
         currentTime +=incrementTime;
         currentTime +=incrementTime;
        if(currentTime == 30000){
            var api = new mw.Api();
            api.get( {
                action: 'updatetracker',
                user: mw.user.getName(),
                activity: window.location.pathname.substring(11,window.location.pathname.length),
            } ).done ( function ( data ) {
                console.log( data );
            } );
            currentTime = 0;
        }
     },
     },
     init = function(){
     init = function(){
         $timer1 = $('#output1');
         $timer1 = $('#output1');
         Obj1.Timer = $.timer(updateTimer, incrementTime, true);
         window.Timer1 = $.timer(updateTimer, incrementTime, true);
     };
     };
     this.pause = function(){
     this.pause = function(){
         this.Timer.pause().once();
         window.Timer1.pause().once();
     };
     };
     this.play = function(){
     this.play = function(){
         this.Timer.play().once();
         if(!this.Timer.isActive){
        window.Timer1.play().once();
        }
     };
     };
$(init);
$(init);
Line 25: Line 40:
     var $timer2,
     var $timer2,
     incrementTime = 100,
     incrementTime = 100,
     currentTime = 5000,
     currentTime = 120000,
     updateTimer = function() {
     updateTimer = function() {
         $timer2.html(currentTime);
         $timer2.html(currentTime);
         currentTime -=incrementTime;
         currentTime -=incrementTime;
         if(currentTime === 0){
         if(currentTime === 100){
             Obj1.pause();
             window.Timer1.pause();
             this.Timer.pause().once();
             alert("Click OK to continue accruing CME Time");
            window.Timer2.pause().once();
            currentTime = 5000;
         }
         }
     },
     },
     init = function(){
     init = function(){
         $timer2 = $('#output2');
         $timer2 = $('#output2');
         Obj2.Timer = $.timer(updateTimer, incrementTime, true);
         window.Timer2 = $.timer(updateTimer, incrementTime, true);
     };
     };
     this.resetTimer = function(){
     this.resetTimer = function(){
         currentTime = 5000;
         currentTime = 120000;
         Obj1.play();
         if(!window.Timer2.isActive){
        window.Timer2.play().once();
        }
        window.Timer1.play();
     }
     }
$(init);
$(init);
Line 48: Line 68:
$(document).mousemove(function(){Obj2.resetTimer();});
$(document).mousemove(function(){Obj2.resetTimer();});
$(document).scroll(function(){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