User:Ciencia Al Poder-fduser/Load lang selector.js

/* Lang selector - By w:User:Ciencia Al Poder "Jesús Martínez Novo" Displays only the div or span in the 'actual' language of the wiki. Works with ?uselang=lang External element class: "langselect" Internal element lang attribute example: lang="es". If omitted then it will be the fallback element displayed.

function loadLangSelector{ dc = document.getElementById('bodyContent'); if (!dc) return; var se = dc.getElementsByTagName('span'); for (var i = 0; i < se.length; i++){ if ((' '+se[i].className+' ').indexOf(' langselect ') != -1){ var le = se[i].getElementsByTagName('span'); var matched = false; var def = false; for (var j = 0; j < le.length; j++){ if (le[j].lang == wgUserLanguage){ le[j].style.display = 'inline'; matched = true; }else{ le[j].style.display = 'none'; if (le[j].lang == '') def = le[j]; }     }      if (!matched && def) def.style.display = 'inline'; } }  se = dc.getElementsByTagName('div'); for (var i = 0; i < se.length; i++){ if ((' '+se[i].className+' ').indexOf(' langselect ') != -1){ var le = se[i].getElementsByTagName('div'); var matched = false; var def = false; for (var j = 0; j < le.length; j++){ if (le[j].lang == wgUserLanguage){ le[j].style.display = 'block'; matched = true; }else{ le[j].style.display = 'none'; if (le[j].lang == '') def = le[j]; }     }      if (!matched && def) def.style.display = 'block'; } } }