Skip to content

Commit 107377d

Browse files
committed
Merge branch 'add-after-vaccine'
2 parents 8a2eaa9 + e9e0698 commit 107377d

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

after-vaccine.html

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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>

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ <h1>xtetsuji/html-javascript-tinyapps</h1>
1818
<li><a href="kachimai-download.html">kachimai-download.html</a> - 十勝毎日新聞電子版の指定日付のアクセス・ダウンロード用(そのブラウザで要事前ログイン)</li>
1919
<li><a href="tweet-count.html">tweet-count.html</a> - Twitter向け(?)の風変わりな文字数カウント</li>
2020
<li><a href="copy-per-line.html">copy-per-line.html</a> - クリップボード行ごとコピー支援</li>
21+
<li><a href="after-vaccine.html">after-vaccine.html</a> - ワクチン接種後何日?</li>
2122
</ul>
2223

2324
</body>

0 commit comments

Comments
 (0)