From 763fb86ad02b9d1517f89dfc67878017739d2f3d Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 9 Feb 2023 18:04:47 +0100 Subject: [PATCH] userlang query param is removed from the URL If the userlang query param is present in the URL it is used to set the UI language and then is removed from the URL. Unlike the ZIM viewer, changing the UI language on the welcome page isn't recorded in the navigation history (and probably it should work the same way in the ZIM viewer where the appearance of the web page is affected by the UI language changes to a significantly smaller extent). --- static/skin/index.js | 6 +++--- test/server.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/static/skin/index.js b/static/skin/index.js index 072ab59a..06147f88 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -15,6 +15,7 @@ let noResultInjected = false; let filters = getCookie(filterCookieName); let params = new URLSearchParams(window.location.search || filters || ''); + params.delete('userlang'); let timer; let languages = {}; @@ -34,9 +35,8 @@ function changeUILanguage() { const s = document.getElementById("ui_language"); const lang = s.options[s.selectedIndex].value; - const q = new URLSearchParams(window.location.search); - q.set("userlang", lang); - location.search = q.toString(); + setPermanentGlobalCookie('userlang', lang); + window.location.reload(); } function queryUrlBuilder() { diff --git a/test/server.cpp b/test/server.cpp index 6188ee30..ce3836c9 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -63,7 +63,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.css" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/index.css?cacheid=ac5767d8" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/index.js" }, - { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=f045ea14" }, + { STATIC_CONTENT, "/ROOT%23%3F/skin/index.js?cacheid=5b1775c2" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js" }, { STATIC_CONTENT, "/ROOT%23%3F/skin/iso6391To3.js?cacheid=ecde2bb3" }, { DYNAMIC_CONTENT, "/ROOT%23%3F/skin/isotope.pkgd.min.js" }, @@ -284,7 +284,7 @@ R"EXPECTEDRESULT( href="/ROOT%23%3F/skin/index.css?cacheid=ac5767d8" - +