mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-30 16:03:37 -04:00
Merginated.
This commit is contained in:
commit
d53d1d5ace
7 changed files with 69 additions and 60 deletions
app
assets
core
styles/common
templates/play/menu
views/play
server/payments
|
@ -56,24 +56,8 @@
|
||||||
|
|
||||||
<div id="modal-wrapper" class="modal-content"></div>
|
<div id="modal-wrapper" class="modal-content"></div>
|
||||||
|
|
||||||
<div class="modal fade" id="module-loading-list">
|
<div class="progress" id="module-load-progress">
|
||||||
<div class="modal-dialog">
|
<div class="progress-bar"></div>
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h4 class="modal-title">LOADING</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<ul class="list-group"></ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--<div class="panel panel-primary" id="module-loading-list">-->
|
|
||||||
<!--<div class="panel-heading">-->
|
|
||||||
<!--<div class="panel-title">LOADING</div>-->
|
|
||||||
<!--</div>-->
|
|
||||||
<!--<ul class="list-group"></ul>-->
|
|
||||||
<!--</div>-->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -24,10 +24,12 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
|
||||||
return func(name, loaderPath)
|
return func(name, loaderPath)
|
||||||
_.extend wrapped, window.require # for functions like 'list'
|
_.extend wrapped, window.require # for functions like 'list'
|
||||||
window.require = wrapped
|
window.require = wrapped
|
||||||
|
@updateProgress = _.throttle _.bind(@updateProgress, @), 700
|
||||||
|
@lastShownProgress = 0
|
||||||
|
|
||||||
load: (path, first=true) ->
|
load: (path, first=true) ->
|
||||||
|
$('#module-load-progress').css('opacity', 1)
|
||||||
if first
|
if first
|
||||||
$('#module-loading-list ul').empty()
|
|
||||||
@recentPaths = []
|
@recentPaths = []
|
||||||
@recentLoadedBytes = 0
|
@recentLoadedBytes = 0
|
||||||
|
|
||||||
|
@ -35,14 +37,8 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
|
||||||
wad = _.find ModuleLoader.WADS, (wad) -> _.string.startsWith(path, wad)
|
wad = _.find ModuleLoader.WADS, (wad) -> _.string.startsWith(path, wad)
|
||||||
path = wad if wad
|
path = wad if wad
|
||||||
return false if @loaded[path]
|
return false if @loaded[path]
|
||||||
$('#module-loading-list').modal('show') if first
|
|
||||||
@loaded[path] = true
|
@loaded[path] = true
|
||||||
@recentPaths.push(path)
|
@recentPaths.push(path)
|
||||||
li = $("<li class='list-group-item loading' data-path='#{path}'>#{path}</li>")
|
|
||||||
.prepend($("<span class='glyphicon glyphicon-minus'></span>"))
|
|
||||||
.prepend($("<span class='glyphicon glyphicon-ok'></span>"))
|
|
||||||
ul = $('#module-loading-list ul')
|
|
||||||
ul.append(li).scrollTop(ul[0].scrollHeight)
|
|
||||||
console.debug 'Loading js file:', "/javascripts/app/#{path}.js" if LOG
|
console.debug 'Loading js file:', "/javascripts/app/#{path}.js" if LOG
|
||||||
@queue.loadFile({
|
@queue.loadFile({
|
||||||
id: path
|
id: path
|
||||||
|
@ -59,8 +55,6 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
|
||||||
return @load("locale/#{firstBit}", false) or loading
|
return @load("locale/#{firstBit}", false) or loading
|
||||||
|
|
||||||
onFileLoad: (e) =>
|
onFileLoad: (e) =>
|
||||||
$("#module-loading-list li[data-path='#{e.item.id}']").removeClass('loading').addClass('success')
|
|
||||||
|
|
||||||
# load dependencies if it's not a vendor library
|
# load dependencies if it's not a vendor library
|
||||||
if not _.string.startsWith(e.item.id, 'vendor')
|
if not _.string.startsWith(e.item.id, 'vendor')
|
||||||
have = window.require.list()
|
have = window.require.list()
|
||||||
|
@ -80,19 +74,25 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
|
||||||
|
|
||||||
# get treema set up only when the library loads, if it loads
|
# get treema set up only when the library loads, if it loads
|
||||||
if e.item.id is 'vendor/treema'
|
if e.item.id is 'vendor/treema'
|
||||||
console.log 'setting up treema-ext'
|
|
||||||
treemaExt = require 'core/treema-ext'
|
treemaExt = require 'core/treema-ext'
|
||||||
treemaExt.setup()
|
treemaExt.setup()
|
||||||
|
|
||||||
# a module and its dependencies have loaded!
|
# a module and its dependencies have loaded!
|
||||||
if @queue.progress is 1
|
if @queue.progress is 1
|
||||||
$('#module-loading-list').modal('hide')
|
|
||||||
@recentPaths.sort()
|
@recentPaths.sort()
|
||||||
console.debug @recentPaths.join('\n')
|
console.debug @recentPaths.join('\n')
|
||||||
console.debug 'loaded', @recentPaths.length, 'files,', parseInt(@recentLoadedBytes/1024), 'KB'
|
console.debug 'loaded', @recentPaths.length, 'files,', parseInt(@recentLoadedBytes/1024), 'KB'
|
||||||
@trigger 'load-complete'
|
@trigger 'load-complete'
|
||||||
|
|
||||||
@trigger 'loaded', e.item
|
@trigger 'loaded', e.item
|
||||||
|
|
||||||
|
@updateProgress()
|
||||||
|
|
||||||
|
updateProgress: ->
|
||||||
|
return if @queue.progress < @lastShownProgress
|
||||||
|
$('#module-load-progress .progress-bar').css('width', (100*@queue.progress)+'%')
|
||||||
|
if @queue.progress is 1
|
||||||
|
$('#module-load-progress').css('opacity', 0)
|
||||||
|
|
||||||
parseDependencies: (raw) ->
|
parseDependencies: (raw) ->
|
||||||
bits = raw.match(/(require\(['"](.+?)['"])|(register\(['"].+?['"])/g) or []
|
bits = raw.match(/(require\(['"](.+?)['"])|(register\(['"].+?['"])/g) or []
|
||||||
|
|
|
@ -353,26 +353,14 @@ html.no-borderimage
|
||||||
body > iframe[src^="https://apis.google.com"]
|
body > iframe[src^="https://apis.google.com"]
|
||||||
display: none
|
display: none
|
||||||
|
|
||||||
#module-loading-list
|
#module-load-progress
|
||||||
.modal-content
|
position: absolute
|
||||||
background: white
|
top: 0
|
||||||
border-shadow: 2px 2px 10px black
|
left: 0
|
||||||
|
right: 0
|
||||||
|
height: 5px
|
||||||
|
z-index: 1
|
||||||
|
transition: 1s
|
||||||
|
|
||||||
ul
|
.progress-bar
|
||||||
max-height: 500px
|
background-color: lightblue
|
||||||
overflow: scroll
|
|
||||||
|
|
||||||
li
|
|
||||||
padding: 2px 15px
|
|
||||||
font-size: 10px
|
|
||||||
.glyphicon
|
|
||||||
margin-right: 10px
|
|
||||||
|
|
||||||
&.loading
|
|
||||||
.glyphicon-ok
|
|
||||||
display: none
|
|
||||||
|
|
||||||
&.success
|
|
||||||
font-weight: bold
|
|
||||||
.glyphicon-minus
|
|
||||||
display: none
|
|
||||||
|
|
|
@ -31,9 +31,10 @@
|
||||||
if itemGroups.availableItems.models.length
|
if itemGroups.availableItems.models.length
|
||||||
h4#available-description(data-i18n="inventory.available_item")
|
h4#available-description(data-i18n="inventory.available_item")
|
||||||
for item in itemGroups.availableItems.models
|
for item in itemGroups.availableItems.models
|
||||||
.item.available(class=item.classes, data-item-id=item.id)
|
if selectedHeroClass && item.classes.indexOf(selectedHeroClass) > -1
|
||||||
img(src=item.getPortraitURL())
|
.item.available(class=item.classes, data-item-id=item.id)
|
||||||
button.btn.equip-item(data-i18n="inventory.equip")
|
img
|
||||||
|
button.btn.equip-item(data-i18n="inventory.equip")
|
||||||
.clearfix
|
.clearfix
|
||||||
|
|
||||||
#double-click-hint.alert.alert-info
|
#double-click-hint.alert.alert-info
|
||||||
|
@ -43,15 +44,17 @@
|
||||||
if itemGroups.restrictedItems.models.length
|
if itemGroups.restrictedItems.models.length
|
||||||
h4#restricted-description(data-i18n="inventory.restricted_title")
|
h4#restricted-description(data-i18n="inventory.restricted_title")
|
||||||
for item in itemGroups.restrictedItems.models
|
for item in itemGroups.restrictedItems.models
|
||||||
.item(class=item.classes, data-item-id=item.id)
|
if selectedHeroClass && item.classes.indexOf(selectedHeroClass) > -1
|
||||||
img(src=item.getPortraitURL(), draggable="false")
|
.item(class=item.classes, data-item-id=item.id)
|
||||||
|
img(draggable="false")
|
||||||
.clearfix
|
.clearfix
|
||||||
|
|
||||||
if itemGroups.lockedItems.models.length
|
if itemGroups.lockedItems.models.length
|
||||||
h4#locked-description(data-i18n="play.locked")
|
h4#locked-description(data-i18n="play.locked")
|
||||||
for item in itemGroups.lockedItems.models
|
for item in itemGroups.lockedItems.models
|
||||||
.item(class=item.classes, data-item-id=item.id)
|
if selectedHeroClass && item.classes.indexOf(selectedHeroClass) > -1
|
||||||
img(src=item.getPortraitURL(), draggable="false")
|
.item(class=item.classes, data-item-id=item.id)
|
||||||
|
img(draggable="false")
|
||||||
.clearfix
|
.clearfix
|
||||||
|
|
||||||
#item-details-view
|
#item-details-view
|
||||||
|
|
|
@ -35,6 +35,7 @@ module.exports = class InventoryModal extends ModalView
|
||||||
'click #close-modal': 'hide'
|
'click #close-modal': 'hide'
|
||||||
'click .buy-gems-prompt-button': 'onBuyGemsPromptButtonClicked'
|
'click .buy-gems-prompt-button': 'onBuyGemsPromptButtonClicked'
|
||||||
'click': 'onClickedSomewhere'
|
'click': 'onClickedSomewhere'
|
||||||
|
'update #unequipped .nano': 'onScrollUnequipped'
|
||||||
|
|
||||||
shortcuts:
|
shortcuts:
|
||||||
'esc': 'clearSelection'
|
'esc': 'clearSelection'
|
||||||
|
@ -44,6 +45,7 @@ module.exports = class InventoryModal extends ModalView
|
||||||
#- Setup
|
#- Setup
|
||||||
|
|
||||||
initialize: (options) ->
|
initialize: (options) ->
|
||||||
|
@onScrollUnequipped = _.throttle(_.bind(@onScrollUnequipped, @), 200)
|
||||||
super(arguments...)
|
super(arguments...)
|
||||||
@items = new CocoCollection([], {model: ThangType})
|
@items = new CocoCollection([], {model: ThangType})
|
||||||
# TODO: switch to item store loading system?
|
# TODO: switch to item store loading system?
|
||||||
|
@ -121,6 +123,7 @@ module.exports = class InventoryModal extends ModalView
|
||||||
context.itemGroups = @itemGroups
|
context.itemGroups = @itemGroups
|
||||||
context.slots = @slots
|
context.slots = @slots
|
||||||
context.selectedHero = @selectedHero
|
context.selectedHero = @selectedHero
|
||||||
|
context.selectedHeroClass = @selectedHero?.get('heroClass')
|
||||||
context.equipment = _.clone @equipment
|
context.equipment = _.clone @equipment
|
||||||
context.equipment[slot] = @items.findWhere {original: itemOriginal} for slot, itemOriginal of context.equipment
|
context.equipment[slot] = @items.findWhere {original: itemOriginal} for slot, itemOriginal of context.equipment
|
||||||
context.gems = me.gems()
|
context.gems = me.gems()
|
||||||
|
@ -524,6 +527,21 @@ module.exports = class InventoryModal extends ModalView
|
||||||
onClickedSomewhere: (e) ->
|
onClickedSomewhere: (e) ->
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
@$el.find('.unlock-button').popover 'destroy'
|
@$el.find('.unlock-button').popover 'destroy'
|
||||||
|
|
||||||
|
|
||||||
|
#- Dynamic portrait loading
|
||||||
|
|
||||||
|
onScrollUnequipped: ->
|
||||||
|
# dynamically load visible items when the user scrolls enough to see them
|
||||||
|
nanoContent = @$el.find('#unequipped .nano-content')
|
||||||
|
items = nanoContent.find('.item:visible:not(.loaded)')
|
||||||
|
threshold = nanoContent.height() + 100
|
||||||
|
for itemEl in items
|
||||||
|
itemEl = $(itemEl)
|
||||||
|
if itemEl.position().top < threshold
|
||||||
|
itemEl.addClass('loaded')
|
||||||
|
item = @items.get(itemEl.data('item-id'))
|
||||||
|
itemEl.find('img').attr('src', item.getPortraitURL())
|
||||||
|
|
||||||
|
|
||||||
#- Paper doll equipment updating
|
#- Paper doll equipment updating
|
||||||
|
@ -544,6 +562,7 @@ module.exports = class InventoryModal extends ModalView
|
||||||
@$el.find('#hero-image-thumb').toggle not ('gloves' in slotsWithImages)
|
@$el.find('#hero-image-thumb').toggle not ('gloves' in slotsWithImages)
|
||||||
|
|
||||||
@equipment = @options.equipment = equipment
|
@equipment = @options.equipment = equipment
|
||||||
|
@onScrollUnequipped()
|
||||||
|
|
||||||
removeDollImages: ->
|
removeDollImages: ->
|
||||||
@$el.find('.doll-image').remove()
|
@$el.find('.doll-image').remove()
|
||||||
|
|
|
@ -53,10 +53,20 @@ module.exports = class SubscribeModal extends ModalView
|
||||||
return @openModalView new AuthModal() if me.get('anonymous')
|
return @openModalView new AuthModal() if me.get('anonymous')
|
||||||
application.tracker?.trackEvent 'Started subscription purchase', {}
|
application.tracker?.trackEvent 'Started subscription purchase', {}
|
||||||
application.tracker?.trackPageView "subscription/start-purchase", ['Google Analytics']
|
application.tracker?.trackPageView "subscription/start-purchase", ['Google Analytics']
|
||||||
stripeHandler.open({
|
options = {
|
||||||
description: $.i18n.t('subscribe.stripe_description')
|
description: $.i18n.t('subscribe.stripe_description')
|
||||||
amount: @product.amount
|
amount: @product.amount
|
||||||
})
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# }
|
||||||
|
|
||||||
|
stripeHandler.open(options)
|
||||||
|
|
||||||
onStripeReceivedToken: (e) ->
|
onStripeReceivedToken: (e) ->
|
||||||
@state = 'purchasing'
|
@state = 'purchasing'
|
||||||
|
|
|
@ -68,6 +68,11 @@ class SubscriptionHandler extends Handler
|
||||||
|
|
||||||
checkForExistingSubscription: (req, user, customer, done) ->
|
checkForExistingSubscription: (req, user, customer, done) ->
|
||||||
couponID = user.get('stripe')?.couponID
|
couponID = user.get('stripe')?.couponID
|
||||||
|
|
||||||
|
# SALE LOGIC
|
||||||
|
# overwrite couponID with another for everyone-sales
|
||||||
|
# couponID = 'hoc_bonanza' if not couponID
|
||||||
|
|
||||||
if subscription = customer.subscriptions?.data?[0]
|
if subscription = customer.subscriptions?.data?[0]
|
||||||
|
|
||||||
if subscription.cancel_at_period_end
|
if subscription.cancel_at_period_end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue