mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-16 08:29:56 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
07fd54bbb3
10 changed files with 83 additions and 25 deletions
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
BIN
app/assets/images/pages/play/modal/subscribe-gems.png
Normal file
BIN
app/assets/images/pages/play/modal/subscribe-gems.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
|
@ -29,7 +29,7 @@ elementAcceptsKeystrokes = (el) ->
|
|||
# not radio, checkbox, range, or color
|
||||
return (tag is 'textarea' or (tag is 'input' and type in textInputTypes) or el.contentEditable in ['', 'true']) and not (el.readOnly or el.disabled)
|
||||
|
||||
COMMON_FILES = ['/images/pages/base/modal_background.png', '/images/level/code_palette_wood_background.png', '/images/level/popover_background.png', '/images/level/code_editor_background.png']
|
||||
COMMON_FILES = ['/images/pages/base/modal_background.png', '/images/level/popover_background.png'] #'/images/level/code_palette_wood_background.png', , '/images/level/code_editor_background.png'
|
||||
preload = (arrayOfImages) ->
|
||||
$(arrayOfImages).each ->
|
||||
$('<img/>')[0].src = @
|
||||
|
|
|
@ -29,8 +29,10 @@ module.exports = class LevelBus extends Bus
|
|||
constructor: ->
|
||||
super(arguments...)
|
||||
@changedSessionProperties = {}
|
||||
#@saveSession = _.debounce(@reallySaveSession, 1000, {maxWait: 5000}) # not during HoC apparently
|
||||
@saveSession = _.debounce(@reallySaveSession, 10000, {maxWait: 30000})
|
||||
if document.location.href.search('codecombat.com') isnt -1
|
||||
@saveSession = _.debounce(@reallySaveSession, 10000, {maxWait: 30000}) # Save us during HoC
|
||||
else
|
||||
@saveSession = _.debounce(@reallySaveSession, 1000, {maxWait: 5000}) # Not this fast during HoC
|
||||
@playerIsIdle = false
|
||||
|
||||
init: ->
|
||||
|
|
|
@ -127,6 +127,7 @@ module.exports = class User extends CocoModel
|
|||
@fastVictoryModalGroup
|
||||
|
||||
getGemPromptGroup: ->
|
||||
# A/B Testing whether extra prompt when low gems leads to more gem purchases
|
||||
return @gemPromptGroup if @gemPromptGroup
|
||||
group = me.get('testGroupNumber') % 8
|
||||
@gemPromptGroup = switch group
|
||||
|
@ -136,6 +137,19 @@ module.exports = class User extends CocoModel
|
|||
application.tracker.identify gemPromptGroup: @gemPromptGroup unless me.isAdmin()
|
||||
@gemPromptGroup
|
||||
|
||||
getSubscribeCopyGroup: ->
|
||||
# A/B Testing alternate subscribe modal copy
|
||||
return @subscribeCopyGroup if @subscribeCopyGroup
|
||||
group = me.get('testGroupNumber') % 6
|
||||
@subscribeCopyGroup = switch group
|
||||
when 0, 1, 2 then 'original'
|
||||
when 3, 4, 5 then 'new'
|
||||
if /^en/.test(@get('preferredLanguage')) and not me.isAdmin()
|
||||
application.tracker.identify subscribeCopyGroup: @subscribeCopyGroup
|
||||
else
|
||||
@subscribeCopyGroup = 'original'
|
||||
@subscribeCopyGroup
|
||||
|
||||
isPremium: ->
|
||||
return false unless stripe = @get('stripe')
|
||||
return true if stripe.subscriptionID
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
top: -61px
|
||||
left: 0px
|
||||
|
||||
#subscribe-gems
|
||||
position: absolute
|
||||
top: 155px
|
||||
right: 65px
|
||||
|
||||
|
||||
//- Header
|
||||
h1
|
||||
|
@ -80,6 +85,22 @@
|
|||
text-decoration: underline
|
||||
cursor: pointer
|
||||
|
||||
#selling-points-BTest
|
||||
position: absolute
|
||||
left: 65px
|
||||
top: 150px
|
||||
width: 500px
|
||||
font-weight: normal
|
||||
line-height: 18px
|
||||
color: black
|
||||
font-family: $headings-font-family
|
||||
font-size: 18px
|
||||
|
||||
.point
|
||||
overflow: none
|
||||
text-align: left
|
||||
margin: 20px
|
||||
|
||||
.popover
|
||||
z-index: 1050
|
||||
|
||||
|
|
|
@ -7,24 +7,39 @@
|
|||
#retrying-alert.alert.alert-danger(data-i18n="buy_gems.retrying")
|
||||
|
||||
else
|
||||
img(src="/images/pages/play/modal/subscribe-background.png")#subscribe-background
|
||||
|
||||
if BTest
|
||||
img(src="/images/pages/play/modal/subscribe-background-blank.png")#subscribe-background
|
||||
img(src="/images/pages/play/modal/subscribe-gems.png")#subscribe-gems
|
||||
else
|
||||
img(src="/images/pages/play/modal/subscribe-background.png")#subscribe-background
|
||||
|
||||
h1(data-i18n="subscribe.subscribe_title") Subscribe
|
||||
|
||||
div#close-modal
|
||||
span.glyphicon.glyphicon-remove
|
||||
|
||||
#selling-points
|
||||
#point-levels.point
|
||||
.blurb(data-i18n="subscribe.levels")
|
||||
#point-heroes.point
|
||||
.blurb(data-i18n="subscribe.heroes")
|
||||
#point-gems.point
|
||||
.blurb(data-i18n="subscribe.gems")
|
||||
#point-items.point
|
||||
.blurb(data-i18n="subscribe.items")
|
||||
if BTest
|
||||
#selling-points-BTest
|
||||
#point-levels.point
|
||||
.blurb(style="font-style:italic") "Great product ... I have been looking for a good tool to teach my kids programming."
|
||||
#point-heroes.point
|
||||
.blurb Join the CodeCombat subscription and get even more learn-to-code goodness!
|
||||
#point-gems.point
|
||||
.blurb For $#{price}/mo, you'll get access to bonus levels and 3500 extra gems per month! Players who complete bonus levels learn more programming and advance further in the game.
|
||||
#point-items.point
|
||||
.blurb There's no risk: 100% money back guarantee.
|
||||
else
|
||||
#selling-points
|
||||
#point-levels.point
|
||||
.blurb(data-i18n="subscribe.levels")
|
||||
#point-heroes.point
|
||||
.blurb(data-i18n="subscribe.heroes")
|
||||
#point-gems.point
|
||||
.blurb(data-i18n="subscribe.gems")
|
||||
#point-items.point
|
||||
.blurb(data-i18n="subscribe.items")
|
||||
|
||||
#parents-info(data-i18n="subscribe.parents")
|
||||
#parents-info(data-i18n="subscribe.parents")
|
||||
|
||||
button.btn.btn-lg.btn-illustrated.purchase-button(data-i18n="subscribe.subscribe_button")
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
button.btn.btn-illustrated.signup-button.btn-danger(data-i18n="signup.sign_up")
|
||||
else
|
||||
span.player-name.spr= me.get('name')
|
||||
button#logout-button.btn.btn-default.btn-flat.btn-sm(data-i18n="login.log_out") Log Out
|
||||
button#logout-button.btn.btn-illustrated.btn-warning(data-i18n="login.log_out") Log Out
|
||||
|
||||
button.btn.btn-lg.btn-inverse#volume-button(title="Adjust volume")
|
||||
.glyphicon.glyphicon-volume-off
|
||||
|
|
|
@ -28,6 +28,9 @@ module.exports = class SubscribeModal extends ModalView
|
|||
c = super()
|
||||
c.state = @state
|
||||
c.stateMessage = @stateMessage
|
||||
#c.price = @product.amount / 100
|
||||
c.price = 5.99 # Sale
|
||||
c.BTest = me.getSubscribeCopyGroup() is 'new'
|
||||
return c
|
||||
|
||||
afterRender: ->
|
||||
|
@ -36,6 +39,8 @@ module.exports = class SubscribeModal extends ModalView
|
|||
popoverContent = "<p>" + $.i18n.t('subscribe.parents_blurb1') + "</p>"
|
||||
popoverContent += "<p>" + $.i18n.t('subscribe.parents_blurb2') + "</p>"
|
||||
popoverContent += "<p>" + $.i18n.t('subscribe.parents_blurb3') + "</p>"
|
||||
popoverContent = popoverContent.replace /9[.,]99/g, '5.99' # Sale
|
||||
window.popoverContent = popoverContent
|
||||
@$el.find('#parents-info').popover(
|
||||
animation: true
|
||||
html: true
|
||||
|
@ -61,10 +66,11 @@ module.exports = class SubscribeModal extends ModalView
|
|||
# SALE LOGIC
|
||||
# overwrite amount with sale price
|
||||
# maybe also put in another description with details about how long it lasts, etc
|
||||
# options = {
|
||||
# description: 'Subscription. Half price for three months!'
|
||||
# amount: 499
|
||||
# }
|
||||
# NOTE: Do not change this price without updating the context.price in getRenderData
|
||||
options = {
|
||||
description: 'Monthly Subscription (HoC sale)'
|
||||
amount: 599
|
||||
}
|
||||
|
||||
stripeHandler.open(options)
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class SubscriptionHandler extends Handler
|
|||
@logSubscriptionError(user, 'Cannot find customer: ', +customer.id + '\n\n' + err)
|
||||
return done({res: 'Cannot find customer.', code: 404})
|
||||
@checkForExistingSubscription(req, user, customer, done)
|
||||
|
||||
|
||||
else
|
||||
newCustomer = {
|
||||
card: token
|
||||
|
@ -47,7 +47,7 @@ class SubscriptionHandler extends Handler
|
|||
else
|
||||
@logSubscriptionError(user, 'Stripe customer creation error. '+err)
|
||||
return done({res: 'Database error.', code: 500})
|
||||
|
||||
|
||||
stripeInfo = _.cloneDeep(user.get('stripe') ? {})
|
||||
stripeInfo.customerID = customer.id
|
||||
user.set('stripe', stripeInfo)
|
||||
|
@ -68,11 +68,11 @@ class SubscriptionHandler extends Handler
|
|||
|
||||
checkForExistingSubscription: (req, user, customer, done) ->
|
||||
couponID = user.get('stripe')?.couponID
|
||||
|
||||
|
||||
# SALE LOGIC
|
||||
# overwrite couponID with another for everyone-sales
|
||||
# couponID = 'hoc_bonanza' if not couponID
|
||||
|
||||
couponID = 'hoc_599' if not couponID
|
||||
|
||||
if subscription = customer.subscriptions?.data?[0]
|
||||
|
||||
if subscription.cancel_at_period_end
|
||||
|
|
Loading…
Reference in a new issue