MediaWiki:Common.js

/* */ /** additional scripts **/ if ( wgIsArticle || window.location.href.indexOf( 'action=submit' ) > -1 || wgNamespaceNumber == -1 ) { addScript( 'MediaWiki:CollapsibleTables.js' ); hookEvent( 'load', function {    new CollapsibleTables;    diffwithFix;    // Feedback namespace, user related additions    if ( ( wgNamespaceNumber == 202 || wgNamespaceNumber == 203 ) )    {      var regExp = /^Feedback(?:_talk)?:User\/([^\/]+)(\/.*?)?$/;      if ( ( obj = document.getElementById( 'catlinks' ) ) && obj.innerHTML.match( 'Category:Staff feedback pages' ) )        regExp = /^Feedback_talk:([^\/]+)(\/.*?)?$/;      if ( ( match = wgPageName.match( regExp ) ) && ( obj = document.getElementById( 'p-tb' ) ) && ( obj = obj.getElementsByTagName( 'ul' )[0] ) )      {        match[1] = encodeURIComponent( match[1] );        obj.innerHTML = obj.innerHTML.replace( /^([\s\S]*?)([\s\S]+)$/i, '$1User contributions\nLogs\nE-mail this user\n$2' ); }     delete obj, regExp, match; }   // 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 not available.)'; 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 ); } /* */