File size: 1,403 Bytes
315f0c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>admin設定ページ</title>
  <style>
    body {
      font-family: sans-serif;
      padding: 2rem;
      background-color: #f4f4f4;
    }
    button {
      margin: 1rem 0;
      padding: 0.5rem 1rem;
      font-size: 1rem;
    }
    #status {
      margin-top: 1rem;
      font-weight: bold;
    }
  </style>
</head>
<body>
  <h1>Admin ローカルストレージ設定</h1>

  <button onclick="setAdmin()">admin = 1 に設定</button><br>
  <button onclick="removeAdmin()">admin を解除</button>

  <div id="status"></div>

  <script>
    function setAdmin() {
      localStorage.setItem("admin", "1");
      updateStatus();
    }

    function removeAdmin() {
      localStorage.removeItem("admin");
      updateStatus();
    }

    function updateStatus() {
      const value = localStorage.getItem("admin");
      const status = document.getElementById("status");
      if (value === "1") {
        status.textContent = "現在の状態: admin=1(Socket.IO スクリプトは無視されます)";
        status.style.color = "green";
      } else {
        status.textContent = "現在の状態: admin 未設定(Socket.IO スクリプトが実行されます)";
        status.style.color = "red";
      }
    }

    // ページ読み込み時に状態を表示
    updateStatus();
  </script>
</body>
</html>