MediaWiki:Wikia.js/preload.js

/** * Template Preloads * Replaces Wikia's template preloads with something more useful * * @author       Grunny (Wookieepedia) * @author      A proofreader * @author      Ryan PM * @author       Cqm * @dependencies insertAtCursor * @todo        Rewrite and implement as default gadget */ /* function customPreloadTemplates { // temp disabling for me       if (wgUserName === 'Cqm') { return; }	if ( ( mw.config.get( 'wgAction' ) !== 'edit' && mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'CreatePage' ) || !$( 'div.module_content' ).length ) { return; }	var	preloadOptionsHtml = '', $preloadOptionsList, preloadBaseHtml = ' Standard preloads: ' +			' Custom preload pagename: '	$( 'span.cke_buttons.cke_toolbar_templates' ).replaceWith( preloadBaseHtml ); $.get( mw.config.get( 'wgScript' ), { title: 'Template:Stdpreloads', action: 'raw', ctype: 'text/plain' }, function( data ) {		var lines = data.split( '\n' );		for( var i = 0; i < lines.length; i++ ) {			var value = ( lines[i].indexOf( '-- ' ) === 0 ) ? lines[i].substring(3) : "";			preloadOptionsHtml += '' + lines[i] + ' ';		}               // @todo change id to #stdPreloads                // need to check there's no dependencies anywhere else		$preloadOptionsList = $( ' ' ).attr( 'id', 'stdSummaries' ).html( preloadOptionsHtml ).change( function { var value = $( this ).val; if ( value !== '' ) { value = 'Template:' + value + '/preload'; value = value.replace( ' ', '_' ); $.get( mw.config.get( 'wgScript' ), { title: value, action: 'raw', ctype: 'text/plain' }, function( data ) {					insertAtCursor( document.getElementById( 'wpTextbox1' ), data );				} ); }		} );		$( 'div#lf-preload' ).append( $preloadOptionsList );	} ); $( '#lf-preload-pagename-w' ).html( '' ); $( '#lf-preload-button-w' ).html( '' ); } $( customPreloadTemplates ); function doCustomPreloadOasis { var value = $( '#lf-preload-pagename-w > input' ).val; value = value.replace( ' ', '_' ); $.get( mw.config.get( 'wgScript' ), { title: value, action: 'raw', ctype: 'text/plain' }, function( data ) {		insertAtCursor( document.getElementById( 'wpTextbox1' ), data );	} ); }