MediaWiki:Common.js

From SpongePedia, the First SpongeBob Wiki.
(Difference between revisions)
Jump to: navigation, search
(test)
Line 109: Line 109:
 
document.write('<script type="text/javascript" src="http://de.spongepedia.org/index.php?title='
 
document.write('<script type="text/javascript" src="http://de.spongepedia.org/index.php?title='
 
     + 'MediaWiki:Extra-Editbuttons.js&action=raw&ctype=text/javascript"><\/script>');
 
     + 'MediaWiki:Extra-Editbuttons.js&action=raw&ctype=text/javascript"><\/script>');
 +
 +
////////////////////////////////////////////////////////////////
 +
// Javascript made by Rasmus - http://www.peters1.dk //
 +
////////////////////////////////////////////////////////////////
 +
 +
var SNOW_Picture = "http://www.domain.com/billeder/snow.gif"
 +
var SNOW_no = 15;
 +
 +
var SNOW_browser_IE_NS = (document.body.clientHeight) ? 1 : 0;
 +
var SNOW_browser_MOZ = (self.innerWidth) ? 1 : 0;
 +
var SNOW_browser_IE7 = (document.documentElement.clientHeight) ? 1 : 0;
 +
 +
var SNOW_Time;
 +
var SNOW_dx, SNOW_xp, SNOW_yp;
 +
var SNOW_am, SNOW_stx, SNOW_sty;
 +
var i, SNOW_Browser_Width, SNOW_Browser_Height;
 +
 +
if (SNOW_browser_IE_NS)
 +
{
 +
SNOW_Browser_Width = document.body.clientWidth;
 +
SNOW_Browser_Height = document.body.clientHeight;
 +
}
 +
else if (SNOW_browser_MOZ)
 +
{
 +
SNOW_Browser_Width = self.innerWidth - 20;
 +
SNOW_Browser_Height = self.innerHeight;
 +
}
 +
else if (SNOW_browser_IE7)
 +
{
 +
SNOW_Browser_Width = document.documentElement.clientWidth;
 +
SNOW_Browser_Height = document.documentElement.clientHeight;
 +
}
 +
 +
SNOW_dx = new Array();
 +
SNOW_xp = new Array();
 +
SNOW_yp = new Array();
 +
SNOW_am = new Array();
 +
SNOW_stx = new Array();
 +
SNOW_sty = new Array();
 +
 +
for (i = 0; i < SNOW_no; ++ i)
 +
{
 +
SNOW_dx[i] = 0;
 +
SNOW_xp[i] = Math.random()*(SNOW_Browser_Width-50);
 +
SNOW_yp[i] = Math.random()*SNOW_Browser_Height;
 +
SNOW_am[i] = Math.random()*20;
 +
SNOW_stx[i] = 0.02 + Math.random()/10;
 +
SNOW_sty[i] = 0.7 + Math.random();
 +
if (i == 0) document.write("<\div id=\"SNOW_flake"+ i +"\" style=\"position: absolute; z-index: "+ i +"; visibility: visible; top: 15px; left: 15px;\"><a href=\"http://www.peters1.dk\" target=\"_blank\"><\img src=\""+SNOW_Picture+"\" border=\"0\"></a><\/div>");
 +
else document.write("<\div id=\"SNOW_flake"+ i +"\" style=\"position: absolute; z-index: "+ i +"; visibility: visible; top: 15px; left: 15px;\"><\img src=\""+SNOW_Picture+"\" border=\"0\"><\/div>");
 +
}
 +
 +
