Benutzer:Thomas Karcher/common.js: Unterschied zwischen den Versionen
Aus Klexikon – das Kinderlexikon
KKeine Bearbeitungszusammenfassung |
(Test) |
||
Zeile 1: | Zeile 1: | ||
mappedPages = { | |||
'Klexikon:Willkommen_im_Klexikon': ['Hauptseite', 'Wikipedia:Hauptseite'], | |||
'Hasen': ['Hasen', 'Hasen'], | |||
'Ostern': ['', 'Ostern'] | |||
} | |||
function ModifySidebar( action, section, name, link ) { | function ModifySidebar( action, section, name, link ) { | ||
try { | try { | ||
var target = 'p-' + section; | |||
if ( action == 'add' ) { | if ( action == 'add' ) { | ||
Zeile 32: | Zeile 23: | ||
node.appendChild( liNode ); | node.appendChild( liNode ); | ||
} | } | ||
} catch( e ) { | } catch( e ) { | ||
Zeile 64: | Zeile 36: | ||
op.setAttribute('role','navigation') | op.setAttribute('role','navigation') | ||
op.setAttribute('id','p-othproj') | op.setAttribute('id','p-othproj') | ||
op.innerHTML = '<h3> | op.innerHTML = '<h3>In anderen Projekte</h3><div class="body"><ul></ul></div>' | ||
document.getElementById('p-tb').parentNode.appendChild(op) | document.getElementById('p-tb').parentNode.appendChild(op) | ||
if (wgPageName in mappedPages) { | |||
l0 = mappedPages[wgPageName][0] | |||
l1 = mappedPages[wgPageName][1] | |||
if (l0 != '') {ModifySidebar( 'add', 'othproj', 'Einfach Lexikon', 'https://einfach.zum.de/wiki/' + l0 );} | |||
if (l1 != '') {ModifySidebar( 'add', 'othproj', 'Wikipedia', 'http://en.wikipedia.org/wiki/' + l1 );} | |||
} | |||
} | } | ||
jQuery( CustomizeModificationsOfSidebar ); | jQuery( CustomizeModificationsOfSidebar ); |
Version vom 18. April 2019, 12:38 Uhr
mappedPages = {
'Klexikon:Willkommen_im_Klexikon': ['Hauptseite', 'Wikipedia:Hauptseite'],
'Hasen': ['Hasen', 'Hasen'],
'Ostern': ['', 'Ostern']
}
function ModifySidebar( action, section, name, link ) {
try {
var target = 'p-' + section;
if ( action == 'add' ) {
var node = document.getElementById( target )
.getElementsByTagName( 'div' )[0]
.getElementsByTagName( 'ul' )[0];
var aNode = document.createElement( 'a' );
var liNode = document.createElement( 'li' );
aNode.appendChild( document.createTextNode( name ) );
aNode.setAttribute( 'href', link );
liNode.appendChild( aNode );
liNode.className = 'plainlinks';
node.appendChild( liNode );
}
} catch( e ) {
// let's just ignore what's happened
return;
}
}
function CustomizeModificationsOfSidebar() {
op = document.createElement('div')
op.setAttribute('class','portal')
op.setAttribute('role','navigation')
op.setAttribute('id','p-othproj')
op.innerHTML = '<h3>In anderen Projekte</h3><div class="body"><ul></ul></div>'
document.getElementById('p-tb').parentNode.appendChild(op)
if (wgPageName in mappedPages) {
l0 = mappedPages[wgPageName][0]
l1 = mappedPages[wgPageName][1]
if (l0 != '') {ModifySidebar( 'add', 'othproj', 'Einfach Lexikon', 'https://einfach.zum.de/wiki/' + l0 );}
if (l1 != '') {ModifySidebar( 'add', 'othproj', 'Wikipedia', 'http://en.wikipedia.org/wiki/' + l1 );}
}
}
jQuery( CustomizeModificationsOfSidebar );