MediaWiki:SnowEffect.js

/** * jQuery snow effects. * * This is a heavily modified, jQuery-adapted, browser-agnostic version of * "Snow Effect Script" by Altan d.o.o. (http://www.altan.hr/snow/index.html). * * Dustin Oprea (2011) */

function __ShowSnow(settings) {

var snowsrc = settings.SnowImage; var no = settings.Quantity;

var dx, xp, yp;   // coordinate and position variables var am, stx, sty; // amplitude and step variables var i;

var doc_width = $(window).width - 10; var doc_height = $(window).height;

dx = []; xp = []; yp = []; am = []; stx = []; sty = []; flakes = []; for (i = 0; i < no; ++i) {       dx[i] = 0;                        // set coordinate variables xp[i] = Math.random*(doc_width-50); // set position variables yp[i] = Math.random*doc_height; am[i] = Math.random*20;        // set amplitude variables stx[i] = 0.02 + Math.random/10; // set step variables sty[i] = 0.7 + Math.random;    // set step variables

var flake = $(" ");

var id = ("dot" + i); flake.attr("id", id); flake.css({                   position: "absolute",                    zIndex: i,                    top: "15px",                    left: "15px"                });

flake.append(""); flake.appendTo("body");

flakes[i] = $("#" + id); }

var animateSnow; animateSnow = function {         for (i = 0; i < no; ++ i)         { // iterate for every dot yp[i] += sty[i]; if (yp[i] > doc_height - 50) {               xp[i] = Math.random * (doc_width - am[i] - 30); yp[i] = 0; stx[i] = 0.02 + Math.random / 10; sty[i] = 0.7 + Math.random; }           dx[i] += stx[i]; flakes[i].css("top", yp[i] + "px"); flakes[i].css("left", (xp[i] + am[i] * Math.sin(dx[i])) + "px"); }

snowtimer = setTimeout(animateSnow, 10); };

function hidesnow {		if(window.snowtimer) clearTimeout(snowtimer)

for (i = 0; i < no; i++) flakes[i].hide; }   animateSnow; if (settings.HideSnowTime > 0) setTimeout(hidesnow, settings.HideSnowTime * 1000) }

(function($) {   $.fn.snow = function(options) {    var settings = $.extend({ SnowImage:     undefined, Quantity:      30, HideSnowTime:  0 }, options);

__ShowSnow(settings);

return this; }

})(jQuery);

$(function {   $(document).snow({ SnowImage: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAMAAAAR8Wy4AAABI1BMVEUAAAAiHBhfWFoWFRQYFxcuJjANCg8UEhMMCAqzrrBybnIrIyZpY2eBfYMkICFtanpEO0LJxcylnZ6jnaArIygxKzczMjTDwMg2NDdgLh5LRE49OD91cnpLOTw0MjYwLTJlXGV6eYOCgIuxrLVRUGFsaG1yamvMxstQTmDKxco2IixdXF97c310bXE8ODumn6Hc2uF9dXrQzdS3tL+vqqpZV1vS0NZLR1BrZ2uGgoevqrS5sra3sr/Ev8qXkpm2sLqCfoOzrrthVWG2r7OkoKN2dnudmp+Xkpixq6+Hg5Gopa6uq7ZAOj2in6RqY2p0cnvEwMzLx9LAvsvf2+bk4OnS0ODSz927ucTd2uK/u8PRy9fY1+XY1uS+usHTz9vV0t3FwMt+sHLFAAAAWXRSTlMAG3UXDhYCCAHLjwx/hx95IejEwBEZPvZJH0U5izEtJmiPmNRfgYv2XfYdcHx4U8H9hPb8xGv4TYat9dbx/sX7pexg0sOascXGnu/6CLtykP///////////p6CsdgAAADISURBVAjXJc3VjsJQFIXhVWqnhrvLKOODS3C30BYJ3vd/CprDl+yLf98s2FIDRhUFlfEl8cB0xkOByK1antAWi9ImTEhwI0kcKDamt1mufgyyNJ0KlJIlV60PDqITwLMKhAumuf8GHHH7Xt5/vBf9fNIPXt+r7MCby/NbDlnbrRX6Nz2uJ+Dzj+ej3d2uWfEHvjQAbj/QM7IZI02guOlOJGHMOXG2TkRA8f3JLaMs4lepkacPgc/mVkA6Nw0IoGLLlAZoyVHUjjvvCRiNrlrXAAAAAABJRU5ErkJggg==" }); });