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

Method onClickAnchor

app/views/HomeView.js:203–243  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

201 }
202
203 onClickAnchor (e) {
204 let anchor, properties, translationKey
205 if (!(anchor = e != null ? e.currentTarget : undefined)) { return }
206 if (isCoco()) {
207 // Track an event with action of the English version of the link text
208 let anchorText
209 translationKey = $(anchor).attr('data-i18n')
210 if (translationKey == null) { translationKey = $(anchor).children('[data-i18n]').attr('data-i18n') }
211 if (translationKey) {
212 anchorText = $.i18n.t(translationKey, { lng: 'en-US' })
213 } else {
214 anchorText = anchor.text
215 }
216
217 properties = {}
218 if (anchorText) {
219 return this.homePageEvent(`Link: ${anchorText}`, properties)
220 } else {
221 properties.clicked = __guard__(e != null ? e.currentTarget : undefined, x => x.host) || 'unknown'
222 return this.homePageEvent('Link:', properties)
223 }
224 } else {
225 let anchorEventAction = $(anchor).data('event-action')
226 if (!anchorEventAction) {
227 // Track an event with action of the English version of the link text
228 translationKey = $(anchor).data('i18n')
229 if (translationKey == null) { translationKey = $(anchor).children('[data-i18n]').data('i18n') }
230 anchorEventAction = translationKey ? $.i18n.t(translationKey, { lng: 'en-US' }) : anchor.text
231 anchorEventAction = `Click: ${anchorEventAction || 'unknown'}`
232 }
233
234 if (anchorEventAction) {
235 return this.homePageEvent(anchorEventAction)
236 } else {
237 _.extend(properties || {}, {
238 clicked: __guard__(e != null ? e.currentTarget : undefined, x1 => x1.host) || 'unknown'
239 })
240 return this.homePageEvent('Click: unknown')
241 }
242 }
243 }
244
245 onClickGetStartedButton (e) {
246 this.homePageEvent($(e.target).data('event-action'))

Callers

nothing calls this directly

Calls 4

homePageEventMethod · 0.95
isCocoFunction · 0.85
dataMethod · 0.80
__guard__Function · 0.70

Tested by

no test coverage detected