MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / init

Function init

scripts/component_docs/toggle_fonts.ts:9–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7const PLATFORM_WINDOWS_CLASS = 'platform-windows';
8
9export function init(): void {
10 document.documentElement.classList.add(PLATFORM_LINUX_CLASS);
11 const button = document.createElement('button');
12 button.className = 'component-docs-ui';
13
14 const loop = [
15 PLATFORM_LINUX_CLASS,
16 PLATFORM_MAC_CLASS,
17 PLATFORM_WINDOWS_CLASS,
18 ];
19
20 function toggleFonts(): void {
21 for (const className of loop) {
22 document.documentElement.classList.toggle(className, className === loop[0]);
23 }
24 loop.push(loop.shift() as string);
25 button.innerText = 'Turn on ' + loop[0] + ' fonts';
26 }
27
28 window.addEventListener('load', () => {
29 toggleFonts();
30
31 button.style.position = 'fixed';
32 button.style.bottom = '10px';
33 button.style.right = '250px';
34 button.style.width = '250px';
35 button.style.fontSize = '16px';
36 button.style.padding = '5px';
37 button.style.cursor = 'pointer';
38
39 button.addEventListener('click', event => {
40 event.preventDefault();
41 toggleFonts();
42 });
43
44 document.body.appendChild(button);
45 });
46}

Callers

nothing calls this directly

Calls 5

toggleFontsFunction · 0.85
addEventListenerMethod · 0.65
appendChildMethod · 0.65
addMethod · 0.45
createElementMethod · 0.45

Tested by

no test coverage detected