userbymahadi commited on
Commit
41adf7c
·
verified ·
1 Parent(s): 12577a4

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +94 -59
index.html CHANGED
@@ -3,35 +3,45 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
6
- <title>Elite WebTermX</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <script src="https://unpkg.com/lucide@latest"></script>
9
  <style>
10
- body { background: #020617; color: #f8fafc; font-family: 'Inter', sans-serif; overflow: hidden; }
11
- .glass { background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(15px); border: 1px solid rgba(255,255,255,0.05); }
12
- #sidebar { transition: transform 0.3s ease; width: 80%; max-width: 280px; z-index: 1000; }
13
  .active-nav { background: #4f46e5; color: white; }
14
- .terminal-text { font-family: 'JetBrains Mono', monospace; font-size: 11px; }
15
  </style>
16
  </head>
17
  <body class="h-screen flex flex-col">
18
 
 
 
19
  <!-- Header -->
20
- <header class="h-14 flex items-center justify-between px-4 glass border-b border-white/5 sticky top-0 z-[100]">
21
- <button onclick="toggleSidebar()" class="p-2"><i data-lucide="menu"></i></button>
22
- <span class="font-bold tracking-widest text-indigo-500">ULTRA V5</span>
23
- <button onclick="logout()"><i data-lucide="log-out" class="w-5 h-5 text-slate-400"></i></button>
 
 
 
 
 
 
 
 
24
  </header>
25
 
26
  <div class="flex flex-1 relative overflow-hidden">
27
  <!-- Sidebar -->
28
- <aside id="sidebar" class="fixed inset-y-0 left-0 glass -translate-x-full pt-16">
29
  <div class="p-4 space-y-2">
30
  <button onclick="openTab('terminal')" id="btn-terminal" class="w-full flex items-center gap-4 p-4 rounded-xl active-nav">
31
  <i data-lucide="terminal"></i> Terminal
32
  </button>
33
  <button onclick="openTab('files')" id="btn-files" class="w-full flex items-center gap-4 p-4 rounded-xl">
34
- <i data-lucide="folder"></i> File Manager
35
  </button>
36
  <button onclick="openTab('proxy')" id="btn-proxy" class="w-full flex items-center gap-4 p-4 rounded-xl">
37
  <i data-lucide="monitor"></i> Web Preview
@@ -39,67 +49,67 @@
39
  </div>
40
  </aside>
41
 
42
- <!-- Overlay -->
43
- <div id="overlay" onclick="toggleSidebar()" class="fixed inset-0 bg-black/60 hidden z-[900]"></div>
44
-
45
  <main class="flex-1 p-3 overflow-y-auto">
46
  <!-- Terminal -->
47
  <div id="tab-terminal" class="tab-content h-full flex flex-col gap-2">
48
- <div id="output" class="flex-1 glass rounded-2xl p-4 overflow-y-auto terminal-text leading-relaxed"></div>
49
  <div class="flex gap-2">
50
- <input type="text" id="cmdInput" class="flex-1 bg-slate-900 border border-slate-800 rounded-xl px-4 py-3 text-sm focus:border-indigo-500" placeholder="Enter command...">
51
- <button onclick="sendCmd()" class="bg-indigo-600 px-5 rounded-xl"><i data-lucide="play" class="w-4 h-4"></i></button>
52
  </div>
53
  </div>
54
 
55
  <!-- File Manager -->
56
  <div id="tab-files" class="tab-content hidden space-y-3">
57
- <div class="flex items-center gap-2">
58
  <button onclick="goBack()" class="p-2 glass rounded-lg"><i data-lucide="chevron-left"></i></button>
59
- <button onclick="createItem()" class="p-2 bg-emerald-600 rounded-lg"><i data-lucide="plus"></i></button>
60
- <div class="flex-1 text-[10px] mono truncate opacity-50 px-2" id="pathBar">.</div>
 
 
 
61
  </div>
62
- <div id="fileList" class="space-y-2"></div>
63
  </div>
64
 
65
  <!-- Proxy -->
66
  <div id="tab-proxy" class="tab-content hidden h-full flex flex-col gap-2">
67
  <div class="flex gap-2">
68
- <input type="text" id="proxyUrl" value="http://localhost:8080" class="flex-1 bg-slate-900 p-2 rounded-lg text-xs">
69
- <button onclick="loadProxy()" class="bg-indigo-600 px-4 rounded-lg text-xs">LOAD</button>
70
  </div>
71
- <iframe id="proxyFrame" class="flex-1 bg-white rounded-xl border-none"></iframe>
72
  </div>
73
  </main>
74
  </div>
75
 
76
- <!-- Editor -->
77
  <div id="editor" class="fixed inset-0 bg-slate-950 z-[1100] hidden flex flex-col p-4">
78
- <div class="flex justify-between mb-4">
79
- <span id="edName" class="text-xs opacity-50"></span>
80
- <div class="flex gap-3">
81
- <button onclick="closeEditor()" class="text-xs">Cancel</button>
82
- <button onclick="saveContent()" class="bg-indigo-600 px-4 py-1 rounded text-xs">Save</button>
83
  </div>
84
  </div>
85
- <textarea id="edArea" class="flex-1 bg-slate-900 p-4 rounded-xl terminal-text outline-none border border-white/5"></textarea>
86
  </div>
87
 
88
  <!-- Login -->
89
  <div id="login" class="fixed inset-0 z-[2000] bg-slate-950 flex items-center justify-center p-6 hidden">
90
- <div class="w-full max-w-xs text-center space-y-6">
91
- <h1 class="text-2xl font-bold">Access Denied</h1>
92
- <input type="password" id="pKey" class="w-full bg-slate-900 border border-slate-800 p-4 rounded-2xl text-center" placeholder="Password">
93
- <button onclick="doLogin()" class="w-full bg-indigo-600 py-4 rounded-2xl font-bold">Login</button>
94
  </div>
95
  </div>
96
 
97
  <script>
98
  lucide.createIcons();
99
- let ws, curPath = ".";
100
 
101
  window.onload = () => {
102
- const k = localStorage.getItem('ultra_v5_key');
103
  if(k) connect(k);
104
  else document.getElementById('login').classList.remove('hidden');
105
  };
@@ -107,17 +117,26 @@
107
  function doLogin() { connect(document.getElementById('pKey').value); }
108
  function logout() { localStorage.clear(); location.reload(); }
109
 
 
 
 
 
 
 
 
 
110
  function connect(p) {
111
  const prot = location.protocol === 'https:' ? 'wss:' : 'ws:';
 
112
  ws = new WebSocket(`${prot}//${location.host}/ws`);
113
  ws.onopen = () => ws.send(p);
114
  ws.onmessage = (e) => {
115
  if(e.data === "AUTH_SUCCESS") {
116
- localStorage.setItem('ultra_v5_key', p);
117
  document.getElementById('login').classList.add('hidden');
 
118
  } else if(e.data === "AUTH_FAILED") {
119
- alert("Wrong!");
120
- logout();
121
  } else append(e.data);
122
  };
123
  }
@@ -129,11 +148,11 @@
129
 
130
  function openTab(t) {
131
  document.querySelectorAll('.tab-content').forEach(c => c.classList.add('hidden'));
132
- document.querySelectorAll('nav button').forEach(b => b.classList.remove('active-nav'));
133
  document.getElementById('tab-'+t).classList.remove('hidden');
134
  document.getElementById('btn-'+t).classList.add('active-nav');
135
  if(t === 'files') fetchFiles(curPath);
136
- if(window.innerWidth < 1024) toggleSidebar();
137
  }
138
 
139
  function sendCmd() {
@@ -144,7 +163,7 @@
144
  function append(t) {
145
  const o = document.getElementById('output');
146
  const d = document.createElement('div');
147
- d.className = "mb-1 text-slate-400 border-l-2 border-indigo-500 pl-2";
148
  d.innerText = t;
149
  o.appendChild(d);
150
  o.scrollTop = o.scrollHeight;
@@ -153,24 +172,39 @@
153
  async function fetchFiles(path) {
154
  curPath = path;
155
  document.getElementById('pathBar').innerText = path;
156
- const res = await fetch(`/api/files?path=${path}`);
157
- const files = await res.json();
158
- document.getElementById('fileList').innerHTML = files.map(f => `
159
- <div class="flex items-center justify-between p-4 glass rounded-xl active:scale-95 transition-all" onclick="${f.is_dir ? `fetchFiles('${f.path}')` : `editFile('${f.path}')`}">
160
- <div class="flex items-center gap-3">
161
- <i data-lucide="${f.is_dir ? 'folder' : 'file-text'}" class="${f.is_dir ? 'text-indigo-400' : 'text-slate-500'}"></i>
162
- <span class="text-sm">${f.name}</span>
 
 
 
 
 
 
163
  </div>
164
- <button onclick="event.stopPropagation(); del('${f.path}')" class="text-rose-500"><i data-lucide="trash-2" class="w-4 h-4"></i></button>
165
- </div>
166
- `).join('');
167
- lucide.createIcons();
 
 
 
 
 
 
 
168
  }
169
 
 
 
170
  async function createItem() {
171
  const name = prompt("Name:");
172
  if(!name) return;
173
- const isDir = confirm("Is it a folder?");
174
  await fetch('/api/create', {
175
  method: 'POST',
176
  headers: {'Content-Type': 'application/json'},
@@ -180,7 +214,7 @@
180
  }
181
 
182
  async function editFile(p) {
183
- const res = await fetch(`/api/read?path=${p}`);
184
  const data = await res.json();
185
  document.getElementById('edName').innerText = p;
186
  document.getElementById('edArea').value = data.content;
@@ -200,14 +234,15 @@
200
 
201
  function closeEditor() { document.getElementById('editor').classList.add('hidden'); }
202
  function goBack() {
203
- const parts = curPath.split('/');
 
204
  parts.pop();
205
- fetchFiles(parts.length ? parts.join('/') : '.');
206
  }
207
  function loadProxy() {
208
  document.getElementById('proxyFrame').src = `/proxy?url=${encodeURIComponent(document.getElementById('proxyUrl').value)}`;
209
  }
210
- async function del(p) { if(confirm('Delete?')) { await fetch(`/api/delete?path=${p}`, {method: 'DELETE'}); fetchFiles(curPath); } }
211
  </script>
212
  </body>
213
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
6
+ <title>WebTermX Ultimate</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <script src="https://unpkg.com/lucide@latest"></script>
9
  <style>
10
+ body { background: #020617; color: #f1f5f9; font-family: 'Inter', sans-serif; overflow: hidden; }
11
+ .glass { background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.05); }
12
+ #sidebar { transition: transform 0.3s ease; width: 280px; z-index: 1000; }
13
  .active-nav { background: #4f46e5; color: white; }
14
+ .terminal-font { font-family: 'JetBrains Mono', monospace; font-size: 11px; }
15
  </style>
16
  </head>
17
  <body class="h-screen flex flex-col">
18
 
19
+ <div id="overlay" onclick="toggleSidebar()" class="fixed inset-0 bg-black/60 hidden z-[900]"></div>
20
+
21
  <!-- Header -->
22
+ <header class="h-14 flex items-center justify-between px-4 glass border-b border-white/5 z-[100]">
23
+ <div class="flex items-center gap-3">
24
+ <button onclick="toggleSidebar()" class="p-2"><i data-lucide="menu"></i></button>
25
+ <span class="font-bold text-indigo-400">ULTRA V6</span>
26
+ </div>
27
+ <div class="flex items-center gap-2">
28
+ <!-- Refresh Button for WebSocket -->
29
+ <button onclick="reconnect()" class="p-2 bg-indigo-600/20 text-indigo-400 rounded-lg" title="Reconnect Session">
30
+ <i data-lucide="refresh-cw" id="refresh-icon"></i>
31
+ </button>
32
+ <button onclick="logout()" class="p-2 text-slate-500"><i data-lucide="power"></i></button>
33
+ </div>
34
  </header>
35
 
36
  <div class="flex flex-1 relative overflow-hidden">
37
  <!-- Sidebar -->
38
+ <aside id="sidebar" class="fixed inset-y-0 left-0 glass -translate-x-full pt-16 shadow-2xl">
39
  <div class="p-4 space-y-2">
40
  <button onclick="openTab('terminal')" id="btn-terminal" class="w-full flex items-center gap-4 p-4 rounded-xl active-nav">
41
  <i data-lucide="terminal"></i> Terminal
42
  </button>
43
  <button onclick="openTab('files')" id="btn-files" class="w-full flex items-center gap-4 p-4 rounded-xl">
44
+ <i data-lucide="folder-tree"></i> File Manager
45
  </button>
46
  <button onclick="openTab('proxy')" id="btn-proxy" class="w-full flex items-center gap-4 p-4 rounded-xl">
47
  <i data-lucide="monitor"></i> Web Preview
 
49
  </div>
50
  </aside>
51
 
 
 
 
52
  <main class="flex-1 p-3 overflow-y-auto">
53
  <!-- Terminal -->
54
  <div id="tab-terminal" class="tab-content h-full flex flex-col gap-2">
55
+ <div id="output" class="flex-1 glass rounded-2xl p-4 overflow-y-auto terminal-font leading-relaxed"></div>
56
  <div class="flex gap-2">
57
+ <input type="text" id="cmdInput" class="flex-1 bg-slate-900 border border-slate-800 rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none" placeholder="Type command...">
58
+ <button onclick="sendCmd()" class="bg-indigo-600 px-5 rounded-xl"><i data-lucide="send" class="w-4 h-4"></i></button>
59
  </div>
60
  </div>
61
 
62
  <!-- File Manager -->
63
  <div id="tab-files" class="tab-content hidden space-y-3">
64
+ <div class="flex items-center gap-2 sticky top-0 bg-[#020617] py-1 z-10">
65
  <button onclick="goBack()" class="p-2 glass rounded-lg"><i data-lucide="chevron-left"></i></button>
66
+ <button onclick="fetchFiles('/')" class="p-2 glass rounded-lg text-indigo-400" title="Root"><i data-lucide="home"></i></button>
67
+ <button onclick="createItem()" class="p-2 bg-indigo-600/20 text-indigo-400 rounded-lg"><i data-lucide="plus"></i></button>
68
+ <button onclick="document.getElementById('fileUp').click()" class="p-2 bg-emerald-600/20 text-emerald-400 rounded-lg"><i data-lucide="upload"></i></button>
69
+ <input type="file" id="fileUp" class="hidden" onchange="handleUpload()">
70
+ <div class="flex-1 text-[10px] mono truncate opacity-40 px-1" id="pathBar">/</div>
71
  </div>
72
+ <div id="fileList" class="space-y-2 pb-24"></div>
73
  </div>
74
 
75
  <!-- Proxy -->
76
  <div id="tab-proxy" class="tab-content hidden h-full flex flex-col gap-2">
77
  <div class="flex gap-2">
78
+ <input type="text" id="proxyUrl" value="http://localhost:8080" class="flex-1 bg-slate-900 p-2 rounded-lg text-xs outline-none">
79
+ <button onclick="loadProxy()" class="bg-indigo-600 px-4 rounded-lg text-xs font-bold">PREVIEW</button>
80
  </div>
81
+ <iframe id="proxyFrame" class="flex-1 bg-white rounded-xl border-none shadow-xl"></iframe>
82
  </div>
83
  </main>
84
  </div>
85
 
86
+ <!-- Modal Editor -->
87
  <div id="editor" class="fixed inset-0 bg-slate-950 z-[1100] hidden flex flex-col p-4">
88
+ <div class="flex justify-between items-center mb-4">
89
+ <span id="edName" class="text-[10px] mono opacity-50 truncate max-w-[200px]"></span>
90
+ <div class="flex gap-4">
91
+ <button onclick="closeEditor()" class="text-xs text-slate-400">Cancel</button>
92
+ <button onclick="saveContent()" class="bg-indigo-600 px-4 py-2 rounded-lg text-xs font-bold">Save</button>
93
  </div>
94
  </div>
95
+ <textarea id="edArea" class="flex-1 bg-slate-900 p-4 rounded-xl terminal-font outline-none border border-white/5"></textarea>
96
  </div>
97
 
98
  <!-- Login -->
99
  <div id="login" class="fixed inset-0 z-[2000] bg-slate-950 flex items-center justify-center p-6 hidden">
100
+ <div class="w-full max-w-xs space-y-6">
101
+ <h1 class="text-center text-xl font-bold tracking-widest text-indigo-500">SECURE ACCESS</h1>
102
+ <input type="password" id="pKey" class="w-full bg-slate-900 border border-slate-800 p-4 rounded-2xl text-center outline-none focus:border-indigo-500" placeholder="Password">
103
+ <button onclick="doLogin()" class="w-full bg-indigo-600 py-4 rounded-2xl font-bold shadow-lg shadow-indigo-600/20">Enter System</button>
104
  </div>
105
  </div>
106
 
107
  <script>
108
  lucide.createIcons();
109
+ let ws, curPath = "/";
110
 
111
  window.onload = () => {
112
+ const k = localStorage.getItem('ultra_v6_key');
113
  if(k) connect(k);
114
  else document.getElementById('login').classList.remove('hidden');
115
  };
 
117
  function doLogin() { connect(document.getElementById('pKey').value); }
118
  function logout() { localStorage.clear(); location.reload(); }
119
 
120
+ function reconnect() {
121
+ const icon = document.getElementById('refresh-icon');
122
+ icon.classList.add('animate-spin');
123
+ const k = localStorage.getItem('ultra_v6_key');
124
+ if(k) connect(k);
125
+ setTimeout(() => icon.classList.remove('animate-spin'), 1000);
126
+ }
127
+
128
  function connect(p) {
129
  const prot = location.protocol === 'https:' ? 'wss:' : 'ws:';
130
+ if(ws) ws.close();
131
  ws = new WebSocket(`${prot}//${location.host}/ws`);
132
  ws.onopen = () => ws.send(p);
133
  ws.onmessage = (e) => {
134
  if(e.data === "AUTH_SUCCESS") {
135
+ localStorage.setItem('ultra_v6_key', p);
136
  document.getElementById('login').classList.add('hidden');
137
+ append("System Connected.");
138
  } else if(e.data === "AUTH_FAILED") {
139
+ alert("Unauthorized!"); logout();
 
140
  } else append(e.data);
141
  };
142
  }
 
148
 
149
  function openTab(t) {
150
  document.querySelectorAll('.tab-content').forEach(c => c.classList.add('hidden'));
151
+ document.querySelectorAll('aside button').forEach(b => b.classList.remove('active-nav'));
152
  document.getElementById('tab-'+t).classList.remove('hidden');
153
  document.getElementById('btn-'+t).classList.add('active-nav');
154
  if(t === 'files') fetchFiles(curPath);
155
+ if(window.innerWidth < 1024 && !document.getElementById('sidebar').classList.contains('-translate-x-full')) toggleSidebar();
156
  }
157
 
158
  function sendCmd() {
 
163
  function append(t) {
164
  const o = document.getElementById('output');
165
  const d = document.createElement('div');
166
+ d.className = "mb-1 text-slate-300 border-l-2 border-indigo-500/30 pl-3 break-words";
167
  d.innerText = t;
168
  o.appendChild(d);
169
  o.scrollTop = o.scrollHeight;
 
172
  async function fetchFiles(path) {
173
  curPath = path;
174
  document.getElementById('pathBar').innerText = path;
175
+ try {
176
+ const res = await fetch(`/api/files?path=${encodeURIComponent(path)}`);
177
+ const files = await res.json();
178
+ document.getElementById('fileList').innerHTML = files.map(f => `
179
+ <div class="flex items-center justify-between p-4 glass rounded-2xl active:scale-95 transition-all" onclick="${f.is_dir ? `fetchFiles('${f.path}')` : `editFile('${f.path}')`}">
180
+ <div class="flex items-center gap-3 overflow-hidden">
181
+ <i data-lucide="${f.is_dir ? 'folder' : 'file-text'}" class="${f.is_dir ? 'text-indigo-400' : 'text-slate-500'} flex-shrink-0"></i>
182
+ <span class="text-sm font-medium truncate">${f.name}</span>
183
+ </div>
184
+ <div class="flex gap-3 flex-shrink-0">
185
+ ${!f.is_dir ? `<button onclick="event.stopPropagation(); downloadF('${f.path}')" class="text-indigo-400"><i data-lucide="download" class="w-4 h-4"></i></button>` : ''}
186
+ <button onclick="event.stopPropagation(); del('${f.path}')" class="text-rose-500"><i data-lucide="trash-2" class="w-4 h-4"></i></button>
187
+ </div>
188
  </div>
189
+ `).join('');
190
+ lucide.createIcons();
191
+ } catch(e) { append("File Error: " + e); }
192
+ }
193
+
194
+ async function handleUpload() {
195
+ const file = document.getElementById('fileUp').files[0];
196
+ const fd = new FormData();
197
+ fd.append('file', file);
198
+ await fetch(`/api/upload?path=${encodeURIComponent(curPath)}`, {method: 'POST', body: fd});
199
+ fetchFiles(curPath);
200
  }
201
 
202
+ function downloadF(p) { window.open(`/api/download?path=${encodeURIComponent(p)}`); }
203
+
204
  async function createItem() {
205
  const name = prompt("Name:");
206
  if(!name) return;
207
+ const isDir = confirm("Folder?");
208
  await fetch('/api/create', {
209
  method: 'POST',
210
  headers: {'Content-Type': 'application/json'},
 
214
  }
215
 
216
  async function editFile(p) {
217
+ const res = await fetch(`/api/read?path=${encodeURIComponent(p)}`);
218
  const data = await res.json();
219
  document.getElementById('edName').innerText = p;
220
  document.getElementById('edArea').value = data.content;
 
234
 
235
  function closeEditor() { document.getElementById('editor').classList.add('hidden'); }
236
  function goBack() {
237
+ if(curPath === "/") return;
238
+ const parts = curPath.split('/').filter(p => p);
239
  parts.pop();
240
+ fetchFiles('/' + parts.join('/'));
241
  }
242
  function loadProxy() {
243
  document.getElementById('proxyFrame').src = `/proxy?url=${encodeURIComponent(document.getElementById('proxyUrl').value)}`;
244
  }
245
+ async function del(p) { if(confirm('Delete?')) { await fetch(`/api/delete?path=${encodeURIComponent(p)}`, {method: 'DELETE'}); fetchFiles(curPath); } }
246
  </script>
247
  </body>
248
  </html>