From 3a40b6b6d7781a7243c8fa7ae37c3b9d62896f67 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 7 Feb 2023 15:24:46 +0100 Subject: [PATCH] Fixed broken ZIM viewer under SeaMonkey SeaMonkey doesn't yet support ['import.meta'][1]. This change requires that a function `setPermanentGlobalCookie(name, value)` is defined before `setUserLanguage()` (exported by i18n.js) can be called. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta --- static/skin/i18n.js | 3 +-- static/skin/viewer.js | 4 ++++ test/server.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/static/skin/i18n.js b/static/skin/i18n.js index 72d7d3b2..d451f11b 100644 --- a/static/skin/i18n.js +++ b/static/skin/i18n.js @@ -92,8 +92,7 @@ function getUserLanguage() { } function setUserLanguage(lang, callback) { - const rootPath = new URL('..', import.meta.url).pathname.replace(/\/$/, ''); - document.cookie = `userlang=${lang};path=${rootPath};max-age=31536000`; + setPermanentGlobalCookie('userlang', lang); Translations.load(lang); Translations.whenReady(callback); } diff --git a/static/skin/viewer.js b/static/skin/viewer.js index b4fe88a9..0426aea0 100644 --- a/static/skin/viewer.js +++ b/static/skin/viewer.js @@ -512,3 +512,7 @@ function finishViewerSetupOnceTranslationsAreLoaded() viewerSetupComplete = true; } + +function setPermanentGlobalCookie(name, value) { + document.cookie = `${name}=${value};path=${root};max-age=31536000`; +} diff --git a/test/server.cpp b/test/server.cpp index d208e5f9..0ec08c82 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -59,7 +59,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT/skin/favicon/favicon.ico" }, { STATIC_CONTENT, "/ROOT/skin/favicon/favicon.ico?cacheid=fba03a27" }, { DYNAMIC_CONTENT, "/ROOT/skin/i18n.js" }, - { STATIC_CONTENT, "/ROOT/skin/i18n.js?cacheid=dcf3d584" }, + { STATIC_CONTENT, "/ROOT/skin/i18n.js?cacheid=6da2bca0" }, { DYNAMIC_CONTENT, "/ROOT/skin/index.css" }, { STATIC_CONTENT, "/ROOT/skin/index.css?cacheid=0f9ba34e" }, { DYNAMIC_CONTENT, "/ROOT/skin/index.js" }, @@ -73,7 +73,7 @@ const ResourceCollection resources200Compressible{ { DYNAMIC_CONTENT, "/ROOT/skin/taskbar.css" }, { STATIC_CONTENT, "/ROOT/skin/taskbar.css?cacheid=2cbac34b" }, { DYNAMIC_CONTENT, "/ROOT/skin/viewer.js" }, - { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=b3c754ec" }, + { STATIC_CONTENT, "/ROOT/skin/viewer.js?cacheid=430d45b0" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf" }, { STATIC_CONTENT, "/ROOT/skin/fonts/Poppins.ttf?cacheid=af705837" }, { DYNAMIC_CONTENT, "/ROOT/skin/fonts/Roboto.ttf" }, @@ -300,9 +300,9 @@ R"EXPECTEDRESULT( - + - + const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032";