qol
This commit is contained in:
@@ -1,268 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>File Browser</title>
|
||||
<link rel="stylesheet" href="../style/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="breadcrumbs">Folder Path</div>
|
||||
<div class="path-container" id="pathContainer">
|
||||
<!-- Breadcrumbs will be generated here -->
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="meta">
|
||||
<div id="summary">
|
||||
<span class="meta-item"><b id="dirCount">0</b> directories</span>
|
||||
<span class="meta-item"><b id="fileCount">0</b> files</span>
|
||||
<span class="meta-item"><b id="totalSize">0 B</b> total</span>
|
||||
</div>
|
||||
<div class="layout-toggle">
|
||||
<button class="layout-btn active" id="layoutList" onclick="setLayout('list')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="3" y="3" width="18" height="7" rx="1"></rect>
|
||||
<rect x="3" y="14" width="18" height="7" rx="1"></rect>
|
||||
</svg>
|
||||
List
|
||||
</button>
|
||||
<button class="layout-btn" id="layoutGrid" onclick="setLayout('grid')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="3" y="3" width="7" height="7"></rect>
|
||||
<rect x="14" y="3" width="7" height="7"></rect>
|
||||
<rect x="14" y="14" width="7" height="7"></rect>
|
||||
<rect x="3" y="14" width="7" height="7"></rect>
|
||||
</svg>
|
||||
Grid
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn theme-toggle" onclick="toggleTheme()"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="listing" id="listing">
|
||||
<div class="file-list" id="fileList">
|
||||
<!-- Files will be generated here -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Mock data - replace with actual file data
|
||||
const mockFiles = [
|
||||
{ name: 'documents', type: 'directory', size: null, modified: '2024-11-20' },
|
||||
{ name: 'downloads', type: 'directory', size: null, modified: '2024-11-19' },
|
||||
{ name: 'projects', type: 'directory', size: null, modified: '2024-11-15' },
|
||||
{ name: 'report.pdf', type: 'file', size: 2457600, modified: '2024-11-18' },
|
||||
{ name: 'presentation.pptx', type: 'file', size: 6082560, modified: '2024-11-17' },
|
||||
{ name: 'data.json', type: 'file', size: 350208, modified: '2024-11-16' },
|
||||
{ name: 'notes.txt', type: 'file', size: 12288, modified: '2024-11-14' },
|
||||
{ name: 'archive.zip', type: 'file', size: 131072000, modified: '2024-11-10' },
|
||||
];
|
||||
|
||||
let currentPath = '/home/user/documents';
|
||||
let currentLayout = 'list';
|
||||
|
||||
// Theme management
|
||||
function initTheme() {
|
||||
const savedTheme = localStorage.getItem('theme') || 'dark';
|
||||
document.documentElement.setAttribute('data-theme', savedTheme);
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
const current = document.documentElement.getAttribute('data-theme');
|
||||
const newTheme = current === 'dark' ? 'light' : 'dark';
|
||||
document.documentElement.setAttribute('data-theme', newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
}
|
||||
|
||||
function getIcon(type, name) {
|
||||
if (type === 'directory') return '📁';
|
||||
const ext = name.split('.').pop().toLowerCase();
|
||||
const icons = {
|
||||
pdf: '📄', pptx: '📊', xlsx: '📊', csv: '📊',
|
||||
txt: '📝', md: '📝', json: '🔧', xml: '🔧',
|
||||
jpg: '🖼️', png: '🖼️', gif: '🖼️', svg: '🖼️',
|
||||
zip: '🗜️', rar: '🗜️', "7z": '🗜️',
|
||||
mp3: '🎵', mp4: '🎬', avi: '🎬',
|
||||
py: '🐍', js: '📜', html: '🌐', css: '🎨'
|
||||
};
|
||||
return icons[ext] || '📄';
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
if (!bytes) return '-';
|
||||
const units = ['B', 'KB', 'MB', 'GB'];
|
||||
let size = bytes;
|
||||
let unitIndex = 0;
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024;
|
||||
unitIndex++;
|
||||
}
|
||||
return (size < 10 ? size.toFixed(2) : size.toFixed(0)) + ' ' + units[unitIndex];
|
||||
}
|
||||
|
||||
function formatDate(dateStr) {
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric'
|
||||
});
|
||||
}
|
||||
|
||||
function renderBreadcrumbs() {
|
||||
const parts = currentPath.split('/').filter(p => p);
|
||||
const pathContainer = document.getElementById('pathContainer');
|
||||
let html = '<a href="#" onclick="navigateTo(\'/\'); return false;" class="breadcrumb-link">/</a>';
|
||||
|
||||
let accumulatedPath = '';
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
accumulatedPath += '/' + parts[i];
|
||||
const isLast = i === parts.length - 1;
|
||||
if (isLast) {
|
||||
html += '<span class="breadcrumb-text">' + parts[i] + '</span>';
|
||||
} else {
|
||||
html += '<a href="#" onclick="navigateTo(\'' + accumulatedPath + '\'); return false;" class="breadcrumb-link">' + parts[i] + '</a>';
|
||||
}
|
||||
if (i < parts.length - 1) {
|
||||
html += '<span class="breadcrumb-sep">/</span>';
|
||||
} else {
|
||||
html += '<span class="breadcrumb-sep">/</span>';
|
||||
}
|
||||
}
|
||||
|
||||
pathContainer.innerHTML = html;
|
||||
}
|
||||
|
||||
function renderFileList() {
|
||||
const fileList = document.getElementById('fileList');
|
||||
|
||||
if (mockFiles.length === 0) {
|
||||
fileList.innerHTML = `
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">📭</div>
|
||||
<p>This folder is empty</p>
|
||||
</div>
|
||||
`;
|
||||
updateSummary(0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sort: directories first, then alphabetically
|
||||
const sorted = [...mockFiles].sort((a, b) => {
|
||||
if (a.type === b.type) return a.name.localeCompare(b.name);
|
||||
return a.type === 'directory' ? -1 : 1;
|
||||
});
|
||||
|
||||
let dirCount = 0;
|
||||
let fileCount = 0;
|
||||
let totalSize = 0;
|
||||
|
||||
if (currentLayout === 'grid') {
|
||||
const gridItems = sorted.map(file => {
|
||||
if (file.type === 'directory') dirCount++;
|
||||
else {
|
||||
fileCount++;
|
||||
totalSize += file.size || 0;
|
||||
}
|
||||
return `
|
||||
<div class="grid-item" onclick="handleFileClick('${file.name}', '${file.type}')">
|
||||
<div class="grid-icon">${getIcon(file.type, file.name)}</div>
|
||||
<div class="grid-name">${file.name}</div>
|
||||
${file.size ? `<div class="grid-size">${formatSize(file.size)}</div>` : ''}
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
fileList.innerHTML = `<div class="grid">${gridItems}</div>`;
|
||||
} else {
|
||||
const tableRows = sorted.map(file => {
|
||||
if (file.type === 'directory') dirCount++;
|
||||
else {
|
||||
fileCount++;
|
||||
totalSize += file.size || 0;
|
||||
}
|
||||
return `
|
||||
<tr class="file-row ${file.type}" onclick="handleFileClick('${file.name}', '${file.type}')">
|
||||
<td class="icon">${getIcon(file.type, file.name)}</td>
|
||||
<td class="name">${file.name}</td>
|
||||
<td class="size">${file.size ? formatSize(file.size) : '-'}</td>
|
||||
<td class="date">${formatDate(file.modified)}</td>
|
||||
</tr>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
fileList.innerHTML = `
|
||||
<table class="file-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th>Size</th>
|
||||
<th>Modified</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${tableRows}
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
}
|
||||
|
||||
updateSummary(dirCount, fileCount, totalSize);
|
||||
}
|
||||
|
||||
function updateSummary(dirs, files, bytes) {
|
||||
document.getElementById('dirCount').textContent = dirs;
|
||||
document.getElementById('fileCount').textContent = files;
|
||||
document.getElementById('totalSize').textContent = formatSize(bytes);
|
||||
}
|
||||
|
||||
function handleFileClick(name, type) {
|
||||
if (type === 'directory') {
|
||||
navigateTo(currentPath + (currentPath.endsWith('/') ? '' : '/') + name);
|
||||
} else {
|
||||
console.log('Opening file:', name);
|
||||
}
|
||||
}
|
||||
|
||||
function navigateTo(path) {
|
||||
currentPath = path;
|
||||
renderBreadcrumbs();
|
||||
renderFileList();
|
||||
}
|
||||
|
||||
function navigateUp() {
|
||||
const parts = currentPath.split('/').filter(p => p);
|
||||
if (parts.length > 0) {
|
||||
parts.pop();
|
||||
currentPath = '/' + parts.join('/');
|
||||
if (currentPath === '/') currentPath = '/';
|
||||
navigateTo(currentPath);
|
||||
}
|
||||
}
|
||||
|
||||
function refreshList() {
|
||||
renderFileList();
|
||||
}
|
||||
|
||||
function setLayout(layout) {
|
||||
currentLayout = layout;
|
||||
document.getElementById('layoutList').classList.toggle('active', layout === 'list');
|
||||
document.getElementById('layoutGrid').classList.toggle('active', layout === 'grid');
|
||||
document.getElementById('listing').classList.toggle('list-view', layout === 'list');
|
||||
document.getElementById('listing').classList.toggle('grid-view', layout === 'grid');
|
||||
renderFileList();
|
||||
}
|
||||
|
||||
// Initialize
|
||||
initTheme();
|
||||
renderBreadcrumbs();
|
||||
renderFileList();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,260 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>File Browser</title>
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="">
|
||||
<link rel="stylesheet" href="../style/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="breadcrumbs">Folder Path</div>
|
||||
<div class="path-container" id="pathContainer">
|
||||
<!-- Breadcrumbs will be generated here -->
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="meta">
|
||||
<div id="summary">
|
||||
<span class="meta-item"><b id="dirCount">0</b> directories</span>
|
||||
<span class="meta-item"><b id="fileCount">0</b> files</span>
|
||||
<span class="meta-item"><b id="totalSize">0 B</b> total</span>
|
||||
</div>
|
||||
<button class="btn theme-toggle" onclick="toggleTheme()">🌙</button> <!-- needs svgs -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="listing" id="listing">
|
||||
<div class="file-list" id="fileList">
|
||||
<!-- Files will be generated here -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <script>
|
||||
// Mock data - replace with actual file data
|
||||
const mockFiles = [
|
||||
{ name: 'documents', type: 'directory', size: null, modified: '2024-11-20' },
|
||||
{ name: 'downloads', type: 'directory', size: null, modified: '2024-11-19' },
|
||||
{ name: 'projects', type: 'directory', size: null, modified: '2024-11-15' },
|
||||
{ name: 'report.pdf', type: 'file', size: 2457600, modified: '2024-11-18' },
|
||||
{ name: 'presentation.pptx', type: 'file', size: 6082560, modified: '2024-11-17' },
|
||||
{ name: 'data.json', type: 'file', size: 350208, modified: '2024-11-16' },
|
||||
{ name: 'notes.txt', type: 'file', size: 12288, modified: '2024-11-14' },
|
||||
{ name: 'archive.zip', type: 'file', size: 131072000, modified: '2024-11-10' },
|
||||
];
|
||||
|
||||
let currentPath = '/home/user/documents';
|
||||
let currentLayout = 'list';
|
||||
|
||||
function initTheme()
|
||||
{
|
||||
const savedTheme = localStorage.getItem('theme') || 'dark';
|
||||
document.documentElement.setAttribute('data-theme', savedTheme);
|
||||
updateThemeButton();
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
const current = document.documentElement.getAttribute('data-theme');
|
||||
const newTheme = current === 'dark' ? 'light' : 'dark';
|
||||
document.documentElement.setAttribute('data-theme', newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
updateThemeButton();
|
||||
}
|
||||
|
||||
function updateThemeButton() {
|
||||
const theme = document.documentElement.getAttribute('data-theme');
|
||||
const btn = document.querySelector('.theme-toggle');
|
||||
btn.textContent = theme === 'dark' ? '☀️' : '🌙';
|
||||
}
|
||||
|
||||
function getIcon(type, name) {
|
||||
if (type === 'directory') return '📁';
|
||||
const ext = name.split('.').pop().toLowerCase();
|
||||
const icons = {
|
||||
pdf: '📄', pptx: '📊', xlsx: '📊', csv: '📊',
|
||||
txt: '📝', md: '📝', json: '🔧', xml: '🔧',
|
||||
jpg: '🖼️', png: '🖼️', gif: '🖼️', svg: '🖼️',
|
||||
zip: '🗜️', rar: '🗜️', "7z": '🗜️',
|
||||
mp3: '🎵', mp4: '🎬', avi: '🎬',
|
||||
py: '🐍', js: '📜', html: '🌐', css: '🎨'
|
||||
};
|
||||
return icons[ext] || '📄';
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
if (!bytes) return '-';
|
||||
const units = ['B', 'KB', 'MB', 'GB'];
|
||||
let size = bytes;
|
||||
let unitIndex = 0;
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024;
|
||||
unitIndex++;
|
||||
}
|
||||
return (size < 10 ? size.toFixed(2) : size.toFixed(0)) + ' ' + units[unitIndex];
|
||||
}
|
||||
|
||||
function formatDate(dateStr) {
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric'
|
||||
});
|
||||
}
|
||||
|
||||
function renderBreadcrumbs() {
|
||||
const parts = currentPath.split('/').filter(p => p);
|
||||
const pathContainer = document.getElementById('pathContainer');
|
||||
let html = '<a href="#" onclick="navigateTo(\'/\'); return false;" class="breadcrumb-link">/</a>';
|
||||
|
||||
let accumulatedPath = '';
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
accumulatedPath += '/' + parts[i];
|
||||
const isLast = i === parts.length - 1;
|
||||
if (isLast) {
|
||||
html += '<span class="breadcrumb-text">' + parts[i] + '</span>';
|
||||
} else {
|
||||
html += '<a href="#" onclick="navigateTo(\'' + accumulatedPath + '\'); return false;" class="breadcrumb-link">' + parts[i] + '</a>';
|
||||
}
|
||||
if (i < parts.length - 1) {
|
||||
html += '<span class="breadcrumb-sep">/</span>';
|
||||
} else {
|
||||
html += '<span class="breadcrumb-sep">/</span>';
|
||||
}
|
||||
}
|
||||
|
||||
pathContainer.innerHTML = html;
|
||||
}
|
||||
|
||||
function renderFileList() {
|
||||
const fileList = document.getElementById('fileList');
|
||||
|
||||
if (mockFiles.length === 0) {
|
||||
fileList.innerHTML = `
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">📭</div>
|
||||
<p>This folder is empty</p>
|
||||
</div>
|
||||
`;
|
||||
updateSummary(0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sort: directories first, then alphabetically
|
||||
const sorted = [...mockFiles].sort((a, b) => {
|
||||
if (a.type === b.type) return a.name.localeCompare(b.name);
|
||||
return a.type === 'directory' ? -1 : 1;
|
||||
});
|
||||
|
||||
let dirCount = 0;
|
||||
let fileCount = 0;
|
||||
let totalSize = 0;
|
||||
|
||||
if (currentLayout === 'grid') {
|
||||
const gridItems = sorted.map(file => {
|
||||
if (file.type === 'directory') dirCount++;
|
||||
else {
|
||||
fileCount++;
|
||||
totalSize += file.size || 0;
|
||||
}
|
||||
return `
|
||||
<div class="grid-item" onclick="handleFileClick('${file.name}', '${file.type}')">
|
||||
<div class="grid-icon">${getIcon(file.type, file.name)}</div>
|
||||
<div class="grid-name">${file.name}</div>
|
||||
${file.size ? `<div class="grid-size">${formatSize(file.size)}</div>` : ''}
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
fileList.innerHTML = `<div class="grid">${gridItems}</div>`;
|
||||
} else {
|
||||
const tableRows = sorted.map(file => {
|
||||
if (file.type === 'directory') dirCount++;
|
||||
else {
|
||||
fileCount++;
|
||||
totalSize += file.size || 0;
|
||||
}
|
||||
return `
|
||||
<tr class="file-row ${file.type}" onclick="handleFileClick('${file.name}', '${file.type}')">
|
||||
<td class="icon">${getIcon(file.type, file.name)}</td>
|
||||
<td class="name">${file.name}</td>
|
||||
<td class="size">${file.size ? formatSize(file.size) : '-'}</td>
|
||||
<td class="date">${formatDate(file.modified)}</td>
|
||||
</tr>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
fileList.innerHTML = `
|
||||
<table class="file-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th>Size</th>
|
||||
<th>Modified</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${tableRows}
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
}
|
||||
|
||||
updateSummary(dirCount, fileCount, totalSize);
|
||||
}
|
||||
|
||||
function updateSummary(dirs, files, bytes) {
|
||||
document.getElementById('dirCount').textContent = dirs;
|
||||
document.getElementById('fileCount').textContent = files;
|
||||
document.getElementById('totalSize').textContent = formatSize(bytes);
|
||||
}
|
||||
|
||||
function handleFileClick(name, type) {
|
||||
if (type === 'directory') {
|
||||
navigateTo(currentPath + (currentPath.endsWith('/') ? '' : '/') + name);
|
||||
} else {
|
||||
console.log('Opening file:', name);
|
||||
}
|
||||
}
|
||||
|
||||
function navigateTo(path) {
|
||||
currentPath = path;
|
||||
renderBreadcrumbs();
|
||||
renderFileList();
|
||||
}
|
||||
|
||||
function navigateUp() {
|
||||
const parts = currentPath.split('/').filter(p => p);
|
||||
if (parts.length > 0) {
|
||||
parts.pop();
|
||||
currentPath = '/' + parts.join('/');
|
||||
if (currentPath === '/') currentPath = '/';
|
||||
navigateTo(currentPath);
|
||||
}
|
||||
}
|
||||
|
||||
function refreshList() {
|
||||
renderFileList();
|
||||
}
|
||||
|
||||
function setLayout(layout) {
|
||||
currentLayout = layout;
|
||||
document.getElementById('layoutList').classList.toggle('active', layout === 'list');
|
||||
document.getElementById('layoutGrid').classList.toggle('active', layout === 'grid');
|
||||
document.getElementById('listing').classList.toggle('list-view', layout === 'list');
|
||||
document.getElementById('listing').classList.toggle('grid-view', layout === 'grid');
|
||||
renderFileList();
|
||||
}
|
||||
|
||||
// Initialize
|
||||
initTheme();
|
||||
renderBreadcrumbs();
|
||||
renderFileList();
|
||||
</script> -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,9 +1,8 @@
|
||||
// src/controller/structs/structs.v
|
||||
// util/structs.v
|
||||
module util
|
||||
|
||||
import os
|
||||
import time
|
||||
import encoding.base64
|
||||
|
||||
pub struct Database {
|
||||
pub:
|
||||
|
||||
Reference in New Issue
Block a user