on master help sign in
Simplify
ed691dcChris
scripts/portal.js+3−2
@@ -71,9 +71,10 @@ 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.navLangs = [... new Set(navigator.languages.map(lang => lang.split('-').shift()))]
75+
75 this.sitesMatchingLangs = this.sites
76 this.sitesMatchingLangs = this.sites
76− .filter(site => site.langs && site.langs.some(lang => simplifiedCodes.includes(lang)))
77+ .filter(site => site.langs && site.langs.some(lang => this.navLangs.includes(lang)))
77
78
78 this.nextSiteIndex = (ceiling, index) => index === ceiling ? 0 : index + 1
79 this.nextSiteIndex = (ceiling, index) => index === ceiling ? 0 : index + 1
79 this.randomSite = this.sitesMatchingLangs[Math.floor(Math.random() * this.sitesMatchingLangs.length)]
80 this.randomSite = this.sitesMatchingLangs[Math.floor(Math.random() * this.sitesMatchingLangs.length)]