Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
Created page with "$(function() { var knownNewMoon = new Date('2000-01-06').getTime(); var lunarCycle = 29.53058867 * 86400000; var phase = ((Date.now() - knownNewMoon) % lunarCycle) / lunarCycle; var moons = ['🌑','🌒','🌓','🌔','🌕','🌖','🌗','🌘']; var labels = ['New Moon','Waxing Crescent','First Quarter','Waxing Gibbous', 'Full Moon','Waning Gibbous','Last Quarter','Waning Crescent']; var idx = Math.round(phase * 8) % 8; v..."
 
No edit summary
 
Line 1: Line 1:
$(function() {
$(document).ready(function () {
    var knownNewMoon = new Date('2000-01-06').getTime();
  // No external CSS needed — everything done via JS inline styles
    var lunarCycle = 29.53058867 * 86400000;
  var colors = ['#ff0000', '#ff8000', '#ffff00', '#00cc00', '#0099ff', '#8b00ff', '#ff00ff'];
    var phase = ((Date.now() - knownNewMoon) % lunarCycle) / lunarCycle;
    var moons = ['🌑','🌒','🌓','🌔','🌕','🌖','🌗','🌘'];
    var labels = ['New Moon','Waxing Crescent','First Quarter','Waxing Gibbous',
                  'Full Moon','Waning Gibbous','Last Quarter','Waning Crescent'];
    var idx = Math.round(phase * 8) % 8;


     var div = $('<div>').css({padding:'8px',textAlign:'center',fontSize:'1.4em'})
  $('.rainbow-text').each(function () {
        .html(moons[idx] + '<br><small>' + labels[idx] + '</small>');
     var chars = $(this).text().split('');
     $('#mw-panel').prepend(div); // or .append() to put it at the bottom
    var spans = chars.map(function (ch) {
      var s = document.createElement('span');
      s.textContent = ch === ' ' ? '\u00a0' : ch;
      return s;
    });
 
    $(this).empty();
     spans.forEach(function (s) { $(this).append(s); }.bind(this));
 
    spans.forEach(function (span, i) {
      var phase = i;
      setInterval(function () {
        span.style.color = colors[phase % colors.length];
        phase++;
      }, 150);
    });
  });
});
});