User:Majr/hydra.js

mw.loader.localLoad = function( url ) { return mw.loader.load( 'http://www.minecraftwiki.net/wiki/' + url + '?action=raw&ctype=text/javascript' ); };

// Uses AJAX for previewing and showing changes - Original script: wikipedia:User:Js/ajaxPreview.js if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) { mw.loader.localLoad( 'User:Ultradude25/ajaxPreview.js' ); }

// Counts all your edits and saves them to a page - Original script: if ( mw.config.get( 'wgTitle' ) === mw.config.get( 'wgUserName' ) && mw.config.get( 'wgNamespaceNumber' ) === 2) { mw.loader.localLoad( 'User:Ultradude25/editcounter.js' ); }

// Adds JavaScript, CSS and Lua syntax highlighting, see User:Ultradude25/Prism.js for license // Requires a theme from prismjs.com to be added to usercss mw.loader.localLoad( 'User:Ultradude25/Prism.js' );

// Make links work in code blocks mw.loader.localLoad( 'User:Ultradude25/codeLinks.js' );

// Adds Doc + Doc discussion tabs to template pages and change Template + Discussion tabs to always link to the original template + discussion page if ( mw.config.get( 'wgNamespaceNumber' ) === 10 || mw.config.get( 'wgNamespaceNumber' ) === 11 ) { mw.loader.localLoad( 'User:Ultradude25/docTabs.js' ); }

// Allows rollback summary to be edited mw.loader.localLoad( 'User:Ultradude25/editableRollback.js' );

// Parse tweets //mw.loader.localLoad( 'User:Ultradude25/twitterFeed.js' );

// Test ref tooltips mw.loader.localLoad( 'User:Ultradude25/refTooltip.js' );

// Test bug titles //mw.loader.localLoad( 'User:Ultradude25/bugSummary.js' );

$( function { 'use strict';

// Adds a history link to the new messages box - Original script: wikipedia:User:Davidgothberg/newmessageshistory.js $( '#mw-youhavenewmessages a:last' ).after( ', history' );

// Changes vector menu items into tabs $( '#p-cactions' ).addClass( 'emptyPortlet' ).find( '> .menu li' ).addClass( 'collapsible' ).find( 'a' ).wrap( ' ' ); $( '#p-views > ul' ).append( $( '#p-cactions > .menu li' ) );

// Replaces ugly links with fancy ones ("/wiki/Pagename?action=edit" instead of "/index.php?title=Pagename&action=edit") $( 'a' ).prop( 'href', function {   return this.href.replace( /minecraftwiki\.net\/index\.php\?title=([^&]*)&(?!action=(?:un)?watch&token=)(.*)/, "minecraftwiki.net/wiki/$1?$2" ); } );

// Test minetip window.mcw.minetip = { // Add normal minetip events, removing legacy tooltip create: function { var tooltip; $( 'body' ).delegate( '.minetip, .grid .image', {			'mouseenter.minetip': function( e ) {				var $elem = $( this ),					title = $elem.data( 'minetip-title' ),					description = $elem.data( 'minetip-text' );				if ( title === undefined ) {					// Use title attribute of the element or the first link directly under it					title = $elem.attr( 'title' ) || $elem.find( '> a:first' ).attr( 'title' );					if ( title ) {						// Set the retrieved title as data for future use						$elem.data( 'minetip-title', title );					} else {						return;					}				}				$elem.add( '*', $elem ).filter( '[title]' ).removeAttr( 'title' );				if ( title === 0 ) {					return;				}				var text = ' ' + title + '&f ';				if ( description ) {					text += '\n ' +						description.replace( /\\\//g, '&#47;' ).replace( /\//g, ' ' ) +						'&f ';				}				$( 'body' ).append( ' ' );				tooltip = $( '#minetip-tooltip' );				// Style formatting with classes (colours) text = text.replace( /&([0-9a-el-o])((?:(?!&f).)*)/g, '$2 ' ) // Remove reset formatting .replace( /&f/g, '' ); tooltip.html( text ); // Trigger a mouse movement to position the tooltip $elem.trigger( 'mousemove', e ); },			'mousemove.minetip': function( e, trigger ) { if ( !tooltip || !tooltip.length ) { return; }				// Get event data from remote trigger e = trigger || e;				var top = e.pageY - 34, left = e.pageX + 14, width = tooltip.outerWidth( true ), height = tooltip.outerHeight( true ), $win = $( window ), winTop = $win.scrollTop, winWidth = $win.width, winHeight = $win.height, winBottom = winTop + winHeight; // If going off the right of the screen, go to the left of the cursor if ( left + width > winWidth ) { left -= width + 36; }				// If now going off to the left of the screen, resort to going below the cursor if ( left < 0 ) { left = 0; top += 82; // Go above the cursor if too low if ( top + height > winBottom ) { top -= 77 + height; }				} else { // Don't go off the top of the screen if ( top < winTop ) { top = winTop; // Don't go off the bottom of the screen } else if ( top + height > winBottom ) { top = winBottom - height; }				}				tooltip.css( {					'top': top,					'left': left				} ); },			'mouseleave.minetip': function { if ( !tooltip ) { return; }				tooltip.remove; }		} ).undelegate( '.minetipNative' );	},	// Remove all events	destroy: function {		$( 'body' ).undelegate( '.minetip' ).undelegate( '.minetipNative' );	},	// Add native browser tooltip events, removing normal minetip	native: function {		$( 'body' ).delegate( '.minetip, .grid .image', 'mouseenter.minetipNative', function { var title = $( this ).data( 'minetip-title' ), description = $( this ).data( 'minetip-text' ), existingTitle = $( this ).attr( 'title' ) || $( this ).find( '> a:first' ).attr( 'title' ); if ( title || title === 0 || $( this ).attr( 'title' ) ) { // Remove titles within so they don't interfere $( this ).find( '[title]' ).removeAttr( 'title' ); }			if ( title === 0 ) { $( this ).removeAttr( 'title' ); return; } else if ( !title && ( !existingTitle || !description ) ) { return; }			var text = title || existingTitle; if ( description ) { text += '\n' + description; }			// Remove formatting text = text.replace( /&([0-9a-fl-o])/g, '' ) .replace( /\\\//g, '&#47;' ) .replace( /\//g, '\n' ) .replace( /&#47;/g, '/' ); $( this ).attr( 'title', text ); } ).undelegate( '.minetip' );	} };

if ( window.mcw.useNativeMinetip ) { window.mcw.minetip.native; } else { window.mcw.minetip.create; }

} );