MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
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 () { | ||
 // No external CSS needed — everything done via JS inline styles | |||
 var colors = ['#ff0000', '#ff8000', '#ffff00', '#00cc00', '#0099ff', '#8b00ff', '#ff00ff']; | |||
   var |  $('.rainbow-text').each(function () { | ||
   var chars = $(this).text().split(''); | |||
   $( |   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); | |||
  }); | |||
 }); | |||
}); | }); | ||