Welcome to the RuneGlory Wiki, where we do our best to make your life easier!

You can use the search menu on the right side of the wiki (or at the bottom if you are on mobile) to search for the page you are looking for. The most popular pages can be found on the right side of the wiki aswell (or again at the bottom if you are on mobile).

MediaWiki:Common.js

From RuneGlory
Revision as of 20:10, 12 August 2021 by Dannyx (talk | contribs)
Jump to: navigation, search
// ***************************** Structure *****************************

// Remove unnecessary elements

$( "div#p-tb" ).remove();

// Wrap the content

$( "div#content, div#mw-navigation" ).wrapAll( "<div id='wrap'></div>" );

// Insert the header

$( "<header><div id='logo'><a href='https://wiki.etherumps.com/Main_page'><img src='https://i.imgur.com/ggx8Fv6.png' draggable='false' style='width: 375px'></a></div><nav><ul><li id='n-Home'><a href='https://www.etherumps.com/'>Home</a></li><li id='n-Forums'><a href='http://forum.etherumps.com/'>Forums</a></li><li id='n-Discord'><a href='https://discordapp.com/invite/nDWHzGG'>Discord</a></li><li id='n-Wiki'><a href='/Main_page'>Wiki</a></li><li id='n-Vote'><a href='https://www.etherumps.com/vote/status'>Vote</a></li><li id='n-Donate'><a href='https://www.etherumps.com/donate'>Donate</a></li><li id='n-Marketplace'><a href='https://www.etherumps.com/marketplace/all'>Marketplace</a></li><li id='n-Highscores'><a href='https://www.etherumps.com/highscores/mode/regular'>Highscores</a></li><li id='n-Webclient'><a href='http://www.etherumps.com/play'>Webclient</a></li><li id='n-Download'><a href='https://www.etherumps.com/play/download'>Download</a></li></ul></nav></header>" ).insertBefore( "div#wrap" );

// Insert the footer

$( "<div id='customFooter'><div style='margin-bottom: 30px; line-height: 0;'><a href='https://www.facebook.com/etherumps.com' style='background: url(https://i.imgur.com/DeOQfOs.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3a589e; border: 1px solid #17274D;'></a><a href='https://twitter.com/Etherum' style='background: url(https://i.imgur.com/GZzo3yV.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #3A89C4; border: 1px solid #0E3959;'></a><a href='https://www.youtube.com/channel/UCVGi_iQHwRSGY36ff40SkYA' style='background: url(https://i.imgur.com/wF3Xf61.png) no-repeat center, linear-gradient( transparent,rgba(0, 0, 0, 0.15)), #C8312B; border: 1px solid #78130F;'></a></div><p style='margin-bottom: 0;'>Etherum is not affiliated with Jagex or RuneScape in any way.</p></div>" ).insertBefore( "ul#footer-places" );

// Organize the elements

$( "div#mw-navigation" ).insertBefore( "div#content" );
$( "div#content" ).wrap( "<div id='content-sidebar-wrap'></div>" );
$( "div#mw-panel" ).insertAfter( "div#content" );
$( "div#content" ).wrap( "<div id='content-wrap'></div>" );

$( "<div id='navigation'></div>" ).prependTo( "div#content" );
$( "div#left-navigation" ).appendTo( "div#navigation" );
$( "div#right-navigation" ).appendTo( "div#navigation" );

$( "<div id='pageInfo'></div>" ).insertBefore( "div#content" );

$( "div#content" ).wrap( "<div id='content-navigation-wrap'></div>" );
$( "div#siteNotice" ).insertAfter( "div#mw-navigation" );
$( "ul#footer-info" ).insertAfter( "div#content" );

// Set up the page footer info

if ( $( "li#footer-info-credits" ).length > 0 ) {
	$( "li#footer-info-credits" ).html( $( "li#footer-info-credits" ).html().replace( /\[/g, "<span style='position: absolute; right: 0;'>" ).replace( /\]/g, "</span>" ).replace( /\{/g, "<p id='contentFooter' style='position: relative;'>" ).replace( /\}/g, "</p>" ) );
	$( "p#contentFooter" ).insertBefore( "li#footer-info-credits" );
	$( "li#footer-info-credits" ).remove();
}

// Set up the page title and breadcrumb

var title = $( "h1#firstHeading" ).html().split('/');
$( "h1#firstHeading" ).html( title[ title.length - 1 ] );
$( "h1#firstHeading" ).appendTo( "div#pageInfo" );

