User:Zhuyifei1999/common.js: Difference between revisions

From WikiIndex
Jump to navigation Jump to search
(rm reason)
(++)
Line 8: Line 8:
if (mw.config.get("wgAction") == "delete") {
if (mw.config.get("wgAction") == "delete") {
     $("#wpReason").val("")
     $("#wpReason").val("")
}
/**
* withJS
*
* Allow to load custom scripts from the MediaWiki namespace without
* editing [[Special:Mypage/common.js]]
*
* Attribution: [[commons:User:Platonides]], [[commons:User:Lupo]]
*/
var extraJS = mw.util.getParamValue('withJS');
// Leave here for backwards compatibility
(function (extraJS) {
if (!extraJS) {
  return;
}
if (extraJS.match(/^MediaWiki:[^&<>=%#]*\.js$/)) {
  // Disallow some characters in file name
  importScript(extraJS);
} else {
  // Dont use alert but the jsMsg system. Run jsMsg only once the DOM is ready.
  $(function () {
  jsMsgAppend(extraJS + ' javascript not allowed to be loaded.', 'error');
  });
}
})(extraJS);
/**
* withCSS
*
* Allow to load custom styles from the MediaWiki namespace without
* editing [[Special:Mypage/common.css]]
*
* Attribution: [[commons:User:Krinkle]]
*/
var extraCSS = mw.util.getParamValue('withCSS');
if ( extraCSS ) {
  // Disallow some characters in file name
  if (extraCSS.match(/^MediaWiki:[^&<>=%#]*\.css$/)) {
    importStylesheet(extraCSS);
  // Dont use alert but the jsMsg system. Run jsMsg only once the DOM is ready.
  } else {
    $(function() {
      jsMsgAppend(extraCSS + ' stylesheet not allowed to be loaded.', 'error');
    });
  }
}
}

Revision as of 10:45, 7 January 2014

/**
 * Add a toolbox link to enable/disable my scripts
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Toggle_user_scripts
 * @rev: 1
 */

if (mw.config.get("wgAction") == "delete") {
    $("#wpReason").val("")
}

/**
 * withJS
 *
 * Allow to load custom scripts from the MediaWiki namespace without
 * editing [[Special:Mypage/common.js]]
 *
 * Attribution: [[commons:User:Platonides]], [[commons:User:Lupo]]
 */
var extraJS = mw.util.getParamValue('withJS');
// Leave here for backwards compatibility
(function (extraJS) {
 if (!extraJS) {
  return;
 }
 if (extraJS.match(/^MediaWiki:[^&<>=%#]*\.js$/)) {
  // Disallow some characters in file name
  importScript(extraJS);
 } else {
  // Dont use alert but the jsMsg system. Run jsMsg only once the DOM is ready.
  $(function () {
   jsMsgAppend(extraJS + ' javascript not allowed to be loaded.', 'error');
  });
 }
})(extraJS);
 
 
/**
 * withCSS
 *
 * Allow to load custom styles from the MediaWiki namespace without
 * editing [[Special:Mypage/common.css]]
 *
 * Attribution: [[commons:User:Krinkle]]
 */
var extraCSS = mw.util.getParamValue('withCSS');
if ( extraCSS ) {
  // Disallow some characters in file name
  if (extraCSS.match(/^MediaWiki:[^&<>=%#]*\.css$/)) {
    importStylesheet(extraCSS);
  // Dont use alert but the jsMsg system. Run jsMsg only once the DOM is ready.
  } else {
    $(function() {
      jsMsgAppend(extraCSS + ' stylesheet not allowed to be loaded.', 'error');
    });
  }
}