diff options
author | Fomafix <fomafix@googlemail.com> | 2023-05-01 14:50:09 +0000 |
---|---|---|
committer | Fomafix <fomafix@googlemail.com> | 2023-05-01 15:00:53 +0000 |
commit | 2ea6137e6fb926b0cb0936ad73b6f230d8c88b10 (patch) | |
tree | 42e9b0cc4f58891f9da6623dce2ec905d992269a /resources/src | |
parent | ee4e0d776052b769f45be40675f81908e9f4d6be (diff) | |
download | mediawikicore-2ea6137e6fb926b0cb0936ad73b6f230d8c88b10.tar.gz mediawikicore-2ea6137e6fb926b0cb0936ad73b6f230d8c88b10.zip |
upload.js: Use variable instead of DOM query for $warningBox
The error box is generated in JavaScript and therefor a DOM query is
not needed to find the element again.
The ID 'wpDestFile-warning' is not referenced in code:
https://codesearch.wmcloud.org/search/?q=wpDestFile-warning
But in some styles and scripts:
https://global-search.toolforge.org/?q=%22wpDestFile-warning%22&namespaces=2%2C4%2C8&title=(Gadgets-definition|.*\.(js|css|json))
Therefor keep it for compatibility.
Change-Id: I4b7a379afa3a772895eaa2beffb2887359ae5f34
Diffstat (limited to 'resources/src')
-rw-r--r-- | resources/src/mediawiki.special.upload/upload.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/resources/src/mediawiki.special.upload/upload.js b/resources/src/mediawiki.special.upload/upload.js index c1545dc3a54f..3d9980ba9a6d 100644 --- a/resources/src/mediawiki.special.upload/upload.js +++ b/resources/src/mediawiki.special.upload/upload.js @@ -7,7 +7,7 @@ */ ( function () { - var uploadWarning, uploadTemplatePreview, + var uploadWarning, uploadTemplatePreview, $warningBox, NS_FILE = mw.config.get( 'wgNamespaceIds' ).file, $license = $( '#wpLicense' ); @@ -71,8 +71,7 @@ }, setWarning: function ( warning ) { - var $warningBox = $( '#wpDestFile-warning' ), - $warning = $( $.parseHTML( warning ) ); + var $warning = $( $.parseHTML( warning ) ); mw.hook( 'wikipage.content' ).fire( $warning ); $warningBox.empty().append( $warning ); @@ -139,12 +138,11 @@ } ); // Insert a row where the warnings will be displayed just below the // wpDestFile row + $warningBox = $( '<td>' ) + .attr( 'id', 'wpDestFile-warning' ) + .attr( 'colspan', 2 ); $( '#mw-htmlform-description tbody' ).append( - $( '<tr>' ).append( - $( '<td>' ) - .attr( 'id', 'wpDestFile-warning' ) - .attr( 'colspan', 2 ) - ) + $( '<tr>' ).append( $warningBox ) ); if ( mw.config.get( 'wgAjaxLicensePreview' ) && $license.length ) { |