Fixed a few bugs. Removed Olark; disabled LinkedIn. Added ladder submission to HeroVictoryModal.

This commit is contained in:
Nick Winter 2014-10-19 17:38:10 -07:00
parent 440e1700b1
commit 1fb48f2b85
13 changed files with 48 additions and 150 deletions

View file

@ -37,18 +37,14 @@
<script src="/javascripts/aether.js"></script> <script src="/javascripts/aether.js"></script>
<script src="/javascripts/app.js"></script> <!-- it's all Backbone! --> <script src="/javascripts/app.js"></script> <!-- it's all Backbone! -->
<script> <!-- Can move to lib/services/linkedin.coffee instead somehow? Or just get rid of LinkedIn...
window.linkedInAsyncInit = function() {
console.log("Linkedin Async Init!");
Backbone.Mediator.publish('linkedin-loaded');
};
</script> </script>
<script type="text/javascript" async src="http://platform.linkedin.com/in.js"> <script type="text/javascript" async src="http://platform.linkedin.com/in.js">
api_key: 75v8mv4ictvmx6 api_key: 75v8mv4ictvmx6
onLoad: linkedInAsyncInit onLoad: linkedInAsyncInit
authorize: true authorize: true
</script> </script>
-->
<script> <script>
window.userObject = "userObjectTag"; window.userObject = "userObjectTag";

View file

@ -78,7 +78,6 @@ initializeUtilityServices = ->
services = [ services = [
'./lib/services/filepicker' './lib/services/filepicker'
'./lib/services/segmentio' './lib/services/segmentio'
'./lib/services/olark'
] ]
for service in services for service in services

View file

@ -108,7 +108,7 @@ module.exports = class LevelLoader extends CocoClass
@loadThangsRequiredByThangType heroThangType @loadThangsRequiredByThangType heroThangType
for itemThangType in _.values(heroConfig.inventory) for itemThangType in _.values(heroConfig.inventory)
url = "/db/thang.type/#{itemThangType}/version?project=name,components,original,rasterIcon" url = "/db/thang.type/#{itemThangType}/version?project=name,components,original,rasterIcon,kind"
if itemResource = @maybeLoadURL(url, ThangType, 'thang') if itemResource = @maybeLoadURL(url, ThangType, 'thang')
@worldNecessities.push itemResource @worldNecessities.push itemResource
else else
@ -193,7 +193,7 @@ module.exports = class LevelLoader extends CocoClass
else if component.config.requiredThangTypes else if component.config.requiredThangTypes
requiredThangTypes = requiredThangTypes.concat component.config.requiredThangTypes requiredThangTypes = requiredThangTypes.concat component.config.requiredThangTypes
for thangType in requiredThangTypes for thangType in requiredThangTypes
url = "/db/thang.type/#{thangType}/version?project=name,components,original,rasterIcon" url = "/db/thang.type/#{thangType}/version?project=name,components,original,rasterIcon,kind"
@worldNecessities.push @maybeLoadURL(url, ThangType, 'thang') @worldNecessities.push @maybeLoadURL(url, ThangType, 'thang')
onThangNamesLoaded: (thangNames) -> onThangNamesLoaded: (thangNames) ->
@ -250,7 +250,6 @@ module.exports = class LevelLoader extends CocoClass
console.log 'SuperModel for Level loaded in', new Date().getTime() - @t0, 'ms' console.log 'SuperModel for Level loaded in', new Date().getTime() - @t0, 'ms'
@loadLevelSounds() @loadLevelSounds()
@denormalizeSession() @denormalizeSession()
app.tracker.updatePlayState(@level, @session) unless @headless
buildLoop: => buildLoop: =>
someLeft = false someLeft = false

View file

