From 289943a5a67018e7dc0202af44dfae9cd3037a8e Mon Sep 17 00:00:00 2001 From: gurpreetsinghmatharoo Date: Fri, 25 Oct 2024 14:08:48 +0530 Subject: [PATCH] docs(general): language switcher fix - didn't appear on no context pages and sometimes input didn't work --- Manual/contents/assets/scripts/main_script.js | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/Manual/contents/assets/scripts/main_script.js b/Manual/contents/assets/scripts/main_script.js index f3f6bf340..46c90e603 100644 --- a/Manual/contents/assets/scripts/main_script.js +++ b/Manual/contents/assets/scripts/main_script.js @@ -2591,7 +2591,7 @@ var listStyle = `float: right; padding: 8px; border-radius: 4px;` -var myParent = window.parent.document.body.getElementsByClassName("header")[0]; +var myParent = window.parent.document.getElementsByClassName("header")[0]; // No context view style and parent elm if (myParent == undefined) { @@ -2603,25 +2603,25 @@ if (myParent == undefined) { `; } +//Create array of options to be added +var array = [ + { name: "English", code: "en" }, + { name: "Français", code: "fr" }, + { name: "Español", code: "es" }, + { name: "Deutsch", code: "de" }, + { name: "Русский", code: "ru" }, + { name: "Italiano", code: "it" }, + { name: "Polski", code: "pl" }, + { name: "Português Brasileiro", code: "br" }, + { name: "한국인", code: "ko" }, + { name: "中国人", code: "zh" }, + { name: "日本語", code: "ja" } +]; + // Make sure it doesn't already exist var existingSelectList = window.parent.document.getElementById("mySelect"); if (existingSelectList == undefined) { - //Create array of options to be added - var array = [ - { name: "English", code: "en" }, - { name: "Français", code: "fr" }, - { name: "Español", code: "es" }, - { name: "Deutsch", code: "de" }, - { name: "Русский", code: "ru" }, - { name: "Italiano", code: "it" }, - { name: "Polski", code: "pl" }, - { name: "Português Brasileiro", code: "br" }, - { name: "한국인", code: "ko" }, - { name: "中国人", code: "zh" }, - { name: "日本語", code: "ja" } - ]; - //Create and append select list var selectList = document.createElement("select"); selectList.id = "mySelect"; @@ -2646,18 +2646,19 @@ if (existingSelectList == undefined) { for( var i=0; i= 3) { folders[2] = entry.code; } // end if - window.parent.location.pathname = `${folders.join('/')}`; + var newpath = `${folders.join('/')}`; + window.parent.location.pathname = newpath; } });