$( "span.subpages" ).appendTo( "div#pageInfo" );
$( "span.subpages" ).html( $( "span.subpages" ).children() );
$( "<span>" + title[ title.length - 1 ] + "</span>" ).appendTo( "span.subpages" );
$( "<span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>" ).insertAfter( "span.subpages > a" );

// Set up the page title

document.title = title[ title.length - 1 ] + " - Etherum Wiki";

// Set up the announcement

$( "<div id='noticeTitle'>Notice</div>" ).prependTo( "div#siteNotice" );

// Remove href from selected tabs

$.each( $( "div.vectorTabs li.selected" ), function() {
	$( this ).find( "a" ).removeAttr( "href" );
});

// Remove title from links

$( "a" ).removeAttr( "title" );

// Set up the search box

$( "div#p-search" ).prependTo( "div#mw-panel" );
$( "<div id='searchTitle'>Search</div>" ).insertBefore( "form#searchform" );
$( "input#searchInput" ).val( "Search..." ).removeAttr( "placeholder" ).attr( "onfocus", "if (this.value == 'Search...') {this.value = '';}" ).attr( "onblur", "if (this.value == '') {this.value = 'Search...';}" );

// Set up the edit box

function wrapText( elementID, openTag, closeTag ) {
	var textArea = $( "#" + elementID );
	var len = textArea.val().length;
	var start = textArea[0].selectionStart;
	var end = textArea[0].selectionEnd;
	var selectedText = textArea.val().substring( start, end );
	var replacement = openTag + selectedText + closeTag;
	textArea.val( textArea.val().substring( 0, start ) + replacement + textArea.val().substring( end, len ) );
}

$( "input#wpWatchthis" ).prop( "checked", false );

$( "<div class='customButton' id='CB-Nowiki' style='background: url(https://i.imgur.com/Fx2AsCt.png);' title='Ignore wiki formatting'></div>" ).appendTo( "div#toolbar" );
$( "#CB-Nowiki" ).click( function() {
	wrapText( "wpTextbox1", "<nowiki>", "</nowiki>" );
});

$( "<div class='customButton' id='CB-Heading2' style='background: url(https://i.imgur.com/8uajyYO.png);' title='Level 2 heading'></div>" ).prependTo( "div#toolbar" );
$( "#CB-Heading2" ).click( function() {
	wrapText( "wpTextbox1", "<h2>", "</h2>" );
});

$( "<div class='customButton' id='CB-Heading1' style='background: url(https://i.imgur.com/jKOOZnF.png);' title='Level 1 heading'></div>" ).prependTo( "div#toolbar" );
$( "#CB-Heading1" ).click( function() {
	wrapText( "wpTextbox1", "<h1>", "</h1>" );
});

$( "<div class='customButton' id='CB-Italic' style='background: url(https://i.imgur.com/zdPfv0X.png);' title='Italic text'></div>" ).prependTo( "div#toolbar" );
$( "#CB-Italic" ).click( function() {
	wrapText( "wpTextbox1", "<i>", "</i>" );
});

$( "<div class='customButton' id='CB-Bold' style='background: url(https://i.imgur.com/lyqhAM9.png);' title='Bold text'></div>" ).prependTo( "div#toolbar" );
$( "#CB-Bold" ).click( function() {
	wrapText( "wpTextbox1", "<b>", "</b>" );
});

// Remove auto correct from text boxes

$( "textarea#wpTextbox1, input#searchInput, input#database_input" ).attr( "spellcheck", "false" );










// ***************************** Indices *****************************

$.each( $( "div.timestamp" ), function() {
	var str = $( this ).html();
	var year = str.substr( 0, 4 );
	var month = str.substr( 4, 2 );
		if ( month == 01 ) { month = " January " }
		else if ( month == 02 ) { month = " February " }
		else if ( month == 03 ) { month = " March " }
		else if ( month == 04 ) { month = " April " }
		else if ( month == 05 ) { month = " May " }
		else if ( month == 06 ) { month = " June " }
		else if ( month == 07 ) { month = " July " }
		else if ( month == 08 ) { month = " August " }
		else if ( month == 09 ) { month = " September " }
		else if ( month == 10 ) { month = " October " }
		else if ( month == 11 ) { month = " November " }
		else if ( month == 12 ) { month = " December " }
	var day = str.substr( 6, 2 );
	$( this ).html( "Last modified on " + day + month + year + "." );
	if ( str == "" ) {
		$( this ).html( "This page is under construction." );
	}
});
$.each( $( "div.link > a" ), function() {
	var link = $( this ).html().split( "/" );
	$( this ).html( link[ link.length - 1 ].replace( /\_/g, " " ) );
});









