diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-11-05 20:52:40 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-11-05 20:52:40 +0100 |
| commit | f7ac115cc2c43d08f61c0e5a16657fd732a0a520 (patch) | |
| tree | 08b1289094669d8b75f418ec46dacb0bdf0cc0d9 | |
| parent | 60a306af8be5e06ac4c13419dd6b4189105f216e (diff) | |
API check
| -rwxr-xr-x | StoneIsland/www/js/index.js | 9 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/etc/sim.js | 13 | ||||
| -rwxr-xr-x | StoneIsland/www/js/lib/products/ProductView.js | 6 | ||||
| -rwxr-xr-x | StoneIsland/www/js/sdk/_sdk.js | 6 |
4 files changed, 26 insertions, 8 deletions
diff --git a/StoneIsland/www/js/index.js b/StoneIsland/www/js/index.js index e554f672..511849ad 100755 --- a/StoneIsland/www/js/index.js +++ b/StoneIsland/www/js/index.js @@ -79,11 +79,16 @@ var app = (function(){ cordova.plugins.Keyboard.disableScroll(true) cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false) geo.fetch() - sim.fetch() + sim.fetch(app.api_ready) var image = new Image image.src = "./img/compass-logo.png" } - + else { + app.api_ready() + } + } + + app.api_ready = function(){ if (is_iphone_x) { StatusBar.hide() } diff --git a/StoneIsland/www/js/lib/etc/sim.js b/StoneIsland/www/js/lib/etc/sim.js index 4507e160..c9cb77fe 100644 --- a/StoneIsland/www/js/lib/etc/sim.js +++ b/StoneIsland/www/js/lib/etc/sim.js @@ -4,24 +4,33 @@ var sim = (function(){ sim.loaded = false sim.data = { carrierName: 'unknown', - countryCode: 'xx', + countryCode: 'us', mcc: '0', mnc: '0', } - sim.fetch = function(){ + 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) 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") + sim.afterFetch() } return sim diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index de29bf73..1c13a7c4 100755 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -44,7 +44,7 @@ var ProductView = ScrollableView.extend({ if (this.not_available) { app.footer.show("SOLD OUT") } - else if (this.isNotAvailableInCanada) { + else if (this.isNotAvailable) { app.footer.show("NOT AVAILABLE") } else { @@ -185,10 +185,10 @@ var ProductView = ScrollableView.extend({ var notAvailableInCanada = !! app.store.notAvailableInCanada app.product.$notAvailableInCanada.toggle( notAvailableInCanada ) if (notAvailableInCanada && sim.data.countryCode === 'ca') { - this.isNotAvailableInCanada = true + this.isNotAvailable = true } else { - this.isNotAvailableInCanada = false + this.isNotAvailable = false } this.showFooter() diff --git a/StoneIsland/www/js/sdk/_sdk.js b/StoneIsland/www/js/sdk/_sdk.js index 7b4966a5..fc871727 100755 --- a/StoneIsland/www/js/sdk/_sdk.js +++ b/StoneIsland/www/js/sdk/_sdk.js @@ -22,13 +22,17 @@ var sdk = (function(){ } sdk.path = function(api, path){ - return endpoint + api + "/STONEISLAND_US/" + path + return endpoint + api + "/STONEISLAND_" + sdk.cc() + "/" + path } sdk.image = function(code, size){ return "https://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_" + size + ".jpg" } + sdk.cc = function(){ + return sim.data.countryCode.toUpperCase() + } + sdk.cms = function(){ return "https://stone.giraffe.life" // return "https://staging.stone.giraffe.life" |
