Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add randomized examples to demo playground on doc page #106

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>Mathup</h1>
<div class="input">
<p><label for="try-input">You write…</label></p>

<textarea id="try-input">bb E[X] = int_(-oo)^oo x f(x) dx</textarea>
<textarea id="try-input">E[X] = int_(-oo)^oo x f(x) dx</textarea>

<div class="options">
<label for="try-decimalmark">Decimal mark</label>
Expand Down Expand Up @@ -1001,7 +1001,7 @@ <h3>Operators</h3>
<li>
<!-- prettier-ignore -->
<use-example>
sum_(n=0)^k a_n = a_0 + a_i + cdots + a_k
sum_(n=0)^k a_n = a_0 + a_1 + cdots + a_k
</use-example>
</li>
<li>
Expand Down Expand Up @@ -1787,6 +1787,10 @@ <h3>Fenced Groups</h3>
</use-example>
</li>

<li>
<use-example> |(Psi(t):) = int Psi(x, t) |(x:) dx </use-example>
</li>

<li>
<!-- prettier-ignore -->
<use-example>
Expand Down
28 changes: 28 additions & 0 deletions docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,31 @@ function removePolyfill(outputEl, mathupEl) {
}
}

const DEMO_EQUATIONS = [
"E[X] = int_(-oo)^oo x f(x) dx",
"sum_(n=0)^k a_n = a_0 + a_1 + cdots + a_k",
"e = sum_(n=0)^oo 1 / n!",
"vec x = a hat i + b hat j + c hat k",
"grad f(x,y) = ((del f)/(del x) (x, y), (del f)/(del y)(x,y))",
"oint_(del S) bf F * d bf s = dint_S grad xx bf F * d bf s",
"cc N(x | μ, σ^2) = 1 / (σ sqrt(2π)) e^(-1/2 (x-μ / σ)^2)",
"`Gamma`(theta | alpha, beta) = beta^alpha / Gamma(alpha) theta^(alpha - 1) e^(-beta theta)",
"P(A | B) = P(B | A)P(A) / P(B)",
String.raw`phi =.^\def a/b = a+b / a`,
"binom(n, k) = n! / k!(n-k)!",
"|(Psi(t):) = int Psi(x, t) |(x:) dx",
"<<V(t)^2>> = lim_(T->oo) 1/T int_(-T/2)^(T/2) V(t)^2 dt",
`[λ_0, λ_1, ...;] [p_(0 0), p_(0 1), ...
p_(1 0), p_(1 1), ...
vdots, vdots, ddots]`,
"||(bf x)||^2 = [x_1 ; x_2 ; x_3]*[x_1 ; x_2 ; x_3]",
`n! = { 1, if n=0 or n=1
n(n-1)!, if n > 1`,
"x = -b+-sqrt(b^2 - 4ac) / 2a",
"ln x = int_1^x 1/t dt",
"bf F @ bf G: U sube RR^3 -> RR^2",
];

/**
* @returns {void}
*/
Expand Down Expand Up @@ -138,6 +163,9 @@ function setupPlayground() {
return;
}

tryInput.value =
DEMO_EQUATIONS[Math.floor(Math.random() * DEMO_EQUATIONS.length)];

const tryMathUp = /** @type {MathUpElement} */ (
tryOutput.querySelector("math-up")
);
Expand Down