function SNOW_Weather()
 +
{
 +
 +
for (i = 0; i < SNOW_no; ++ i)
 +
{
 +
SNOW_yp[i] += SNOW_sty[i];
 +
 +
if (SNOW_yp[i] > SNOW_Browser_Height-50)
 +
{
 +
SNOW_xp[i] = Math.random()*(SNOW_Browser_Width-SNOW_am[i]-30);
 +
SNOW_yp[i] = 0;
 +
SNOW_stx[i] = 0.02 + Math.random()/10;
 +
SNOW_sty[i] = 0.7 + Math.random();
 +
}
 +
 +
SNOW_dx[i] += SNOW_stx[i];
 +
 +
document.getElementById("SNOW_flake"+i).style.top=SNOW_yp[i]+"px";
 +
document.getElementById("SNOW_flake"+i).style.left=SNOW_xp[i] + SNOW_am[i]*Math.sin(SNOW_dx[i])+"px";
 +
}
 +
 +
SNOW_Time = setTimeout("SNOW_Weather()", 10);
 +
 +
}
 +
 +
SNOW_Weather();

Revision as of 18:16, 19 December 2012

/* Any JavaScript here will be loaded for all users on every page load. */

/** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed, showing only the header. See
 *			   http://www.mediawiki.org/wiki/Manual:Collapsible_tables.
 *  Maintainers: [[en:User:R. Koot]]
 */
 
var autoCollapse = 2;
var collapseCaption = 'hide';
var expandCaption = 'show';
 
function collapseTable( tableIndex ) {
	var Button = document.getElementById( 'collapseButton' + tableIndex );
	var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 
	if ( !Table || !Button ) {
		return false;
	}
 
	var Rows = Table.rows;
 
	if ( Button.firstChild.data == collapseCaption ) {
		for ( var i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = 'none';
		}
		Button.firstChild.data = expandCaption;
	} else {
		for ( var i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = Rows[0].style.display;
		}
		Button.firstChild.data = collapseCaption;
	}
}
 
function createCollapseButtons() {
	var tableIndex = 0;
	var NavigationBoxes = new Object();
	var Tables = document.getElementsByTagName( 'table' );
 
	for ( var i = 0; i < Tables.length; i++ ) {
		if ( hasClass( Tables[i], 'collapsible' ) ) {
 
			/* only add button and increment count if there is a header row to work with */
			var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
			if ( !HeaderRow ) {
				continue;
			}
			var Header = HeaderRow.getElementsByTagName( 'th' )[0];
			if ( !Header ) {
				continue;
			}
 
			NavigationBoxes[tableIndex] = Tables[i];
			Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
 
			var Button = document.createElement( 'span' );
			var ButtonLink = document.createElement( 'a' );
			var ButtonText = document.createTextNode( collapseCaption );
 
			Button.className = 'collapseButton'; // Styles are declared in [[MediaWiki:Common.css]]
 
			ButtonLink.style.color = Header.style.color;
			ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
			ButtonLink.setAttribute( 'href', "javascript:collapseTable(" + tableIndex + ");" );
			ButtonLink.appendChild( ButtonText );
 
			Button.appendChild( document.createTextNode( '[' ) );
			Button.appendChild( ButtonLink );
			Button.appendChild( document.createTextNode( ']' ) );
 
			Header.insertBefore( Button, Header.childNodes[0] );
			tableIndex++;
		}
	}
 
	for ( var i = 0;  i < tableIndex; i++ ) {
		if ( hasClass( NavigationBoxes[i], 'collapsed' ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], 'autocollapse' ) ) ) {
			collapseTable( i );
		} else if ( hasClass( NavigationBoxes[i], 'innercollapse' ) ) {
			var element = NavigationBoxes[i];
			while ( element = element.parentNode ) {
				if ( hasClass( element, 'outercollapse' ) ) {
					collapseTable( i );
					break;
				}
			}
		}
	}
}
 
addOnloadHook( createCollapseButtons );
 
/** Test if an element has a certain class **************************************
 *
 * Description: Uses regular expressions and caching for better performance.
 * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 */
 
var hasClass = ( function() {
	var reCache = {};
	return function( element, className ) {
		return ( reCache[className] ? reCache[className] : ( reCache[className] = new RegExp( "(?:\\s|^)" + className + "(?:\\s|$)" ) ) ).test( element.className );
	};
})();

