mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-18 06:01:14 -05:00
* rename js files to ts * start migrating ajax * finish migrating ajax * migrate algolia-locale-setup * migrate format * migrate format.test * migrate get-words * install axios for types in handled-error * migrate handled-error * migrate handled-error.test * migrate report-error * migrate script-loaders * migrate to-learn-path * correct renamed imports * remove unnecessary type assertions in searchBar * remove unnecessary global comment * remove unnecessary max-len enable/disable * change axios imports to type imports * revert to .then() from await * use UserType from redux/prop-types * replace assertion with generic type * revert format to JS * remove unused getArticleById() * update putUpdateUserFlag() to use Record * remove unnecessary envData cast * update algolia-locale-setup types * remove invalid key property
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
export function scriptLoader(
|
|
id: string,
|
|
async: boolean,
|
|
src: string,
|
|
onload: (() => void) | null,
|
|
text: string
|
|
): void {
|
|
const s = document.createElement('script');
|
|
s.type = 'text/javascript';
|
|
s.id = id;
|
|
s.async = async;
|
|
s.onload = onload;
|
|
s.src = src;
|
|
s.text = text;
|
|
document.getElementsByTagName('head')[0].appendChild(s);
|
|
}
|
|
|
|
export function scriptRemover(id: string): void {
|
|
const script = document.getElementById(id);
|
|
if (script) {
|
|
script.remove();
|
|
}
|
|
}
|
|
|
|
export function mathJaxScriptLoader(): void {
|
|
scriptLoader(
|
|
'mathjax',
|
|
false,
|
|
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' +
|
|
'2.7.4/MathJax.js?config=TeX-AMS_HTML',
|
|
null,
|
|
`MathJax.Hub.Config({
|
|
tex2jax: {
|
|
inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],
|
|
processEscapes: true,
|
|
processClass: 'rosetta-code|project-euler'
|
|
}
|
|
});
|
|
MathJax.Hub.Queue([
|
|
'Typeset',
|
|
MathJax.Hub,
|
|
document.querySelector('.rosetta-code'),
|
|
document.querySelector('.project-euler')
|
|
]);`
|
|
);
|
|
}
|