on master help sign in
Use simplified code when matching language
8b65fdaRosano
scripts/portal.js+2−1
@@ -71,8 +71,9 @@ function Portal (sites) {
71 setTimeout(() => { window.location.href = target }, 3000)
71 setTimeout(() => { window.location.href = target }, 3000)
72 }
72 }
73
73
74+ const simplifiedCodes = Array.from(new Set([].concat.apply([], navigator.languages.map(code => [code, code.split('-').shift()]))))
74 this.sitesMatchingLangs = this.sites
75 this.sitesMatchingLangs = this.sites
75− .filter(site => site.langs && site.langs.some(lang => navigator.languages.includes(lang)))
76+ .filter(site => site.langs && site.langs.some(lang => simplifiedCodes.includes(lang)))
76
77
77 this.nextSiteIndex = (ceiling, index) => index === ceiling ? 0 : index + 1
78 this.nextSiteIndex = (ceiling, index) => index === ceiling ? 0 : index + 1
78 this.randomSite = this.sitesMatchingLangs[Math.floor(Math.random() * this.sitesMatchingLangs.length)]
79 this.randomSite = this.sitesMatchingLangs[Math.floor(Math.random() * this.sitesMatchingLangs.length)]