@ -9,7 +9,6 @@ module.exports = class Tracker
window.tracker = @ window.tracker = @
@isProduction = document.location.href.search('codecombat.com') isnt -1 @isProduction = document.location.href.search('codecombat.com') isnt -1
@identify() @identify()
@updateOlark()
identify: (traits) -> identify: (traits) ->
console.log 'Would identify', traits if debugAnalytics console.log 'Would identify', traits if debugAnalytics
@ -20,24 +19,6 @@ module.exports = class Tracker
traits[userTrait] ?= me.get(userTrait) traits[userTrait] ?= me.get(userTrait)
analytics.identify me.id, traits analytics.identify me.id, traits
updateOlark: ->
return unless me and olark?
olark 'api.chat.updateVisitorStatus', snippet: ["User ID: #{me.id}"]
return if me.get('anonymous')
olark 'api.visitor.updateEmailAddress', emailAddress: me.get('email') if me.get('email')
olark 'api.chat.updateVisitorNickname', snippet: me.displayName()
updatePlayState: (level, session) ->
return unless olark?
link = "codecombat.com/play/level/#{level.get('slug') or level.id}?session=#{session.id}"
snippet = [
"#{link}"
"User ID: #{me.id}"
"Session ID: #{session.id}"
"Level: #{level.get('name')}"
]
olark 'api.chat.updateVisitorStatus', snippet: snippet
trackPageView: -> trackPageView: ->
return unless @isProduction and analytics? return unless @isProduction and analytics?
url = Backbone.history.getFragment() url = Backbone.history.getFragment()

View file

