mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Make language selectors of browser supported languages visible
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
window.onload = function() {
|
||||
show_lang_selector();
|
||||
|
||||
var container = document.querySelector('#toc-aside');
|
||||
|
||||
if (container != null) {
|
||||
@@ -61,3 +63,19 @@ function toc_scroll_position(container) {
|
||||
current_toc_item.classList.add("active");
|
||||
}
|
||||
}
|
||||
|
||||
function show_lang_selector() {
|
||||
var show_lang_selector = false;
|
||||
for (language_selector of document.querySelectorAll('#language-selector li')) {
|
||||
var lang = language_selector.getAttribute("data-lang-switch-to");
|
||||
this.console.log(lang)
|
||||
if (this.navigator.languages.includes(lang)) {
|
||||
this.console.log("supported!");
|
||||
language_selector.classList.remove("hidden");
|
||||
show_lang_selector = true
|
||||
}
|
||||
}
|
||||
if (show_lang_selector) {
|
||||
document.querySelector("#language-selector").classList.remove("hidden")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user