// [[MediaWiki:Extra-Editbuttons.js]] – diese Zeile bitte mitkopieren
document.write('<script type="text/javascript" src="http://de.spongepedia.org/index.php?title='
     + 'MediaWiki:Extra-Editbuttons.js&action=raw&ctype=text/javascript"><\/script>');

////////////////////////////////////////////////////////////////
// Javascript made by Rasmus - http://www.peters1.dk //
////////////////////////////////////////////////////////////////

var SNOW_Picture = "http://www.domain.com/billeder/snow.gif"
var SNOW_no = 15;

var SNOW_browser_IE_NS = (document.body.clientHeight) ? 1 : 0;
var SNOW_browser_MOZ = (self.innerWidth) ? 1 : 0;
var SNOW_browser_IE7 = (document.documentElement.clientHeight) ? 1 : 0;

var SNOW_Time;
var SNOW_dx, SNOW_xp, SNOW_yp;
var SNOW_am, SNOW_stx, SNOW_sty; 
var i, SNOW_Browser_Width, SNOW_Browser_Height;

if (SNOW_browser_IE_NS)
{
	SNOW_Browser_Width = document.body.clientWidth;
	SNOW_Browser_Height = document.body.clientHeight;
}
else if (SNOW_browser_MOZ)
{
	SNOW_Browser_Width = self.innerWidth - 20;
	SNOW_Browser_Height = self.innerHeight;
}
else if (SNOW_browser_IE7)
{
	SNOW_Browser_Width = document.documentElement.clientWidth;
	SNOW_Browser_Height = document.documentElement.clientHeight;
}

SNOW_dx = new Array();
SNOW_xp = new Array();
SNOW_yp = new Array();
SNOW_am = new Array();
SNOW_stx = new Array();
SNOW_sty = new Array();

for (i = 0; i < SNOW_no; ++ i) 
{ 
	SNOW_dx[i] = 0; 
	SNOW_xp[i] = Math.random()*(SNOW_Browser_Width-50);
	SNOW_yp[i] = Math.random()*SNOW_Browser_Height;
	SNOW_am[i] = Math.random()*20; 
	SNOW_stx[i] = 0.02 + Math.random()/10;
	SNOW_sty[i] = 0.7 + Math.random();
	if (i == 0) document.write("<\div id=\"SNOW_flake"+ i +"\" style=\"position: absolute; z-index: "+ i +"; visibility: visible; top: 15px; left: 15px;\"><a href=\"http://www.peters1.dk\" target=\"_blank\"><\img src=\""+SNOW_Picture+"\" border=\"0\"></a><\/div>");
	else document.write("<\div id=\"SNOW_flake"+ i +"\" style=\"position: absolute; z-index: "+ i +"; visibility: visible; top: 15px; left: 15px;\"><\img src=\""+SNOW_Picture+"\" border=\"0\"><\/div>");
}

function SNOW_Weather() 
{ 

for (i = 0; i < SNOW_no; ++ i) 
{ 
	SNOW_yp[i] += SNOW_sty[i];

	if (SNOW_yp[i] > SNOW_Browser_Height-50) 
	{
		SNOW_xp[i] = Math.random()*(SNOW_Browser_Width-SNOW_am[i]-30);
		SNOW_yp[i] = 0;
		SNOW_stx[i] = 0.02 + Math.random()/10;
		SNOW_sty[i] = 0.7 + Math.random();
	}

	SNOW_dx[i] += SNOW_stx[i];

	document.getElementById("SNOW_flake"+i).style.top=SNOW_yp[i]+"px";
	document.getElementById("SNOW_flake"+i).style.left=SNOW_xp[i] + SNOW_am[i]*Math.sin(SNOW_dx[i])+"px";
}

SNOW_Time = setTimeout("SNOW_Weather()", 10);

}

SNOW_Weather();
Personal tools
Namespaces

Variants
Actions
Navigation
Community
Content
Toolbox