mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-29 15:35:15 -04:00
Merge branch 'master' into production
This commit is contained in:
commit
a9859d0522
2 changed files with 17 additions and 14 deletions
|
@ -5,17 +5,17 @@ module.exports = class BuyGemsModal extends ModalView
|
||||||
id: 'buy-gems-modal'
|
id: 'buy-gems-modal'
|
||||||
template: template
|
template: template
|
||||||
plain: true
|
plain: true
|
||||||
|
|
||||||
products: [
|
originalProducts: [
|
||||||
{ price: '$4.99', gems: 5000, id: 'gems_5', i18n: 'buy_gems.few_gems' }
|
{ price: '$4.99', gems: 5000, id: 'gems_5', i18n: 'buy_gems.few_gems' }
|
||||||
{ price: '$9.99', gems: 11000, id: 'gems_10', i18n: 'buy_gems.pile_gems' }
|
{ price: '$9.99', gems: 11000, id: 'gems_10', i18n: 'buy_gems.pile_gems' }
|
||||||
{ price: '$19.99', gems: 25000, id: 'gems_20', i18n: 'buy_gems.chest_gems' }
|
{ price: '$19.99', gems: 25000, id: 'gems_20', i18n: 'buy_gems.chest_gems' }
|
||||||
]
|
]
|
||||||
|
|
||||||
subscriptions:
|
subscriptions:
|
||||||
'ipad:products': 'onIPadProducts'
|
'ipad:products': 'onIPadProducts'
|
||||||
'ipad:iap-complete': 'onIAPComplete'
|
'ipad:iap-complete': 'onIAPComplete'
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click .product button': 'onClickProductButton'
|
'click .product button': 'onClickProductButton'
|
||||||
|
|
||||||
|
@ -23,34 +23,36 @@ module.exports = class BuyGemsModal extends ModalView
|
||||||
super(options)
|
super(options)
|
||||||
if application.isIPadApp
|
if application.isIPadApp
|
||||||
@products = []
|
@products = []
|
||||||
Backbone.Mediator.publish 'buy-gems-modal:update-products'
|
Backbone.Mediator.publish 'buy-gems-modal:update-products'
|
||||||
|
else
|
||||||
|
@products = @originalProducts
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
c = super()
|
c = super()
|
||||||
c.products = @products
|
c.products = @products
|
||||||
return c
|
return c
|
||||||
|
|
||||||
onIPadProducts: (e) ->
|
onIPadProducts: (e) ->
|
||||||
newProducts = []
|
newProducts = []
|
||||||
for iapProduct in e.products
|
for iapProduct in e.products
|
||||||
localProduct = _.find @products, { id: iapProduct.id }
|
localProduct = _.find @originalProducts, { id: iapProduct.id }
|
||||||
continue unless localProduct
|
continue unless localProduct
|
||||||
localProduct.price = iapProduct.price
|
localProduct.price = iapProduct.price
|
||||||
newProducts.push localProduct
|
newProducts.push localProduct
|
||||||
@products = newProducts
|
@products = _.sortBy newProducts, 'gems'
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
onClickProductButton: (e) ->
|
onClickProductButton: (e) ->
|
||||||
productID = $(e.target).closest('button.product').val()
|
productID = $(e.target).closest('button.product').val()
|
||||||
console.log 'purchasing', _.find @products, { id: productID }
|
console.log 'purchasing', _.find @products, { id: productID }
|
||||||
|
|
||||||
if application.isIPadApp
|
if application.isIPadApp
|
||||||
Backbone.Mediator.publish 'buy-gems-modal:purchase-initiated', { productID: productID }
|
Backbone.Mediator.publish 'buy-gems-modal:purchase-initiated', { productID: productID }
|
||||||
|
|
||||||
else
|
else
|
||||||
application.tracker?.trackEvent 'Started purchase', {productID:productID}, ['Google Analytics']
|
application.tracker?.trackEvent 'Started purchase', {productID:productID}, ['Google Analytics']
|
||||||
alert('Not yet implemented, but thanks for trying!')
|
alert('Not yet implemented, but thanks for trying!')
|
||||||
|
|
||||||
onIAPComplete: (e) ->
|
onIAPComplete: (e) ->
|
||||||
product = _.find @products, { id: e.productID }
|
product = _.find @products, { id: e.productID }
|
||||||
purchased = me.get('purchased') ? {}
|
purchased = me.get('purchased') ? {}
|
||||||
|
@ -58,4 +60,4 @@ module.exports = class BuyGemsModal extends ModalView
|
||||||
purchased.gems ?= 0
|
purchased.gems ?= 0
|
||||||
purchased.gems += product.gems
|
purchased.gems += product.gems
|
||||||
me.set('purchased', purchased)
|
me.set('purchased', purchased)
|
||||||
@hide()
|
@hide()
|
||||||
|
|
|
@ -16,9 +16,10 @@ config.mongo =
|
||||||
host: process.env.COCO_MONGO_HOST or 'localhost'
|
host: process.env.COCO_MONGO_HOST or 'localhost'
|
||||||
db: process.env.COCO_MONGO_DATABASE_NAME or 'coco'
|
db: process.env.COCO_MONGO_DATABASE_NAME or 'coco'
|
||||||
mongoose_replica_string: process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING or ''
|
mongoose_replica_string: process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING or ''
|
||||||
|
|
||||||
config.apple =
|
config.apple =
|
||||||
verifyURL: process.env.COCO_APPLE_VERIFY_URL or 'https://sandbox.itunes.apple.com/verifyReceipt' # 'https://buy.itunes.apple.com/verifyReceipt'
|
#verifyURL: process.env.COCO_APPLE_VERIFY_URL or 'https://sandbox.itunes.apple.com/verifyReceipt'
|
||||||
|
verifyURL: process.env.COCO_APPLE_VERIFY_URL or 'https://buy.itunes.apple.com/verifyReceipt'
|
||||||
|
|
||||||
config.redis =
|
config.redis =
|
||||||
port: process.env.COCO_REDIS_PORT or 6379
|
port: process.env.COCO_REDIS_PORT or 6379
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue