MediaWiki:Monobook.js

From Illogicopedia
Jump to navigation Jump to search

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
 function nextFullMoonTime(){
 //Authored by: JaeSharp (http://furry.wikia.com/wiki/User:JSharp)
 //this function calculates the date/time of the next full moon using the current date/time and moon cycle
 //this is evil, evil, evil... watch for interactions with script load order and dynamic updating of countdowntimer from Splarka's script.
 
 time = document.getElementsByClassName('countdowntimer'); //get all timer spans on page (an array)
 if (time.length == 0) return; //no timers on page, nothing to do.
 
 for (var timedisplay in time) {
   currentMoonScaledPhase = parseFloat(timedisplay.nextSibling.firstChild.nodeValue);//grab current moon scaled cycle position
   var t;
   if (currentMoonScaledPhase > 2.0) {
     t = 6.0-currentMoonScaledPhase; }
   else {
     t = 2.0-currentMoonScaledPhase; }
   //t is scaled time remaining until next full moon
   daysRemaining = 7.382647 * t; //scale back to actual days
   timedisplay.eventdate = new Date((new Date()).getTime()+ daysRemaining*24*60*60*1000);
  }
 }
$(nextFullMoonTime);