|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta charset='utf-8'> |
| 5 | + <title>接種後経過時間</title> |
| 6 | + <meta name='viewport' content='width=device-width, initial-scale=1'> |
| 7 | + <script> |
| 8 | + // 接種日時を設定 |
| 9 | + const injection_date = new Date(2021, 8-1, 17, 16, 40); |
| 10 | + function parse_ms(ms) { |
| 11 | + const total_second = Math.floor( ms / 1000 ); |
| 12 | + const day = Math.floor( total_second / 86400 ); |
| 13 | + const hour = Math.floor( total_second % 86400 / 3600 ); |
| 14 | + const minute = Math.floor( total_second % 3600 / 60 ); |
| 15 | + return [day, hour, minute]; |
| 16 | + } |
| 17 | + function update_message() { |
| 18 | + const now_date = new Date(); |
| 19 | + const diff = now_date - injection_date; |
| 20 | + const [day, hour, minute] = parse_ms(diff); |
| 21 | + const sesshugo = `${day}日と${hour}時間${minute}分` + ( |
| 22 | + day >= 1 ? `(${hour + 24 * day}時間)` : '' |
| 23 | + ); |
| 24 | + document.getElementById("sesshugo").innerText = sesshugo; |
| 25 | + document.getElementById("last_update").innerText = now_date.toString(); |
| 26 | + document.getElementById("menekiato").innerText = 14 - day; |
| 27 | + // TODO: 14 - day <= 0 の場合の表示 |
| 28 | + document.getElementById("toggle_description").addEventListener("click", () => { |
| 29 | + const style = document.getElementById("description").style |
| 30 | + if ( style.display !== "block" ) { |
| 31 | + style.display = "block"; |
| 32 | + } else { |
| 33 | + style.display = "none"; |
| 34 | + } |
| 35 | + }); |
| 36 | + } |
| 37 | + addEventListener("load", () => { |
| 38 | + update_message(); |
| 39 | + setInterval(update_message, 60 * 1000); |
| 40 | + }); |
| 41 | + </script> |
| 42 | + <style> |
| 43 | + body { |
| 44 | + font-size: 24pt; |
| 45 | + } |
| 46 | + #sesshugo { |
| 47 | + font-weight: bold; |
| 48 | + font-size: 1.5em; |
| 49 | + } |
| 50 | + #description { |
| 51 | + border: 1px solid green; |
| 52 | + display: none; |
| 53 | + } |
| 54 | + @media (prefers-color-scheme: dark) { |
| 55 | + body { |
| 56 | + background-color: #000; |
| 57 | + color: #888 |
| 58 | + } |
| 59 | + } |
| 60 | + </style> |
| 61 | +</head> |
| 62 | +<body> |
| 63 | +<div>接種後<br><span id="sesshugo">...</span><br>経過しました。</div> |
| 64 | +<div>免疫が付くまであと<span id="menekiato">...</span>日</div> |
| 65 | +<hr> |
| 66 | +<div>Last Update: <span id="last_update"></span></div> |
| 67 | + |
| 68 | +<div><legend><button id="toggle_description">▼説明</button></legend></div> |
| 69 | +<p id="description">時間はHTMLに直接書かれています。使う方はダウンロードしてその箇所を書き換えてローカルで開いて使用して下さい。</p> |
| 70 | + |
| 71 | +</body> |
| 72 | +</html> |
0 commit comments