2024 wird gefeiert: 10 Jahre Klexikon und 5 Jahre MiniKlexikon. Spenden helfen uns sehr!

Benutzer:Thomas Karcher/common.js: Unterschied zwischen den Versionen

Aus Klexikon – das Kinderlexikon
KKeine Bearbeitungszusammenfassung
KKeine Bearbeitungszusammenfassung
Zeile 41: Zeile 41:
l1 = mappedPages[wgPageName][1]
l1 = mappedPages[wgPageName][1]
if (l0 != '') {ModifySidebar( 'add', 'othproj', 'Einfach Lexikon', 'https://einfach.zum.de/wiki/' + l0 );}
if (l0 != '') {ModifySidebar( 'add', 'othproj', 'Einfach Lexikon', 'https://einfach.zum.de/wiki/' + l0 );}
if (l1 != '') {ModifySidebar( 'add', 'othproj', 'Wikipedia', 'http://de.wikipedia.org/wiki/' + l1 );}
if (l1 != '') {ModifySidebar( 'add', 'othproj', 'Wikipedia', 'https://de.wikipedia.org/wiki/' + l1 );}
}
}
}
}


jQuery( CustomizeModificationsOfSidebar );
jQuery( CustomizeModificationsOfSidebar );

Version vom 18. April 2019, 12:44 Uhr

// Format: <Titel im Klexikon>: [<Titel im Einfach-Lexikon>, <Titel in Wikipedia>]
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 Projekten</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', 'https://de.wikipedia.org/wiki/' + l1 );}
	}
}

jQuery( CustomizeModificationsOfSidebar );