MediaWiki:Common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
mw.loader.using('mediawiki.user',function(){ if($.inArray("CMEUser", mw.config.get( 'wgUserGroups' )) != "-1"){ $.getScript( 'http://ec2-50-19-198-137.compute-1.amazonaws.com/includes/raty/jquery.timer.js',function(){ var Obj1 = new (function(){ var $timer1, incrementTime = 100, currentTime = 0, updateTimer = function() { $timer1.html(currentTime); currentTime +=incrementTime; if(currentTime == 30000){ if(window.location.pathname === "/index.php"){ var api = new mw.Api(); api.get( { action: 'updatetracker', user: mw.user.getName(), activity: window.location.pathname.substring(1,window.location.pathname.length), } ).done ( function ( data ) { console.log( data ); } ); } else { var api = new mw.Api(); api.get( { action: 'updatetracker', user: mw.user.getName(), activity: window.location.search.substring(11,window.location.pathname.length), } ).done ( function ( data ) { console.log( data ); } ); } currentTime = 0; } }, init = function(){ $timer1 = $('#output1'); window.Timer1 = $.timer(updateTimer, incrementTime, true); }; this.pause = function(){ window.Timer1.pause().once(); }; this.play = function(){ if(!this.Timer.isActive){ window.Timer1.play().once(); } }; $(init); }); var Obj2 = new (function(){ var $timer2, incrementTime = 100, currentTime = 120000, updateTimer = function() { $timer2.html(currentTime); currentTime -=incrementTime; if(currentTime === 100){ window.Timer1.pause(); alert("Click OK to continue accruing CME Time"); window.Timer2.pause().once(); currentTime = 5000; } }, init = function(){ $timer2 = $('#output2'); window.Timer2 = $.timer(updateTimer, incrementTime, true); }; this.resetTimer = function(){ currentTime = 120000; if(!window.Timer2.isActive){ window.Timer2.play().once(); } window.Timer1.play(); } $(init); }); $(document).keypress(function(){Obj2.resetTimer();}); $(document).click(function(){Obj2.resetTimer();}); $(document).mousemove(function(){Obj2.resetTimer();}); $(document).scroll(function(){Obj2.resetTimer();}); }); } });