Update add-admin.html
Browse files- add-admin.html +16 -24
add-admin.html
CHANGED
@@ -2,17 +2,15 @@
|
|
2 |
<html lang="ja">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
-
<title>
|
6 |
<style>
|
7 |
body {
|
8 |
font-family: sans-serif;
|
9 |
padding: 2rem;
|
10 |
-
background-color: #f4f4f4;
|
11 |
}
|
12 |
button {
|
13 |
-
margin:
|
14 |
padding: 0.5rem 1rem;
|
15 |
-
font-size: 1rem;
|
16 |
}
|
17 |
#status {
|
18 |
margin-top: 1rem;
|
@@ -21,38 +19,32 @@
|
|
21 |
</style>
|
22 |
</head>
|
23 |
<body>
|
24 |
-
<h1>Admin
|
25 |
-
|
26 |
-
<button onclick="
|
27 |
-
<button onclick="removeAdmin()">admin を解除</button>
|
28 |
-
|
29 |
<div id="status"></div>
|
30 |
|
31 |
<script>
|
32 |
-
function
|
33 |
-
|
|
|
34 |
updateStatus();
|
35 |
}
|
36 |
|
37 |
-
function
|
38 |
-
|
|
|
39 |
updateStatus();
|
40 |
}
|
41 |
|
42 |
function updateStatus() {
|
43 |
-
const
|
44 |
-
|
45 |
-
|
46 |
-
status.textContent = "現在の状態: admin=1(Socket.IO スクリプトは無視されます)";
|
47 |
-
status.style.color = "green";
|
48 |
-
} else {
|
49 |
-
status.textContent = "現在の状態: admin 未設定(Socket.IO スクリプトが実行されます)";
|
50 |
-
status.style.color = "red";
|
51 |
-
}
|
52 |
}
|
53 |
|
54 |
-
//
|
55 |
-
updateStatus
|
56 |
</script>
|
57 |
</body>
|
58 |
</html>
|
|
|
2 |
<html lang="ja">
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
+
<title>Admin Access Cookie 切り替え</title>
|
6 |
<style>
|
7 |
body {
|
8 |
font-family: sans-serif;
|
9 |
padding: 2rem;
|
|
|
10 |
}
|
11 |
button {
|
12 |
+
margin: 0.5rem;
|
13 |
padding: 0.5rem 1rem;
|
|
|
14 |
}
|
15 |
#status {
|
16 |
margin-top: 1rem;
|
|
|
19 |
</style>
|
20 |
</head>
|
21 |
<body>
|
22 |
+
<h1>Admin Access Cookie 切り替え</h1>
|
23 |
+
<button onclick="setAdminAccess()">admin_access=true を設定</button>
|
24 |
+
<button onclick="removeAdminAccess()">admin_access を削除</button>
|
|
|
|
|
25 |
<div id="status"></div>
|
26 |
|
27 |
<script>
|
28 |
+
function setAdminAccess() {
|
29 |
+
// Cookie を設定(有効期限は1日)
|
30 |
+
document.cookie = "admin_access=true; path=/; max-age=86400";
|
31 |
updateStatus();
|
32 |
}
|
33 |
|
34 |
+
function removeAdminAccess() {
|
35 |
+
// Cookie を削除(有効期限を過去にする)
|
36 |
+
document.cookie = "admin_access=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
37 |
updateStatus();
|
38 |
}
|
39 |
|
40 |
function updateStatus() {
|
41 |
+
const status = document.cookie.includes("admin_access=true");
|
42 |
+
document.getElementById("status").textContent =
|
43 |
+
`document.cookie.includes("admin_access=true") の結果: ${status}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
+
// ページ読み込み時にステータスを表示
|
47 |
+
window.onload = updateStatus;
|
48 |
</script>
|
49 |
</body>
|
50 |
</html>
|