// ***************************** Databases *****************************

function commaSeparateNumber( val ){
	while ( /(\d+)(\d{3})/.test( val.toString() ) ) {
		val = val.toString().replace( /(\d+)(\d{3})/, '$1' + '.' + '$2' );
	};
	return val;
};

$( "button#database_button" ).click( function() {
	searchDatabase();
});






// **************************** SNOW *****************************
/*window.snowStorm = {
 
	// --- common properties ---
 
	autoStart: true,		// Whether the snow should start automatically or not.
	flakesMax: 50,			// Limit total amount of snow made (falling + sticking)
	flakesMaxActive: 50,		// Limit amount of snow falling at once (less = lower CPU use)
	animationInterval: 35,		// Theoretical "miliseconds per frame" measurement. 20 = fast + smooth, but high CPU use. 50 = more conservative, but slower
	excludeMobile: true,		// Snow is likely to be bad news for mobile phones' CPUs (and batteries.) By default, be nice.
	flakeBottom: null,		// Integer for Y axis snow limit, 0 or null for "full-screen" snow effect
	followMouse: false,		// Snow movement can respond to the user's mouse
	snowColor: '#fff',		// Don't eat (or use?) yellow snow.
	snowCharacter: '&bull;',	// &bull; = bullet, &middot; is square on some systems etc.
	snowStick: false,		// Whether or not snow should "stick" at the bottom. When off, will never collect.
	targetElement: document.body,	// element which snow will be appended to (null = document.body) - can be an element ID eg. 'myDiv', or a DOM node reference
	useMeltEffect: true,		// When recycling fallen snow (or rarely, when falling), have it "melt" and fade out if browser supports it
	useTwinkleEffect: false,	// Allow snow to randomly "flicker" in and out of view while falling
	usePositionFixed: true,		// true = snow does not shift vertically when scrolling. May increase CPU load, disabled by default - if enabled, used only where supported
 
	// --- less-used bits ---
 
	freezeOnBlur: true,		// Only snow when the window is in focus (foreground.) Saves CPU.
	flakeLeftOffset: 0,		// Left margin/gutter space on edge of container (eg. browser window.) Bump up these values if seeing horizontal scrollbars.
	flakeRightOffset: 0,		// Right margin/gutter space on edge of container
	flakeWidth: 8,			// Max pixel width reserved for snow element
	flakeHeight: 8,			// Max pixel height reserved for snow element
	vMaxX: 5,			// Maximum X velocity range for snow
	vMaxY: 4,			// Maximum Y velocity range for snow
	zIndex: 0			// CSS stacking order applied to each snowflake
};
// --- End of user section ---
 
snowStorm.internal = {
	// UA sniffing and backCompat rendering mode checks for fixed position, etc.
	isIE: navigator.userAgent.match(/msie/i),
	isIE6: navigator.userAgent.match(/msie 6/i),
	isWin98: navigator.appVersion.match(/windows 98/i),
	isMobile: navigator.userAgent.match(/mobile|opera m(ob|in)/i),
	screenX: null,
	screenX2: null,
	screenY: null,
	scrollY: null,
	vRndX: null,
	vRndY: null,
	windOffset: 1,
	windMultiplier: 2,
	flakeTypes: 6,
	fixedForEverything: false,
	opacitySupported: true,
	didInit: false,
	docFrag: document.createDocumentFragment()
};
snowStorm.internal.isBackCompatIE = (snowStorm.internal.isIE && document.compatMode == 'BackCompat');
snowStorm.internal.noFixed = (snowStorm.internal.isMobile || snowStorm.internal.isBackCompatIE || snowStorm.internal.isIE6);
try {
	document.createElement('div').style.opacity = '0.5';
} catch(e) {
	snowStorm.internal.opacitySupported = false;
}
 
snowStorm.timers = [];
snowStorm.flakes = [];
snowStorm.disabled = false;
snowStorm.active = false;
snowStorm.meltFrameCount = 20;
snowStorm.meltFrames = [];
 
snowStorm.events = {};
snowStorm.events.add = function(element, listener, func) {
	if (!window.addEventListener && window.attachEvent) {
		element.attachEvent('on' + listener, func);
	}
	else {
		element.addEventListener.apply(element, Array.prototype.slice.call(arguments, 1))
	}
}
snowStorm.events.remove = function(element, listener, func) {
	if (!window.addEventListener && window.attachEvent) {
		element.detachEvent('on' + listener, func);
	}
	else {
		element.removeEventListener.apply(element, Array.prototype.slice.call(arguments, 1))
	}
}
 
function rnd(n, min) {
	if (isNaN(min)) {
		min = 0;
	}
	return (Math.random() * n) + min;
}
 
function plusMinus(n) {
	if (parseInt(rnd(2), 10) == 1) {
		return n * -1;
	}
	else {
		return n;
	}
}
 
snowStorm.randomizeWind = function() {
	snowStorm.internal.vRndX = plusMinus(rnd(snowStorm.vMaxX, 0.2));
	snowStorm.internal.vRndY = rnd(snowStorm.vMaxY, 0.2);
	if (snowStorm.flakes) {
		for (var i = 0; i < snowStorm.flakes.length; i++) {
			if (snowStorm.flakes[i].active) {
				snowStorm.flakes[i].setVelocities();
			}
		}
	}
};
 
snowStorm.scrollHandler = function() {
	// "attach" snowflakes to bottom of window if no absolute bottom value was given
	snowStorm.internal.scrollY = (snowStorm.flakeBottom ? 0 : parseInt(window.scrollY || document.documentElement.scrollTop || document.body.scrollTop, 10));
	if (isNaN(snowStorm.internal.scrollY)) {
		snowStorm.internal.scrollY = 0; // Netscape 6 scroll fix
	}
	if (!snowStorm.internal.fixedForEverything && !snowStorm.flakeBottom && snowStorm.flakes) {
		for (var i = snowStorm.flakes.length - 1; i >= 0; i--) {
			if (snowStorm.flakes[i].active == 0) {
				snowStorm.flakes[i].stick();
			}
		}
	}
};
 
snowStorm.resizeHandler = function() {
	if (window.innerWidth || window.innerHeight) {
		snowStorm.internal.screenX = window.innerWidth - 16 - snowStorm.flakeRightOffset;
		snowStorm.internal.screenY = (snowStorm.flakeBottom ? snowStorm.flakeBottom : window.innerHeight);
	} else {
		snowStorm.internal.screenX = (document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth) - (!snowStorm.internal.isIE ? 8 : 0) - snowStorm.flakeRightOffset;
		snowStorm.internal.screenY = snowStorm.flakeBottom ? snowStorm.flakeBottom : (document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight);
	}
	snowStorm.internal.screenX2 = parseInt(snowStorm.internal.screenX / 2, 10);
};
 
snowStorm.resizeHandlerAlt = function() {
	snowStorm.internal.screenX = snowStorm.targetElement.offsetLeft + snowStorm.targetElement.offsetWidth - snowStorm.flakeRightOffset;
	snowStorm.internal.screenY = snowStorm.flakeBottom ? snowStorm.flakeBottom : snowStorm.targetElement.offsetTop + snowStorm.targetElement.offsetHeight;
	snowStorm.internal.screenX2 = parseInt(snowStorm.internal.screenX/2,10);
};
 
snowStorm.freeze = function() {
	// pause animation
	if (!snowStorm.disabled) {
		snowStorm.disabled = 1;
	} else {
		return false;
	}
	for (var i = snowStorm.timers.length - 1; i >= 0; i--) {
		clearInterval(snowStorm.timers[i]);
	}
};
 
snowStorm.resume = function() {
	if (snowStorm.disabled) {
		snowStorm.disabled = 0;
	} else {
		return false;
	}
	snowStorm.timerInit();
};
 
snowStorm.toggleSnow = function() {
	if (!snowStorm.flakes.length) {
		// first run
		snowStorm.start();
	} else {
		snowStorm.active = !snowStorm.active;
		if (snowStorm.active) {
			snowStorm.show();
			snowStorm.resume();
		} else {
			snowStorm.stop();
			snowStorm.freeze();
		}
	}
};
 
snowStorm.stop = function() {
	snowStorm.freeze();
	for (var i = snowStorm.flakes.length - 1; i >= 0; i--) {
		snowStorm.flakes[i].o.style.display = 'none';
	}
	snowStorm.events.remove(window, 'scroll', snowStorm.scrollHandler);
	snowStorm.events.remove(window, 'resize', snowStorm.resizeHandler);
	if (snowStorm.freezeOnBlur) {
		if (snowStorm.internal.isIE) {
			snowStorm.events.remove(document, 'focusout', snowStorm.freeze);
			snowStorm.events.remove(document, 'focusin', snowStorm.resume);
		} else {
			snowStorm.events.remove(window, 'blur', snowStorm.freeze);
			snowStorm.events.remove(window, 'focus', snowStorm.resume);
		}
	}
};
 
snowStorm.show = function() {
	for (var i = snowStorm.flakes.length - 1; i >= 0; i--) {
		snowStorm.flakes[i].o.style.display = 'block';
	}
};
 
snowStorm.SnowFlake = function(type, x, y) {
	this.type = type;
	this.x = x || parseInt(rnd(snowStorm.internal.screenX - 20), 10);
	this.y = (!isNaN(y) ? y : -rnd(snowStorm.internal.screenY) - 12);
	this.vX = null;
	this.vY = null;
	this.vAmpTypes = [1, 1.2, 1.4, 1.6, 1.8]; // "amplification" for vX/vY (based on flake size/type)
	this.vAmp = this.vAmpTypes[this.type];
	this.melting = false;
	this.meltFrameCount = snowStorm.meltFrameCount;
	this.meltFrames = snowStorm.meltFrames;
	this.meltFrame = 0;
	this.twinkleFrame = 0;
	this.active = 1;
	this.fontSize = (10 + (this.type / 5) * 10);
	this.o = document.createElement('div');
	this.o.innerHTML = snowStorm.snowCharacter;
	this.o.style.color = snowStorm.snowColor;
	this.o.style.position = (snowStorm.internal.fixedForEverything ? 'fixed' : 'absolute');
	this.o.style.width = snowStorm.flakeWidth + 'px';
	this.o.style.height = snowStorm.flakeHeight + 'px';
	this.o.style.fontFamily = 'arial,verdana';
	this.o.style.cursor = 'default';
	this.o.style.overflow = 'hidden';
	this.o.style.fontWeight = 'normal';
	this.o.style.zIndex = snowStorm.zIndex;
	snowStorm.internal.docFrag.appendChild(this.o);
 
	this.refresh = function() {
		if (isNaN(this.x) || isNaN(this.y)) {
			// safety check
			return false;
		}
		this.o.style.left = this.x + 'px';
		this.o.style.top = this.y + 'px';
	};
 
	this.stick = function() {
		if (snowStorm.internal.noFixed || (snowStorm.targetElement !== document.documentElement && snowStorm.targetElement !== document.body)) {
			this.o.style.top = (snowStorm.internal.screenY + snowStorm.internal.scrollY - snowStorm.flakeHeight) + 'px';
		} else if (snowStorm.flakeBottom) {
			this.o.style.top = snowStorm.flakeBottom + 'px';
		} else {
			this.o.style.display = 'none';
			this.o.style.top = 'auto';
			this.o.style.bottom = '0px';
			this.o.style.position = 'fixed';
			this.o.style.display = 'block';
		}
	};
 
	this.vCheck = function() {
		if (this.vX >= 0 && this.vX < 0.2) {
			this.vX = 0.2;
		} else if (this.vX < 0 && this.vX > -0.2) {
			this.vX = -0.2;
		}
		if (this.vY >= 0 && this.vY < 0.2) {
			this.vY = 0.2;
		}
	};
 
	this.move = function() {
		var vX = this.vX * snowStorm.internal.windOffset;
		this.x += vX;
		this.y += (this.vY * this.vAmp);
		if (this.x >= snowStorm.internal.screenX || snowStorm.internal.screenX - this.x < snowStorm.flakeWidth) { // X-axis scroll check
			this.x = 0;
		} else if (vX < 0 && this.x - snowStorm.flakeLeftOffset < -snowStorm.flakeWidth) {
			this.x = snowStorm.internal.screenX - snowStorm.flakeWidth-1; // flakeWidth;
		}
		this.refresh();
		var yDiff = snowStorm.internal.screenY + snowStorm.internal.scrollY - this.y;
		if (yDiff < snowStorm.flakeHeight) {
			this.active = 0;
			if (snowStorm.snowStick) {
				this.stick();
			} else {
				this.recycle();
			}
		} else {
			if (snowStorm.useMeltEffect && this.active && this.type < 3 && !this.melting && Math.random() > 0.998) {
				// ~1/1000 chance of melting mid-air, with each frame
				this.melting = true;
				this.melt();
				// only incrementally melt one frame
				// this.melting = false;
			}
			if (snowStorm.useTwinkleEffect) {
				if (!this.twinkleFrame) {
					if (Math.random() > 0.9) {
						this.twinkleFrame = parseInt(Math.random() * 20, 10);
					}
				} else {
					this.twinkleFrame--;
					this.o.style.visibility = (this.twinkleFrame && this.twinkleFrame % 2 == 0 ? 'hidden' : 'visible');
				}
			}
		}
	};
 
	this.animate = function() {
		// main animation loop
		// move, check status, die etc.
		this.move();
	};
 
	this.setVelocities = function() {
		this.vX = snowStorm.internal.vRndX + rnd(snowStorm.vMaxX * 0.12, 0.1);
		this.vY = snowStorm.internal.vRndY + rnd(snowStorm.vMaxY * 0.12, 0.1);
	};
 
	this.setOpacity = function(o, opacity) {
		if (!snowStorm.internal.opacitySupported) {
			return false;
		}
		o.style.opacity = opacity;
	};
 
	this.melt = function() {
		if (!snowStorm.useMeltEffect || !this.melting) {
			this.recycle();
		} else {
			if (this.meltFrame < this.meltFrameCount) {
				this.setOpacity(this.o, this.meltFrames[this.meltFrame]);
				this.o.style.fontSize = this.fontSize - (this.fontSize * (this.meltFrame / this.meltFrameCount)) + 'px';
				this.o.style.lineHeight = snowStorm.flakeHeight + 2 + (snowStorm.flakeHeight * 0.75 * (this.meltFrame / this.meltFrameCount)) + 'px';
				this.meltFrame++;
			} else {
				this.recycle();
			}
		}
	};
 
	this.recycle = function() {
		this.o.style.display = 'none';
		this.o.style.position = (snowStorm.internal.fixedForEverything ? 'fixed' : 'absolute');
		this.o.style.bottom = 'auto';
		this.setVelocities();
		this.vCheck();
		this.meltFrame = 0;
		this.melting = false;
		this.setOpacity(this.o, 1);
		this.o.style.padding = '0px';
		this.o.style.margin = '0px';
		this.o.style.fontSize = this.fontSize + 'px';
		this.o.style.lineHeight = (snowStorm.flakeHeight + 2) + 'px';
		this.o.style.textAlign = 'center';
		this.o.style.verticalAlign = 'baseline';
		this.x = parseInt(rnd(snowStorm.internal.screenX - snowStorm.flakeWidth - 20), 10);
		this.y = parseInt(rnd(snowStorm.internal.screenY) * -1, 10) - snowStorm.flakeHeight;
		this.refresh();
		this.o.style.display = 'block';
		this.active = 1;
	};
 
	this.recycle(); // set up x/y coords etc.
	this.refresh();
 
};
 
snowStorm.snow = function() {
	var active = 0;
	var used = 0;
	var waiting = 0;
	var flake = null;
	for (var i = snowStorm.flakes.length - 1; i >= 0; i--) {
		if (snowStorm.flakes[i].active == 1) {
			snowStorm.flakes[i].move();
			active++;
		} else if (snowStorm.flakes[i].active == 0) {
			used++;
		} else {
			waiting++;
		}
		if (snowStorm.flakes[i].melting) {
			snowStorm.flakes[i].melt();
		}
	}
	if (active < snowStorm.flakesMaxActive) {
		flake = snowStorm.flakes[parseInt(rnd(snowStorm.flakes.length), 10)];
		if (flake.active == 0) {
			flake.melting = true;
		}
	}
};
 
snowStorm.mouseMove = function(e) {
	if (!snowStorm.followMouse) {
		return true;
	}
	var x = parseInt(e.clientX, 10);
	if (x < snowStorm.internal.screenX2) {
		snowStorm.internal.windOffset = -snowStorm.internal.windMultiplier + (x / snowStorm.internal.screenX2 * snowStorm.internal.windMultiplier);
	} else {
		x -= snowStorm.internal.screenX2;
		snowStorm.internal.windOffset = (x / snowStorm.internal.screenX2) * snowStorm.internal.windMultiplier;
	}
};
 
snowStorm.createSnow = function(limit, allowInactive) {
	for (var i = 0; i < limit; i++) {
		snowStorm.flakes.push(new snowStorm.SnowFlake(parseInt(rnd(snowStorm.internal.flakeTypes), 10)));
		if (allowInactive || i > snowStorm.flakesMaxActive) {
			snowStorm.flakes[snowStorm.flakes.length - 1].active = -1;
		}
	}
	snowStorm.targetElement.appendChild(snowStorm.internal.docFrag);
};
 
snowStorm.timerInit = function() {
	snowStorm.timers = (!snowStorm.internal.isWin98 ? [setInterval(snowStorm.snow, snowStorm.animationInterval)] : [setInterval(snowStorm.snow, snowStorm.animationInterval * 3), setInterval(snowStorm.snow, snowStorm.animationInterval)]);
};
 
snowStorm.init = function() {
	for (var i = 0; i < snowStorm.meltFrameCount; i++) {
		snowStorm.meltFrames.push(1 - (i / snowStorm.meltFrameCount));
	}
	snowStorm.randomizeWind();
	snowStorm.createSnow(snowStorm.flakesMax); // create initial batch
	snowStorm.events.add(window, 'resize', snowStorm.resizeHandler);
	snowStorm.events.add(window, 'scroll', snowStorm.scrollHandler);
	if (snowStorm.freezeOnBlur) {
		if (snowStorm.internal.isIE) {
			snowStorm.events.add(document, 'focusout', snowStorm.freeze);
			snowStorm.events.add(document, 'focusin', snowStorm.resume);
		} else {
			snowStorm.events.add(window, 'blur', snowStorm.freeze);
			snowStorm.events.add(window, 'focus', snowStorm.resume);
		}
	}
	snowStorm.resizeHandler();
	snowStorm.scrollHandler();
	if (snowStorm.followMouse) {
		snowStorm.events.add(snowStorm.internal.isIE ? document : window, 'mousemove', snowStorm.mouseMove);
	}
	snowStorm.animationInterval = Math.max(20, snowStorm.animationInterval);
	snowStorm.timerInit();
};
 
snowStorm.start = function(bFromOnLoad) {
	if (!snowStorm.internal.didInit) {
		snowStorm.internal.didInit = true;
	} else if (bFromOnLoad) {
		// already loaded and running
		return true;
	}
	if (typeof snowStorm.targetElement == 'string') {
		var targetID = snowStorm.targetElement;
		snowStorm.targetElement = document.getElementById(targetID);
		if (!snowStorm.targetElement) {
			throw new Error('Snowstorm: Unable to get targetElement "' + targetID + '"');
		}
	}
	if (!snowStorm.targetElement) {
		snowStorm.targetElement = (!snowStorm.internal.isIE ? (document.documentElement ? document.documentElement : document.body) : document.body);
	}
	if (snowStorm.targetElement !== document.documentElement && snowStorm.targetElement !== document.body) {
		snowStorm.resizeHandler = snowStorm.resizeHandlerAlt; // re-map handler to get element instead of screen dimensions
	}
	snowStorm.resizeHandler(); // get bounding box elements
	snowStorm.usePositionFixed = (snowStorm.usePositionFixed && !snowStorm.internal.noFixed); // whether or not position:fixed is supported
	snowStorm.internal.fixedForEverything = snowStorm.usePositionFixed;
	if (snowStorm.internal.screenX && snowStorm.internal.screenY && !snowStorm.disabled) {
		snowStorm.init();
		snowStorm.active = true;
	}
};
 
function doDelayedStart() {
	setTimeout(function() {
		snowStorm.start(true);
	}, 20);
	// event cleanup
	snowStorm.events.remove(snowStorm.internal.isIE ? document : window, 'mousemove', doDelayedStart);
}
 
function doStart() {
	if (!snowStorm.excludeMobile || !snowStorm.internal.isMobile) {
		if (snowStorm.freezeOnBlur) {
			snowStorm.events.add(snowStorm.internal.isIE ? document : window, 'mousemove', doDelayedStart);
		} else {
			doDelayedStart();
		}
	}
	// event cleanup
	snowStorm.events.remove(window, 'load', doStart);
}
 
// hooks for starting the snow
if (snowStorm.autoStart) {
	snowStorm.events.add(window, 'load', doStart, false);
}*/




// ***************************** Close *****************************
// Remove the loader

	$( "div#mw-head-base" ).hide();
	$( "div#mw-page-base" ).hide();