p.subtitle — Podtytuł strony kalkulatora
All reusable UI components for kalkulator pages — HTML, CSS & JS reference
/* HTML pattern */ <div class="input-unit"> <input type="number" id="len" value="1"
step="0.1" oninput="calc()"> <span class="unit-badge" onclick="cycleUnit(this)"
data-unit="m,cm,mm,ft">m</span> </div> /* JS — getV() handles unit conversion
automatically */ const len = getV('len'); // always returns value in SI base unit
function stepperInc(id, step=1) { var el = document.getElementById(id); el.value =
(parseFloat(el.value)||0) + step; el.dispatchEvent(new Event('input')); } function stepperDec(id,
step=1) { var el = document.getElementById(id); el.value = Math.max(parseFloat(el.min)||0,
(parseFloat(el.value)||0) - step); el.dispatchEvent(new Event('input')); }
/* HTML */ <div class="result-box [success|warning|error|empty]" id="box-NAME"> <div
class="result-label">Label</div> <span class="result-value"
id="res-NAME">—</span> <span class="result-unit">unit</span> </div> /* JS
— via shared.js */ setResult('NAME', value); // sets value, removes empty class setResult('NAME',
null); // shows —, adds empty class
/* Useful HTML entities for formulas */ · → · (multiply) ÷ → ÷ α → α β → β γ → γ δ → δ λ → λ μ → μ η
→ η ρ → ρ σ → σ τ → τ ω → ω φ → φ Δ → Δ Σ → Σ Π → Π ∞ → ∞ ² → ² ³ → ³ ½ → ½ Ω → Ω ° → ° ± → ± ≠ → ≠
≤ → ≤ ≥ → ≥ √ → √ ∑ → ∑
| Symbol | Opis | Jednostka | Wartość |
|---|---|---|---|
| Re | Liczba Reynoldsa | — | 2300 |
| v | Prędkość przepływu | m/s | 1.42 |
| D | Średnica rury | mm | 50 |
| ν | Lepkość kinematyczna | m²/s | 1.0×10⁻⁶ |
| λ | Współczynnik oporów | — | 0.028 |
Czy chcesz zresetować wszystkie pola? Tej operacji nie można cofnąć.
Re = v·D/ν = 1.42·0.05/1e-6 = 71000
Ocena: 3/5
p — Tekst akapitu. Lorem ipsum dolor sit amet consectetur.
small/muted — Dodatkowe info, opisy pól
code — wzór inline: Re = v·D/ν
bold · italic · sub · sup · del
/* Sections */ <div class="section"> — full width section, card background <div
class="section section--narrow"> — narrower, centered /* Column layouts */ <div
class="one-column"> — single column (inputs top, results below) <div class="two-columns"> —
inputs left | results right (responsive) /* Input group */ <div class="field"> — label + input
wrapper <div class="input-unit"> — input + unit badge side by side /* Shape forms (for
multi-shape calculators) */ <div class="shape-form" id="form-NAME"> — hidden by default
<div class="shape-form active"> — visible form /* switchForm('NAME', calc) from shared.js
toggles these */
/* SVG circular progress — circumference = 2πr = 2π×32 ≈ 201 */ /* stroke-dashoffset = 201 × (1 -
percentage/100) */ /* 0%→201, 50%→100.5, 70%→60, 100%→0 */ <circle r="32" stroke-dasharray="201"
stroke-dashoffset="60" .../>
/* script.js — standard pattern for a single-formula calculator */ function calc() { // 1. Read
inputs (auto-converts units via shared.js getV) const v = getV('velocity'); // m/s const D =
getV('diameter'); // m (even if badge shows mm) const nu = getV('viscosity'); // m²/s // 2. Validate
— clear and bail if invalid if ([v, D, nu].some(isNaN) || v <= 0 || D <= 0 || nu <= 0) {
clearResults(['re', 'regime']); return; } // 3. Compute const Re = v * D / nu; // 4. Write outputs
setResult('re', Re); setResult('regime', Re < 2300 ? 'Laminarny' : Re < 4000 ? 'Przejściowy' :
'Turbulentny'); // 5. Optional: update result box class for colour coding
document.getElementById('box-regime').className = 'result-box ' + (Re < 2300 ? 'success' : Re < 4000
? 'warning' : 'error'); } calc(); // run on load so defaults populate immediately