MCPcopy Create free account
hub / github.com/hackmdio/codimd / jsonp

Function jsonp

public/js/extra.js:269–284  ·  view source on GitHub ↗
(url, callback)

Source from the content-addressed store, hash-verified

267}
268
269function jsonp (url, callback) {
270 const callbackName = 'jsonp_callback_' + Math.round(1000000000 * Math.random())
271 window[callbackName] = function (data) {
272 delete window[callbackName]
273 document.body.removeChild(script)
274 callback(data)
275 }
276
277 const script = document.createElement('script')
278 script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + callbackName
279 document.body.appendChild(script)
280 script.onerror = function (e) {
281 console.error(e)
282 script.remove()
283 }
284}
285
286// dynamic event or object binding here
287export function finishView (view) {

Callers 1

finishViewFunction · 0.85

Calls 1

removeMethod · 0.80

Tested by

no test coverage detected