common.js: Unterschied zwischen den Versionen

Aus Klexikon - Das Freie Kinderlexikon
Wechseln zu: Navigation, Suche
K
Zeile 1: Zeile 1:
 
// Format: <Titel im Klexikon>: [<Titel im Einfach-Lexikon>, <Titel in Wikipedia>]
 
// Format: <Titel im Klexikon>: [<Titel im Einfach-Lexikon>, <Titel in Wikipedia>]
 +
// '' --> Keine entsprechende Seite vorhanden
 +
// '~' --> Seitentitel entspricht Titel im Klexikon
 
mappedPages = {
 
mappedPages = {
'Klexikon:Willkommen_im_Klexikon': ['Hauptseite', 'Wikipedia:Hauptseite'],
+
  'Klexikon:Willkommen_im_Klexikon': ['Hauptseite', 'Wikipedia:Hauptseite'],
'Hasen': ['Hasen', 'Hasen'],
+
  'Hasen': ['~', '~'],
'Ostern': ['', 'Ostern']
+
  'Ostern': ['', '~']
 
}
 
}
  
 
function ModifySidebar( action, section, name, link ) {
 
function ModifySidebar( action, section, name, link ) {
try {
+
  try {
var target = 'p-' + section;
+
    var target = 'p-' + section;
if ( action == 'add' ) {
+
 
var node = document.getElementById( target )
+
    if ( action == 'add' ) {
  .getElementsByTagName( 'div' )[0]
+
      var node = document.getElementById( target )
  .getElementsByTagName( 'ul' )[0];
+
                .getElementsByTagName( 'div' )[0]
var aNode = document.createElement( 'a' );
+
                .getElementsByTagName( 'ul' )[0];
var liNode = document.createElement( 'li' );
+
      var aNode = document.createElement( 'a' );
aNode.appendChild( document.createTextNode( name ) );
+
      var liNode = document.createElement( 'li' );
aNode.setAttribute( 'href', link );
+
      aNode.appendChild( document.createTextNode( name ) );
liNode.appendChild( aNode );
+
      aNode.setAttribute( 'href', link );
liNode.className = 'plainlinks';
+
      liNode.appendChild( aNode );
node.appendChild( liNode );
+
      liNode.className = 'plainlinks';
}
+
      node.appendChild( liNode );
} catch( e ) {
+
    }
// let's just ignore what's happened
+
  } catch( e ) {
return;
+
    // let's just ignore what's happened
}
+
    return;
 +
  }
 
}
 
}
  
 
function CustomizeModificationsOfSidebar() {
 
function CustomizeModificationsOfSidebar() {
+
  op = document.createElement('div')
op = document.createElement('div')
+
  op.setAttribute('class','portal')
op.setAttribute('class','portal')
+
  op.setAttribute('role','navigation')
op.setAttribute('role','navigation')
+
  op.setAttribute('id','p-othproj')
op.setAttribute('id','p-othproj')
+
  op.innerHTML = '<h3>In anderen Projekten</h3><div class="body"><ul></ul></div>'
op.innerHTML = '<h3>In anderen Projekten</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) {
if (wgPageName in mappedPages) {
+
    l0 = mappedPages[wgPageName][0].replace('~', wgPageName)
l0 = mappedPages[wgPageName][0]
+
    l1 = mappedPages[wgPageName][1].replace('~', wgPageName)
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', 'https://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, 14:58 Uhr

// Format: <Titel im Klexikon>: [<Titel im Einfach-Lexikon>, <Titel in Wikipedia>]
// '' --> Keine entsprechende Seite vorhanden
// '~' --> Seitentitel entspricht Titel im Klexikon
mappedPages = {
  'Klexikon:Willkommen_im_Klexikon': ['Hauptseite', 'Wikipedia:Hauptseite'],
  'Hasen': ['~', '~'],
  '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].replace('~', wgPageName)
    l1 = mappedPages[wgPageName][1].replace('~', wgPageName)
    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 );