MCPcopy Create free account
hub / github.com/codecombat/codecombat / onClickCreateClan

Method onClickCreateClan

app/views/clans/ClansView.js:142–172  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

140 }
141
142 onClickCreateClan (e) {
143 let name
144 if (me.isAnonymous()) { return this.openModalView(new CreateAccountModal()) }
145 const clanType = $('.private-clan-checkbox').prop('checked') ? 'private' : 'public'
146 if ((clanType === 'private') && !me.isPremium()) {
147 this.openModalView(new SubscribeModal())
148 if (window.tracker != null) {
149 window.tracker.trackEvent('Show subscription modal', { category: 'Subscription', label: 'create clan' })
150 }
151 return
152 }
153 if (name = $('.create-clan-name').val()) {
154 let description
155 const clan = new Clan()
156 clan.set('type', clanType)
157 clan.set('name', name)
158 if (description = $('.create-clan-description').val()) { clan.set('description', description) }
159 return clan.save({}, {
160 error: (model, response, options) => {
161 return console.error('Error saving clan', response.status)
162 },
163 success: (model, response, options) => {
164 application.router.navigate(`/clans/${model.id}`)
165 return window.location.reload()
166 }
167 }
168 )
169 } else {
170 return console.log('Invalid name')
171 }
172 }
173
174 onJoinClan (e) {
175 let clanID

Callers

nothing calls this directly

Calls 9

isAnonymousMethod · 0.80
isPremiumMethod · 0.80
navigateMethod · 0.80
reloadMethod · 0.80
logMethod · 0.80
trackEventMethod · 0.45
setMethod · 0.45
saveMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected