summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/etc/sim.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/lib/etc/sim.js')
-rw-r--r--StoneIsland/www/js/lib/etc/sim.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/StoneIsland/www/js/lib/etc/sim.js b/StoneIsland/www/js/lib/etc/sim.js
index c9cb77fe..ca01ddc7 100644
--- a/StoneIsland/www/js/lib/etc/sim.js
+++ b/StoneIsland/www/js/lib/etc/sim.js
@@ -18,11 +18,13 @@ var sim = (function(){
sim.success = function(data){
console.log(data)
- sim.data = data
- sim.data.countryCode = sim.data.countryCode.toLowerCase()
- // app is only available in US or Canada, so call the US API regardless
- if (sim.data.countryCode !== 'ca') {
- sim.data.countryCode = 'us'
+ if (sim.data.countryCode) {
+ sim.data = data
+ sim.data.countryCode = sim.data.countryCode.toLowerCase()
+ // app is only available in US or Canada, so call the US API regardless
+ if (sim.data.countryCode !== 'ca') {
+ sim.data.countryCode = 'us'
+ }
}
sim.loaded = true
sim.afterFetch()
@@ -30,7 +32,12 @@ var sim = (function(){
sim.error = function(){
console.log("no SIM card detected")
- sim.afterFetch()
+ $.ajax({
+ url: "http://ip-api.com/json/",
+ jsonp: "callback",
+ dataType: "jsonp",
+ success: sim.success,
+ })
}
return sim