|
| 1 | +<!doctype html> |
| 2 | +<html lang="en-US"> |
| 3 | + |
| 4 | +<head> |
| 5 | + <link href="/assets/index.css" rel="stylesheet" type="text/css" /> |
| 6 | + <script crossorigin="anonymous" src="/test-harness.js"></script> |
| 7 | + <script crossorigin="anonymous" src="/test-page-object.js"></script> |
| 8 | + <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> |
| 9 | + <style> |
| 10 | + [data-math-type=error] { |
| 11 | + color: #9d0000; |
| 12 | + border: 1px dashed currentColor; |
| 13 | + padding: 0.2em 0.4em; |
| 14 | + margin: 0 0.2em; |
| 15 | + border-radius: 2px; |
| 16 | + } |
| 17 | + </style> |
| 18 | +</head> |
| 19 | + |
| 20 | +<body> |
| 21 | + <template id="messages"> |
| 22 | + <x-message> |
| 23 | +## Display Math with ($$) |
| 24 | + |
| 25 | +1. Basic summation: |
| 26 | +$$ \sum\_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} $$ |
| 27 | + |
| 28 | +2. Matrix representation: |
| 29 | + |
| 30 | + $$ |
| 31 | + \begin{pmatrix} |
| 32 | + a & b \\ |
| 33 | + c & d |
| 34 | + \end{pmatrix} |
| 35 | + \begin{pmatrix} |
| 36 | + x \\ |
| 37 | + y |
| 38 | + \end{pmatrix} = |
| 39 | + \begin{pmatrix} |
| 40 | + ax + by \\ |
| 41 | + cx + dy |
| 42 | + \end{pmatrix} |
| 43 | + $$ |
| 44 | + |
| 45 | +3. Equation system: |
| 46 | + $$ |
| 47 | + \begin{cases} |
| 48 | + x + y + z = 1 \\ |
| 49 | + 2x - y + z = 3 \\ |
| 50 | + x + 2y - z = 2 |
| 51 | + \end{cases} |
| 52 | + $$ |
| 53 | + </x-message> |
| 54 | + <x-message> |
| 55 | +## Inline Math with \\(...\\) |
| 56 | + |
| 57 | +4. Physics formulas: |
| 58 | + |
| 59 | +- Energy: \(E = mc^2\) |
| 60 | +- Force: \(F = ma\) |
| 61 | +- Gravitational force: \(F = G\frac{m_1m_2}{r^2}\) |
| 62 | + |
| 63 | +5. Complex numbers: |
| 64 | + |
| 65 | +- Euler's formula: \(e^{ix} = \cos(x) + i\sin(x)\) |
| 66 | +- De Moivre's formula: \((\cos\theta + i\sin\theta)^n = \cos(n\theta) + i\sin(n\theta)\) |
| 67 | + |
| 68 | + </x-message> |
| 69 | + <x-message> |
| 70 | +## Display Math with \\[...\\] |
| 71 | + |
| 72 | +6. Calculus expressions: |
| 73 | + \[\lim\_{h \to 0} \frac{f(x + h) - f(x)}{h} = f'(x)\] |
| 74 | + |
| 75 | +7. Double integral: |
| 76 | + \[\iint_D \left(\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}\right) dx\,dy = \oint_C P\,dx + Q\,dy\] |
| 77 | + |
| 78 | +8. Taylor series: |
| 79 | + \[f(x) = \sum\_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n\] |
| 80 | + </x-message> |
| 81 | + <x-message> |
| 82 | +## Mixed Usage Examples |
| 83 | + |
| 84 | +9. Quantum mechanics: |
| 85 | + The Schrödinger equation \(\hat{H}\Psi = E\Psi\) can be written in position basis as: |
| 86 | + $$ -\frac{\hbar^2}{2m}\frac{d^2\Psi}{dx^2} + V(x)\Psi = E\Psi $$ |
| 87 | + |
| 88 | +10. Statistics: |
| 89 | + If \(X \sim N(\mu, \sigma^2)\), then its probability density function is: |
| 90 | + $$ f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} $$ |
| 91 | + |
| 92 | +11. Linear Algebra: |
| 93 | + For a matrix \(A\), its determinant can be computed as: |
| 94 | + \[\det(A) = \sum*{\sigma \in S_n} \text{sgn}(\sigma) \prod*{i=1}^n a\_{i,\sigma(i)}\] |
| 95 | + </x-message> |
| 96 | + </template> |
| 97 | + <main id="webchat"></main> |
| 98 | + <script> |
| 99 | + run(async function () { |
| 100 | + await host.windowSize(640, 720, document.getElementById('webchat')); |
| 101 | + |
| 102 | + const { |
| 103 | + WebChat: { renderWebChat } |
| 104 | + } = window; // Imports in UMD fashion. |
| 105 | + |
| 106 | + const { directLine, store } = testHelpers.createDirectLineEmulator(); |
| 107 | + |
| 108 | + renderWebChat({ directLine, store }, document.getElementById('webchat')); |
| 109 | + |
| 110 | + await pageConditions.uiConnected(); |
| 111 | + |
| 112 | + const messages = Array.from(window.messages.content.querySelectorAll('x-message')).map(el => el.innerText) |
| 113 | + for (const message of messages) { |
| 114 | + await directLine.emulateIncomingActivity({ |
| 115 | + text: message, |
| 116 | + type: 'message' |
| 117 | + }); |
| 118 | + await host.snapshot('local'); |
| 119 | + await pageConditions.numActivitiesShown(messages.indexOf(message) + 1); |
| 120 | + } |
| 121 | + }); |
| 122 | + </script> |
| 123 | +</body> |
| 124 | + |
| 125 | +</html> |
0 commit comments