MediaWiki:Gadget-script-installer-core.js and MediaWiki talk:Gadget-script-installer-core.js/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Add advert to normalize per request |
better |
||
Line 1: | Line 1: | ||
// <code><nowiki> |
|||
( function () { |
( function () { |
||
// An mw.Api object |
// An mw.Api object |
||
Line 345: | Line 347: | ||
action: 'edit', |
action: 'edit', |
||
title: getFullTarget( target ), |
title: getFullTarget( target ), |
||
summary: STRINGS.normalizeSummary |
summary: STRINGS.normalizeSummary, |
||
text: newLines.join( '\n' ) |
text: newLines.join( '\n' ) |
||
} ); |
} ); |
||
Line 588: | Line 590: | ||
// <span id='User:Foo/Bar.js' class='scriptInstallerLink'></span> |
// <span id='User:Foo/Bar.js' class='scriptInstallerLink'></span> |
||
$( 'span.scriptInstallerLink' ).each( function () { |
$( 'span.scriptInstallerLink' ).each( function () { |
||
const scriptName = this.id.replace( /_/g, ' ' ); |
const scriptName = this.id.replace( /_/g, ' ' ); // if the script name happens to contain underscores, this purges it |
||
$( this ).append( ' | ', $( '<a>' ) |
$( this ).append( ' | ', $( '<a>' ) |
||
.text( localScriptsByName[ scriptName ] ? STRINGS.uninstallLinkText : STRINGS.installLinkText ) |
.text( localScriptsByName[ scriptName ] ? STRINGS.uninstallLinkText : STRINGS.installLinkText ) |
||
Line 594: | Line 596: | ||
} ); |
} ); |
||
// For each {{Infobox user script}}, add a big blue install button |
|||
$( 'table.infobox-user-script' ).each( function () { |
$( 'table.infobox-user-script' ).each( function () { |
||
const $infoboxScriptField = $( this ).find( "th:contains('Source')" ).next(); |
const $infoboxScriptField = $( this ).find( "th:contains('Source')" ).next(); |
||
Line 608: | Line 609: | ||
scriptName = $infoboxScriptField.text(); |
scriptName = $infoboxScriptField.text(); |
||
} |
} |
||
⚫ | |||
scriptName = /user:.+?\/.+?.js/i.exec( scriptName )[ 0 ]; |
scriptName = /user:.+?\/.+?.js/i.exec( scriptName )[ 0 ]; |
||
⚫ | |||
$( this ).children( 'tbody' ).append( $( '<tr>' ).append( $( '<td>' ) |
$( this ).children( 'tbody' ).append( $( '<tr>' ).append( $( '<td>' ) |
||
.attr( 'colspan', '2' ) |
.attr( 'colspan', '2' ) |
||
Line 797: | Line 799: | ||
} ); |
} ); |
||
}() ); |
}() ); |
||
// </nowiki></code> |