mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
fc2c68a7af
Mechanics have changed a bit: first param is an action string, second param has specific properties if Google Analytics. Updating some of the trackEvent calls to use correct actions and categories.
62 lines
2.4 KiB
CoffeeScript
62 lines
2.4 KiB
CoffeeScript
RootView = require 'views/kinds/RootView'
|
|
template = require 'templates/home'
|
|
WizardLank = require 'lib/surface/WizardLank'
|
|
ThangType = require 'models/ThangType'
|
|
Simulator = require 'lib/simulator/Simulator'
|
|
|
|
{me} = require '/lib/auth'
|
|
|
|
module.exports = class HomeView extends RootView
|
|
id: 'home-view'
|
|
template: template
|
|
|
|
events:
|
|
'click #play-button': 'onClickBeginnerCampaign'
|
|
|
|
constructor: ->
|
|
super()
|
|
window.tracker?.trackEvent 'Homepage Loaded', category: 'Homepage', ['Google Analytics']
|
|
if not me.get('hourOfCode') and @getQueryVariable 'hour_of_code'
|
|
@setUpHourOfCode()
|
|
elapsed = (new Date() - new Date(me.get('dateCreated')))
|
|
if me.get('hourOfCode') and elapsed < 86400 * 1000 and me.get('preferredLanguage', true) is 'en-US'
|
|
# Show the Hour of Code footer explanation in English until it's been more than a day
|
|
@explainsHourOfCode = true
|
|
|
|
getRenderData: ->
|
|
c = super()
|
|
if $.browser
|
|
majorVersion = $.browser.versionNumber
|
|
c.isOldBrowser = true if $.browser.mozilla && majorVersion < 21
|
|
c.isOldBrowser = true if $.browser.chrome && majorVersion < 17
|
|
c.isOldBrowser = true if $.browser.safari && majorVersion < 6
|
|
else
|
|
console.warn 'no more jquery browser version...'
|
|
c.isEnglish = (me.get('preferredLanguage') or 'en').startsWith 'en'
|
|
c.languageName = me.get('preferredLanguage')
|
|
c.explainsHourOfCode = @explainsHourOfCode
|
|
c
|
|
|
|
onClickBeginnerCampaign: (e) ->
|
|
@playSound 'menu-button-click'
|
|
e.preventDefault()
|
|
e.stopImmediatePropagation()
|
|
window.tracker?.trackEvent 'Click Play', category: 'Homepage'
|
|
window.open '/play', '_blank'
|
|
|
|
afterInsert: ->
|
|
super(arguments...)
|
|
@$el.addClass 'hour-of-code' if @explainsHourOfCode
|
|
if me.isAdmin() and me.get('slug') is 'nick'
|
|
LevelSetupManager = require 'lib/LevelSetupManager'
|
|
setupManager = new LevelSetupManager levelID: 'dungeons-of-kithgard', hadEverChosenHero: true, parent: @
|
|
setupManager.open()
|
|
|
|
setUpHourOfCode: ->
|
|
elapsed = (new Date() - new Date(me.get('dateCreated')))
|
|
if elapsed < 5 * 60 * 1000
|
|
me.set 'hourOfCode', true
|
|
me.patch()
|
|
# We may also insert the tracking pixel for everyone on the WorldMapView so as to count directly-linked visitors.
|
|
$('body').append($('<img src="http://code.org/api/hour/begin_codecombat.png" style="visibility: hidden;">'))
|
|
application.tracker?.trackEvent 'Hour of Code Begin', {}
|