-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTLE_TeXRenderer.html
56 lines (55 loc) · 2.94 KB
/
TLE_TeXRenderer.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<div style="display:none;">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.css"
integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI" crossorigin="anonymous">
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.js"
integrity="sha384-G0zcxDFp5LWZtDuRMnBkk3EphCK1lhEf4UEyEM693ka574TZGwo4IWwS6QLzM/2t"
crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/contrib/mhchem.min.js"
integrity="sha384-ifpG+NlgMq0kvOSGqGQxW1mJKpjjMDmZdpKGq3tbvD3WPhyshCEEYClriK/wRVU0"
crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/contrib/auto-render.min.js"
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
delimiters: [
{ left: '$$', right: '$$', display: true },
{ left: '$', right: '$', display: false },
{ left: '\\(', right: '\\)', display: false },
{ left: '\\[', right: '\\]', display: true }
],
throwOnError: false
});
});
</script>
</div>
<script>
const tleId = globalThis.tleSeq.toString();
const orbitalElements = globalThis.orbitalElement[tleId];
let elementsRaw = new Array(10);
elementsRaw[0] = `${orbitalElements[0].toFixed(2)} km`;
elementsRaw[1] = `${orbitalElements[1].toFixed(6)}`;
elementsRaw[2] = `${orbitalElements[2].toFixed(2)} rad`;
elementsRaw[3] = `\\left(${(orbitalElements[2] * 180 / Math.PI).toFixed(2)}^{\\circ}\\right)`;
elementsRaw[4] = `${orbitalElements[3].toFixed(2)} rad`;
elementsRaw[5] = `\\left(${(orbitalElements[3] * 180 / Math.PI).toFixed(2)}^{\\circ}\\right)`;
elementsRaw[6] = `${orbitalElements[4].toFixed(2)} rad`;
elementsRaw[7] = `\\left(${(orbitalElements[4] * 180 / Math.PI).toFixed(2)}^{\\circ}\\right)`;
elementsRaw[8] = `${orbitalElements[5].toFixed(2)} rad`;
elementsRaw[9] = `\\left(${(orbitalElements[5] * 180 / Math.PI).toFixed(2)}^{\\circ}\\right)`;
// 获取所有需要更新的DOM元素
const elements = document.getElementsByClassName("tleTeX")[globalThis.tleSeq];
for (let i = 0; i < 10; i++) {
try {
// 使用 KaTeX 渲染字符串
const renderedHtml = katex.renderToString(elementsRaw[i]);
elements[i].innerHTML = renderedHtml;
} catch (error) {
// 处理可能的渲染错误
console.error(`KaTeX rendering error for element ${i}:`, error);
elements[i].innerHTML = "Error rendering with KaTeX";
}
}
</script>