|
1 | 1 | <html> |
2 | 2 | <head> |
3 | | - <style>body { |
| 3 | + <style> |
| 4 | +body { |
4 | 5 | font-family: 'Segoe UI', Arial, sans-serif; |
5 | 6 | background: #f4f8fb; |
6 | 7 | margin: 0; |
7 | 8 | padding: 0; |
8 | 9 | min-height: 100vh; |
9 | 10 | } |
10 | | - |
11 | 11 | #tabs { |
12 | 12 | display: flex; |
13 | 13 | justify-content: center; |
14 | 14 | margin: 24px 0 0 0; |
15 | 15 | } |
16 | | - |
17 | 16 | .tab { |
18 | 17 | background: #f7f7f7; |
19 | 18 | border: 1px solid #bbb; |
|
30 | 29 | transition: background 0.2s, font-weight 0.2s; |
31 | 30 | color: #555; |
32 | 31 | } |
33 | | - |
34 | 32 | .tab.active { |
35 | 33 | background: #fff; |
36 | 34 | font-weight: bold; |
37 | 35 | border-color: #888 #888 #fff #888; |
38 | 36 | z-index: 1; |
39 | 37 | color: #222; |
40 | 38 | } |
41 | | - |
42 | 39 | .tab:not(.active):hover { |
43 | 40 | background: #ececec; |
44 | 41 | } |
45 | | - |
46 | 42 | .tab-content { |
47 | 43 | display: none; |
48 | 44 | border: 1px solid #ccc; |
|
54 | 50 | box-shadow: 0 2px 16px 0 rgba(0,0,0,0.06); |
55 | 51 | font-size: 15px; |
56 | 52 | } |
57 | | - |
58 | 53 | .tab-content.active { |
59 | 54 | display: block !important; |
60 | 55 | } |
61 | | - |
62 | 56 | .above-tabs { |
63 | 57 | display: flex; |
64 | 58 | justify-content: center; |
|
74 | 68 | position: relative; |
75 | 69 | top: 24px; |
76 | 70 | } |
77 | | - |
78 | 71 | .above-tabs input[type="text"], |
79 | 72 | .above-tabs input[type="number"] { |
80 | 73 | width: 180px; |
|
86 | 79 | background-color: #f9f9f9; |
87 | 80 | transition: border-color 0.2s; |
88 | 81 | } |
89 | | - |
90 | 82 | .above-tabs input[type="text"]:focus, |
91 | 83 | .above-tabs input[type="number"]:focus { |
92 | 84 | outline: none; |
93 | 85 | border-color: #0078d7; |
94 | 86 | } |
95 | | - |
96 | 87 | .above-tabs button { |
97 | 88 | background: #f7f7f7; |
98 | 89 | color: #555; |
|
104 | 95 | box-shadow: 0 4px 12px 0 rgba(0,0,0,0.06); |
105 | 96 | transition: background 0.2s, color 0.2s, border 0.2s; |
106 | 97 | } |
107 | | - |
108 | 98 | .above-tabs button:hover, .above-tabs button:focus { |
109 | 99 | background: #ececec; |
110 | 100 | color: #222; |
111 | 101 | border-color: #888; |
112 | 102 | } |
113 | | - |
114 | 103 | input[type="text"], input[type="number"] { |
115 | 104 | width: 220px; |
116 | 105 | padding: 7px 12px; |
|
121 | 110 | background-color: #f9f9f9; |
122 | 111 | transition: border-color 0.2s; |
123 | 112 | } |
124 | | - |
125 | 113 | input[type="text"]:focus, input[type="number"]:focus { |
126 | 114 | outline: none; |
127 | 115 | border-color: #0078d7; |
128 | 116 | } |
129 | | - |
130 | 117 | textarea { |
131 | 118 | width: 100%; |
132 | 119 | min-height: 80px; |
|
138 | 125 | background: #f9f9f9; |
139 | 126 | resize: vertical; |
140 | 127 | } |
141 | | - |
142 | 128 | button { |
143 | 129 | padding: 8px 20px; |
144 | 130 | margin: 0 8px 10px 0; |
|
151 | 137 | transition: background 0.18s; |
152 | 138 | box-shadow: 0 1px 2px 0 rgba(0,0,0,0.04); |
153 | 139 | } |
154 | | - |
155 | 140 | button:hover, button:focus { |
156 | 141 | background: #005fa3; |
157 | 142 | } |
158 | 143 |
|
| 144 | +/* New file pills style */ |
159 | 145 | .file-list { |
160 | 146 | margin: 8px 0 14px 0; |
161 | 147 | padding: 0; |
162 | 148 | list-style: none; |
163 | 149 | font-size: 14px; |
| 150 | + display: flex; |
| 151 | + flex-direction: column; |
| 152 | + gap: 10px; |
| 153 | +} |
| 154 | +.file-pill { |
| 155 | + display: flex; |
| 156 | + align-items: center; |
| 157 | + background: #e6eaf3; |
| 158 | + border-radius: 24px; |
| 159 | + box-shadow: 0 1px 4px 0 rgba(0,0,0,0.05); |
| 160 | + padding: 8px 16px 8px 10px; |
| 161 | + min-height: 40px; |
| 162 | + min-width: 0; |
| 163 | + transition: box-shadow 0.15s; |
| 164 | + gap: 14px; |
164 | 165 | } |
165 | | -.file-list li { |
166 | | - margin: 0 0 3px 0; |
167 | | - padding: 2px 0 2px 16px; |
168 | | - background: url('data:image/svg+xml;utf8,<svg width="10" height="10" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="5" fill="%2388c" /></svg>') 0 6px no-repeat; |
169 | | - background-size: 10px 10px; |
170 | | - color: #444; |
171 | | - word-break: break-all; |
| 166 | +.file-pill .file-icon { |
| 167 | + min-width: 28px; |
| 168 | + min-height: 28px; |
| 169 | + width: 28px; |
| 170 | + height: 28px; |
| 171 | + display: flex; |
| 172 | + align-items: center; |
| 173 | + justify-content: center; |
| 174 | + background: #d5daf5; |
| 175 | + border-radius: 50%; |
| 176 | + font-size: 17px; |
| 177 | + margin-right: 6px; |
| 178 | +} |
| 179 | +.file-pill .file-title { |
| 180 | + flex: 1 1 auto; |
| 181 | + overflow: hidden; |
| 182 | + text-overflow: ellipsis; |
| 183 | + white-space: nowrap; |
| 184 | + font-size: 15px; |
| 185 | + color: #27304e; |
| 186 | + margin-right: 16px; |
| 187 | + margin-left: 0; |
| 188 | +} |
| 189 | +.file-pill .file-actions { |
| 190 | + display: flex; |
| 191 | + gap: 6px; |
| 192 | +} |
| 193 | +.file-pill button { |
| 194 | + background: #fff; |
| 195 | + color: #3b4d77; |
| 196 | + border: 1px solid #b7bedb; |
| 197 | + border-radius: 8px; |
| 198 | + font-size: 14px; |
| 199 | + padding: 5px 9px; |
| 200 | + box-shadow: none; |
| 201 | + margin: 0; |
| 202 | + transition: background 0.18s, border-color 0.18s, color 0.18s; |
| 203 | +} |
| 204 | +.file-pill button:hover, .file-pill button:focus { |
| 205 | + background: #f0f2fa; |
| 206 | + border-color: #7a8bd6; |
| 207 | + color: #2244c7; |
| 208 | +} |
| 209 | +.file-pill .remove-btn { |
| 210 | + color: #a22e2e; |
| 211 | + border-color: #e3b7b7; |
| 212 | +} |
| 213 | +.file-pill .remove-btn:hover, .file-pill .remove-btn:focus { |
| 214 | + color: #fff; |
| 215 | + background: #e55a5a; |
| 216 | + border-color: #d22; |
172 | 217 | } |
173 | | - |
174 | 218 | @media (max-width: 600px) { |
175 | 219 | .tab-content { |
176 | 220 | padding: 16px 4vw; |
|
220 | 264 | </div> |
221 | 265 | </body> |
222 | 266 | <script> |
223 | | - showTabContent('tab1') |
224 | | -document.getElementById('newMessageBtn').addEventListener('click', function() { |
225 | | - document.getElementById('message').value = ''; |
226 | | - let fileInput = document.getElementById('fileInput'); |
227 | | - if(fileInput) fileInput.value = ''; |
228 | | - let msgNum = Math.floor(Math.random() * 900000) + 100000; |
229 | | - document.getElementById('messageNum').value = msgNum; |
230 | | -}); |
| 267 | + showTabContent('tab1'); |
| 268 | + document.getElementById('newMessageBtn').addEventListener('click', function() { |
| 269 | + document.getElementById('plaintext').value = ''; |
| 270 | + let fileInput = document.getElementById('fileInput'); |
| 271 | + if(fileInput) fileInput.value = ''; |
| 272 | + attachedFiles = []; |
| 273 | + updateAttachedFilesList(); |
| 274 | + let msgNum = Math.floor(Math.random() * 900000) + 100000; |
| 275 | + document.getElementById('num').value = msgNum; |
| 276 | + }); |
| 277 | + |
231 | 278 | function strToBuf(str) { |
232 | 279 | return new TextEncoder().encode(str); |
233 | 280 | } |
|
270 | 317 | document.getElementById('downloadAttachedBtn').style.display = "none"; |
271 | 318 | }); |
272 | 319 |
|
| 320 | + function getFileTypeIcon(fileName) { |
| 321 | + const ext = fileName.split('.').pop().toLowerCase(); |
| 322 | + if (['jpg','jpeg','png','gif','bmp','svg','webp'].includes(ext)) return '🖼️'; |
| 323 | + if (['pdf'].includes(ext)) return '📄'; |
| 324 | + if (['doc','docx'].includes(ext)) return '📝'; |
| 325 | + if (['xls','xlsx','csv'].includes(ext)) return '📊'; |
| 326 | + if (['ppt','pptx'].includes(ext)) return '📊'; |
| 327 | + if (['zip','rar','7z','tar','gz'].includes(ext)) return '🗜️'; |
| 328 | + if (['mp3','wav','ogg','m4a'].includes(ext)) return '🎵'; |
| 329 | + if (['mp4','avi','mov','mkv'].includes(ext)) return '🎬'; |
| 330 | + if (['txt','md','rtf','json','log'].includes(ext)) return '📃'; |
| 331 | + return '📁'; |
| 332 | + } |
| 333 | + |
273 | 334 | function updateAttachedFilesList() { |
274 | 335 | const list = document.getElementById('attachedFilesList'); |
275 | 336 | list.innerHTML = ""; |
276 | 337 | if (attachedFiles.length > 0) { |
277 | | - attachedFiles.forEach(f => { |
| 338 | + attachedFiles.forEach((f, i) => { |
278 | 339 | const li = document.createElement('li'); |
279 | | - li.textContent = f.name; |
| 340 | + li.className = "file-pill"; |
| 341 | + |
| 342 | + const icon = document.createElement('span'); |
| 343 | + icon.className = "file-icon"; |
| 344 | + icon.textContent = getFileTypeIcon(f.name); |
| 345 | + |
| 346 | + const title = document.createElement('span'); |
| 347 | + title.className = "file-title"; |
| 348 | + title.textContent = f.name; |
| 349 | + |
| 350 | + const actions = document.createElement('span'); |
| 351 | + actions.className = "file-actions"; |
| 352 | + |
| 353 | + const downloadBtn = document.createElement('button'); |
| 354 | + downloadBtn.type = "button"; |
| 355 | + downloadBtn.title = "Download"; |
| 356 | + downloadBtn.innerHTML = "⬇️"; |
| 357 | + downloadBtn.onclick = function() { |
| 358 | + const blob = new Blob([f], {type: f.type}); |
| 359 | + const url = URL.createObjectURL(blob); |
| 360 | + const a = document.createElement('a'); |
| 361 | + a.href = url; |
| 362 | + a.download = f.name; |
| 363 | + document.body.appendChild(a); |
| 364 | + a.click(); |
| 365 | + setTimeout(() => { |
| 366 | + document.body.removeChild(a); |
| 367 | + URL.revokeObjectURL(url); |
| 368 | + }, 100); |
| 369 | + }; |
| 370 | + |
| 371 | + const removeBtn = document.createElement('button'); |
| 372 | + removeBtn.type = "button"; |
| 373 | + removeBtn.title = "Remove"; |
| 374 | + removeBtn.className = "remove-btn"; |
| 375 | + removeBtn.innerHTML = "🗑️"; |
| 376 | + removeBtn.onclick = function() { |
| 377 | + attachedFiles.splice(i, 1); |
| 378 | + updateAttachedFilesList(); |
| 379 | + }; |
| 380 | + |
| 381 | + actions.appendChild(downloadBtn); |
| 382 | + actions.appendChild(removeBtn); |
| 383 | + |
| 384 | + li.appendChild(icon); |
| 385 | + li.appendChild(title); |
| 386 | + li.appendChild(actions); |
| 387 | + |
280 | 388 | list.appendChild(li); |
281 | 389 | }); |
282 | 390 | } |
|
420 | 528 | }, 100); |
421 | 529 | }); |
422 | 530 | } |
423 | | - |
| 531 | + |
424 | 532 | function showTabContent(tabId) { |
425 | 533 | document.querySelectorAll('.tab-content').forEach( |
426 | 534 | c => c.classList.remove('active')); |
|
0 commit comments