MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / start

Function start

static/main.ts:558–797  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

556}
557
558async function start() {
559 takeUsersOutOfRealDark();
560
561 initializeResetLayoutLink();
562
563 await languagesService.getLanguages();
564
565 const hostnameParts = window.location.hostname.split('.');
566 let subLangId: LanguageKey | undefined;
567 // Only set the subdomain lang id if it makes sense to do so
568 if (hostnameParts.length > 0) {
569 const subdomainPart = hostnameParts[0];
570 const langBySubdomain = Object.values(languagesService.getLanguagesOrFail()).find(
571 lang => lang.id === subdomainPart || lang.alias.includes(subdomainPart),
572 );
573 if (langBySubdomain) {
574 subLangId = langBySubdomain.id;
575 }
576 }
577
578 const defaultLangId = getDefaultLangId(subLangId);
579
580 // Cookie domains are matched as a RE against the window location. This allows a flexible
581 // way that works across multiple domains (e.g. godbolt.org and compiler-explorer.com).
582 // We allow this to be configurable so that (for example), gcc.godbolt.org and d.godbolt.org
583 // share the same cookie domain for some settings.
584 const cookieDomain = new RegExp(options.cookieDomainRe).exec(window.location.hostname);
585 if (cookieDomain?.[0]) {
586 jsCookie = jsCookie.withAttributes({domain: cookieDomain[0]});
587 }
588
589 const defaultConfig: GoldenLayoutConfig = {
590 settings: {showPopoutIcon: false},
591 content: [
592 createLayoutItem('row', [Components.getEditor(defaultLangId, 1), Components.getCompiler(1, defaultLangId)]),
593 ],
594 };
595
596 $(window).on('hashchange', () => {
597 // punt on hash events and just reload the page if there's a hash
598 if (window.location.hash.substring(1)) window.location.reload();
599 });
600
601 // Which buttons act as a linkable popup
602 const linkablePopups = ['#ces', '#sponsors', '#changes', '#cookies', '#setting', '#privacy'];
603 let hashPart = linkablePopups.includes(window.location.hash) ? window.location.hash : null;
604 if (hashPart) {
605 window.location.hash = '';
606 // Handle the time we renamed sponsors to ces to work around issues with blockers.
607 if (hashPart === '#sponsors') hashPart = '#ces';
608 }
609
610 const config = findConfig(defaultConfig, options, defaultLangId);
611
612 const root = $('#root');
613
614 let layout: GoldenLayout;
615 let hub: Hub;

Callers

nothing calls this directly

Calls 15

hasTreeMethod · 0.95
takeUsersOutOfRealDarkFunction · 0.85
getDefaultLangIdFunction · 0.85
createLayoutItemFunction · 0.85
findConfigFunction · 0.85
initializeLayoutFunction · 0.85
setSentryLayoutFunction · 0.85
handleCtrlSFunction · 0.85
setupButtonsFunction · 0.85
setupAddFunction · 0.85
initPoliciesFunction · 0.85

Tested by

no test coverage detected