Spaces:
Running
Running
Download deformation_gradient.html from Narunat/strain_measures: direct link, hf CLI and curl.
- Browser
- Download file 19.9 kB
-
https://huggingface.co/spaces/Narunat/strain_measures/resolve/main/deformation_gradient.html
- Command line
-
hf download hf://spaces/Narunat/strain_measures/deformation_gradient.html
-
curl -L -o deformation_gradient.html https://huggingface.co/spaces/Narunat/strain_measures/resolve/main/deformation_gradient.html
19.9 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> | |
| <style>body { margin: 0; } [hidden] { display: none ; }</style> | |
| <title>Deformation Gradient</title> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans+Condensed:wght@500;600&family=IBM+Plex+Sans:wght@400;500&display=swap"> | |
| <style> | |
| /* Layout: drafting-sheet tool. Plot (the deformed square) on the left, controls + tensors on the right; stacks on phones. | |
| Column 1 of F is coded orange, column 2 violet, in the plot and in the matrices. */ | |
| :root { | |
| --bg: #eef1f4; /* drafting sheet */ | |
| --panel: #f9fafb; | |
| --fg: #1b2530; | |
| --muted: #5d6a78; | |
| --line: #cfd6de; | |
| --grid: #dde3e9; | |
| --ref: #8a96a3; /* reference configuration */ | |
| --body: #0f6e78; /* deformed body */ | |
| --body-fill: rgba(15, 110, 120, 0.13); | |
| --c1: #c2570c; /* first column of F = image of e1 */ | |
| --c2: #6b3fc4; /* second column of F = image of e2 */ | |
| --flash: rgba(194, 87, 12, 0.22); | |
| --font-display: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif; | |
| --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; | |
| --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; | |
| } | |
| @media (prefers-color-scheme: dark) { | |
| :root:not([data-theme="light"]) { | |
| --bg: #12181e; --panel: #19212a; --fg: #e3e8ee; --muted: #93a0ad; --line: #2c3743; --grid: #222c36; | |
| --ref: #6f7c89; --body: #4fc1cc; --body-fill: rgba(79, 193, 204, 0.14); --c1: #f08a3c; --c2: #a98bf0; | |
| --flash: rgba(240, 138, 60, 0.28); color-scheme: dark; | |
| } | |
| } | |
| :root[data-theme="dark"] { | |
| --bg: #12181e; --panel: #19212a; --fg: #e3e8ee; --muted: #93a0ad; --line: #2c3743; --grid: #222c36; | |
| --ref: #6f7c89; --body: #4fc1cc; --body-fill: rgba(79, 193, 204, 0.14); --c1: #f08a3c; --c2: #a98bf0; | |
| --flash: rgba(240, 138, 60, 0.28); color-scheme: dark; | |
| } | |
| * { box-sizing: border-box; } | |
| body { | |
| background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5; | |
| padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); | |
| padding-block: 20px 32px; | |
| } | |
| .wrap { max-width: 1180px; margin: 0 auto; display: grid; gap: 18px; } | |
| header { display: grid; gap: 4px; } | |
| h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.6rem, 3.2vw, 2.2rem); line-height: 1.1; margin: 0; letter-spacing: 0.01em; text-wrap: balance; } | |
| .sub { color: var(--muted); margin: 0; max-width: 70ch; } | |
| .sub code, .note code { font-family: var(--font-mono); font-size: 0.92em; } | |
| .main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; } | |
| @media (max-width: 860px) { .main { grid-template-columns: minmax(0, 1fr); } } | |
| .plot { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px; display: grid; gap: 8px; min-width: 0; } | |
| .plot svg { width: 100%; height: auto; aspect-ratio: 1 / 1; max-width: 100%; display: block; } | |
| .legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.82rem; color: var(--muted); } | |
| .legend span { display: inline-flex; align-items: center; gap: 6px; } | |
| .sw { width: 18px; height: 0; border-top: 2px solid; display: inline-block; } | |
| .side { display: grid; gap: 14px; min-width: 0; } | |
| .card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px; display: grid; gap: 12px; min-width: 0; } | |
| .label { font-family: var(--font-display); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; } | |
| .formula { font-family: var(--font-mono); font-size: 0.86rem; color: var(--muted); margin: 0; overflow-x: auto; white-space: nowrap; } | |
| .sliders { display: grid; gap: 10px; } | |
| .slider { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr) 4.4rem; align-items: center; gap: 10px; } | |
| .slider label { font-size: 0.9rem; } | |
| .slider label b { font-family: var(--font-mono); font-weight: 500; } | |
| .slider output { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; font-size: 0.9rem; } | |
| input[type="range"] { width: 100%; accent-color: var(--body); } | |
| input[type="range"]:focus-visible, button:focus-visible, input[type="checkbox"]:focus-visible { outline: 2px solid var(--body); outline-offset: 2px; } | |
| .presets { display: flex; flex-wrap: wrap; gap: 8px; } | |
| button { | |
| font: inherit; font-size: 0.85rem; color: var(--fg); background: transparent; border: 1px solid var(--line); | |
| border-radius: 999px; padding: 5px 12px; cursor: pointer; | |
| } | |
| button:hover { border-color: var(--body); color: var(--body); } | |
| .toggles { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.88rem; } | |
| .toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; } | |
| .tensors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } | |
| @media (max-width: 420px) { .tensors { grid-template-columns: minmax(0, 1fr); } } | |
| .tensor { display: grid; gap: 4px; min-width: 0; } | |
| .tensor .name { font-family: var(--font-mono); font-size: 0.9rem; } | |
| .tensor .what { font-size: 0.78rem; color: var(--muted); } | |
| .mat { | |
| display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; padding: 6px 12px; | |
| border-left: 2px solid var(--fg); border-right: 2px solid var(--fg); border-radius: 4px; | |
| font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.98rem; text-align: right; | |
| } | |
| .mat span { padding: 1px 3px; border-radius: 3px; transition: background-color 0.6s ease; } | |
| .mat span.flash { background: var(--flash); transition: none; } | |
| #F .c1 { color: var(--c1); } #F .c2 { color: var(--c2); } | |
| .scalars { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 14px; margin: 0; } | |
| .scalars div { display: grid; gap: 0; } | |
| .scalars dt { font-size: 0.78rem; color: var(--muted); } | |
| .scalars dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1rem; } | |
| .note { font-size: 0.88rem; color: var(--muted); margin: 0; } | |
| .note b { color: var(--fg); font-weight: 500; } | |
| ol.try { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; font-size: 0.9rem; } | |
| @media (prefers-reduced-motion: reduce) { .mat span { transition: none; } } | |
| </style> | |
| </head> | |
| <body> | |
| <nav style="font: 13px system-ui, sans-serif; padding: 8px max(16px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid #cfd6de; background: #f9fafb;"><a href="index.html">All pages</a></nav> | |
| <div class="wrap"> | |
| <header> | |
| <h1>Deformation Gradient Explorer</h1> | |
| <p class="sub">A unit square is mapped by <code>x = F X</code>. Drag the sliders and watch which tensors change. | |
| <code>F</code> holds stretch <em>and</em> rotation; <code>C = FᵀF</code> and <code>E</code> keep only the change of shape.</p> | |
| </header> | |
| <div class="main"> | |
| <section class="plot" aria-label="Reference and deformed square"> | |
| <svg id="svg" viewBox="-2 -2 4 4" role="img" aria-label="Reference square, deformed square, images of the unit edges and of a circle of fibres"></svg> | |
| <div class="legend"> | |
| <span><i class="sw" style="border-top-style:dashed;border-color:var(--ref)"></i>reference square</span> | |
| <span><i class="sw" style="border-color:var(--body)"></i>deformed square</span> | |
| <span><i class="sw" style="border-color:var(--c1)"></i>F e₁ = 1st column of F</span> | |
| <span><i class="sw" style="border-color:var(--c2)"></i>F e₂ = 2nd column of F</span> | |
| <span id="lg-ell"><i class="sw" style="border-color:var(--body);border-top-style:dotted"></i>circle of fibres → ellipse, principal stretches</span> | |
| </div> | |
| </section> | |
| <div class="side"> | |
| <section class="card" aria-label="Controls"> | |
| <p class="label">Deformation</p> | |
| <p class="formula">F = R(θ) · [[λ₁, γ], [0, λ₂]] — stretch/shear first, then rotate</p> | |
| <div class="sliders"> | |
| <div class="slider"><label for="th">rotation <b>θ</b></label><input id="th" type="range" min="-180" max="180" step="1" value="30"><output id="th-o" for="th"></output></div> | |
| <div class="slider"><label for="l1">stretch <b>λ₁</b> (x)</label><input id="l1" type="range" min="0.4" max="2.5" step="0.01" value="1.5"><output id="l1-o" for="l1"></output></div> | |
| <div class="slider"><label for="l2">stretch <b>λ₂</b> (y)</label><input id="l2" type="range" min="0.4" max="2.5" step="0.01" value="1"><output id="l2-o" for="l2"></output></div> | |
| <div class="slider"><label for="g">shear <b>γ</b></label><input id="g" type="range" min="-1" max="1" step="0.01" value="0"><output id="g-o" for="g"></output></div> | |
| </div> | |
| <div class="presets" role="group" aria-label="Presets"> | |
| <button type="button" data-p="0,1,1,0">Undeformed</button> | |
| <button type="button" data-p="45,1,1,0">Rigid rotation 45°</button> | |
| <button type="button" data-p="0,1.5,1,0">Stretch x 1.5</button> | |
| <button type="button" data-p="0,1,1,0.8">Simple shear</button> | |
| <button type="button" data-p="60,1.5,0.8,0">Stretch + rotate</button> | |
| </div> | |
| <div class="toggles"> | |
| <label for="t-ell"><input id="t-ell" type="checkbox" checked>circle of fibres</label> | |
| <label for="t-grid"><input id="t-grid" type="checkbox" checked>grid</label> | |
| </div> | |
| </section> | |
| <section class="card" aria-label="Tensors"> | |
| <p class="label">Tensors (cells flash when they change)</p> | |
| <div class="tensors"> | |
| <div class="tensor"><span class="name">F = ∂x/∂X</span><span class="what">deformation gradient: stretch + rotation</span><div class="mat" id="F"></div></div> | |
| <div class="tensor"><span class="name">C = FᵀF</span><span class="what">right Cauchy–Green: squared stretches, no rotation</span><div class="mat" id="C"></div></div> | |
| <div class="tensor"><span class="name">E = ½(C − I)</span><span class="what">Green–Lagrange strain (exact)</span><div class="mat" id="E"></div></div> | |
| <div class="tensor"><span class="name">ε = sym(F − I)</span><span class="what">linear (small) strain</span><div class="mat" id="eps"></div></div> | |
| </div> | |
| <dl class="scalars"> | |
| <div><dt>J = det F (area ratio)</dt><dd id="J"></dd></div> | |
| <div><dt>rotation in F (polar R)</dt><dd id="rot"></dd></div> | |
| <div><dt>principal stretches λ_I, λ_II</dt><dd id="ps"></dd></div> | |
| <div><dt>‖E − ε‖ (linear-strain error)</dt><dd id="err"></dd></div> | |
| </dl> | |
| </section> | |
| <section class="card" aria-label="What to try"> | |
| <p class="label">Try this</p> | |
| <ol class="try"> | |
| <li>Press <b>Rigid rotation 45°</b> and drag <b>θ</b>: <code>F</code> changes, <code>C</code> = I and <code>E</code> = 0 stay put, but <code>ε</code> is not zero.</li> | |
| <li>Set λ₁ = 1.5, then drag <b>θ</b>: <code>F</code> keeps changing, <code>C</code> and <code>E</code> do not. The shape is the same, only turned.</li> | |
| <li>Read <code>F</code> off the plot: its columns are where the edges e₁ and e₂ went (orange and violet arrows).</li> | |
| <li><b>Simple shear</b>: <code>E₁₂ = γ/2</code> changes the right angle; <code>E₂₂ = γ²/2</code> is a stretch the linear strain misses.</li> | |
| </ol> | |
| </section> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| (function () { | |
| const $ = (id) => document.getElementById(id); | |
| const ids = ["th", "l1", "l2", "g"]; | |
| const NS = "http://www.w3.org/2000/svg"; | |
| const svg = $("svg"); | |
| const prev = {}; | |
| function fmt(v, d = 3) { | |
| const s = (Math.abs(v) < 0.5 * Math.pow(10, -d) ? 0 : v).toFixed(d); | |
| return (s.startsWith("-") ? "−" + s.slice(1) : " " + s); // figure space keeps columns aligned | |
| } | |
| function state() { | |
| return { th: +$("th").value, l1: +$("l1").value, l2: +$("l2").value, g: +$("g").value }; | |
| } | |
| function compute(p) { | |
| const t = p.th * Math.PI / 180, c = Math.cos(t), s = Math.sin(t); | |
| const F = [[c * p.l1, c * p.g - s * p.l2], [s * p.l1, s * p.g + c * p.l2]]; | |
| const C = [[F[0][0] ** 2 + F[1][0] ** 2, F[0][0] * F[0][1] + F[1][0] * F[1][1]], [0, F[0][1] ** 2 + F[1][1] ** 2]]; | |
| C[1][0] = C[0][1]; | |
| const E = [[(C[0][0] - 1) / 2, C[0][1] / 2], [C[1][0] / 2, (C[1][1] - 1) / 2]]; | |
| const eps = [[F[0][0] - 1, (F[0][1] + F[1][0]) / 2], [(F[0][1] + F[1][0]) / 2, F[1][1] - 1]]; | |
| const J = F[0][0] * F[1][1] - F[0][1] * F[1][0]; | |
| const rot = Math.atan2(F[1][0] - F[0][1], F[0][0] + F[1][1]) * 180 / Math.PI; // polar decomposition F = R U | |
| const tr = C[0][0] + C[1][1], det = C[0][0] * C[1][1] - C[0][1] ** 2; | |
| const disc = Math.sqrt(Math.max(tr * tr / 4 - det, 0)); | |
| const lamI = Math.sqrt(tr / 2 + disc), lamII = Math.sqrt(Math.max(tr / 2 - disc, 0)); | |
| const psi = 0.5 * Math.atan2(2 * C[0][1], C[0][0] - C[1][1]); // principal direction N_I (reference) | |
| const err = Math.hypot(E[0][0] - eps[0][0], E[0][1] - eps[0][1], E[1][0] - eps[1][0], E[1][1] - eps[1][1]); | |
| return { F, C, E, eps, J, rot, lamI, lamII, psi, err }; | |
| } | |
| function showMat(id, M, cls) { | |
| const el = $(id); | |
| if (!el.children.length) { | |
| for (let i = 0; i < 4; i++) { | |
| const sp = document.createElement("span"); | |
| if (cls) sp.className = i % 2 === 0 ? "c1" : "c2"; | |
| el.appendChild(sp); | |
| } | |
| } | |
| const vals = [M[0][0], M[0][1], M[1][0], M[1][1]]; | |
| vals.forEach((v, i) => { | |
| const sp = el.children[i], key = id + i, txt = fmt(v); | |
| if (prev[key] !== undefined && prev[key] !== txt) { | |
| sp.classList.remove("flash"); void sp.offsetWidth; sp.classList.add("flash"); | |
| clearTimeout(sp._t); sp._t = setTimeout(() => sp.classList.remove("flash"), 60); | |
| } | |
| prev[key] = txt; sp.textContent = txt; | |
| }); | |
| } | |
| function el(tag, attrs, parent) { | |
| const e = document.createElementNS(NS, tag); | |
| for (const k in attrs) e.setAttribute(k, attrs[k]); | |
| (parent || svg).appendChild(e); | |
| return e; | |
| } | |
| function arrow(g, x, y, color, head) { | |
| const L = Math.hypot(x, y); | |
| el("line", { x1: 0, y1: 0, x2: x, y2: y, stroke: color, "stroke-width": 2.4, "vector-effect": "non-scaling-stroke" }, g); | |
| if (L < 1e-6) return; | |
| const ux = x / L, uy = y / L, h = Math.min(head, 0.45 * L), w = 0.45 * h; | |
| const bx = x - ux * h, by = y - uy * h; | |
| el("polygon", { points: `${x},${y} ${bx - uy * w},${by + ux * w} ${bx + uy * w},${by - ux * w}`, fill: color }, g); | |
| } | |
| function draw(p, r) { | |
| const css = getComputedStyle(document.documentElement); | |
| const col = (n) => css.getPropertyValue(n).trim(); | |
| const F = r.F, map = (X, Y) => [F[0][0] * X + F[0][1] * Y, F[1][0] * X + F[1][1] * Y]; | |
| const sq = [[0, 0], [1, 0], [1, 1], [0, 1]]; | |
| const def = sq.map(([a, b]) => map(a, b)); | |
| const ext = Math.max(1.2, ...def.flat().map(Math.abs)) + 0.35; | |
| const R = Math.max(2, Math.ceil(ext * 2) / 2); // view grows in half-unit steps | |
| svg.setAttribute("viewBox", `${-R} ${-R} ${2 * R} ${2 * R}`); | |
| svg.textContent = ""; | |
| const g = el("g", { transform: "scale(1,-1)" }); // y up | |
| const head = 0.075 * R; | |
| if ($("t-grid").checked) { | |
| for (let k = -Math.floor(R); k <= Math.floor(R); k++) { | |
| el("line", { x1: k, y1: -R, x2: k, y2: R, stroke: col("--grid"), "stroke-width": k === 0 ? 1.4 : 1, "vector-effect": "non-scaling-stroke" }, g); | |
| el("line", { x1: -R, y1: k, x2: R, y2: k, stroke: col("--grid"), "stroke-width": k === 0 ? 1.4 : 1, "vector-effect": "non-scaling-stroke" }, g); | |
| } | |
| } | |
| el("polygon", { points: sq.map((q) => q.join(",")).join(" "), fill: "none", stroke: col("--ref"), "stroke-width": 1.5, "stroke-dasharray": "5 4", "vector-effect": "non-scaling-stroke" }, g); | |
| el("polygon", { points: def.map((q) => q.join(",")).join(" "), fill: col("--body-fill"), stroke: col("--body"), "stroke-width": 2.2, "vector-effect": "non-scaling-stroke" }, g); | |
| if ($("t-ell").checked) { | |
| const rad = 0.3, cx = 0.5, cy = 0.5, pts = [], ref = []; | |
| for (let i = 0; i <= 72; i++) { | |
| const a = (2 * Math.PI * i) / 72, X = cx + rad * Math.cos(a), Y = cy + rad * Math.sin(a); | |
| ref.push(`${X},${Y}`); pts.push(map(X, Y).join(",")); | |
| } | |
| el("polyline", { points: ref.join(" "), fill: "none", stroke: col("--ref"), "stroke-width": 1, "stroke-dasharray": "2 3", "vector-effect": "non-scaling-stroke" }, g); | |
| el("polyline", { points: pts.join(" "), fill: "none", stroke: col("--body"), "stroke-width": 1.4, "stroke-dasharray": "2 3", "vector-effect": "non-scaling-stroke" }, g); | |
| const [ccx, ccy] = map(cx, cy); | |
| [[r.psi, r.lamI], [r.psi + Math.PI / 2, r.lamII]].forEach(([ang, lam]) => { | |
| const [dx, dy] = map(Math.cos(ang), Math.sin(ang)), L = Math.hypot(dx, dy) || 1; | |
| const sx = (dx / L) * lam * rad, sy = (dy / L) * lam * rad; // R N_i scaled by lambda_i * r | |
| el("line", { x1: ccx - sx, y1: ccy - sy, x2: ccx + sx, y2: ccy + sy, stroke: col("--body"), "stroke-width": 1.4, "vector-effect": "non-scaling-stroke" }, g); | |
| }); | |
| } | |
| el("line", { x1: 0, y1: 0, x2: 1, y2: 0, stroke: col("--ref"), "stroke-width": 1, "vector-effect": "non-scaling-stroke" }, g); | |
| el("line", { x1: 0, y1: 0, x2: 0, y2: 1, stroke: col("--ref"), "stroke-width": 1, "vector-effect": "non-scaling-stroke" }, g); | |
| arrow(g, F[0][0], F[1][0], col("--c1"), head); | |
| arrow(g, F[0][1], F[1][1], col("--c2"), head); | |
| const t = el("g", {}); | |
| const lab = (x, y, s, c) => { | |
| const e = el("text", { x, y: -y, fill: c, "font-size": 0.055 * 2 * R, "font-family": "IBM Plex Mono, ui-monospace, monospace", "text-anchor": "middle", "dominant-baseline": "middle" }, t); | |
| e.textContent = s; | |
| }; | |
| const lp = (x, y, k) => { const L = Math.hypot(x, y) || 1; return [x + (x / L) * k, y + (y / L) * k]; }; | |
| lab(...lp(F[0][0], F[1][0], 0.12 * R), "F e₁", col("--c1")); | |
| lab(...lp(F[0][1], F[1][1], 0.12 * R), "F e₂", col("--c2")); | |
| lab(1.0, -0.16 * R, "e₁", col("--ref")); | |
| lab(-0.12 * R, 1.0, "e₂", col("--ref")); | |
| if ($("t-grid").checked) { | |
| for (let k = -Math.floor(R); k <= Math.floor(R); k++) if (k) { | |
| lab(k, -0.06 * R, String(k), col("--muted")); | |
| } | |
| } | |
| } | |
| function update() { | |
| const p = state(); | |
| $("th-o").value = p.th + "°"; | |
| $("l1-o").value = p.l1.toFixed(2); | |
| $("l2-o").value = p.l2.toFixed(2); | |
| $("g-o").value = fmt(p.g, 2); | |
| const r = compute(p); | |
| showMat("F", r.F, true); showMat("C", r.C); showMat("E", r.E); showMat("eps", r.eps); | |
| $("J").textContent = fmt(r.J); | |
| $("rot").textContent = fmt(r.rot, 1) + "°"; | |
| $("ps").textContent = r.lamI.toFixed(3) + ", " + r.lamII.toFixed(3); | |
| $("err").textContent = fmt(r.err); | |
| $("lg-ell").hidden = !$("t-ell").checked; | |
| draw(p, r); | |
| } | |
| ids.forEach((id) => $(id).addEventListener("input", update)); | |
| ["t-ell", "t-grid"].forEach((id) => $(id).addEventListener("change", update)); | |
| document.querySelectorAll("[data-p]").forEach((b) => b.addEventListener("click", () => { | |
| b.dataset.p.split(",").forEach((v, i) => { $(ids[i]).value = v; }); | |
| update(); | |
| })); | |
| if (window.matchMedia) { | |
| const mq = window.matchMedia("(prefers-color-scheme: dark)"); | |
| (mq.addEventListener ? mq.addEventListener("change", update) : mq.addListener(update)); | |
| } | |
| new MutationObserver(update).observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] }); | |
| update(); | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |