User:MZMcBride/scotus.js

/** * https://en.wikipedia.org/wiki/Wikipedia:SCOTUS helper code * @author MZMcBride * Warning: This code is really bad and is shamelessly stolen from * https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization#Default_sections */

var infobox = ` `;

var customizeToolbar = function { /* Add a little gavel icon to insert "Infobox SCOTUS case" into an article */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {       'section': 'main',        'group': 'insert',        'tools': {                'smile': {                        label: 'Insert "Infobox SCOTUS case"', // or use labelMsg for a localized label, see above                        type: 'button',                        icon: 'https://upload.wikimedia.org/wikipedia/commons/6/6e/Font_Awesome_5_solid_gavel.svg',                        action: {                                type: 'encapsulate',                                options: {                                        pre: infobox + '\n' // text to be inserted                                }                        }                }        } } ); };

/* Check if we are in edit mode and the required modules are available and then customize the toolbar */ if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { mw.loader.using( 'user.options', function {                if ( mw.user.options.get('usebetatoolbar') ) {                        mw.loader.using( 'ext.wikiEditor', function  { $(document).ready( customizeToolbar ); } );               }        } ); }