MediaWiki:Gadget-fileupload.js: Difference between revisions

From Path of Exile 2 Wiki
Jump to navigation Jump to search
(Created page with "→‎global mw: →‎jshint strict:true, jquery:true, esversion:5, bitwise:true, curly:true, eqeqeq:true, undef:true, latedef:true, trailingcomma:true: ( function () { 'use strict'; →‎Translation strings: var i18n = { defaultLicense: 'Unlicensed', }; →‎Fires when wiki content is added.: mw.hook('wikipage.content').add( function ($wikipageContent) { if ( mw.config.get('wgCanonicalSpecialPageName') === 'Upload' ) { mw.loader.using( 'mediawiki.spec...")
 
(No difference)

Latest revision as of 19:06, 24 September 2024

/* global mw */
/* jshint strict:true, jquery:true, esversion:5, bitwise:true, curly:true, eqeqeq:true, undef:true, latedef:true, trailingcomma:true */

( function () {
'use strict';

/* Translation strings */
var i18n = {
    defaultLicense: 'Unlicensed',
};

/* Fires when wiki content is added. */
mw.hook('wikipage.content').add( function ($wikipageContent) {

    if ( mw.config.get('wgCanonicalSpecialPageName') === 'Upload' ) {
        mw.loader.using( 'mediawiki.special.upload', function () {
            // Wait until the next event cycle to ensure that the licensing template preview loads
            setTimeout( function () {
                var licenseField = document.getElementById('wpLicense');
                if ( licenseField ) {
                    if ( licenseField.value === '' ) {
                        licenseField.value = i18n.defaultLicense;
                        licenseField.dispatchEvent( new Event('change') );
                    }
                    licenseField.querySelector('option[title="{{}}"]').remove();
                }
            } );
        } );
    }

} );

}() );