Spaces:
Running
Running
File size: 38,724 Bytes
ecbdee5 |
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 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 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced File Finder</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Inter', sans-serif;
}
.file-icon {
color: #6366f1;
}
.folder-icon {
color: #f59e0b;
}
.sort-active {
background-color: #e0e7ff;
}
.file-row:hover {
background-color: #f8fafc;
transform: translateY(-1px);
}
.sidebar-item:hover {
background-color: #f1f5f9;
}
.transition-all {
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-shadow {
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}
.modal-shadow {
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.glow {
animation: glow 2s infinite alternate;
}
@keyframes glow {
from {
box-shadow: 0 0 0px 0px rgba(99, 102, 241, 0.3);
}
to {
box-shadow: 0 0 8px 2px rgba(99, 102, 241, 0.3);
}
}
.highlight {
background: linear-gradient(90deg, rgba(224,231,255,0) 0%, rgba(224,231,255,0.5) 50%, rgba(224,231,255,0) 100%);
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f5f9;
border-radius: 4px;
}
::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
</style>
</head>
<body class="bg-slate-50">
<div id="app" class="flex h-screen">
<!-- Sidebar -->
<div class="w-64 bg-white border-r border-slate-200 flex flex-col">
<div class="p-5 border-b border-slate-200">
<div class="flex items-center space-x-3 mb-6">
<div class="w-9 h-9 rounded-lg bg-indigo-100 flex items-center justify-center">
<i class="fas fa-search text-indigo-500"></i>
</div>
<h1 class="text-xl font-semibold text-slate-800">Advanced Finder</h1>
</div>
<div class="relative">
<input
type="text"
v-model="sidebarSearch"
placeholder="Search locations..."
class="w-full px-4 py-2.5 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent placeholder-slate-400"
>
<i class="fas fa-search absolute right-3 top-3 text-slate-400"></i>
</div>
</div>
<div class="flex-1 overflow-y-auto">
<div class="p-2">
<div
v-for="location in filteredLocations"
:key="location.id"
class="sidebar-item px-3 py-2.5 rounded-lg cursor-pointer flex items-center transition-all group"
:class="{'bg-indigo-50': currentLocation.id === location.id}"
@click="selectLocation(location)"
>
<div class="w-8 h-8 rounded-md flex items-center justify-center mr-2"
:class="{'bg-indigo-100': currentLocation.id === location.id, 'bg-slate-100 group-hover:bg-slate-200': currentLocation.id !== location.id}">
<i :class="location.icon" class="text-slate-600 group-hover:text-slate-800"
:class="{'text-indigo-500': currentLocation.id === location.id}"></i>
</div>
<span class="text-sm font-medium truncate"
:class="{'text-indigo-600': currentLocation.id === location.id, 'text-slate-700 group-hover:text-slate-900': currentLocation.id !== location.id}">
{{ location.name }}
</span>
</div>
</div>
</div>
<div class="p-4 border-t border-slate-200 text-xs text-slate-500 bg-slate-50">
<div class="flex items-center mb-1">
<i class="fas fa-database mr-2"></i>
<span>Indexed: {{ indexedCount }} items</span>
</div>
<div class="flex items-center">
<i class="fas fa-sync-alt mr-2"></i>
<span>Last indexed: {{ lastIndexed }}</span>
</div>
</div>
</div>
<!-- Main Content -->
<div class="flex-1 flex flex-col overflow-hidden">
<!-- Toolbar -->
<div class="bg-white border-b border-slate-200 p-4 flex items-center justify-between">
<div class="flex items-center space-x-2">
<button
class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 flex items-center transition-all focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
@click="refreshFiles"
>
<i class="fas fa-sync-alt mr-2"></i> Refresh
</button>
<button
class="px-4 py-2 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 flex items-center transition-all focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
@click="toggleIndexing"
:class="{'glow': isIndexing}"
>
<i class="fas fa-database mr-2" :class="{'text-indigo-600': isIndexing}"></i>
<span v-if="isIndexing">Indexing...</span>
<span v-else>Index Now</span>
</button>
<div class="relative" v-if="selectedFiles.length > 0">
<button
class="px-4 py-2 bg-red-50 text-red-600 rounded-lg hover:bg-red-100 flex items-center transition-all focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2"
@click="showDeleteConfirm = true"
>
<i class="fas fa-trash mr-2"></i> Delete ({{ selectedFiles.length }})
</button>
</div>
</div>
<div class="flex items-center space-x-3">
<div class="relative">
<input
type="text"
v-model="searchQuery"
placeholder="Search files..."
class="px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent w-64 placeholder-slate-400"
>
<i class="fas fa-search absolute right-3 top-3 text-slate-400"></i>
</div>
<button
class="px-4 py-2 bg-white border border-slate-200 rounded-lg hover:bg-slate-50 flex items-center transition-all focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
@click="showAdvancedSearch = !showAdvancedSearch"
>
<i class="fas fa-sliders-h mr-2"></i> Filters
</button>
</div>
</div>
<!-- Advanced Search Panel -->
<div
class="bg-white border-b border-slate-200 px-5 py-4 transition-all duration-300 ease-in-out overflow-hidden"
:style="showAdvancedSearch ? 'max-height: 240px' : 'max-height: 0'"
>
<div class="grid grid-cols-1 md:grid-cols-3 gap-5">
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">File Type</label>
<select
v-model="filters.fileType"
class="w-full px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
>
<option value="all">All Files</option>
<option value="documents">Documents</option>
<option value="images">Images</option>
<option value="audio">Audio</option>
<option value="video">Video</option>
<option value="archives">Archives</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">Author/Creator</label>
<input
type="text"
v-model="filters.author"
placeholder="Search by author..."
class="w-full px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent placeholder-slate-400"
>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">Size Range</label>
<div class="flex items-center space-x-3">
<input
type="number"
v-model="filters.sizeMin"
placeholder="Min (KB)"
class="w-full px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent placeholder-slate-400"
>
<span class="text-sm text-slate-400">to</span>
<input
type="number"
v-model="filters.sizeMax"
placeholder="Max (KB)"
class="w-full px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent placeholder-slate-400"
>
</div>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">Date Modified</label>
<select
v-model="filters.dateRange"
class="w-full px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
>
<option value="all">Any Time</option>
<option value="today">Today</option>
<option value="week">This Week</option>
<option value="month">This Month</option>
<option value="year">This Year</option>
<option value="custom">Custom Range</option>
</select>
</div>
<div v-if="filters.dateRange === 'custom'" class="md:col-span-3">
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">From</label>
<input
type="date"
v-model="filters.dateFrom"
class="w-full px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">To</label>
<input
type="date"
v-model="filters.dateTo"
class="w-full px-4 py-2 text-sm border border-slate-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
>
</div>
</div>
</div>
</div>
</div>
<!-- File Table Header -->
<div class="bg-white border-b border-slate-200 px-5 py-3">
<div class="grid grid-cols-12 gap-4 text-xs font-medium text-slate-500 uppercase tracking-wider">
<div class="col-span-5 flex items-center">
<input
type="checkbox"
class="mr-3 h-4 w-4 text-indigo-600 rounded border-slate-300 focus:ring-indigo-500"
@change="toggleSelectAll"
:checked="selectedFiles.length === filteredFiles.length && filteredFiles.length > 0"
>
<span
class="cursor-pointer flex items-center hover:text-slate-700 transition-colors"
@click="sortBy('name')"
>
Name
<i
class="fas ml-1"
:class="{
'fa-sort': activeSort !== 'name',
'fa-sort-up': activeSort === 'name' && sortDirection === 'asc',
'fa-sort-down': activeSort === 'name' && sortDirection === 'desc'
}"
></i>
</span>
</div>
<div
class="col-span-2 cursor-pointer flex items-center hover:text-slate-700 transition-colors"
@click="sortBy('author')"
>
<span>Author</span>
<i
class="fas ml-1"
:class="{
'fa-sort': activeSort !== 'author',
'fa-sort-up': activeSort === 'author' && sortDirection === 'asc',
'fa-sort-down': activeSort === 'author' && sortDirection === 'desc'
}"
></i>
</div>
<div
class="col-span-2 cursor-pointer flex items-center hover:text-slate-700 transition-colors"
@click="sortBy('type')"
>
<span>Type</span>
<i
class="fas ml-1"
:class="{
'fa-sort': activeSort !== 'type',
'fa-sort-up': activeSort === 'type' && sortDirection === 'asc',
'fa-sort-down': activeSort === 'type' && sortDirection === 'desc'
}"
></i>
</div>
<div
class="col-span-2 cursor-pointer flex items-center justify-end hover:text-slate-700 transition-colors"
@click="sortBy('size')"
>
<span>Size</span>
<i
class="fas ml-1"
:class="{
'fa-sort': activeSort !== 'size',
'fa-sort-up': activeSort === 'size' && sortDirection === 'asc',
'fa-sort-down': activeSort === 'size' && sortDirection === 'desc'
}"
></i>
</div>
<div
class="col-span-1 cursor-pointer flex items-center justify-end hover:text-slate-700 transition-colors"
@click="sortBy('modified')"
>
<span>Modified</span>
<i
class="fas ml-1"
:class="{
'fa-sort': activeSort !== 'modified',
'fa-sort-up': activeSort === 'modified' && sortDirection === 'asc',
'fa-sort-down': activeSort === 'modified' && sortDirection === 'desc'
}"
></i>
</div>
</div>
</div>
<!-- File List -->
<div class="flex-1 overflow-y-auto bg-white">
<div v-if="filteredFiles.length === 0" class="flex flex-col items-center justify-center h-64 text-slate-400">
<i class="fas fa-folder-open text-5xl mb-4 opacity-30"></i>
<p class="text-lg font-medium text-slate-500">No files found</p>
<p class="text-sm mt-1 text-slate-400">Try adjusting your search or filters</p>
</div>
<template v-else>
<div
v-for="file in filteredFiles"
:key="file.id"
class="file-row px-5 py-3 border-b border-slate-100 grid grid-cols-12 gap-4 text-sm items-center transition-all"
:class="{'highlight': selectedFiles.includes(file)}"
@dblclick="openFile(file)"
>
<div class="col-span-5 flex items-center truncate">
<input
type="checkbox"
class="mr-3 h-4 w-4 text-indigo-600 rounded border-slate-300 focus:ring-indigo-500"
:checked="selectedFiles.includes(file)"
@change="toggleFileSelection(file, $event)"
>
<div class="w-8 h-8 rounded-md flex items-center justify-center mr-2"
:class="{'bg-indigo-50': selectedFiles.includes(file), 'bg-slate-100': !selectedFiles.includes(file)}">
<i :class="getFileIcon(file)" class="text-slate-600"></i>
</div>
<div class="truncate">
<div class="font-medium text-slate-800 truncate">{{ file.name }}</div>
<div class="text-xs text-slate-500 truncate">{{ file.path || currentLocation.name }}</div>
</div>
<i v-if="file.isFavorite" class="fas fa-star text-yellow-400 ml-2 text-xs"></i>
</div>
<div class="col-span-2 text-slate-600 truncate">
<span class="inline-flex items-center">
<i class="fas fa-user-circle mr-2 text-slate-400"></i>
{{ file.author || 'Unknown' }}
</span>
</div>
<div class="col-span-2 text-slate-600 truncate text-sm">{{ file.type }}</div>
<div class="col-span-2 text-slate-600 text-right text-sm">{{ formatFileSize(file.size) }}</div>
<div class="col-span-1 text-slate-600 text-right text-sm">{{ formatDate(file.modified) }}</div>
</div>
</template>
</div>
<!-- Status Bar -->
<div class="bg-slate-50 border-t border-slate-200 px-5 py-2.5 text-xs text-slate-500 flex justify-between">
<div>
<span v-if="selectedFiles.length > 0" class="font-medium">{{ selectedFiles.length }} selected</span>
<span v-else>{{ filteredFiles.length }} items</span>
</div>
<div class="flex items-center space-x-5">
<div class="flex items-center">
<span class="mr-2">Index status:</span>
<span v-if="isIndexing" class="text-indigo-600 font-medium flex items-center">
<span class="w-2 h-2 rounded-full bg-indigo-500 mr-1.5 animate-pulse"></span>
Running
</span>
<span v-else class="text-slate-400">Idle</span>
</div>
<div class="flex items-center">
<i class="fas fa-circle text-xs mr-1.5" :class="{
'text-emerald-500': performanceRating === 'fast',
'text-amber-500': performanceRating === 'normal',
'text-rose-500': performanceRating === 'slow'
}"></i>
<span>{{ performanceRating }} performance</span>
</div>
</div>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div v-if="showDeleteConfirm" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 backdrop-blur-sm">
<div class="bg-white rounded-xl modal-shadow p-6 w-96">
<div class="flex items-start mb-5">
<div class="flex-shrink-0 mt-1">
<div class="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center">
<i class="fas fa-exclamation-triangle text-red-500"></i>
</div>
</div>
<div class="ml-4">
<h3 class="text-lg font-medium text-slate-800">Delete Files</h3>
<p class="mt-1 text-sm text-slate-500">
Are you sure you want to delete {{ selectedFiles.length }} file(s)? This action cannot be undone.
</p>
</div>
</div>
<div class="mt-6 flex justify-end space-x-3">
<button
type="button"
class="px-4 py-2 bg-white border border-slate-200 rounded-lg text-slate-700 hover:bg-slate-50 transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
@click="showDeleteConfirm = false"
>
Cancel
</button>
<button
type="button"
class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2"
@click="deleteSelectedFiles"
>
Delete
</button>
</div>
</div>
</div>
</div>
<script>
class Reactive {
constructor(data) {
this.data = data;
this.subscribers = [];
}
get(prop) {
return this.data[prop];
}
set(prop, value) {
this.data[prop] = value;
this.notify();
}
subscribe(callback) {
this.subscribers.push(callback);
}
notify() {
this.subscribers.forEach(callback => callback(this.data));
}
}
function bindInput(input, state, property) {
input.value = state.get(property);
input.addEventListener('input', (e) => {
state.set(property, e.target.value);
});
state.subscribe((data) => {
input.value = data[property];
});
}
function renderList(container, template, data) {
container.innerHTML = '';
data.forEach((item, index) => {
const element = document.createElement('div');
element.innerHTML = template(item, index);
container.appendChild(element.firstChild);
});
}
document.addEventListener('DOMContentLoaded', () => {
const state = new Reactive({
sidebarSearch: '',
currentLocation: { id: 1, name: 'Home', icon: 'fas fa-home' },
indexedCount: 2847,
lastIndexed: '5 minutes ago',
searchQuery: '',
showAdvancedSearch: false,
isIndexing: false,
activeSort: 'name',
sortDirection: 'asc',
selectedFiles: [],
showDeleteConfirm: false,
filters: {
fileType: 'all',
author: '',
sizeMin: '',
sizeMax: '',
dateRange: 'all',
dateFrom: '',
dateTo: ''
},
performanceRating: 'fast',
locations: [
{ id: 1, name: 'Home', icon: 'fas fa-home' },
{ id: 2, name: 'Documents', icon: 'fas fa-folder' },
{ id: 3, name: 'Downloads', icon: 'fas fa-download' },
{ id: 4, name: 'Pictures', icon: 'fas fa-image' },
{ id: 5, name: 'Music', icon: 'fas fa-music' },
{ id: 6, name: 'Videos', icon: 'fas fa-video' },
{ id: 7, name: 'Desktop', icon: 'fas fa-desktop' }
],
files: [
{ id: 1, name: 'Project Proposal.pdf', path: 'Documents/Projects', author: 'John Doe', type: 'PDF Document', size: 2456, modified: '2023-06-15T14:30:00', isFavorite: false },
{ id: 2, name: 'Budget 2023.xlsx', path: 'Documents/Finance', author: 'Jane Smith', type: 'Excel Spreadsheet', size: 4532, modified: '2023-05-22T09:45:00', isFavorite: true },
{ id: 3, name: 'Team Photo.jpg', path: 'Pictures/Work', author: 'Mike Johnson', type: 'JPEG Image', size: 3245, modified: '2023-06-10T11:20:00', isFavorite: false },
{ id: 4, name: 'Meeting Notes.docx', path: 'Documents/Meetings', author: 'Sarah Wilson', type: 'Word Document', size: 876, modified: '2023-06-14T16:10:00', isFavorite: false },
{ id: 5, name: 'Presentation.pptx', path: 'Documents/Presentations', author: 'David Brown', type: 'PowerPoint', size: 6543, modified: '2023-06-12T13:30:00', isFavorite: false },
{ id: 6, name: 'Project Backup.zip', path: 'Downloads', author: 'Emma Davis', type: 'ZIP Archive', size: 24567, modified: '2023-06-09T18:05:00', isFavorite: false },
{ id: 7, name: 'Interview.mp3', path: 'Music/Recordings', author: 'James Miller', type: 'MP3 Audio', size: 12345, modified: '2023-05-30T10:15:00', isFavorite: false },
{ id: 8, name: 'Tutorial.mp4', path: 'Videos/Learning', author: 'Olivia Wilson', type: 'MP4 Video', size: 45678, modified: '2023-05-28T14:20:00', isFavorite: false },
{ id: 9, name: 'Configuration.ini', path: 'System', author: 'System', type: 'Configuration File', size: 23, modified: '2023-06-13T12:40:00', isFavorite: false },
{ id: 10, name: 'Code Repository', path: 'Documents/Projects', author: 'John Doe', type: 'Folder', size: 10245, modified: '2023-06-05T08:30:00', isFavorite: true }
]
});
function computedFilteredLocations() {
const search = state.get('sidebarSearch').toLowerCase();
return state.get('locations').filter(loc =>
loc.name.toLowerCase().includes(search)
);
}
function computedFilteredFiles() {
let files = [...state.get('files')];
const filters = state.get('filters');
const search = state.get('searchQuery').toLowerCase();
const activeSort = state.get('activeSort');
const sortDirection = state.get('sortDirection');
if (search) {
files = files.filter(file =>
file.name.toLowerCase().includes(search) ||
file.type.toLowerCase().includes(search) ||
(file.author && file.author.toLowerCase().includes(search))
);
}
if (filters.fileType !== 'all') {
const typeMap = {
'documents': ['PDF Document', 'Word Document', 'Excel Spreadsheet', 'PowerPoint'],
'images': ['JPEG Image', 'PNG Image', 'GIF Image'],
'audio': ['MP3 Audio', 'WAV Audio'],
'video': ['MP4 Video', 'MOV Video'],
'archives': ['ZIP Archive', 'RAR Archive']
};
const types = typeMap[filters.fileType] || [];
files = files.filter(file =>
types.includes(file.type) ||
(filters.fileType === 'documents' && file.type.includes('Document'))
);
}
if (filters.author) {
const authorSearch = filters.author.toLowerCase();
files = files.filter(file =>
file.author && file.author.toLowerCase().includes(authorSearch)
);
}
if (filters.sizeMin || filters.sizeMax) {
const min = filters.sizeMin ? parseInt(filters.sizeMin) : 0;
const max = filters.sizeMax ? parseInt(filters.sizeMax) : Infinity;
files = files.filter(file => file.size >= min && file.size <= max);
}
if (filters.dateRange && filters.dateRange !== 'all') {
const now = new Date();
let fromDate = new Date();
switch (filters.dateRange) {
case 'today':
fromDate.setHours(0, 0, 0, 0);
break;
case 'week':
fromDate.setDate(fromDate.getDate() - 7);
break;
case 'month':
fromDate.setMonth(fromDate.getMonth() - 1);
break;
case 'year':
fromDate.setFullYear(fromDate.getFullYear() - 1);
break;
case 'custom':
if (filters.dateFrom) {
fromDate = new Date(filters.dateFrom);
}
break;
}
files = files.filter(file => {
const fileDate = new Date(file.modified);
return fileDate >= fromDate;
});
if (filters.dateRange === 'custom' && filters.dateTo) {
const toDate = new Date(filters.dateTo);
toDate.setHours(23, 59, 59, 999);
files = files.filter(file => {
const fileDate = new Date(file.modified);
return fileDate <= toDate;
});
}
}
files.sort((a, b) => {
let aVal, bVal;
switch (activeSort) {
case 'name':
aVal = a.name.toLowerCase();
bVal = b.name.toLowerCase();
break;
case 'author':
aVal = a.author ? a.author.toLowerCase() : '';
bVal = b.author ? b.author.toLowerCase() : '';
break;
case 'type':
aVal = a.type.toLowerCase();
bVal = b.type.toLowerCase();
break;
case 'size':
aVal = a.size;
bVal = b.size;
break;
case 'modified':
aVal = new Date(a.modified);
bVal = new Date(b.modified);
break;
default:
aVal = a.name.toLowerCase();
bVal = b.name.toLowerCase();
}
if (aVal < bVal) return sortDirection === 'asc' ? -1 : 1;
if (aVal > bVal) return sortDirection === 'asc' ? 1 : -1;
return 0;
});
return files;
}
function formatFileSize(bytes) {
if (bytes === 0) return '0 Bytes';
if (typeof bytes === 'string') bytes = parseInt(bytes);
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
function formatDate(dateString) {
const date = new Date(dateString);
return date.toLocaleDateString('en-US', {month: 'short', day: 'numeric'});
}
function getFileIcon(file) {
if (file.type === 'Folder') return 'fas fa-folder folder-icon';
const extension = file.name.split('.').pop().toLowerCase();
const iconMap = {
'pdf': 'fas fa-file-pdf file-icon',
'docx': 'fas fa-file-word file-icon',
'xlsx': 'fas fa-file-excel file-icon',
'pptx': 'fas fa-file-powerpoint file-icon',
'jpg': 'fas fa-file-image file-icon',
'jpeg': 'fas fa-file-image file-icon',
'png': 'fas fa-file-image file-icon',
'gif': 'fas fa-file-image file-icon',
'mp3': 'fas fa-file-audio file-icon',
'wav': 'fas fa-file-audio file-icon',
'mp4': 'fas fa-file-video file-icon',
'mov': 'fas fa-file-video file-icon',
'zip': 'fas fa-file-archive file-icon',
'rar': 'fas fa-file-archive file-icon',
'ini': 'fas fa-file-code file-icon'
};
return iconMap[extension] || 'fas fa-file file-icon';
}
function toggleIndexing() {
state.set('isIndexing', !state.get('isIndexing'));
if (state.get('isIndexing')) {
let count = state.get('indexedCount');
const interval = setInterval(() => {
count += Math.floor(Math.random() * 10);
state.set('indexedCount', count);
state.set('lastIndexed', 'Just now');
if (!state.get('isIndexing')) {
clearInterval(interval);
}
}, 3000);
setTimeout(() => {
if (Math.random() > 0.7) {
state.set('isIndexing', false);
}
}, 15000);
}
}
function refreshFiles() {
state.set('performanceRating', ['fast', 'normal', 'slow'][Math.floor(Math.random() * 3)]);
if (Math.random() > 0.7) {
const newFiles = [...state.get('files')];
if (newFiles.length > 5 && Math.random() > 0.5) {
newFiles.splice(Math.floor(Math.random() * newFiles.length), 1);
} else {
const authors = ['John Doe', 'Jane Smith', 'Mike Johnson', 'Sarah Wilson', 'Emma Davis'];
const newFile = {
id: Math.max(...newFiles.map(f => f.id)) + 1,
name: ['New Document.docx', 'Report.pdf', 'Image.jpg', 'Archive.zip', 'Data.xlsx'][Math.floor(Math.random() * 5)],
path: ['Documents', 'Downloads', 'Pictures', 'Music', 'Videos'][Math.floor(Math
</html> |