summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xStoneIsland/www/js/index.js9
-rw-r--r--StoneIsland/www/js/lib/etc/sim.js13
-rwxr-xr-xStoneIsland/www/js/lib/products/ProductView.js6
-rwxr-xr-xStoneIsland/www/js/sdk/_sdk.js6
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"