MediaWiki:Gadget-ImprovedUploadForm.js

From Sarkarverse
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.
/**
 * Special:Upload enhancements
 *
 * Moved to [[MediaWiki:Upload.js]]
 *
 * Maintainer: [[User:Lupo]]
 */
mw.loader.using(['mediawiki.user', 'mediawiki.legacy.wikibits', 'site', 'user'], function() {


function enableNewUploadForm() {
 if ("1" === mw.user.options.get('gadget-OldUploadForm')) UploadForm_forcebasic = true;

 //Set UploadForm_forcebasic, while taking JSconfig cookies into account.
 if (typeof UploadForm_forcebasic === 'undefined') {
  UploadForm_forcebasic = (typeof JSconfig.keys.UploadForm_newlayout === 'undefined' ) ? false : (!JSconfig.keys.UploadForm_newlayout);
 }
 var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
 if (match) {
  var webKitVersion = parseInt(match[1], 10);
  if (webKitVersion < 420) {
   return; // Safari 2 crashes hard with the new upload form
  }
 }
 var isNlWLM = (document.URL.indexOf('uselang=nlwikilovesmonuments') >= 0);
 // honor JSConfig user settings
 if (!isNlWLM && !JSconfig.keys.UploadForm_loadform && UploadForm_forcebasic) {
  return;
 }
 importScript('MediaWiki:UploadForm.js');
 // Load additional enhancements for a special upload form (request by User:Multichill)
 if (isNlWLM) {
  importScript('MediaWiki:UploadFormNlWikiLovesMonuments.js');
 }
}
if (mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload') {
 // (Un)comment the following line (the call to enableNewUploadForm) to globally enable/disable
 // new upload form. Leave the line *above* (the include of MediaWiki:Upload.js) untouched;
 // that script provides useful default behavior if the new upload form is disabled or
 // redirects to the old form in case an error occurs.
 enableNewUploadForm();
}

});