MCPcopy Index your code
hub / github.com/dataease/SQLBot / loadScript

Function loadScript

frontend/src/utils/RemoteJs.ts:1–22  ·  view source on GitHub ↗
(url: string, jsId?: string)

Source from the content-addressed store, hash-verified

1export const loadScript = (url: string, jsId?: string) => {
2 return new Promise(function (resolve, reject) {
3 const scriptId = jsId || 'de-fit2cloud-script-id'
4 let dom = document.getElementById(scriptId)
5 if (dom) {
6 dom.parentElement?.removeChild(dom)
7 dom = null
8 }
9 const script = document.createElement('script')
10
11 script.id = scriptId
12 script.onload = function () {
13 return resolve(null)
14 }
15 script.onerror = function () {
16 return reject(new Error('Load script from '.concat(url, ' failed')))
17 }
18 script.src = url
19 const head = document.head || document.getElementsByTagName('head')[0]
20 ;(document.body || head).appendChild(script)
21 })
22}

Callers 1

loadClientFunction · 0.90

Calls 2

resolveFunction · 0.85
concatMethod · 0.80

Tested by

no test coverage detected