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`;
}