/* Das JavaScript hier wird für die Benutzer der mobilen Website geladen. */
// Siehe-auch-Feld auf Eintragsseiten, die auch ein case-(in)sensitive-äquivalent haben
function showSeeAlso() {
if (mw.config.get('wgNamespaceNumber') == 0 && document.URL.indexOf("oldid=") < 0) {
var vsa = document.getElementById("Vorlage_Siehe_auch");
if (vsa) {
var sn = document.getElementById("mf-section-0");
if (sn) {
sn.parentNode.innerHTML = vsa.innerHTML + sn.parentNode.innerHTML;
}
}
}
}
$(document).ready(showSeeAlso);
// Ausklappbare Navigationsleisten
var NavigationBarHide = 'Einklappen ▲ ';
var NavigationBarShow = 'Ausklappen ▼ ';
var NavigationBarShowDefault = 100;
var NavigationBarShowLang = '';
//Einstellungen (]):
if ( mw.cookie.get('WiktionaryUseJSPreferences') != 'true' ) {
NavigationBarShowDefault = 999;
} else if ( mw.cookie.get('WiktionaryPreferencesHideNav') == 'true' ) {
NavigationBarShowDefault = 0;
NavigationBarShowLang = ',' + mw.cookie.get('WiktionaryPreferencesShowLang') + ',';
NavigationBarShowLang = NavigationBarShowLang.replace(/\s*,\s*/g,','); //remove blanks
} else if ( mw.cookie.get('WiktionaryPreferencesShowNav') == 'true' ) {
NavigationBarShowDefault = 999;
} else {
NavigationBarShowDefault = 999;
}
function toggleNavigationBarAll(indexNavigationBar) {
var mode;
var NavChild;
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {return false;}
mode = NavToggle.firstChild.data;
var collection = document.getElementsByClassName("NavFrame");
for (var i = 0; i < collection.length; i++) {
if (mode == NavigationBarHide) {
for (NavChild = collection.firstChild; NavChild !== null; NavChild = NavChild.nextSibling) {
if (NavChild.className == 'NavPic') {NavChild.style.display = 'none';}
if (NavChild.className == 'NavContent') {NavChild.style.display = 'none';}
if (NavChild.className == 'NavToggle') {NavChild.firstChild.data = NavigationBarShow;}
}
copyLanguages(collection);
} else if (mode == NavigationBarShow) {
for (NavChild = collection.firstChild; NavChild !== null; NavChild = NavChild.nextSibling) {
if (NavChild.className == 'NavPic') {NavChild.style.display = 'block';}
if (NavChild.className == 'NavContent') {NavChild.style.display = 'block';}
if (NavChild.className == 'NavToggle') {NavChild.firstChild.data = NavigationBarHide;}
}
removeLanguages(collection);
}
}
}
function toggleNavigationBar(indexNavigationBar) {
var NavChild;
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {return false;}
if (NavToggle.firstChild.data == NavigationBarHide) {
for (NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling) {
if (NavChild.className == 'NavPic') {NavChild.style.display = 'none';}
if (NavChild.className == 'NavContent') {NavChild.style.display = 'none';}
if (NavChild.className == 'NavToggle') {NavChild.firstChild.data = NavigationBarShow;}
}
copyLanguages(NavFrame);
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling) {
if (NavChild.className == 'NavPic') {NavChild.style.display = 'block';}
if (NavChild.className == 'NavContent') {NavChild.style.display = 'block';}
if (NavChild.className == 'NavToggle') {NavChild.firstChild.data = NavigationBarHide;}
}
removeLanguages(NavFrame);
}
}
function allowedLanguage(lang) {
if (NavigationBarShowLang.indexOf(',' + lang + ',') >= 0) {return true;}
return false;
}
function copyLanguages(NavFrame) {
// Ausnahme für "Deutsch"; die deutsche Übersetzungszeile enthält ein <b> (bold)
var a = NavFrame.querySelectorAll(
".uetab:not(.dialekte) ~ ul li > a:first-of-type, .uetab:not(.dialekte) ~ ul li > b > a:first-of-type"
);
var node,ulnode;
ulnode = document.createElement("ul");
ulnode.classList.add("NavHeadUl");
var nh = NavFrame.getElementsByClassName("NavHead");
if (nh && nh.length > 0) {
if (nh.getElementsByClassName('NavHeadUl')) {
// already there
return;
}
ulnode = document.createElement("ul");
ulnode.classList.add("NavHeadUl");
nh.appendChild(ulnode);
var i = 0;
for (i = 0; i < a.length; i++) {
node = a;
if (allowedLanguage(node.textContent)) {
var clone = node.parentNode.cloneNode(true);
if (clone.tagName == "B") {
clone = node.parentNode.parentNode.cloneNode(true);
}
clone.removeAttribute("style");
if (clone.firstChild) {
clone.firstChild.setAttribute("style","display:inline-block;min-width:7em");
}
ulnode.appendChild(clone);
}
}
}
}
function removeLanguages(NavFrame) {
var ulnode;
var nh = NavFrame.getElementsByClassName("NavHead");
if (nh && nh.length > 0) {
ulnode = nh.getElementsByClassName("NavHeadUl");
if (ulnode) {
nh.removeChild(ulnode);
}
}
}
indexNavigationBar = 0;
function createNavigationBarToggleButton() {
for (i=0; NavFrame = document.getElementsByTagName("div"); i++) {
if (NavFrame.className == "NavFrame") {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar('+indexNavigationBar+')');
NavToggle.innerText = NavigationBarHide;
var node = document.createElement("a"); // Config/Einstellungen
node.setAttribute('href', '//de.m.wiktionary.orghttps://dictious.com/de/Wiktionary:Einstellungen');
node.setAttribute('title', 'Wiktionary:Einstellungen');
node.className = 'NavToggleConfig';
node.innerText = " \u00A0 \u2261 \u00A0 ";
NavFrame.insertBefore(node, NavFrame.firstChild);
node = document.createElement("a"); // Toggle all
node.setAttribute('href', 'javascript:toggleNavigationBarAll('+indexNavigationBar+')');
node.setAttribute('title', 'Alle klappbaren Elemente der Seite Ein-/Ausklappen');
node.className = 'NavToggleAll';
node.innerText = "\u00A0Alle\u00A0";
NavFrame.insertBefore(node, NavFrame.firstChild);
NavFrame.insertBefore(NavToggle, NavFrame.firstChild);
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
if (NavigationBarShowDefault < indexNavigationBar) {
for (var i=1; i<=indexNavigationBar; i++) {toggleNavigationBar(i);}
}
}
$(document).ready(createNavigationBarToggleButton);
// Urgently change ID to class...
function closedNavBar() {
if (mw.cookie.get('WiktionaryUseJSPreferences') != 'true' ) {
for (var i = 0; i < indexNavigationBar; i++) {
var j = i+1;
if (document.getElementById("NavFrame"+j).parentNode.parentNode.parentNode.parentNode.id == "closedNavBar") {toggleNavigationBar(j);}
else {toggleNavigationBar(0);}
}
} else if (mw.cookie.get('WiktionaryPreferencesHideNav') == 'true' ) {
toggleNavigationBar(100);
} else if (mw.cookie.get('WiktionaryPreferencesShowNav') == 'true' ) {
toggleNavigationBar(0);
} else {
for (var i = 0; i < indexNavigationBar; i++) {
var j = i+1;
if (document.getElementById("NavFrame"+j).parentNode.parentNode.parentNode.parentNode.id == "closedNavBar") {toggleNavigationBar(j);}
else {toggleNavigationBar(0);}
}
}
}
$(document).ready(closedNavBar);
// Skript für Einstellungen laden
importScript('MediaWiki:Wiktionary-Einstellungen.js');
// mw.loader funktioniert nicht
//mw.loader.load( 'https://dictious.com/de/index.php?title=MediaWiki:Wiktionary-Einstellungen.js&action=raw&ctype=text/javascript' );