@ -1,115 +0,0 @@
module.exports = initializeOlark = ->
window.olark or ((c) -> #<![CDATA[
f = window
d = document
l = (if f.location.protocol is 'https:' then 'https:' else 'http:')
z = c.name
r = 'load'
nt = ->
s = ->
a.P r
f[z] r
return
f[z] = ->
(a.s = a.s or []).push arguments
return
a = f[z]._ = {}
q = c.methods.length
while q--
((n) ->
f[z][n] = ->
f[z] 'call', n, arguments
return
return
) c.methods[q]
a.l = c.loader
a.i = nt
a.p = 0: +new Date
a.P = (u) ->
a.p[u] = new Date - a.p[0]
return
(if f.addEventListener then f.addEventListener(r, s, false) else f.attachEvent('on' + r, s))
ld = ->
p = (hd) ->
hd = 'head'
[
'<'
hd
'></'
hd
'><'
i
' onl' + 'oad=\"var d='
g
";d.getElementsByTagName('head')[0]."
j
'(d.'
h
"('script'))."
k
"='"
l
'//'
a.l
"'"
'\"'
'></'
i
'>'
].join ''
i = 'body'
m = d[i]
return setTimeout(ld, 100) unless m
a.P 1
j = 'appendChild'
h = 'createElement'
k = 'src'
n = d[h]('div')
v = n[j](d[h](z))
b = d[h]('iframe')
g = 'document'
e = 'domain'
o = undefined
n.style.display = 'none'
m.insertBefore(n, m.firstChild).id = z
b.frameBorder = '0'
b.id = z + '-loader'
b.src = 'javascript:false' if /MSIE[ ]+6/.test(navigator.userAgent)
b.allowTransparency = 'true'
v[j] b
try
b.contentWindow[g].open()
catch w
c[e] = d[e]
o = 'javascript:var d=' + g + ".open();d.domain='" + d.domain + "';"
b[k] = o + 'void(0);'
try
t = b.contentWindow[g]
t.write p()
t.close()
catch x
b[k] = o + 'd.write(\"' + p().replace(/"/g, String.fromCharCode(92) + '\"') + '\");d.close();'
a.P 2
return
ld()
return
nt()
return
)(
loader: 'static.olark.com/jsclient/loader0.js'
name: 'olark'
methods: [
'configure'
'extend'
'declare'
'identify'
]
)
# custom configuration goes here (www.olark.com/documentation)
olark.identify '1451-787-10-5544' #]]>

View file

@ -57,7 +57,8 @@ module.exports = class Level extends CocoModel
if isHero and otherSession if isHero and otherSession
# If it's a hero and there's another session, find the right session for it. # If it's a hero and there's another session, find the right session for it.
# If there is no other session (playing against default code, or on single player), clone all placeholders. # If there is no other session (playing against default code, or on single player), clone all placeholders.
# TODO: actually look at the teams on these things to determine which session should go with which placeholder. # TODO: actually look at the teams on these Thangs to determine which session should go with which placeholder.
console.error 'There is no session but there is a hero and an otherSession?', session, otherSession unless session?.get
if levelThang.id is 'Hero Placeholder 1' and session.get('team') is 'humans' if levelThang.id is 'Hero Placeholder 1' and session.get('team') is 'humans'
session = otherSession session = otherSession
else if levelThang.id is 'Hero Placeholder' and session.get('team') is 'ogres' else if levelThang.id is 'Hero Placeholder' and session.get('team') is 'ogres'

View file

@ -235,6 +235,7 @@ module.exports = class ThangType extends CocoModel
return if _.isString spriteSheet return if _.isString spriteSheet
return unless spriteSheet return unless spriteSheet
canvas = $("<canvas width='#{size}' height='#{size}'></canvas>") canvas = $("<canvas width='#{size}' height='#{size}'></canvas>")
console.log 'made canvas', canvas, 'with size', size unless canvas[0]
stage = new createjs.Stage(canvas[0]) stage = new createjs.Stage(canvas[0])
sprite = new createjs.Sprite(spriteSheet) sprite = new createjs.Sprite(spriteSheet)
pt = @actions.portrait?.positions?.registration pt = @actions.portrait?.positions?.registration

View file

@ -33,6 +33,7 @@
.modal-body .modal-body
padding: 0 20px padding: 0 20px
min-height: 30px
.achievement-panel .achievement-panel
background: url("/images/pages/play/level/modal/achievement_plate.png") background: url("/images/pages/play/level/modal/achievement_plate.png")
@ -184,6 +185,20 @@
float: right float: right
margin-left: 10px margin-left: 10px
.ladder-submission-view
display: inline-block
color: white
.rank-button.btn-block
display: inline-block
width: initial
padding-left: 19px
padding-right: 19px
.last-submitted
float: none
html.no-borderimage html.no-borderimage
#hero-victory-modal #hero-victory-modal
.background-wrapper .background-wrapper

View file

@ -51,9 +51,16 @@ block modal-footer-content
span#gem-total +0 span#gem-total +0
button.btn.btn-warning.hide#saving-progress-label(disabled, data-i18n="play_level.victory_saving_progress") Saving Progress button.btn.btn-warning.hide#saving-progress-label(disabled, data-i18n="play_level.victory_saving_progress") Saving Progress
a.btn.btn-success.world-map-button.hide#continue-button(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_play_continue") Continue
if readyToRank
.ladder-submission-view
else if level.get('type') === 'hero-ladder'
a.btn.btn-primary(href="/play/ladder/#{level.get('slug')}#my-matches", data-dismiss="modal", data-i18n="play_level.victory_return_to_ladder") Return to Ladder
else
a.btn.btn-success.world-map-button.hide#continue-button(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_play_continue") Continue
if me.get('anonymous') if me.get('anonymous')
p.sign-up-poke p.sign-up-poke
button.btn.btn-success.sign-up-button.btn-large(data-toggle="coco-modal", data-target="modal/SignupModal", data-i18n="play_level.victory_sign_up") Sign Up to Save Progress button.btn.btn-success.sign-up-button.btn-large(data-toggle="coco-modal", data-target="modal/SignupModal", data-i18n="play_level.victory_sign_up") Sign Up to Save Progress
span(data-i18n="play_level.victory_sign_up_poke") Want to save your code? Create a free account! span(data-i18n="play_level.victory_sign_up_poke") Want to save your code? Create a free account!

View file

@ -484,7 +484,8 @@ module.exports = class ThangsTabView extends CocoView
folderForThang: (thang) -> folderForThang: (thang) ->
thangType = @supermodel.getModelByOriginal ThangType, thang.thangType thangType = @supermodel.getModelByOriginal ThangType, thang.thangType
[thangType.get('kind'), thangType.get('name')] console.error 'uhh, we had kind', thangType.get('kind', true), 'for', thangType unless thangType.get('kind', true)
[thangType.get('kind', true), thangType.get('name', true)]
pathForThang: (thang) -> pathForThang: (thang) ->
folder = @folderForThang(thang) folder = @folderForThang(thang)

View file

@ -455,8 +455,7 @@ module.exports = class PlayLevelView extends RootView
showVictory: -> showVictory: ->
options = {level: @level, supermodel: @supermodel, session: @session} options = {level: @level, supermodel: @supermodel, session: @session}
ModalClass = if @level.get('type', true) in ['hero', 'hero-coop'] then HeroVictoryModal else VictoryModal ModalClass = if @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop'] then HeroVictoryModal else VictoryModal
# TODO: made HeroVictoryModal able to support hero-ladder and then switch over for that level type, too
victoryModal = new ModalClass(options) victoryModal = new ModalClass(options)
@openModalView(victoryModal) @openModalView(victoryModal)
if me.get('anonymous') if me.get('anonymous')

View file

@ -6,6 +6,7 @@ CocoCollection = require 'collections/CocoCollection'
LocalMongo = require 'lib/LocalMongo' LocalMongo = require 'lib/LocalMongo'
utils = require 'lib/utils' utils = require 'lib/utils'
ThangType = require 'models/ThangType' ThangType = require 'models/ThangType'
LadderSubmissionView = require 'views/play/common/LadderSubmissionView'
module.exports = class HeroVictoryModal extends ModalView module.exports = class HeroVictoryModal extends ModalView
id: 'hero-victory-modal' id: 'hero-victory-modal'
@ -13,6 +14,9 @@ module.exports = class HeroVictoryModal extends ModalView
closeButton: false closeButton: false
closesOnClickOutside: false closesOnClickOutside: false
subscriptions:
'ladder:game-submitted': 'onGameSubmitted'
constructor: (options) -> constructor: (options) ->
super(options) super(options)
@session = options.session @session = options.session
@ -88,6 +92,7 @@ module.exports = class HeroVictoryModal extends ModalView
c.thangTypes = @thangTypes c.thangTypes = @thangTypes
c.me = me c.me = me
c.readyToRank = @level.get('type', true) is 'hero-ladder' and @session.readyToRank()
return c return c
afterRender: -> afterRender: ->
@ -116,6 +121,9 @@ module.exports = class HeroVictoryModal extends ModalView
panel.delay(500) panel.delay(500)
panel.queue(-> complete()) panel.queue(-> complete())
@animationComplete = not @animatedPanels.length @animationComplete = not @animatedPanels.length
if @level.get('type', true) is 'hero-ladder'
@ladderSubmissionView = new LadderSubmissionView session: @session, level: @level
@insertSubView @ladderSubmissionView, @$el.find('.ladder-submission-view')
beginAnimateNumbers: -> beginAnimateNumbers: ->
@numericalItemPanels = _.map(@animatedPanels.find('.numerical'), (panel) -> { @numericalItemPanels = _.map(@animatedPanels.find('.numerical'), (panel) -> {
@ -186,6 +194,11 @@ module.exports = class HeroVictoryModal extends ModalView
@$el.find('#saving-progress-label').toggleClass('hide', @readyToContinue) @$el.find('#saving-progress-label').toggleClass('hide', @readyToContinue)
@$el.find('#continue-button').toggleClass('hide', not @readyToContinue) @$el.find('#continue-button').toggleClass('hide', not @readyToContinue)
onGameSubmitted: (e) ->
ladderURL = "/play/ladder/#{@level.get('slug')}#my-matches"
Backbone.Mediator.publish 'router:navigate', route: ladderURL
# TODO: award heroes/items and play an awesome sound when you get one # TODO: award heroes/items and play an awesome sound when you get one
destroy: -> destroy: ->

View file

@ -17,7 +17,8 @@ transpileLevelSession = (sessionID, cb) ->
if err then return cb err if err then return cb err
submittedCode = session.submittedCode submittedCode = session.submittedCode
unless session.submittedCodeLanguage unless session.submittedCodeLanguage
throw 'SUBMITTED CODE LANGUAGE DOESN\'T EXIST' console.log '\n\n\n#{i++} SUBMITTED CODE LANGUAGE DOESN\'T EXIST\n', session, '\n\n'
return cb()
else else
console.log "Transpiling code for session #{i++} #{session._id} in language #{session.submittedCodeLanguage}" console.log "Transpiling code for session #{i++} #{session._id} in language #{session.submittedCodeLanguage}"
transpiledCode = {} transpiledCode = {}