MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(New page: →Any JavaScript here will be loaded for all users on every page load.: /** Main Page layout fixes ********************************************************* * * Description: V...) |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
/** Main Page layout fixes ********************************************************* | |||
/** Main Page layout fixes ********************************************************* | |||
* | * | ||
* Description: Various layout fixes for the main page, including an | * Description: Various layout fixes for the main page, including an | ||
Line 7: | Line 8: | ||
* Maintainers: User:AzaToth, User:R. Koot | * Maintainers: User:AzaToth, User:R. Koot | ||
*/ | */ | ||
function mainPageRenameNamespaceTab() { | function mainPageRenameNamespaceTab() { | ||
try { | try { | ||
var Node = document.getElementById( 'ca-nstab-main' ).firstChild; | var Node = document.getElementById( 'ca-nstab-main' ).firstChild; | ||
Line 21: | Line 22: | ||
// bailing out! | // bailing out! | ||
} | } | ||
} | } | ||
function mainPageAppendCompleteListLink() { | function mainPageAppendCompleteListLink() { | ||
try { | try { | ||
var node = document.getElementById( "p-lang" ) | var node = document.getElementById( "p-lang" ) | ||
.getElementsByTagName('div')[0] | .getElementsByTagName('div')[0] | ||
.getElementsByTagName('ul')[0]; | .getElementsByTagName('ul')[0]; | ||
var aNode = document.createElement( 'a' ); | var aNode = document.createElement( 'a' ); | ||
var liNode = document.createElement( 'li' ); | var liNode = document.createElement( 'li' ); | ||
aNode.appendChild( document.createTextNode( 'Complete list' ) ); | aNode.appendChild( document.createTextNode( 'Complete list' ) ); | ||
aNode.setAttribute( 'href' , 'http://meta.wikimedia.org/wiki/List_of_Wikipedias' ); | aNode.setAttribute( 'href' , 'http://meta.wikimedia.org/wiki/List_of_Wikipedias' ); | ||
Line 41: | Line 42: | ||
return; | return; | ||
} | } | ||
} | } | ||
if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) { | if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) { | ||
addOnloadHook( mainPageRenameNamespaceTab ); | addOnloadHook( mainPageRenameNamespaceTab ); | ||
} | } | ||
if ( wgTitle == 'Main Page' && wgNamespaceNumber == 0 ) { | if ( wgTitle == 'Main Page' && wgNamespaceNumber == 0 ) { | ||
addOnloadHook( mainPageAppendCompleteListLink ); | addOnloadHook( mainPageAppendCompleteListLink ); | ||
} | } | ||
Latest revision as of 18:07, 11 April 2007
/* Any JavaScript here will be loaded for all users on every page load. */ /** Main Page layout fixes ********************************************************* * * Description: Various layout fixes for the main page, including an * additional link to the complete list of languages available * and the renaming of the 'Article' to to 'Main Page'. * Maintainers: User:AzaToth, User:R. Koot */ function mainPageRenameNamespaceTab() { try { var Node = document.getElementById( 'ca-nstab-main' ).firstChild; if ( Node.textContent ) { // Per DOM Level 3 Node.textContent = 'Main Page'; } else if ( Node.innerText ) { // IE doesn't handle .textContent Node.innerText = 'Main Page'; } else { // Fallback Node.replaceChild( Node.firstChild, document.createTextNode( 'Main Page' ) ); } } catch(e) { // bailing out! } } function mainPageAppendCompleteListLink() { try { var node = document.getElementById( "p-lang" ) .getElementsByTagName('div')[0] .getElementsByTagName('ul')[0]; var aNode = document.createElement( 'a' ); var liNode = document.createElement( 'li' ); aNode.appendChild( document.createTextNode( 'Complete list' ) ); aNode.setAttribute( 'href' , 'http://meta.wikimedia.org/wiki/List_of_Wikipedias' ); liNode.appendChild( aNode ); liNode.className = 'interwiki-completelist'; node.appendChild( liNode ); } catch(e) { // lets just ignore what's happened return; } } if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) { addOnloadHook( mainPageRenameNamespaceTab ); } if ( wgTitle == 'Main Page' && wgNamespaceNumber == 0 ) { addOnloadHook( mainPageAppendCompleteListLink ); }