summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/etc/sim.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/etc/sim.js')
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/etc/sim.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/sim.js b/StoneIsland/platforms/ios/www/js/lib/etc/sim.js
new file mode 100644
index 00000000..ca01ddc7
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/etc/sim.js
@@ -0,0 +1,44 @@
+var sim = (function(){
+ var sim = {}
+
+ sim.loaded = false
+ sim.data = {
+ carrierName: 'unknown',
+ countryCode: 'us',
+ mcc: '0',
+ mnc: '0',
+ }
+
+ sim.fetch = function(cb){
+ sim.afterFetch = cb
+ window.plugins.sim.getSimInfo(sim.success, sim.error)
+ }
+
+ sim.afterFetch = function(){}
+
+ sim.success = function(data){
+ console.log(data)
+ 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()
+ }
+
+ sim.error = function(){
+ console.log("no SIM card detected")
+ $.ajax({
+ url: "http://ip-api.com/json/",
+ jsonp: "callback",
+ dataType: "jsonp",
+ success: sim.success,
+ })
+ }
+
+ return sim
+})() \ No newline at end of file