Add automatic region detection

This commit is contained in:
Matt Isenhower
2017-08-05 16:28:23 -07:00
parent 2404ba73d5
commit 56c55f2633

View File

@@ -126,6 +126,7 @@ export default {
},
},
created() {
this.detectRegion();
this.updateNow();
this.timer = setInterval(() => {
this.updateNow();
@@ -141,6 +142,16 @@ export default {
axios.get('/data/timeline.json').then(response => this.splatnet.timeline = response.data);
axios.get('/data/festivals-na.json').then(response => this.splatnet.festivals.na = response.data);
},
detectRegion() {
if (window.navigator && window.navigator.language) {
switch (window.navigator.language) {
case 'en-US':
case 'en-CA':
case 'es-MX':
this.selectedRegionKey = 'na';
}
}
},
updateNow() {
this.now = Math.trunc((new Date).getTime() / 1000);
},