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
This commit is contained in:
Veloman Yunkan 2023-02-07 15:24:46 +01:00 committed by Matthieu Gautier
parent 2781da3221
commit 3a40b6b6d7
3 changed files with 9 additions and 6 deletions

View File

@ -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);
}

View File

@ -512,3 +512,7 @@ function finishViewerSetupOnceTranslationsAreLoaded()
viewerSetupComplete = true;
}
function setPermanentGlobalCookie(name, value) {
document.cookie = `${name}=${value};path=${root};max-age=31536000`;
}

View File

@ -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( <img src="../skin/download.png?
/* url */ "/ROOT/viewer",
R"EXPECTEDRESULT( <link type="text/css" href="./skin/taskbar.css?cacheid=2cbac34b" rel="Stylesheet" />
<link type="text/css" href="./skin/css/autoComplete.css?cacheid=08951e06" rel="Stylesheet" />
<script type="module" src="./skin/i18n.js?cacheid=dcf3d584" defer></script>
<script type="module" src="./skin/i18n.js?cacheid=6da2bca0" defer></script>
<script type="text/javascript" src="./skin/languages.js?cacheid=fe100348" defer></script>
<script type="text/javascript" src="./skin/viewer.js?cacheid=b3c754ec" defer></script>
<script type="text/javascript" src="./skin/viewer.js?cacheid=430d45b0" defer></script>
<script type="text/javascript" src="./skin/autoComplete.min.js?cacheid=1191aaaf"></script>
const blankPageUrl = root + "/skin/blank.html?cacheid=6b1fa032";
<label for="kiwix_button_show_toggle"><img src="./skin/caret.png?cacheid=22b942b4" alt=""></label>