Spaces:
Running
Running
File size: 15,415 Bytes
771ce22 d096d03 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Manager Editor</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
neon: {
green: '#39FF14',
dark: '#0A1E12'
}
}
}
}
}
</script>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<style>
.glow-text {
text-shadow: 0 0 5px rgba(57, 255, 20, 0.7);
}
.glow-border {
box-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}
.scrollbar-hide::-webkit-scrollbar {
display: none;
}
.scrollbar-hide {
-ms-overflow-style: none;
scrollbar-width: none;
}
</style>
</head>
<body class="bg-neon-dark text-gray-200 min-h-screen">
<div class="container mx-auto px-4 py-8">
<header class="mb-12 text-center">
<h1 class="text-4xl md:text-5xl font-bold mb-2 glow-text text-neon-green">PASSWORD MANAGER EDITOR</h1>
<p class="text-gray-400 max-w-2xl mx-auto">Securely modify and export your password data with this futuristic editor</p>
</header>
<main>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Import Section -->
<div class="bg-gray-800 rounded-lg p-6 border border-gray-700 glow-border" data-aos="fade-right">
<div class="flex items-center mb-4">
<i data-feather="upload" class="text-neon-green mr-2"></i>
<h2 class="text-xl font-semibold text-neon-green">Import CSV</h2>
</div>
<p class="text-gray-400 mb-4">Upload your password CSV file from your local computer to begin editing.</p>
<input type="file" id="csvFile" accept=".csv" class="hidden">
<label for="csvFile" class="cursor-pointer bg-neon-green text-neon-dark font-medium py-2 px-4 rounded flex items-center justify-center hover:bg-opacity-90 transition">
<i data-feather="file" class="mr-2"></i> Choose File
</label>
<div id="fileName" class="mt-2 text-sm text-gray-400"></div>
</div>
<!-- Password List -->
<div class="lg:col-span-2 bg-gray-800 rounded-lg border border-gray-700 glow-border" data-aos="fade-left">
<div class="p-4 border-b border-gray-700 flex justify-between items-center">
<h2 class="text-xl font-semibold text-neon-green flex items-center">
<i data-feather="lock" class="mr-2"></i> Password Entries
</h2>
<div id="entryCount" class="text-gray-400 text-sm">0 entries</div>
</div>
<div id="passwordList" class="overflow-y-auto max-h-96 scrollbar-hide">
<div class="text-center py-12 text-gray-500" id="emptyState">
<i data-feather="database" class="mx-auto w-12 h-12 mb-4"></i>
<p>No password data loaded. Import a CSV file to begin.</p>
</div>
</div>
</div>
</div>
<!-- Export Section (hidden initially) -->
<div id="exportSection" class="hidden mt-8 bg-gray-800 rounded-lg p-6 border border-gray-700 glow-border" data-aos="fade-up">
<div class="flex items-center mb-4">
<i data-feather="download" class="text-neon-green mr-2"></i>
<h2 class="text-xl font-semibold text-neon-green">Export Options</h2>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<button id="exportCsv" class="bg-gray-700 hover:bg-gray-600 text-white font-medium py-3 px-4 rounded flex items-center justify-center transition">
<i data-feather="file-text" class="mr-2"></i> Export as CSV
</button>
<button id="exportPdf" class="bg-gray-700 hover:bg-gray-600 text-white font-medium py-3 px-4 rounded flex items-center justify-center transition">
<i data-feather="file" class="mr-2"></i> Export as PDF
</button>
</div>
</div>
</main>
</div>
<!-- Edit Modal -->
<div id="editModal" class="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50 hidden">
<div class="bg-gray-800 rounded-lg border border-gray-700 w-full max-w-md mx-4 p-6 glow-border">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold text-neon-green">Edit Password Entry</h3>
<button id="closeModal" class="text-gray-400 hover:text-white">
<i data-feather="x"></i>
</button>
</div>
<form id="editForm" class="space-y-4">
<input type="hidden" id="editIndex">
<div>
<label for="editWebsite" class="block text-sm font-medium text-gray-400 mb-1">Website URL</label>
<input type="url" id="editWebsite" class="w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-neon-green">
</div>
<div>
<label for="editUsername" class="block text-sm font-medium text-gray-400 mb-1">Username</label>
<input type="text" id="editUsername" class="w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-neon-green">
</div>
<div>
<label for="editEmail" class="block text-sm font-medium text-gray-400 mb-1">Email</label>
<input type="email" id="editEmail" class="w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-neon-green">
</div>
<div>
<label for="editPassword" class="block text-sm font-medium text-gray-400 mb-1">Password</label>
<div class="relative">
<input type="password" id="editPassword" class="w-full bg-gray-700 border border-gray-600 rounded px-3 py-2 text-white focus:outline-none focus:ring-1 focus:ring-neon-green pr-10">
<button type="button" id="togglePassword" class="absolute right-3 top-2 text-gray-400 hover:text-neon-green">
<i data-feather="eye"></i>
</button>
</div>
</div>
<div class="pt-2">
<button type="submit" class="w-full bg-neon-green text-neon-dark font-medium py-2 px-4 rounded hover:bg-opacity-90 transition">
Save Changes
</button>
</div>
</form>
</div>
</div>
<script>
// Initialize libraries
AOS.init();
feather.replace();
// Global variables
let passwordData = [];
const { jsPDF } = window.jspdf;
// DOM elements
const csvFileInput = document.getElementById('csvFile');
const fileNameDisplay = document.getElementById('fileName');
const passwordList = document.getElementById('passwordList');
const emptyState = document.getElementById('emptyState');
const entryCount = document.getElementById('entryCount');
const exportSection = document.getElementById('exportSection');
const exportCsvBtn = document.getElementById('exportCsv');
const exportPdfBtn = document.getElementById('exportPdf');
const editModal = document.getElementById('editModal');
const closeModalBtn = document.getElementById('closeModal');
const editForm = document.getElementById('editForm');
const togglePasswordBtn = document.getElementById('togglePassword');
// Event listeners
csvFileInput.addEventListener('change', handleFileUpload);
closeModalBtn.addEventListener('click', () => editModal.classList.add('hidden'));
togglePasswordBtn.addEventListener('click', togglePasswordVisibility);
editForm.addEventListener('submit', handleFormSubmit);
exportCsvBtn.addEventListener('click', exportAsCsv);
exportPdfBtn.addEventListener('click', exportAsPdf);
// Functions
function handleFileUpload(event) {
const file = event.target.files[0];
if (!file) return;
fileNameDisplay.textContent = file.name;
Papa.parse(file, {
header: true,
complete: function(results) {
passwordData = results.data;
renderPasswordList();
exportSection.classList.remove('hidden');
entryCount.textContent = `${passwordData.length} ${passwordData.length === 1 ? 'entry' : 'entries'}`;
},
error: function(error) {
console.error("Error parsing CSV:", error);
alert("Error parsing CSV file. Please ensure it's a valid CSV format.");
}
});
}
function renderPasswordList() {
if (passwordData.length === 0) {
emptyState.classList.remove('hidden');
passwordList.innerHTML = '';
return;
}
emptyState.classList.add('hidden');
passwordList.innerHTML = '';
passwordData.forEach((entry, index) => {
const entryElement = document.createElement('div');
entryElement.className = 'border-b border-gray-700 hover:bg-gray-750 transition cursor-pointer';
entryElement.innerHTML = `
<div class="p-4 flex items-center justify-between" onclick="openEditModal(${index})">
<div class="flex items-center space-x-4">
<div class="bg-gray-700 p-3 rounded-lg">
<i data-feather="globe" class="text-neon-green"></i>
</div>
<div>
<h3 class="font-medium">${entry.name || entry.url || 'Untitled'}</h3>
<p class="text-sm text-gray-400">${entry.username || entry.email || 'No username'}</p>
</div>
</div>
<i data-feather="chevron-right" class="text-gray-400"></i>
</div>
`;
passwordList.appendChild(entryElement);
});
feather.replace();
}
function openEditModal(index) {
const entry = passwordData[index];
document.getElementById('editIndex').value = index;
document.getElementById('editWebsite').value = entry.url || entry.name || '';
document.getElementById('editUsername').value = entry.username || '';
document.getElementById('editEmail').value = entry.email || '';
document.getElementById('editPassword').value = entry.password || '';
editModal.classList.remove('hidden');
}
function togglePasswordVisibility() {
const passwordInput = document.getElementById('editPassword');
const icon = togglePasswordBtn.querySelector('i');
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
icon.setAttribute('data-feather', 'eye-off');
} else {
passwordInput.type = 'password';
icon.setAttribute('data-feather', 'eye');
}
feather.replace();
}
function handleFormSubmit(event) {
event.preventDefault();
const index = document.getElementById('editIndex').value;
passwordData[index] = {
...passwordData[index],
name: document.getElementById('editWebsite').value,
url: document.getElementById('editWebsite').value,
username: document.getElementById('editUsername').value,
email: document.getElementById('editEmail').value,
password: document.getElementById('editPassword').value
};
renderPasswordList();
editModal.classList.add('hidden');
}
function exportAsCsv() {
const csv = Papa.unparse(passwordData);
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'passwords_export.csv');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
function exportAsPdf() {
const doc = new jsPDF();
let y = 20;
doc.setFontSize(18);
doc.setTextColor(57, 255, 20);
doc.text('Password Manager Export', 105, y, { align: 'center' });
y += 15;
doc.setFontSize(12);
doc.setTextColor(255, 255, 255);
passwordData.forEach((entry, index) => {
if (y > 270) {
doc.addPage();
y = 20;
}
doc.setFillColor(40, 40, 40);
doc.rect(10, y - 5, 190, 15, 'F');
doc.setTextColor(57, 255, 20);
doc.text(`${entry.name || entry.url || 'Untitled'}`, 15, y);
y += 10;
doc.setTextColor(200, 200, 200);
doc.text(`Username: ${entry.username || 'N/A'}`, 15, y);
y += 7;
doc.text(`Email: ${entry.email || 'N/A'}`, 15, y);
y += 7;
doc.text(`Password: ${entry.password || 'N/A'}`, 15, y);
y += 15;
});
doc.save('passwords_export.pdf');
}
// Make functions available globally for inline event handlers
window.openEditModal = openEditModal;
</script>
</body>
</html>
|