Difference between revisions of "User:Suicide machine/common.js"
From PCGamingWiki, the wiki about fixing PC games
m |
m |
||
Line 44: | Line 44: | ||
} | } | ||
− | function | + | function addAnchorInHeadersExtended() { |
$('span.mw-headline', '#mw-content-text').each(function() { | $('span.mw-headline', '#mw-content-text').each(function() { | ||
var $this = $(this); | var $this = $(this); | ||
Line 55: | Line 55: | ||
} | } | ||
− | $( | + | $(addAnchorInHeadersExtended); |
Revision as of 21:27, 14 July 2018
var customizeToolbar2 = function() { $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { sections: { 'templates': { type: 'toolbar', label: 'Extended Templates', groups: { templates: { 'label': 'Extended Templates', 'tools': { 'testrow': { label: 'Test row', type: 'button', icon: '//pcgamingwiki.com/images/6/67/Editor_Icon_-_Availability_Table_Row.svg', action: { type: 'encapsulate', options: { pre: "{{Availability/row| ", peri: "store", post: " | id | DRM | notes | Key | OS }}", ownline: true } } }, } } } } } } ); }; /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */ if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) { mw.loader.using( 'user.options', function () { // This can be the string "0" if the user disabled the preference ([[bugzilla:52542#c3]]) if ( mw.user.options.get( 'usebetatoolbar' ) == 1 && mw.user.options.get( 'showtoolbar' ) == 1 ) { $.when( mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready ).then( customizeToolbar2 ); } } ); } function addAnchorInHeadersExtended() { $('span.mw-headline', '#mw-content-text').each(function() { var $this = $(this); if ($this.attr('id') !== undefined) { $('<span class="mw-linkhere"></span>').text(' • ').append( $('<a></a>').text('Link').attr({title: 'Link', href: '#'+$this.attr('id')}) ).appendTo(this); } }); } $(addAnchorInHeadersExtended);