summaryrefslogtreecommitdiffhomepage
path: root/docs/ucode.js
blob: 2377c7ed1bf1463519bd4e3c393732bbc006d71b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
document.addEventListener('DOMContentLoaded', (ev) => {
	const accordionState = window.localStorage.getItem('accordion-id');

	if (accordionState == null || accordionState == '{}')
		document.querySelectorAll('[data-isopen="false"]')
			.forEach(item => item.setAttribute('data-isopen', 'true'));

	const moduleName = location.pathname.match(/\/module-(.+)\.html$/)?.[1];

	if (moduleName) {
		const modulePrefix = `module:${moduleName}.`;

		document.querySelectorAll(`a[href^="module-${CSS.escape(moduleName)}."]`).forEach(a => {
			if (a.text?.indexOf(modulePrefix) == 0)
				a.text = a.text.substring(modulePrefix.length);
		});
	}

	document.querySelectorAll('.param-type, .type-signature').forEach(span => {
		let replaced;
		do {
			replaced = false;
			span.innerHTML = span.innerHTML.replace(/\b(Object|Array)\.<((?:(?!&[lg]t;).)+)>/,
				(m, t, st) => {
					replaced = true;

					if (t == 'Object')
						return `Object<${st.replace(/,\s*/, ': ')}>`;
					else
						return `${st}[]`;
				});
		} while (replaced);
	});

	document.querySelectorAll('.type-signature').forEach(span => {
		span.innerHTML = span.innerHTML.replace(/\(nullable\) (.+)$/,
			'$1<span class="signature-attributes">nullable</span>');
	});
});