Difference between revisions of "MediaWiki:Common.js"

From EncyclopAtys

Jump to: navigation, search
(Code is obsolete)
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
βˆ’
/*<nowiki>*/
+
/* nothing anymore */
βˆ’
/** additional scripts **/
 
βˆ’
if ( wgIsArticle || window.location.href.indexOf( 'action=submit' ) > -1 )
 
βˆ’
{
 
βˆ’
  addScript( 'MediaWiki:CollapsibleTables.js' );
 
βˆ’
  hookEvent( 'load', function()
 
βˆ’
  {
 
βˆ’
    new CollapsibleTables();
 
βˆ’
    diffwithFix();
 
βˆ’
   
 
βˆ’
    // Extension for the deletion drop down list
 
βˆ’
    if ( wgAction == 'delete' && ( delReasonBtn = document.getElementById( 'wpConfirmB' ) ) )
 
βˆ’
    {
 
βˆ’
      var delReasonList        = document.getElementById( 'wpDeleteReasonList' );
 
βˆ’
      var delLink              = document.createElement( 'a' );
 
βˆ’
      delLink.href            = 'javascript:void(0);'
 
βˆ’
      delLink.title            = document.getElementById( 'wpReason' ).value;
 
βˆ’
      delLink.style.fontSize  = '0.9em';
 
βˆ’
      delLink.style.marginLeft = '1em';
 
βˆ’
      delLink.onclick          = function()
 
βˆ’
      {
 
βˆ’
        document.getElementById( 'wpReason' ).value = this.title;
 
βˆ’
      }
 
βˆ’
      delReasonList.onchange  = function ()
 
βˆ’
      {
 
βˆ’
        document.getElementById( 'wpReason' ).value = '';
 
βˆ’
        this.onchange = null;
 
βˆ’
      }
 
βˆ’
      delLink.appendChild( document.createTextNode( 'restore default reason' ) );
 
βˆ’
      delReasonBtn.parentNode.appendChild( delLink );
 
βˆ’
      delete delLink, delReasonList, delReasonBtn;
 
βˆ’
    }
 
βˆ’
  } );
 
βˆ’
}
 
βˆ’
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  = '/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', '/api.php?format=xml&action=query&prop=revisions&rvprop=ids&rvlimit=1&titles=' + diffTitle, true );
 
βˆ’
  xmlHttp.send( null );
 
βˆ’
}
 
βˆ’
/*</nowiki>*/
 

Latest revision as of 14:17, 22 October 2017

/* nothing anymore */