Difference between revisions of "MediaWiki:Common.js"

From EncyclopAtys

Jump to: navigation, search
(Removed obsolete code)
(Code is obsolete)
 
Line 1: Line 1:
βˆ’
function hs(id,mod) {
+
/* nothing anymore */
βˆ’
if(document.getElementById(id).style.display == 'none') {
 
βˆ’
document.getElementById(id).style.display=mod;
 
βˆ’
}
 
βˆ’
else {
 
βˆ’
document.getElementById(id).style.display='none';
 
βˆ’
}
 
βˆ’
}
 
βˆ’
 
 
βˆ’
 
 
βˆ’
/** Test if an element has a certain class **************************************
 
βˆ’
*
 
βˆ’
* Description: Uses regular expressions and caching for better performance.
 
βˆ’
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
 
βˆ’
*/
 
βˆ’
 
βˆ’
var hasClass = (function() {
 
βˆ’
var reCache = {};
 
βˆ’
return function( element, className ) {
 
βˆ’
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
 
βˆ’
};
 
βˆ’
})();
 
βˆ’
 
 
βˆ’
 
 
βˆ’
 
 
βˆ’
if ( wgPageName == 'Special:Upload' && document.getElementById( 'mw-upload-form' ) !== 'undefined' )
 
βˆ’
{
 
βˆ’
  addScript( 'MediaWiki:UploadForm.js' );
 
βˆ’
  hookEvent( 'load', function()
 
βˆ’
  {
 
βˆ’
    new UploadForm();
 
βˆ’
  } );
 
βˆ’
}
 
βˆ’
 
 
βˆ’
/**** function addScript.js
 
βˆ’
* by Patrick Westerhoff [poke]
 
βˆ’
*/
 
βˆ’
function addScript ( pagename )
 
βˆ’
{
 
βˆ’
  var script  = document.createElement( 'script' );
 
βˆ’
  pagename    = encodeURI( pagename.replace( ' ', '_' ) );
 
βˆ’
  script.src  = '/w/index.php?title=' + pagename + '&action=raw&ctype=text/javascript';
 
βˆ’
  script.type = 'text/javascript';
 
βˆ’
 
 
βˆ’
  document.getElementsByTagName( 'head' )[0].appendChild( script );
 
βˆ’
}
 
βˆ’
 
 
βˆ’
/**** function diffwithFix.js
 
βˆ’
* by Patrick Westerhoff [poke]
 
βˆ’
*/
 
βˆ’
function diffwithFix ()
 
βˆ’
{
 
βˆ’
  var diffSpan = document.getElementById( 'diffwith' );
 
βˆ’
  if ( diffSpan == undefined )
 
βˆ’
    return;
 
βˆ’
 
 
βˆ’
  var diffLink  = diffSpan.getElementsByTagName( 'a' )[0];
 
βˆ’
  var diffTitle = diffSpan.title;
 
βˆ’
  var xmlHttp;
 
βˆ’
 
 
βˆ’
  try
 
βˆ’
  {
 
βˆ’
    xmlHttp = new XMLHttpRequest();
 
βˆ’
  }
 
βˆ’
  catch ( e )
 
βˆ’
  {
 
βˆ’
    try
 
βˆ’
    {
 
βˆ’
      xmlHttp = new ActiveXObject( 'Msxml2.XMLHTTP' );
 
βˆ’
    }
 
βˆ’
    catch ( e )
 
βˆ’
    {
 
βˆ’
      try
 
βˆ’
      {
 
βˆ’
        xmlHttp = new ActiveXObject( 'Microsoft.XMLHTTP' );
 
βˆ’
      }
 
βˆ’
      catch ( e )
 
βˆ’
      {
 
βˆ’
        diffSpan.style.fontSize = '90%';
 
βˆ’
        diffSpan.innerHTML      = '(Automated diff <b>not available</b>.)';
 
βˆ’
        return;
 
βˆ’
      }
 
βˆ’
    }
 
βˆ’
  }
 
βˆ’
 
 
βˆ’
  xmlHttp.onreadystatechange = function ()
 
βˆ’
  {
 
βˆ’
    if ( xmlHttp.readyState != 4 )
 
βˆ’
      return;
 
βˆ’
   
 
βˆ’
    revs = xmlHttp.responseXML.getElementsByTagName( 'rev' );
 
βˆ’
   
 
βˆ’
    if ( revs.length > 0 )
 
βˆ’
    {
 
βˆ’
      diffLink.href += '&oldid=' + revs[0].getAttribute( 'revid' );
 
βˆ’
      diffSpan.title = '';
 
βˆ’
    } 
 
βˆ’
  }
 
βˆ’
  xmlHttp.open( 'GET', '/w/api.php?format=xml&action=query&prop=revisions&rvprop=ids&rvlimit=1&titles=' + diffTitle, true );
 
βˆ’
  xmlHttp.send( null );
 
βˆ’
}
 
βˆ’
/** </nowiki> **/
 

Latest revision as of 13:17, 22 October 2017

/* nothing anymore */