( function () { const api = new mw.Api(); const util = require( 'mediawiki.util' ); /** * Show the edit summary. * * @private * @param {jQuery} $formNode * @param {Object} response */ function showEditSummary( $formNode, response ) { const $summaryPreview = $formNode.find( '.mw-summary-preview' ).empty(); const parse = response.parse; if ( !parse || !parse.parsedsummary ) { return; } $summaryPreview.append( mw.message( 'summary-preview' ).parse(), ' ', $( '' ).addClass( 'comment' ).html( parenthesesWrap( parse.parsedsummary ) ) ); } /** * Wrap a string in parentheses. * * @private * @param {string} str * @return {string} */ function parenthesesWrap( str ) { if ( str === '' ) { return str; } // There is no equivalent to rawParams return mw.message( 'parentheses' ).escaped() // Specify a function as the replacement, // so that "$" characters in str are not interpreted. .replace( '$1', () => str ); } /** * Show status indicators. * * @private * @param {Array} indicators */ function showIndicators( indicators ) { // eslint-disable-next-line no-jquery/no-map-util indicators = $.map( indicators, ( indicator, name ) => $( '
' ) .addClass( 'mw-indicator' ) .attr( 'id', mw.util.escapeIdForAttribute( 'mw-indicator-' + name ) ) .html( indicator ) .get( 0 ) ); if ( indicators.length ) { mw.hook( 'wikipage.indicators' ).fire( $( indicators ) ); } // Add whitespace between the
s because // they get displayed with display: inline-block const newList = []; indicators.forEach( ( indicator ) => { newList.push( indicator, document.createTextNode( '\n' ) ); } ); $( '.mw-indicators' ).empty().append( newList ); } /** * Show the templates used. * * The formatting here repeats what is done in includes/TemplatesOnThisPageFormatter.php * * @private * @param {Array} templates List of template titles. */ function showTemplates( templates ) { // The .templatesUsed div can be empty, if no templates are in use. // In that case, we have to create the required structure. const $parent = $( '.templatesUsed' ); // Find or add the explanation text (the toggler for collapsing). let $explanation = $parent.find( '.mw-templatesUsedExplanation p' ); if ( $explanation.length === 0 ) { $explanation = $( '

' ); $parent.append( $( '

' ) .addClass( 'mw-templatesUsedExplanation' ) .append( $explanation ) ); } // Find or add the list. The makeCollapsible() method is called on this // in resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js let $list = $parent.find( 'ul' ); if ( $list.length === 0 ) { $list = $( '