-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browser detection improvements (#22)
Improved detection of incompatible web browsers.
- Loading branch information
Showing
7 changed files
with
137 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(() => { | ||
const specificLocale = (/\?(.*)\blang=([^&]+)/.exec(window.location.href) || [])[2]; | ||
const urlLocale = (/\borloj\/([^/]+)/.exec(window.location.href) || [])[1]; | ||
let locales = []; | ||
|
||
if (navigator.languages) | ||
locales = navigator.languages; | ||
else if (navigator.language) | ||
locales = [navigator.language]; | ||
|
||
if (specificLocale) | ||
locales = [specificLocale]; | ||
else if (urlLocale) { | ||
let matched = false; | ||
|
||
for (const locale of locales) { | ||
if (locale.startsWith(urlLocale)) { | ||
locales = [locale]; | ||
matched = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!matched) | ||
locales = [urlLocale]; | ||
} | ||
|
||
for (const locale of locales) { | ||
if (locale.startsWith('cs')) { | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.querySelector('title').innerText = 'Simulátor pražského orloje'; | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.getElementById('loading').innerText = 'Načítání...'; | ||
break; | ||
} | ||
else if (locale.startsWith('de')) { | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.querySelector('title').innerText = 'Pražský Orloj - Simulator der Prager astronomischen Uhr'; | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.getElementById('loading').innerText = 'Wird geladen...'; | ||
break; | ||
} | ||
else if (locale.startsWith('es')) { | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.querySelector('title').innerText = 'Pražský Orloj - Simulador de Reloj Astronómico de Praga'; | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.getElementById('loading').innerText = 'Cargando...'; | ||
break; | ||
} | ||
else if (locale.startsWith('fr')) { | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.querySelector('title').innerText = 'Pražský Orloj - Simulateur d\'horloge astronomique de Prague'; | ||
/* cSpell:disable-next-line */ // noinspection SpellCheckingInspection | ||
document.getElementById('loading').innerText = 'Chargement...'; | ||
break; | ||
} | ||
else if (locale.startsWith('en')) | ||
break; | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.