ケルビン を編集
戻る
menu-all
▲
▼
リンクを挿入
保存する
<a href="/dictionary/K">K</a><br><a href="/dictionary/物質">物質</a>の運動量(温度)のこと。℃+273が公式らしい。0Kは絶対零度で現在のサーバーは<div id="temp"></div> <script> const tempEl = document.getElementById('temp'); let inFlight = false; async function fetchAndRenderTemp() { if (inFlight) return; inFlight = true; try { const res = await fetch('/temp', { cache: 'no-store' }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const text = (await res.text()).trim(); // 例: "60℃" "60 C" " 60.5度 " // 数値部分だけ抽出(負・小数対応、カンマ小数も許容) const match = text.replace(',', '.').match(/-?\d+(\.\d+)?/); if (!match) throw new Error('数値が見つかりませんでした'); const celsius = parseFloat(match[0]); const kelvin = celsius + 273.15; // 表示(小数2桁) tempEl.textContent = `${kelvin.toFixed(2)} K`; // データ属性に元情報も保持(デバッグやCSS用) tempEl.dataset.celsius = String(celsius); tempEl.dataset.kelvin = kelvin.toFixed(2); tempEl.dataset.raw = text; tempEl.title = `Raw: ${text} / Celsius: ${celsius}°C`; } catch (err) { console.error(err); tempEl.textContent = '—'; tempEl.title = `Error: ${err.message}`; } finally { inFlight = false; } } // 初回実行と2秒ごとのポーリング fetchAndRenderTemp(); setInterval(fetchAndRenderTemp, 2000); </script>
リンクを挿入
例えば「まきこ」を引用する場合は
「まきこ」と入力してください。
挿入する
キャンセル