User:Grunny/infoboxpreloads-neweditor.js

/** * * Custom preload templates for the new oasis editor * * @author Grunny * @version 0.0.1 * @notes As the new editor is still in development, this script may *       potentially break whenever the editor's code is changed * */

function customPreloadTemplates {

if( wgAction !== 'edit' || !$( 'div.module_content' ).length ) { return; }

var	preloadOptionsHtml = '', $preloadOptionsList;

$( 'div.module_content:first' ).append( ' Standard preloads: ' );

$.get( wgScript, { title: 'Template:Stdpreloads', action: 'raw', ctype: 'text/plain' }, function( data ) {		var lines = data.split( '\n' );		for( var i in lines ) {			var value = ( lines[i].indexOf( '-- ' ) === 0 ) ? lines[i].substring(3) : "";			preloadOptionsHtml += '' + lines[i] + ' ';		}		$preloadOptionsList = $( ' ' ).attr( 'id', 'stdSummaries' ).html( preloadOptionsHtml ).change( function { var value = $( this ).val; if ( value !== '' ) { value = 'Template:' + value + '/preload'; value = value.replace( ' ', '_' ); $.get( wgScript, { title: value, action: 'raw', ctype: 'text/plain' }, function( data ) {					insertAtCursor( document.getElementById( 'wpTextbox1' ), data );				} ); }		} );

$( 'div#lf-preload' ).append( $preloadOptionsList ); } );

} $( customPreloadTemplates );