debian-mirror-gitlab/app/assets/javascripts/sourcegraph/index.js

29 lines
768 B
JavaScript
Raw Normal View History

2019-12-26 22:10:19 +05:30
function loadScript(path) {
const script = document.createElement('script');
script.type = 'application/javascript';
script.src = path;
script.defer = true;
document.head.appendChild(script);
}
/**
* Loads the Sourcegraph integration for support for Sourcegraph extensions and
* code intelligence.
*/
export default function initSourcegraph() {
const { url } = gon.sourcegraph || {};
if (!url) {
return;
}
2021-02-22 17:27:13 +05:30
const assetsUrl = new URL(process.env.SOURCEGRAPH_PUBLIC_PATH, window.location.href);
2019-12-26 22:10:19 +05:30
const scriptPath = new URL('scripts/integration.bundle.js', assetsUrl).href;
window.SOURCEGRAPH_ASSETS_URL = assetsUrl.href;
window.SOURCEGRAPH_URL = url;
window.SOURCEGRAPH_INTEGRATION = 'gitlab-integration';
loadScript(scriptPath);
}