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

Method loadAPI

app/core/social-handlers/FacebookHandler.js:60–100  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

58 }
59
60 loadAPI (options) {
61 if (options == null) { options = {} }
62 if (options.success == null) { options.success = _.noop }
63 if (options.context == null) { options.context = options }
64 if (this.apiLoaded) {
65 options.success.bind(options.context)()
66 } else {
67 this.once('load-api', options.success, options.context)
68 }
69
70 if (!this.startedLoading) {
71 // Load the SDK asynchronously
72 this.startedLoading = true;
73 (function (d) {
74 const id = 'facebook-jssdk'
75 const ref = d.getElementsByTagName('script')[0]
76 if (d.getElementById(id)) { return }
77 const js = d.createElement('script')
78 js.id = id
79 js.async = true
80 js.src = '//connect.facebook.net/en_US/sdk.js'
81 js.defer = true
82 js.crossorigin = 'anonymous'
83
84 // js.src = '//connect.facebook.net/en_US/all/debug.js'
85 ref.parentNode.insertBefore(js, ref)
86 })(document)
87
88 window.fbAsyncInit = () => {
89 FB.init({
90 appId: ((document.location.origin === 'http://localhost:3000') ? '607435142676437' : '148832601965463'), // App ID
91 channelUrl: document.location.origin + '/channel.html', // Channel File
92 cookie: true, // enable cookies to allow the server to access the session
93 xfbml: true, // parse XFBML
94 version: 'v20.0'
95 })
96 return this.trigger('load-api')
97 }
98 return window.fbAsyncInit
99 }
100 }
101
102 connect (options) {
103 if (options == null) { options = {} }

Callers

nothing calls this directly

Calls 1

initMethod · 0.45

Tested by

no test coverage detected