Files
freeCodeCamp/client/src/utils/scriptLoaders.js
Oliver Eyton-Williams c772382d59 fix: remove remnants of servicebot
None of the code was still in use.
2020-09-04 00:14:24 +05:30

51 lines
1.1 KiB
JavaScript

export const scriptLoader = (id, key, async, src, onload, text) => {
let s = document.createElement('script');
s.type = 'text/javascript';
s.id = id;
s.key = key;
s.async = async;
s.onload = onload;
s.src = src;
s.text = text;
document.getElementsByTagName('head')[0].appendChild(s);
};
export const scriptRemover = id => {
let script = document.getElementById(id);
if (script) {
script.remove();
}
};
export const stripeScriptLoader = onload =>
scriptLoader(
'stripe-js',
'stripe-js',
false,
'https://js.stripe.com/v3/',
onload
);
export const mathJaxScriptLoader = () =>
scriptLoader(
'mathjax',
'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')
]);`
);