soiz1 commited on
Commit
128cba5
·
verified ·
1 Parent(s): c9c0112

Update add-admin.html

Browse files
Files changed (1) hide show
  1. 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>admin設定ページ</title>
6
  <style>
7
  body {
8
  font-family: sans-serif;
9
  padding: 2rem;
10
- background-color: #f4f4f4;
11
  }
12
  button {
13
- margin: 1rem 0;
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 ローカルストレージ設定</h1>
25
-
26
- <button onclick="setAdmin()">admin = 1 に設定</button><br>
27
- <button onclick="removeAdmin()">admin を解除</button>
28
-
29
  <div id="status"></div>
30
 
31
  <script>
32
- function setAdmin() {
33
- localStorage.setItem("admin", "1");
 
34
  updateStatus();
35
  }
36
 
37
- function removeAdmin() {
38
- localStorage.removeItem("admin");
 
39
  updateStatus();
40
  }
41
 
42
  function updateStatus() {
43
- const value = localStorage.getItem("admin");
44
- const status = document.getElementById("status");
45
- if (value === "1") {
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>