diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-08-14 16:34:25 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-08-16 09:13:39 +0200 |
commit | 73023bcc0dba68f6677bc02cdad75145180e2b11 (patch) | |
tree | 66fa7eb6279cd0752e012e286c422b1162d96cea /help3xsl | |
parent | 0d068dc8d5cd64f89c8a8e3d0a6bef6ed9e1ee87 (diff) |
Limit the online help only to the built languages.
Change-Id: Ib81dbd9a4047d9bb63761a43ef0b183a450b03f1
Reviewed-on: https://gerrit.libreoffice.org/59047
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'help3xsl')
-rw-r--r-- | help3xsl/help2.js | 17 | ||||
-rw-r--r-- | help3xsl/index2.html | 9 |
2 files changed, 20 insertions, 6 deletions
diff --git a/help3xsl/help2.js b/help3xsl/help2.js index 0e7b9d3325..aed610371b 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -120,4 +120,21 @@ function getParameterByName(name, url) { } return decodeURIComponent(results[2].replace(/\+/g, " ")); } + +function existingLang(lang) { + if (lang === undefined) { + return 'en-US'; + } + + if (languagesSet.has(lang)) { + return lang; + } + + lang = lang.replace(/[-_].*/, ''); + if (languagesSet.has(lang)) { + return lang; + } + + return 'en-US'; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/help3xsl/index2.html b/help3xsl/index2.html index 6a9a1a6c8e..ad12320433 100644 --- a/help3xsl/index2.html +++ b/help3xsl/index2.html @@ -11,6 +11,7 @@ <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval' piwik.documentfoundation.org *.google.com *.googleapis.com"/> <script type="text/javascript" src="help2.js"></script> <script type="text/javascript" src="hid2file.js"></script> + <script type="text/javascript" src="languages.js"></script> </head> <body> <script type="text/javascript"> @@ -20,7 +21,7 @@ // the URL came from LibreOffice help (F1) var target = getParameterByName("Target",url); var version = getParameterByName("Version",url); - var lang = getParameterByName("Language",url); + var lang = existingLang(getParameterByName("Language", url)); var system = getParameterByName("System",url); var module; var defaultFile; @@ -54,11 +55,7 @@ window.location.href = newURL; } else { // URL came from elsewhere, direct access to webroot, we redirect to main Help page - var userLang = navigator.language; - if (userLang === undefined) { - userlang="en-US"; - } - window.location.href = userLang + '/text/shared/main0108.html?&DbPAR=WRITER&System=WIN'; + window.location.href = existingLang(navigator.language) + '/text/shared/main0108.html?&DbPAR=WRITER&System=WIN'; } </script> </body> |