MediaWiki:Common.js: Difference between revisions

removing calls to mw.util that we can't handle
(removing line that only causes an error)
(removing calls to mw.util that we can't handle)
Line 1: Line 1:
/** extract a URL parameter from the current URL **********
/** extract a URL parameter from the current URL **********
* From [[en:User:Lupin/autoedit.js]]
  *
  *
  * @deprecated: Use mw.util.getParamValue with proper escaping
  * paramName  : the name of the parameter to extract
  */
  */
function getURLParamValue(paramName, url){
function getURLParamValue( paramName, url)  
return mw.util.getParamValue(paramName, url);
{
    if (typeof (url) == 'undefined'  || url === null) url = document.location.href;
    var cmdRe=RegExp( '[&?]' + paramName + '=([^&#]*)' ); // Stop at hash
    var m=cmdRe.exec(url);
    if (m && m.length > 1) return decodeURIComponent(m[1]);
return null;
}
}
 
/** &withCSS= and &withJS= URL parameters *******
/** &withJS= URL parameter *******
  * Allow to try custom scripts from MediaWiki space  
  * Allow to try custom scripts from MediaWiki space  
  * without editing personal .css or .js files
  * without editing [[Special:Mypage/monobook.js]]
  */
  */
var extraCSS = mw.util.getParamValue("withCSS");
var extraJS = getURLParamValue("withJS");
if ( extraCSS && extraCSS.match("^MediaWiki:[^&<>=%]*\.css$") ) {
    importStylesheet(extraCSS);
}
var extraJS = mw.util.getParamValue("withJS");
if ( extraJS && extraJS.match("^MediaWiki:[^&<>=%]*\.js$") ) {
if ( extraJS && extraJS.match("^MediaWiki:[^&<>=%]*\.js$") ) {
     importScript(extraJS);
     importScript(extraJS);
Line 26: Line 28:


/* Import more specific scripts if necessary */
/* Import more specific scripts if necessary */
if (wgAction == 'edit' || wgAction == 'submit' || wgPageName == 'Special:Upload') { //scripts specific to editing pages
if (wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload") //scripts specific to editing pages
     importScript('MediaWiki:Common.js/edit.js');
{
     importScript("MediaWiki:Common.js/edit.js")
}
}
else if (mw.config.get('wgPageName') == 'Special:Watchlist') { //watchlist scripts
else if (wgPageName == "Special:Watchlist") //watchlist scripts
     mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=MediaWiki:Common.js/watchlist.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
{
     importScript("MediaWiki:Common.js/watchlist.js")
}
}


Line 63: Line 67:
      
      
     // In print IE (7?) does not like line-height
     // In print IE (7?) does not like line-height
     mw.util.addCSS( '@media print { sup, sub, p, .documentDescription { line-height: normal; }}');
     appendCSS( '@media print { sup, sub, p, .documentDescription { line-height: normal; }}');


     // IE overflow bug
     // IE overflow bug
     mw.util.addCSS('div.overflowbugx { overflow-x: scroll !important; overflow-y: hidden !important; } div.overflowbugy { overflow-y: scroll !important; overflow-x: hidden !important; }');
     appendCSS('div.overflowbugx { overflow-x: scroll !important; overflow-y: hidden !important; } div.overflowbugy { overflow-y: scroll !important; overflow-x: hidden !important; }');


     // IE zoomfix
     // IE zoomfix
     // Use to fix right floating div/table inside tables
     // Use to fix right floating div/table inside tables
     mw.util.addCSS('.iezoomfix div, .iezoomfix table { zoom: 1;}');
     appendCSS('.iezoomfix div, .iezoomfix table { zoom: 1;}');
      
      
     // Import scripts specific to Internet Explorer 6
     // Import scripts specific to Internet Explorer 6