summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/etc
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-11-06 00:54:06 +0100
committerJules Laplace <julescarbon@gmail.com>2017-11-06 00:54:06 +0100
commit874448ba5fa8ff0796e9934c44eb8ba695c80257 (patch)
treecdcc640a7baf463a49bdc6099be4749789851aa9 /StoneIsland/platforms/ios/www/js/lib/etc
parent207a2d0d311fe602f81e594877bb0a996b01aa18 (diff)
check if hub needed..
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/etc')
-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