KKeine Bearbeitungszusammenfassung |
KKeine Bearbeitungszusammenfassung |
||
(19 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
document. | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
var sp_country_codes = document.querySelectorAll('span.sp-country-code'); | |||
for (i = 0; i < sp_country_codes.length; i++) { | |||
sp_country_codes[i].innerHTML = (navigator.language).substring(0,2); | |||
} | |||
var default_language = document.querySelectorAll('.language.de'); | |||
for (i = 0; i < default_language.length; i++) { | |||
default_language[i].style.display = "inline"; | |||
} | |||
var supported_languages = { | |||
"de": "german", | |||
"en": "english", | |||
"fr": "french", | |||
// beliebig erweiterbar | |||
}; | |||
// sprache des browsers | |||
var browser_langues_code = navigator.language; | |||
if (browser_langues_code.indexOf("-") != -1) { | |||
var browser_langues_code = browser_langues_code.substring(0, browser_langues_code.indexOf("-")); | |||
} | |||
// wird die sprache supportet auswählen | |||
console.log(supported_languages[browser_langues_code]); | |||
if (supported_languages[browser_langues_code] != undefined) { | |||
var default_language = document.querySelectorAll('.language.'+supported_languages[browser_langues_code]); | |||
for (i = 0; i < default_language.length; i++) { | |||
default_language[i].style.display = "inline"; | |||
} | |||
} else { | |||
var default_language = document.querySelectorAll('.language.german'); | |||
for (i = 0; i < default_language.length; i++) { | |||
default_language[i].style.display = "inline"; | |||
} | |||
} | |||
// hier die funktion der buttons | |||
// deutsch button | |||
var language_toggle_german = document.querySelectorAll('.language-toggle-german'); | |||
for (i = 0; i < language_toggle_german.length; i++) { | |||
language_toggle_german[i].addEventListener('click', function(event) { | |||
var language_elements = document.querySelectorAll('.language'); | |||
for (i = 0; i < language_elements.length; i++) { | |||
language_elements[i].style.display = "none"; | |||
} | |||
var language_german = document.querySelectorAll('.language.german'); | |||
for (i = 0; i < language_german.length; i++) { | |||
language_german[i].style.display = "inline"; | |||
} | |||
}); | |||
} | |||
// englisch button | |||
var language_toggle_english = document.querySelectorAll('.language-toggle-english'); | |||
for (i = 0; i < language_toggle_english.length; i++) { | |||
language_toggle_english[i].addEventListener('click', function(event) { | |||
var language_elements = document.querySelectorAll('.language'); | |||
for (i = 0; i < language_elements.length; i++) { | |||
language_elements[i].style.display = "none"; | |||
} | |||
var language_english = document.querySelectorAll('.language.english'); | |||
for (i = 0; i < language_english.length; i++) { | |||
language_english[i].style.display = "inline"; | |||
} | |||
}); | |||
} | |||
// französisch button | |||
var language_toggle_french = document.querySelectorAll('.language-toggle-french'); | |||
for (i = 0; i < language_toggle_french.length; i++) { | |||
language_toggle_french[i].addEventListener('click', function(event) { | |||
var language_elements = document.querySelectorAll('.language'); | |||
for (i = 0; i < language_elements.length; i++) { | |||
language_elements[i].style.display = "none"; | |||
} | |||
var language_french = document.querySelectorAll('.language.french'); | |||
for (i = 0; i < language_french.length; i++) { | |||
language_french[i].style.display = "inline"; | |||
} | |||
}); | |||
} |
Version vom 14. Juni 2022, 11:23 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */ var sp_country_codes = document.querySelectorAll('span.sp-country-code'); for (i = 0; i < sp_country_codes.length; i++) { sp_country_codes[i].innerHTML = (navigator.language).substring(0,2); } var default_language = document.querySelectorAll('.language.de'); for (i = 0; i < default_language.length; i++) { default_language[i].style.display = "inline"; } var supported_languages = { "de": "german", "en": "english", "fr": "french", // beliebig erweiterbar }; // sprache des browsers var browser_langues_code = navigator.language; if (browser_langues_code.indexOf("-") != -1) { var browser_langues_code = browser_langues_code.substring(0, browser_langues_code.indexOf("-")); } // wird die sprache supportet auswählen console.log(supported_languages[browser_langues_code]); if (supported_languages[browser_langues_code] != undefined) { var default_language = document.querySelectorAll('.language.'+supported_languages[browser_langues_code]); for (i = 0; i < default_language.length; i++) { default_language[i].style.display = "inline"; } } else { var default_language = document.querySelectorAll('.language.german'); for (i = 0; i < default_language.length; i++) { default_language[i].style.display = "inline"; } } // hier die funktion der buttons // deutsch button var language_toggle_german = document.querySelectorAll('.language-toggle-german'); for (i = 0; i < language_toggle_german.length; i++) { language_toggle_german[i].addEventListener('click', function(event) { var language_elements = document.querySelectorAll('.language'); for (i = 0; i < language_elements.length; i++) { language_elements[i].style.display = "none"; } var language_german = document.querySelectorAll('.language.german'); for (i = 0; i < language_german.length; i++) { language_german[i].style.display = "inline"; } }); } // englisch button var language_toggle_english = document.querySelectorAll('.language-toggle-english'); for (i = 0; i < language_toggle_english.length; i++) { language_toggle_english[i].addEventListener('click', function(event) { var language_elements = document.querySelectorAll('.language'); for (i = 0; i < language_elements.length; i++) { language_elements[i].style.display = "none"; } var language_english = document.querySelectorAll('.language.english'); for (i = 0; i < language_english.length; i++) { language_english[i].style.display = "inline"; } }); } // französisch button var language_toggle_french = document.querySelectorAll('.language-toggle-french'); for (i = 0; i < language_toggle_french.length; i++) { language_toggle_french[i].addEventListener('click', function(event) { var language_elements = document.querySelectorAll('.language'); for (i = 0; i < language_elements.length; i++) { language_elements[i].style.display = "none"; } var language_french = document.querySelectorAll('.language.french'); for (i = 0; i < language_french.length; i++) { language_french[i].style.display = "inline"; } }); }