Jonell01 commited on
Commit
51a483e
·
verified ·
1 Parent(s): dc3e724

Create public/index.html

Browse files
Files changed (1) hide show
  1. public/index.html +187 -0
public/index.html ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Bot Control Panel CC</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script defer src="https://unpkg.com/alpinejs@3.10.2/dist/cdn.min.js"></script>
9
+ <style>
10
+ @keyframes fadeIn {
11
+ from { opacity: 0; transform: translateY(10px); }
12
+ to { opacity: 1; transform: translateY(0); }
13
+ }
14
+ .fade-in { animation: fadeIn 0.5s ease-out; }
15
+
16
+ @keyframes fadeOut {
17
+ from { opacity: 1; transform: scale(1); }
18
+ to { opacity: 0; transform: scale(0); }
19
+ }
20
+ .fade-out { animation: fadeOut 0.5s ease-out forwards; }
21
+
22
+ @keyframes spin {
23
+ 100% { transform: rotate(360deg); }
24
+ }
25
+ .loading-circle {
26
+ border: 4px solid rgba(255, 255, 255, 0.3);
27
+ border-top-color: white;
28
+ border-radius: 50%;
29
+ width: 40px;
30
+ height: 40px;
31
+ animation: spin 1s linear infinite;
32
+ }
33
+
34
+ .popup {
35
+ position: fixed;
36
+ bottom: 20px;
37
+ left: 50%;
38
+ transform: translateX(-50%);
39
+ background-color: rgba(0, 0, 0, 0.8);
40
+ color: white;
41
+ padding: 12px 20px;
42
+ border-radius: 8px;
43
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
44
+ opacity: 0;
45
+ transition: opacity 0.5s ease-out;
46
+ }
47
+ .popup.show { opacity: 1; }
48
+
49
+ #ping {
50
+ position: fixed;
51
+ bottom: 10px;
52
+ left: 50%;
53
+ transform: translateX(-50%);
54
+ font-size: 14px;
55
+ color: rgba(255, 255, 255, 0.6);
56
+ font-weight: 500;
57
+ font-style: italic;
58
+ pointer-events: none;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body class="bg-gray-900 text-white flex flex-col items-center justify-center min-h-screen p-6">
63
+
64
+ <div class="w-full max-w-3xl space-y-6 fade-in">
65
+ <h1 class="text-3xl font-bold text-center">Bot Control Panel</h1>
66
+
67
+ <div class="bg-gray-800 p-6 rounded-lg shadow-lg">
68
+ <label class="block text-lg font-medium mb-2">Paste JSON:</label>
69
+ <textarea id="jsonInput" class="w-full p-3 rounded-lg bg-gray-700 text-white border border-gray-600 focus:ring focus:ring-blue-500 transition" rows="6" placeholder="Paste JSON here..."></textarea>
70
+ <button onclick="askPasscode('updateAppState')" class="mt-4 w-full bg-blue-600 hover:bg-blue-700 transition px-4 py-2 rounded-lg font-semibold shadow-lg">Proceed</button>
71
+ </div>
72
+
73
+ <div class="bg-gray-800 p-6 rounded-lg shadow-lg fade-in">
74
+ <button onclick="askPasscode('restartBot')" class="w-full bg-red-600 hover:bg-red-700 transition px-4 py-2 rounded-lg font-semibold shadow-lg">Restart Bot</button>
75
+ </div>
76
+
77
+ <div class="bg-gray-800 p-6 rounded-lg shadow-lg fade-in">
78
+ <label class="block text-lg font-medium mb-2">Execute Command:</label>
79
+ <input type="text" id="commandInput" class="w-full p-3 rounded-lg bg-gray-700 text-white border border-gray-600 focus:ring focus:ring-blue-500 transition" placeholder="Enter a command...">
80
+ <button onclick="askPasscode('executeCommand')" class="mt-4 w-full bg-yellow-600 hover:bg-yellow-700 transition px-4 py-2 rounded-lg font-semibold shadow-lg">Execute</button>
81
+ </div>
82
+
83
+ </div>
84
+
85
+ <div id="ping" class="fade-in">Ping: <span id="pingValue">Loading...</span></div>
86
+
87
+ <div id="loading" class="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center hidden">
88
+ <div class="loading-circle"></div>
89
+ </div>
90
+
91
+ <div id="popupNotification" class="popup"></div>
92
+
93
+ <script>
94
+ function showPopup(message) {
95
+ const popup = document.getElementById("popupNotification");
96
+ popup.textContent = message;
97
+ popup.classList.add("show");
98
+ setTimeout(() => popup.classList.remove("show"), 3000);
99
+ }
100
+
101
+ function askPasscode(action) {
102
+ const passcode = prompt("Enter Passcode:");
103
+ if (!passcode) {
104
+ showPopup("Passcode is required.");
105
+ return;
106
+ }
107
+ window[action](passcode);
108
+ }
109
+
110
+ function updateAppState(passcode) {
111
+ const jsonInput = document.getElementById("jsonInput").value;
112
+
113
+ try {
114
+ JSON.parse(jsonInput);
115
+ } catch {
116
+ showPopup("Invalid JSON format.");
117
+ return;
118
+ }
119
+
120
+ document.getElementById("loading").classList.remove("hidden");
121
+
122
+ fetch("/update-appstate", {
123
+ method: "POST",
124
+ headers: { "Content-Type": "application/json" },
125
+ body: JSON.stringify({ passcode, jsonData: JSON.parse(jsonInput) })
126
+ }).then(res => res.text()).then(message => {
127
+ document.getElementById("loading").classList.add("hidden");
128
+ showPopup(message);
129
+ }).catch(() => {
130
+ document.getElementById("loading").classList.add("hidden");
131
+ showPopup("Error updating AppState.");
132
+ });
133
+ }
134
+
135
+ function restartBot(passcode) {
136
+ document.getElementById("loading").classList.remove("hidden");
137
+
138
+ fetch(`/restart?passcode=${encodeURIComponent(passcode)}`)
139
+ .then(res => res.text())
140
+ .then(message => {
141
+ document.getElementById("loading").classList.add("hidden");
142
+ showPopup(message);
143
+ })
144
+ .catch(() => {
145
+ document.getElementById("loading").classList.add("hidden");
146
+ showPopup("Error restarting bot.");
147
+ });
148
+ }
149
+
150
+ function executeCommand(passcode) {
151
+ const commandInput = document.getElementById("commandInput").value;
152
+ if (!commandInput) {
153
+ showPopup("Please enter a command.");
154
+ return;
155
+ }
156
+
157
+ document.getElementById("loading").classList.remove("hidden");
158
+
159
+ fetch("/execute-command", {
160
+ method: "POST",
161
+ headers: { "Content-Type": "application/json" },
162
+ body: JSON.stringify({ passcode, command: commandInput })
163
+ }).then(res => res.text()).then(output => {
164
+ document.getElementById("loading").classList.add("hidden");
165
+ showPopup(output);
166
+ }).catch(() => {
167
+ document.getElementById("loading").classList.add("hidden");
168
+ showPopup("Error executing command.");
169
+ });
170
+ }
171
+
172
+ function updatePing() {
173
+ fetch("/ping")
174
+ .then(res => res.json())
175
+ .then(data => {
176
+ document.getElementById("pingValue").textContent = data.ping + " ms";
177
+ })
178
+ .catch(() => {
179
+ document.getElementById("pingValue").textContent = "Error";
180
+ });
181
+ }
182
+
183
+ setInterval(updatePing, 5000);
184
+ updatePing();
185
+ </script>
186
+ </body>
187
+ </html>