MCPcopy Index your code
hub / github.com/codecombat/codecombat / loadAPI

Method loadAPI

app/core/social-handlers/GPlusHandler.js:90–131  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

88 }
89
90 loadAPI (options) {
91 if (options == null) { options = {} }
92 if (options.success == null) { options.success = _.noop }
93 if (options.context == null) { options.context = options }
94 if (this.apiLoaded) {
95 options.success.bind(options.context)()
96 } else {
97 this.once('load-api', options.success, options.context)
98 }
99
100 if (!this.startedLoading) {
101 window.init = () => {
102 this.apiLoaded = true
103 return this.trigger('load-api')
104 }
105 const po = document.createElement('script')
106 po.type = 'text/javascript'
107 po.async = true
108 po.defer = true
109 po.src = 'https://accounts.google.com/gsi/client'
110 const s = document.getElementsByTagName('script')[0]
111 s.parentNode.insertBefore(po, s)
112 po.addEventListener('load', window.init)
113
114 window.initGapi = () => {
115 return window.gapi.load('client', () => window.gapi.client.init({
116 apiKey: API_KEY,
117 discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest']
118 }))
119 }
120 const po1 = document.createElement('script')
121 po1.type = 'text/javascript'
122 po1.async = true
123 po1.defer = true
124 po1.src = 'https://apis.google.com/js/api.js'
125 const s1 = document.getElementsByTagName('script')[0]
126 s1.parentNode.insertBefore(po1, s1)
127 po1.addEventListener('load', window.initGapi)
128
129 this.startedLoading = true
130 }
131 }
132
133 connect (options) {
134 if (options == null) { options = {} }

Callers 12

constructorMethod · 0.45
constructorMethod · 0.45
initializeMethod · 0.45
afterRenderMethod · 0.45
constructorMethod · 0.45

Calls 2

loadMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected