MediaWiki:Group-sysop.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* JavaScript below is loaded for administrators only */ /* attorneys do not have access to this functionality */ // 05-27-23 from https://en.wikisource.org/wiki/MediaWiki:Gadget-PurgeTab.js ( function ( $, mw ) { $( function () { var link, strings = { long: { purge: 'Purge', hpurge: 'Hard purge', nulled: 'Null edit' }, short: { purge: '*', hpurge: '**', nulled: '***' }, help: { purge: 'Purge cache for this page', hpurge: 'Purge with forced recursive-link table update', nulled: 'Perform a null edit on this page' } }, stringType = ( mw.user.options.get( 'skin' ) === 'vector' ) ? 'long' : 'short', errorLog = function ( msg ) { /* eslint-disable-next-line no-console */ console.error( msg ); }, afterPurgeFunction = function () { location.reload(); }, httpErrorHandler = function ( code, details ) { var mesg; switch ( code ) { case 'http': mesg = 'HTTP error: ' + details.xhr.statusText; break; case 'ok-but-empty': mesg = 'Received empty response.'; break; default: mesg = details.error.info; } mw.util.jsMessage( '<b>Hard purge failed</b>: ' + mesg ); errorLog( arguments ); }, doPurge = function ( hard ) { mw.loader.using( 'mediawiki.api' ).done( function () { var params = { action: 'purge', pageids: mw.config.get( 'wgArticleId' ) }; if ( hard ) { params.forcerecursivelinkupdate = 1; params.redirects = 1; } new mw.Api() .post( params ) .then( afterPurgeFunction, httpErrorHandler ); } ); }, doNullEdit = function () { mw.loader.using( 'mediawiki.api' ).done( function () { new mw.Api().post( { action: 'edit', pageid: mw.config.get( 'wgArticleId' ), appendtext: '', watchlist: 'nochange', nocreate: '1', token: mw.user.tokens.get( 'csrfToken' ) } ) .then( afterPurgeFunction, httpErrorHandler ); } ); }; if ( !mw.config.get( 'wgArticleId' ) ) { return; } link = mw.util.addPortletLink( 'p-cactions', '#', strings[ stringType ].purge, 'ca-purge', strings.help.purge, '*' ); if ( link ) { link.addEventListener( 'click', function ( ev ) { doPurge( false ); ev.preventDefault(); }, false ); } link = mw.util.addPortletLink( 'p-cactions', '#', strings[ stringType ].hpurge, 'ca-purge-forcerecursivelinkupdate', strings.help.hpurge, ',' ); if ( link ) { link.addEventListener( 'click', function ( ev ) { doPurge( true ); ev.preventDefault(); }, false ); } link = mw.util.addPortletLink( 'p-cactions', '#', strings[ stringType ].nulled, 'ca-nulledit', strings.help.nulled, '0' ); if ( link ) { link.addEventListener( 'click', function ( ev ) { doNullEdit(); ev.preventDefault(); }, false ); } } ); }( jQuery, mediaWiki ) ); // 06-19-23 from https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization/Library if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { $textarea.wikiEditor( 'addToToolbar', { section: 'advanced', group: 'format', tools: { comment: { label: 'Comment', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png', action: { type: 'encapsulate', options: { pre: '<!-- ', post: ' -->' } } } } } ); } ); }