Update index.html
Browse files- index.html +193 -182
index.html
CHANGED
|
@@ -40,58 +40,66 @@
|
|
| 40 |
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
| 41 |
}
|
| 42 |
|
| 43 |
-
.
|
| 44 |
-
padding:
|
| 45 |
background: #f8f9fa;
|
| 46 |
border-bottom: 2px solid #e9ecef;
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
-
.
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
-
.
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
| 60 |
}
|
| 61 |
|
| 62 |
-
.
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
cursor: pointer;
|
| 67 |
-
transition: all 0.3s ease;
|
| 68 |
-
border: 2px solid #e9ecef;
|
| 69 |
-
display: flex;
|
| 70 |
-
align-items: center;
|
| 71 |
-
gap: 8px;
|
| 72 |
-
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
| 73 |
}
|
| 74 |
|
| 75 |
-
.
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
| 79 |
}
|
| 80 |
|
| 81 |
-
.
|
| 82 |
-
|
| 83 |
-
color:
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
|
| 87 |
.file-count {
|
| 88 |
-
|
| 89 |
-
padding:
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 94 |
display: inline-block;
|
|
|
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
|
| 97 |
.tabs {
|
|
@@ -100,6 +108,7 @@
|
|
| 100 |
padding: 0 20px;
|
| 101 |
overflow-x: auto;
|
| 102 |
border-bottom: 3px solid #e9ecef;
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
.tabs::-webkit-scrollbar {
|
|
@@ -127,6 +136,9 @@
|
|
| 127 |
position: relative;
|
| 128 |
border-radius: 10px 10px 0 0;
|
| 129 |
margin-top: 5px;
|
|
|
|
|
|
|
|
|
|
| 130 |
}
|
| 131 |
|
| 132 |
.tab:hover {
|
|
@@ -150,6 +162,18 @@
|
|
| 150 |
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
| 151 |
}
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
.content {
|
| 154 |
padding: 30px;
|
| 155 |
min-height: 500px;
|
|
@@ -180,7 +204,7 @@
|
|
| 180 |
height: 700px;
|
| 181 |
border: 2px solid #e9ecef;
|
| 182 |
border-radius: 10px;
|
| 183 |
-
background:
|
| 184 |
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 185 |
}
|
| 186 |
|
|
@@ -205,31 +229,23 @@
|
|
| 205 |
.empty-state p {
|
| 206 |
font-size: 1.1em;
|
| 207 |
}
|
| 208 |
-
|
| 209 |
-
.error-message {
|
| 210 |
-
text-align: center;
|
| 211 |
-
padding: 50px;
|
| 212 |
-
color: #dc3545;
|
| 213 |
-
}
|
| 214 |
-
|
| 215 |
-
.error-message h2 {
|
| 216 |
-
margin-bottom: 10px;
|
| 217 |
-
}
|
| 218 |
</style>
|
| 219 |
</head>
|
| 220 |
<body>
|
| 221 |
<div class="container">
|
| 222 |
<div class="header">
|
| 223 |
-
<h1>📄 PDF
|
| 224 |
-
<p>
|
| 225 |
</div>
|
| 226 |
|
| 227 |
-
<div class="
|
| 228 |
-
<div class="
|
| 229 |
-
<
|
| 230 |
-
<
|
|
|
|
| 231 |
</div>
|
| 232 |
-
<
|
|
|
|
| 233 |
</div>
|
| 234 |
|
| 235 |
<div class="tabs" id="tabs"></div>
|
|
@@ -241,149 +257,153 @@
|
|
| 241 |
<polyline points="14 2 14 8 20 8"></polyline>
|
| 242 |
<line x1="16" y1="13" x2="8" y2="13"></line>
|
| 243 |
<line x1="16" y1="17" x2="8" y2="17"></line>
|
| 244 |
-
<polyline points="10 9 9 9 8 9"></polyline>
|
| 245 |
</svg>
|
| 246 |
-
<h2>Chưa có
|
| 247 |
-
<p>
|
| 248 |
</div>
|
| 249 |
</div>
|
| 250 |
</div>
|
| 251 |
|
| 252 |
<script>
|
| 253 |
-
const
|
|
|
|
| 254 |
const tabsContainer = document.getElementById('tabs');
|
| 255 |
const contentContainer = document.getElementById('content');
|
| 256 |
-
const
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
});
|
| 289 |
|
| 290 |
-
//
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
function toggleFile(fileName, index, element) {
|
| 295 |
-
if (activeFiles.includes(fileName)) {
|
| 296 |
-
// Remove file
|
| 297 |
-
activeFiles = activeFiles.filter(f => f !== fileName);
|
| 298 |
-
element.classList.remove('active');
|
| 299 |
-
removeTab(fileName);
|
| 300 |
-
} else {
|
| 301 |
-
// Add file
|
| 302 |
-
activeFiles.push(fileName);
|
| 303 |
-
element.classList.add('active');
|
| 304 |
-
addTab(fileName, activeFiles.length - 1);
|
| 305 |
}
|
| 306 |
}
|
| 307 |
|
| 308 |
-
function
|
| 309 |
-
pdfFiles.forEach((fileName, index) => {
|
| 310 |
-
activeFiles.push(fileName);
|
| 311 |
-
const fileItems = fileListContainer.querySelectorAll('.file-item');
|
| 312 |
-
fileItems[index].classList.add('active');
|
| 313 |
-
addTab(fileName, index);
|
| 314 |
-
});
|
| 315 |
-
}
|
| 316 |
-
|
| 317 |
-
function addTab(fileName, index) {
|
| 318 |
// Create tab
|
| 319 |
const tab = document.createElement('button');
|
| 320 |
-
tab.className = 'tab' + (
|
| 321 |
-
tab.
|
| 322 |
-
|
| 323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
tabsContainer.appendChild(tab);
|
| 325 |
|
| 326 |
// Create content
|
| 327 |
const tabContent = document.createElement('div');
|
| 328 |
-
tabContent.className = 'tab-content' + (
|
| 329 |
-
tabContent.dataset.
|
| 330 |
-
|
| 331 |
-
// Create
|
| 332 |
-
const
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
tabContent.innerHTML = `
|
| 340 |
-
<div class="error-message">
|
| 341 |
-
<h2>❌ Không thể hiển thị PDF</h2>
|
| 342 |
-
<p><strong>${fileName}</strong> không tồn tại hoặc không thể truy cập</p>
|
| 343 |
-
<p style="margin-top: 15px;">
|
| 344 |
-
<a href="${fileName}" target="_blank" style="color: #667eea; text-decoration: none; font-weight: bold;">
|
| 345 |
-
🔗 Thử mở trực tiếp file này
|
| 346 |
-
</a>
|
| 347 |
-
</p>
|
| 348 |
-
</div>
|
| 349 |
-
`;
|
| 350 |
};
|
| 351 |
-
|
| 352 |
-
tabContent.appendChild(pdfEmbed);
|
| 353 |
|
| 354 |
contentContainer.innerHTML = '';
|
|
|
|
|
|
|
| 355 |
contentContainer.appendChild(tabContent);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
|
| 357 |
-
// Update
|
| 358 |
-
const
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
|
|
|
|
|
|
| 366 |
}
|
| 367 |
|
| 368 |
-
function
|
|
|
|
|
|
|
|
|
|
| 369 |
// Remove tab
|
| 370 |
-
const tab = tabsContainer.querySelector(`[data-
|
| 371 |
-
if (tab)
|
| 372 |
-
const wasActive = tab.classList.contains('active');
|
| 373 |
-
tab.remove();
|
| 374 |
-
|
| 375 |
-
// If removed tab was active, activate first remaining tab
|
| 376 |
-
if (wasActive && activeFiles.length > 0) {
|
| 377 |
-
switchTab(activeFiles[0]);
|
| 378 |
-
}
|
| 379 |
-
}
|
| 380 |
|
| 381 |
// Remove content
|
| 382 |
-
const content = contentContainer.querySelector(`[data-
|
| 383 |
if (content) content.remove();
|
| 384 |
|
| 385 |
-
//
|
| 386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
contentContainer.innerHTML = `
|
| 388 |
<div class="empty-state">
|
| 389 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
@@ -391,28 +411,19 @@
|
|
| 391 |
<polyline points="14 2 14 8 20 8"></polyline>
|
| 392 |
<line x1="16" y1="13" x2="8" y2="13"></line>
|
| 393 |
<line x1="16" y1="17" x2="8" y2="17"></line>
|
| 394 |
-
<polyline points="10 9 9 9 8 9"></polyline>
|
| 395 |
</svg>
|
| 396 |
-
<h2>Chưa có
|
| 397 |
-
<p>
|
| 398 |
</div>
|
| 399 |
`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
}
|
| 401 |
}
|
| 402 |
-
|
| 403 |
-
function switchTab(fileName) {
|
| 404 |
-
// Update tabs
|
| 405 |
-
const tabs = tabsContainer.querySelectorAll('.tab');
|
| 406 |
-
tabs.forEach(tab => {
|
| 407 |
-
tab.classList.toggle('active', tab.dataset.file === fileName);
|
| 408 |
-
});
|
| 409 |
-
|
| 410 |
-
// Update content
|
| 411 |
-
const contents = contentContainer.querySelectorAll('.tab-content');
|
| 412 |
-
contents.forEach(content => {
|
| 413 |
-
content.classList.toggle('active', content.dataset.file === fileName);
|
| 414 |
-
});
|
| 415 |
-
}
|
| 416 |
</script>
|
| 417 |
</body>
|
| 418 |
</html>
|
|
|
|
| 40 |
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
| 41 |
}
|
| 42 |
|
| 43 |
+
.upload-section {
|
| 44 |
+
padding: 40px;
|
| 45 |
background: #f8f9fa;
|
| 46 |
border-bottom: 2px solid #e9ecef;
|
| 47 |
+
text-align: center;
|
| 48 |
}
|
| 49 |
|
| 50 |
+
.upload-area {
|
| 51 |
+
border: 3px dashed #667eea;
|
| 52 |
+
border-radius: 15px;
|
| 53 |
+
padding: 60px 20px;
|
| 54 |
+
background: white;
|
| 55 |
+
transition: all 0.3s ease;
|
| 56 |
+
cursor: pointer;
|
| 57 |
}
|
| 58 |
|
| 59 |
+
.upload-area:hover {
|
| 60 |
+
border-color: #764ba2;
|
| 61 |
+
background: #f8f9ff;
|
| 62 |
+
transform: translateY(-5px);
|
| 63 |
+
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
|
| 64 |
}
|
| 65 |
|
| 66 |
+
.upload-area.dragover {
|
| 67 |
+
border-color: #764ba2;
|
| 68 |
+
background: #f0f0ff;
|
| 69 |
+
transform: scale(1.02);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
+
.upload-icon {
|
| 73 |
+
font-size: 4em;
|
| 74 |
+
margin-bottom: 20px;
|
|
|
|
| 75 |
}
|
| 76 |
|
| 77 |
+
.upload-text {
|
| 78 |
+
font-size: 1.3em;
|
| 79 |
+
color: #495057;
|
| 80 |
+
margin-bottom: 10px;
|
| 81 |
+
font-weight: 600;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.upload-hint {
|
| 85 |
+
color: #6c757d;
|
| 86 |
+
font-size: 1em;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
#fileInput {
|
| 90 |
+
display: none;
|
| 91 |
}
|
| 92 |
|
| 93 |
.file-count {
|
| 94 |
+
margin-top: 20px;
|
| 95 |
+
padding: 15px 30px;
|
| 96 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 97 |
+
color: white;
|
| 98 |
+
border-radius: 30px;
|
|
|
|
| 99 |
display: inline-block;
|
| 100 |
+
font-weight: bold;
|
| 101 |
+
font-size: 1.1em;
|
| 102 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
| 103 |
}
|
| 104 |
|
| 105 |
.tabs {
|
|
|
|
| 108 |
padding: 0 20px;
|
| 109 |
overflow-x: auto;
|
| 110 |
border-bottom: 3px solid #e9ecef;
|
| 111 |
+
gap: 5px;
|
| 112 |
}
|
| 113 |
|
| 114 |
.tabs::-webkit-scrollbar {
|
|
|
|
| 136 |
position: relative;
|
| 137 |
border-radius: 10px 10px 0 0;
|
| 138 |
margin-top: 5px;
|
| 139 |
+
display: flex;
|
| 140 |
+
align-items: center;
|
| 141 |
+
gap: 8px;
|
| 142 |
}
|
| 143 |
|
| 144 |
.tab:hover {
|
|
|
|
| 162 |
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
| 163 |
}
|
| 164 |
|
| 165 |
+
.close-tab {
|
| 166 |
+
margin-left: 8px;
|
| 167 |
+
color: #dc3545;
|
| 168 |
+
font-weight: bold;
|
| 169 |
+
opacity: 0.6;
|
| 170 |
+
transition: opacity 0.2s;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.close-tab:hover {
|
| 174 |
+
opacity: 1;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
.content {
|
| 178 |
padding: 30px;
|
| 179 |
min-height: 500px;
|
|
|
|
| 204 |
height: 700px;
|
| 205 |
border: 2px solid #e9ecef;
|
| 206 |
border-radius: 10px;
|
| 207 |
+
background: #f8f9fa;
|
| 208 |
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 209 |
}
|
| 210 |
|
|
|
|
| 229 |
.empty-state p {
|
| 230 |
font-size: 1.1em;
|
| 231 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
</style>
|
| 233 |
</head>
|
| 234 |
<body>
|
| 235 |
<div class="container">
|
| 236 |
<div class="header">
|
| 237 |
+
<h1>📄 PDF Tab Viewer</h1>
|
| 238 |
+
<p>Chọn hoặc kéo thả nhiều file PDF để xem</p>
|
| 239 |
</div>
|
| 240 |
|
| 241 |
+
<div class="upload-section">
|
| 242 |
+
<div class="upload-area" id="uploadArea">
|
| 243 |
+
<div class="upload-icon">📁</div>
|
| 244 |
+
<div class="upload-text">Nhấn để chọn file PDF</div>
|
| 245 |
+
<div class="upload-hint">hoặc kéo thả file vào đây (có thể chọn nhiều file)</div>
|
| 246 |
</div>
|
| 247 |
+
<input type="file" id="fileInput" accept=".pdf" multiple>
|
| 248 |
+
<div class="file-count" id="fileCount" style="display: none;">0 file đã chọn</div>
|
| 249 |
</div>
|
| 250 |
|
| 251 |
<div class="tabs" id="tabs"></div>
|
|
|
|
| 257 |
<polyline points="14 2 14 8 20 8"></polyline>
|
| 258 |
<line x1="16" y1="13" x2="8" y2="13"></line>
|
| 259 |
<line x1="16" y1="17" x2="8" y2="17"></line>
|
|
|
|
| 260 |
</svg>
|
| 261 |
+
<h2>Chưa có PDF nào</h2>
|
| 262 |
+
<p>Chọn hoặc kéo thả file PDF ở trên để bắt đầu xem</p>
|
| 263 |
</div>
|
| 264 |
</div>
|
| 265 |
</div>
|
| 266 |
|
| 267 |
<script>
|
| 268 |
+
const uploadArea = document.getElementById('uploadArea');
|
| 269 |
+
const fileInput = document.getElementById('fileInput');
|
| 270 |
const tabsContainer = document.getElementById('tabs');
|
| 271 |
const contentContainer = document.getElementById('content');
|
| 272 |
+
const fileCountEl = document.getElementById('fileCount');
|
| 273 |
|
| 274 |
+
let pdfFiles = [];
|
| 275 |
+
let activeIndex = 0;
|
| 276 |
+
|
| 277 |
+
// Click to select files
|
| 278 |
+
uploadArea.addEventListener('click', () => {
|
| 279 |
+
fileInput.click();
|
| 280 |
+
});
|
| 281 |
+
|
| 282 |
+
// File input change
|
| 283 |
+
fileInput.addEventListener('change', (e) => {
|
| 284 |
+
handleFiles(e.target.files);
|
| 285 |
+
});
|
| 286 |
+
|
| 287 |
+
// Drag and drop
|
| 288 |
+
uploadArea.addEventListener('dragover', (e) => {
|
| 289 |
+
e.preventDefault();
|
| 290 |
+
uploadArea.classList.add('dragover');
|
| 291 |
+
});
|
| 292 |
+
|
| 293 |
+
uploadArea.addEventListener('dragleave', () => {
|
| 294 |
+
uploadArea.classList.remove('dragover');
|
| 295 |
+
});
|
| 296 |
+
|
| 297 |
+
uploadArea.addEventListener('drop', (e) => {
|
| 298 |
+
e.preventDefault();
|
| 299 |
+
uploadArea.classList.remove('dragover');
|
| 300 |
+
const files = Array.from(e.dataTransfer.files).filter(f => f.type === 'application/pdf');
|
| 301 |
+
handleFiles(files);
|
| 302 |
+
});
|
| 303 |
+
|
| 304 |
+
function handleFiles(files) {
|
| 305 |
+
if (files.length === 0) return;
|
| 306 |
+
|
| 307 |
+
const newFiles = Array.from(files);
|
| 308 |
+
pdfFiles = [...pdfFiles, ...newFiles];
|
| 309 |
+
|
| 310 |
+
// Update file count
|
| 311 |
+
fileCountEl.style.display = 'inline-block';
|
| 312 |
+
fileCountEl.textContent = `${pdfFiles.length} file đã chọn`;
|
| 313 |
+
|
| 314 |
+
// Add new tabs and content
|
| 315 |
+
newFiles.forEach((file, idx) => {
|
| 316 |
+
const fileIndex = pdfFiles.length - newFiles.length + idx;
|
| 317 |
+
addTab(file, fileIndex);
|
| 318 |
});
|
| 319 |
|
| 320 |
+
// Activate first new file
|
| 321 |
+
if (newFiles.length > 0) {
|
| 322 |
+
switchTab(pdfFiles.length - newFiles.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
}
|
| 324 |
}
|
| 325 |
|
| 326 |
+
function addTab(file, index) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
// Create tab
|
| 328 |
const tab = document.createElement('button');
|
| 329 |
+
tab.className = 'tab' + (pdfFiles.length === 1 ? ' active' : '');
|
| 330 |
+
tab.innerHTML = `
|
| 331 |
+
<span>📄</span>
|
| 332 |
+
<span>${file.name}</span>
|
| 333 |
+
<span class="close-tab" onclick="event.stopPropagation(); closeTab(${index})">×</span>
|
| 334 |
+
`;
|
| 335 |
+
tab.onclick = () => switchTab(index);
|
| 336 |
+
tab.dataset.index = index;
|
| 337 |
tabsContainer.appendChild(tab);
|
| 338 |
|
| 339 |
// Create content
|
| 340 |
const tabContent = document.createElement('div');
|
| 341 |
+
tabContent.className = 'tab-content' + (pdfFiles.length === 1 ? ' active' : '');
|
| 342 |
+
tabContent.dataset.index = index;
|
| 343 |
+
|
| 344 |
+
// Create PDF viewer
|
| 345 |
+
const reader = new FileReader();
|
| 346 |
+
reader.onload = function(e) {
|
| 347 |
+
const embed = document.createElement('embed');
|
| 348 |
+
embed.src = e.target.result;
|
| 349 |
+
embed.type = 'application/pdf';
|
| 350 |
+
embed.className = 'pdf-viewer';
|
| 351 |
+
tabContent.appendChild(embed);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
};
|
| 353 |
+
reader.readAsDataURL(file);
|
|
|
|
| 354 |
|
| 355 |
contentContainer.innerHTML = '';
|
| 356 |
+
const allContents = document.querySelectorAll('.tab-content');
|
| 357 |
+
allContents.forEach(c => contentContainer.appendChild(c));
|
| 358 |
contentContainer.appendChild(tabContent);
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
function switchTab(index) {
|
| 362 |
+
activeIndex = index;
|
| 363 |
|
| 364 |
+
// Update tabs
|
| 365 |
+
const tabs = tabsContainer.querySelectorAll('.tab');
|
| 366 |
+
tabs.forEach((tab, i) => {
|
| 367 |
+
tab.classList.toggle('active', parseInt(tab.dataset.index) === index);
|
| 368 |
+
});
|
| 369 |
+
|
| 370 |
+
// Update content
|
| 371 |
+
const contents = contentContainer.querySelectorAll('.tab-content');
|
| 372 |
+
contents.forEach((content, i) => {
|
| 373 |
+
content.classList.toggle('active', parseInt(content.dataset.index) === index);
|
| 374 |
+
});
|
| 375 |
}
|
| 376 |
|
| 377 |
+
function closeTab(index) {
|
| 378 |
+
// Remove from array
|
| 379 |
+
pdfFiles.splice(index, 1);
|
| 380 |
+
|
| 381 |
// Remove tab
|
| 382 |
+
const tab = tabsContainer.querySelector(`[data-index="${index}"]`);
|
| 383 |
+
if (tab) tab.remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
|
| 385 |
// Remove content
|
| 386 |
+
const content = contentContainer.querySelector(`[data-index="${index}"]`);
|
| 387 |
if (content) content.remove();
|
| 388 |
|
| 389 |
+
// Update indices
|
| 390 |
+
const tabs = tabsContainer.querySelectorAll('.tab');
|
| 391 |
+
tabs.forEach((tab, i) => {
|
| 392 |
+
if (parseInt(tab.dataset.index) > index) {
|
| 393 |
+
tab.dataset.index = parseInt(tab.dataset.index) - 1;
|
| 394 |
+
}
|
| 395 |
+
});
|
| 396 |
+
|
| 397 |
+
const contents = contentContainer.querySelectorAll('.tab-content');
|
| 398 |
+
contents.forEach((content, i) => {
|
| 399 |
+
if (parseInt(content.dataset.index) > index) {
|
| 400 |
+
content.dataset.index = parseInt(content.dataset.index) - 1;
|
| 401 |
+
}
|
| 402 |
+
});
|
| 403 |
+
|
| 404 |
+
// Update file count
|
| 405 |
+
if (pdfFiles.length === 0) {
|
| 406 |
+
fileCountEl.style.display = 'none';
|
| 407 |
contentContainer.innerHTML = `
|
| 408 |
<div class="empty-state">
|
| 409 |
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
|
|
| 411 |
<polyline points="14 2 14 8 20 8"></polyline>
|
| 412 |
<line x1="16" y1="13" x2="8" y2="13"></line>
|
| 413 |
<line x1="16" y1="17" x2="8" y2="17"></line>
|
|
|
|
| 414 |
</svg>
|
| 415 |
+
<h2>Chưa có PDF nào</h2>
|
| 416 |
+
<p>Chọn hoặc kéo thả file PDF ở trên để bắt đầu xem</p>
|
| 417 |
</div>
|
| 418 |
`;
|
| 419 |
+
} else {
|
| 420 |
+
fileCountEl.textContent = `${pdfFiles.length} file đã chọn`;
|
| 421 |
+
// Switch to first tab if active was closed
|
| 422 |
+
if (activeIndex >= pdfFiles.length) {
|
| 423 |
+
switchTab(Math.max(0, pdfFiles.length - 1));
|
| 424 |
+
}
|
| 425 |
}
|
| 426 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
</script>
|
| 428 |
</body>
|
| 429 |
</html>
|