forked from inaniwaudon/kyogaku-dendo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
66 lines (61 loc) · 1.89 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// アクセスカウンタのフェッチ
const fetchAccessCounter = async () => {
const url = "https://renbai-counter.yokohama.dev/counter";
try {
const request = await fetch(url);
return (await request.json()).count;
} catch {
return null;
}
};
// アクセスカウンタの計測 & 表示
const displayAccessCounter = async () => {
let count = await fetchAccessCounter();
// トップページのみ表示
const span = document.querySelector("#access-counter-no");
if (!span) {
return;
}
if (count === null) {
count = 0;
}
const countStr = ("00000" + count).slice(-6);
for (let i = 0; i < 6; i++) {
const digit = countStr[i];
const img = document.createElement("img");
img.src = `img/digits/${digit}.gif`;
span.appendChild(img);
}
};
// 共通ナビゲーションの表示
const displayNavigation = () => {
const navHtml = `<h2>驚額の殿堂</h2>
<ul>
<li><a href="index.html">トップ</a></li>
<li><a href="genka.html">原価</a></li>
<li><a href="poster.html">ポスター</a></li>
<li><a href="heya.html">んぽたその部屋</a></li>
<li><a href="chat.html">んぽとおはなしするんぽ〜〜</a></li>
<li><a href="/maps">地図</a></li>
<li><a href="kiyaku.html">んぽからのお願い</a></li>
<li>レポート(工事中)</li>
</ul>
<a href="https://sites.google.com/view/happy-busy/">
<img src="img/jikan.webp" alt="時間ねぇー" />
</a>`;
const nav = document.getElementById("nav");
nav.innerHTML = navHtml;
};
window.addEventListener("load", async () => {
displayAccessCounter();
displayNavigation();
// 右クリック・コピーの禁止
document.body.addEventListener("contextmenu", (e) => {
e.preventDefault();
alert("右クリックは禁止です!!");
});
document.body.addEventListener("copy", (e) => {
e.preventDefault();
alert("コピーも禁止です!!");
});
});