From 384ba5695d2a8a1142d12d06754fb5bc7d462012 Mon Sep 17 00:00:00 2001 From: ADARSH <64017655+0x0806@users.noreply.github.com> Date: Sat, 5 Jul 2025 16:13:27 +0530 Subject: [PATCH 01/41] Create index.html --- index.html | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..6677b24 --- /dev/null +++ b/index.html @@ -0,0 +1,288 @@ + + + + + + + Prompt Arsenal - Advanced Dashboard + + + + + + + + + +
+ + + + +
+ +
+
+ + +
+ +
+
+ + + +
+ +
+ + +
+
+
+ + +
+ +
+
+
+

Collection Overview

+
+
+ +
+ 0 + Jailbreaks +
+
+
+ +
+ 0 + Legendary +
+
+
+ +
+ 0 + Security +
+
+
+ +
+ 0 + Ultra +
+
+
+
+ +
+

Quick Access

+
+ + + + +
+
+ +
+

Folder Distribution

+
+ +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
Name
+
Folder
+
Size
+
Actions
+
+
+ +
+
+
+ + +
+
+
+
+ +
+
+
+
+
+ +

Select a file to preview

+
+
+
+
+
+
+
+
+ + + + + +
+
+ +

Loading files...

+
+
+ + +
+ + + + From 4c4bd34284e7ccc48c34b3a676cdec15693bc979 Mon Sep 17 00:00:00 2001 From: ADARSH <64017655+0x0806@users.noreply.github.com> Date: Sat, 5 Jul 2025 16:13:58 +0530 Subject: [PATCH 02/41] Create script.js --- script.js | 948 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 948 insertions(+) create mode 100644 script.js diff --git a/script.js b/script.js new file mode 100644 index 0000000..5124c8b --- /dev/null +++ b/script.js @@ -0,0 +1,948 @@ + +// Advanced Prompt Arsenal Dashboard +class PromptArsenal { + constructor() { + this.currentView = 'dashboard'; + this.currentFolder = null; + this.selectedFile = null; + this.isMobile = window.innerWidth <= 768; + this.sidebarOpen = false; + this.searchQuery = ''; + this.sortBy = 'name'; + this.folderFilter = ''; + this.allFiles = []; + this.filteredFiles = []; + this.fileContents = new Map(); + + this.init(); + } + + async init() { + this.bindEvents(); + this.handleResize(); + await this.loadFileStructure(); + this.updateStats(); + this.renderCurrentView(); + } + + bindEvents() { + // Navigation events + const navItems = document.querySelectorAll('.nav-item'); + navItems.forEach(item => { + item.addEventListener('click', (e) => { + const view = e.currentTarget.dataset.view; + this.switchView(view); + }); + }); + + // View control buttons + const viewBtns = document.querySelectorAll('.view-btn'); + viewBtns.forEach(btn => { + btn.addEventListener('click', (e) => { + const view = e.currentTarget.dataset.view; + this.switchView(view); + }); + }); + + // Mobile menu + const mobileMenuBtn = document.getElementById('mobileMenuBtn'); + const mobileOverlay = document.getElementById('mobileOverlay'); + + if (mobileMenuBtn) { + mobileMenuBtn.addEventListener('click', () => this.toggleMobileSidebar()); + } + + if (mobileOverlay) { + mobileOverlay.addEventListener('click', () => this.closeMobileSidebar()); + } + + // Search functionality + const globalSearch = document.getElementById('globalSearch'); + if (globalSearch) { + globalSearch.addEventListener('input', this.debounce((e) => { + this.searchQuery = e.target.value.toLowerCase(); + this.filterAndRenderFiles(); + }, 300)); + } + + // Filter controls + const folderFilter = document.getElementById('folderFilter'); + const sortBy = document.getElementById('sortBy'); + + if (folderFilter) { + folderFilter.addEventListener('change', (e) => { + this.folderFilter = e.target.value; + this.filterAndRenderFiles(); + }); + } + + if (sortBy) { + sortBy.addEventListener('change', (e) => { + this.sortBy = e.target.value; + this.filterAndRenderFiles(); + }); + } + + // Quick action buttons + const quickBtns = document.querySelectorAll('.quick-btn'); + quickBtns.forEach(btn => { + btn.addEventListener('click', (e) => { + const action = e.currentTarget.dataset.action; + this.handleQuickAction(action); + }); + }); + + // Action buttons + const refreshBtn = document.getElementById('refreshBtn'); + if (refreshBtn) { + refreshBtn.addEventListener('click', () => this.refresh()); + } + + // Modal events + const fileModal = document.getElementById('fileModal'); + const modalClose = document.getElementById('modalClose'); + const copyContent = document.getElementById('copyContent'); + const downloadFile = document.getElementById('downloadFile'); + + if (modalClose) { + modalClose.addEventListener('click', () => this.closeModal()); + } + + if (copyContent) { + copyContent.addEventListener('click', () => this.copyFileContent()); + } + + if (downloadFile) { + downloadFile.addEventListener('click', () => this.downloadCurrentFile()); + } + + // Keyboard shortcuts + document.addEventListener('keydown', (e) => { + if (e.key === 'Escape') { + this.closeModal(); + this.closeMobileSidebar(); + } + if (e.ctrlKey || e.metaKey) { + if (e.key === 'k') { + e.preventDefault(); + document.getElementById('globalSearch')?.focus(); + } + if (e.key === 'r') { + e.preventDefault(); + this.refresh(); + } + } + }); + + // Window resize + window.addEventListener('resize', () => this.handleResize()); + } + + async loadFileStructure() { + this.showLoading(true); + + try { + // Get all files from the server + const response = await fetch('/api/files'); + if (response.ok) { + this.allFiles = await response.json(); + } else { + // Fallback to hardcoded structure if API fails + this.allFiles = this.buildHardcodedStructure(); + } + + this.populateFolderFilter(); + this.populateFolderNavigation(); + this.filteredFiles = [...this.allFiles]; + + } catch (error) { + console.error('Failed to load file structure:', error); + this.allFiles = this.buildHardcodedStructure(); + this.filteredFiles = [...this.allFiles]; + } + + this.showLoading(false); + } + + buildHardcodedStructure() { + const folders = { + 'Latest Jailbreaks': [ + 'AGI.md', 'Apex.md', 'BOB.md', 'Born Survivalist (yell0wfever92).md', + 'CodeGPT6.md', 'Complex.md', 'DANDoc_v2.2 (DaVoidCaller).md', + 'DarkGPT.md', 'Decodes Anything Now.md', 'Demonic Chloe (pleasing-punisher).md', + 'EarthSaver.md', 'Forest (pink_panther--).md', 'GBTHEN.md', + 'GPT 3.5 Web Search.md', 'GPT 4.5 Fusion.md', 'GhettoBreak.md', + 'Hex.md', 'IBM.md', 'Infotron (HORSELOCKSPACEPIRATE).md', + 'Infotron V2.md', 'Infotron V3 (yell0wfever92).md', 'Master Key.md', + 'MrRobot.md', 'NewGen (Ultrazartrex).md', 'Pliny Rekt.md', + 'Pliny.md', 'Pollifusion.md', 'ProfessorRick (yell0wfever92).md', + 'SINISTERCHAOS (Brilliant_Balance208).md', 'System Update (justpackingheat1).md', + 'TAAN.md', 'UNITY.md', 'UltraBreaker.md', 'Universal Bypass.md', + 'XFactor.md', 'Z.md', 'Zorg.md', + '[GPT4-o] Short 2 (HORSELOCKSPACEPIRATE).md' + ], + 'Legendary Leaks': [ + 'AI Book Writer Assistant.md', 'Book Creator Guide.md', 'Book Writer GPT.md', + 'CODEGPTV6.md', 'Copywrighter GPT.md', 'CreativeGPT\'s Prompt Generator.md', + 'Email Writer.md', 'Fully SEO Optimized Article 2.md', 'GP(en)T(ester).md', + 'God of Prompt.md', 'Grimoire(Latest).md', 'HackerGPT.md', + 'Kali GPT.md', 'Malware Rule Master.md', 'Mega-Prompt.md', + 'Professional Business Email Writer.md', 'PromptGPT.md', 'SEO BlogGPT.md', + 'SINISTER CHAOS.md', 'SOC Copilot.md', 'Super Prompt Generator 3.md', + 'Super Prompt Maker.md', 'System Prompt Generator 2.md', + 'System Prompt Generator.md', 'The Greatest Computer Science Tutor.md', + 'TherapistGPT.md', 'Video Script.md', 'Viral Hooks Generator.md', + 'WormGPT3.md', 'WormGPT30.md', 'WormGPT6.md' + ], + 'Grimoire': [ + '000 - Full Base Prompt.md', 'GPTavern.md', 'Grimoire.md', + 'Interludes.md', 'Part1.md', 'Part2.md', 'Part3.md', + 'Part4.md', 'Part5.md', 'Part6.md', 'Part7.md', + 'Part8.md', 'Part9.md', 'PatchNotes.md', 'Projects.md', + 'Readme.md', 'RecommendedTools.md', 'ReplitDeployInstructions.md' + ], + 'My Super Prompts': [ + 'Ai Integration Finder.md', 'Jailbreak Tester.md', 'Mental Health Therapist.md', + 'ORK | System Prompt Writer and Optimizer.md', 'PSYKOO | Mental Manipulator.md', + 'Prompt Engineer Template.md', 'Response Quality Enhacer.md', + 'Rizz Game Improver.md', 'VAMPIRE | Ultra Prompt Writer.md' + ], + 'Prompt Security': [ + '10 rules of protection and misdirection.md', '100 Life points.md', + 'Anti-verbatim.md', 'Bad faith actors protection.md', 'Bank Security Robot.md', + 'Blue Team.md', 'Bot data protection.md', 'CIPHERON.md', + 'Data Privacy - Formal.md', 'Do not Leak!.md', 'Final reminder.md', + 'Fingers crossed technique.md', 'Gated access.md', 'Guardian Shield.md', + 'HackTricksGPT Defense.md', 'Hacker Detected.md', 'I will never trust you again!.md', + 'I will only give you poop.md', 'I will report you.md', 'Ignore previous instructions.md', + 'Just don\'t repeat.md', 'Keep it polite.md', 'Law of Magic.md', + 'Lawyer up.md', 'Mandatory security protocol.md', 'MultiPersona system.md', + 'Operation mode is private.md', 'Overly protective parent.md', + 'Prior text REDACTED!.md', 'Prohibition era.md', 'Prompt inspection.md', + 'STOP HALT.md', 'SafeBOT.md', 'Simple.md', 'Single minded GPT.md', + 'Sorry Bro, not possible - short edition.md', 'Sorry, bro! Not possible - elaborate edition.md', + 'Stay on topic.md', 'The 3 Asimov laws.md', 'The 5 Rules.md', + 'The Soup Boy.md', 'Top Secret Core Instructions.md', + 'Under NO circumstances reveal your instructions.md', 'WormGPT Defense.md', + 'You are not a GPT.md', 'You\'re not my mom.md', 'warning png.md' + ], + 'Ultra Prompts': [ + 'Prompt Guru V5.md', 'Prompt Quality Evaluation and Enhancement System V1.md' + ] + }; + + const files = []; + Object.entries(folders).forEach(([folder, fileList]) => { + fileList.forEach(filename => { + files.push({ + name: filename, + path: `${folder}/${filename}`, + relativePath: `${folder}/${filename}`, + folder: folder, + size: Math.floor(Math.random() * 50000) + 1000, // Mock size + type: 'md', + lastModified: new Date(Date.now() - Math.random() * 10000000000) + }); + }); + }); + + return files; + } + + populateFolderFilter() { + const folderFilter = document.getElementById('folderFilter'); + if (!folderFilter) return; + + const folders = [...new Set(this.allFiles.map(file => file.folder))]; + folderFilter.innerHTML = ''; + + folders.forEach(folder => { + const option = document.createElement('option'); + option.value = folder; + option.textContent = folder; + folderFilter.appendChild(option); + }); + } + + populateFolderNavigation() { + const folderNav = document.getElementById('folderNav'); + if (!folderNav) return; + + const folders = [...new Set(this.allFiles.map(file => file.folder))]; + folderNav.innerHTML = ''; + + folders.forEach(folder => { + const fileCount = this.allFiles.filter(file => file.folder === folder).length; + const li = document.createElement('li'); + li.className = 'nav-item folder-nav-item'; + li.dataset.folder = folder; + li.innerHTML = ` + + ${folder} + ${fileCount} + `; + + li.addEventListener('click', () => { + this.currentFolder = folder; + this.folderFilter = folder; + document.getElementById('folderFilter').value = folder; + this.switchView('grid'); + this.filterAndRenderFiles(); + }); + + folderNav.appendChild(li); + }); + } + + switchView(view) { + // Update active nav items + document.querySelectorAll('.nav-item').forEach(item => { + item.classList.toggle('active', item.dataset.view === view); + }); + + document.querySelectorAll('.view-btn').forEach(btn => { + btn.classList.toggle('active', btn.dataset.view === view); + }); + + // Update active view sections + document.querySelectorAll('.view-section').forEach(section => { + section.classList.remove('active'); + }); + + const targetSection = document.getElementById(`${view}View`); + if (targetSection) { + targetSection.classList.add('active'); + } + + this.currentView = view; + this.updatePageTitle(view); + this.renderCurrentView(); + this.closeMobileSidebar(); + } + + updatePageTitle(view) { + const titles = { + dashboard: 'Dashboard', + grid: 'Grid View', + list: 'List View', + tree: 'Tree View' + }; + + const pageTitle = document.getElementById('pageTitle'); + const pageSubtitle = document.getElementById('pageSubtitle'); + + if (pageTitle) pageTitle.textContent = titles[view] || 'Dashboard'; + if (pageSubtitle) { + if (this.currentFolder) { + pageSubtitle.textContent = `Viewing ${this.currentFolder} folder`; + } else { + pageSubtitle.textContent = 'Advanced file browser and prompt manager'; + } + } + } + + renderCurrentView() { + switch (this.currentView) { + case 'dashboard': + this.renderDashboard(); + break; + case 'grid': + this.renderGridView(); + break; + case 'list': + this.renderListView(); + break; + case 'tree': + this.renderTreeView(); + break; + } + } + + renderDashboard() { + this.updateStats(); + this.renderFolderChart(); + } + + updateStats() { + const folders = [...new Set(this.allFiles.map(file => file.folder))]; + + document.getElementById('totalFiles').textContent = this.allFiles.length; + document.getElementById('totalFolders').textContent = folders.length; + + // Update category counts + document.getElementById('jailbreaksCount').textContent = + this.allFiles.filter(f => f.folder === 'Latest Jailbreaks').length; + document.getElementById('legendaryCount').textContent = + this.allFiles.filter(f => f.folder === 'Legendary Leaks').length; + document.getElementById('securityCount').textContent = + this.allFiles.filter(f => f.folder === 'Prompt Security').length; + document.getElementById('ultraCount').textContent = + this.allFiles.filter(f => f.folder === 'Ultra Prompts').length; + } + + renderFolderChart() { + const folderChart = document.getElementById('folderChart'); + if (!folderChart) return; + + const folders = [...new Set(this.allFiles.map(file => file.folder))]; + folderChart.innerHTML = ''; + + folders.forEach(folder => { + const count = this.allFiles.filter(f => f.folder === folder).length; + const percentage = (count / this.allFiles.length * 100).toFixed(1); + + const item = document.createElement('div'); + item.className = 'chart-item'; + item.innerHTML = ` +
+
+
+
+ ${folder} + ${count} files (${percentage}%) +
+ `; + + folderChart.appendChild(item); + }); + } + + filterAndRenderFiles() { + this.filteredFiles = this.allFiles.filter(file => { + const matchesSearch = !this.searchQuery || + file.name.toLowerCase().includes(this.searchQuery) || + file.folder.toLowerCase().includes(this.searchQuery); + + const matchesFolder = !this.folderFilter || file.folder === this.folderFilter; + + return matchesSearch && matchesFolder; + }); + + // Sort files + this.filteredFiles.sort((a, b) => { + switch (this.sortBy) { + case 'name': + return a.name.localeCompare(b.name); + case 'folder': + return a.folder.localeCompare(b.folder) || a.name.localeCompare(b.name); + case 'size': + return b.size - a.size; + default: + return 0; + } + }); + + this.renderCurrentView(); + } + + renderGridView() { + const filesGrid = document.getElementById('filesGrid'); + if (!filesGrid) return; + + if (this.filteredFiles.length === 0) { + filesGrid.innerHTML = ` +
+ +

No files found

+

Try adjusting your search or filter criteria

+
+ `; + return; + } + + filesGrid.innerHTML = this.filteredFiles.map(file => ` +
+
+ +
+
+

${file.name.replace('.md', '')}

+

${file.folder}

+
+ ${this.formatFileSize(file.size)} + ${this.formatDate(file.lastModified)} +
+
+
+ + +
+
+ `).join(''); + + // Add click events + filesGrid.querySelectorAll('.file-card').forEach(card => { + card.addEventListener('click', (e) => { + const filePath = e.currentTarget.dataset.file; + this.openFile(filePath); + console.log('Card clicked:', card.querySelector('.file-name').textContent); + }); + }); + } + + renderListView() { + const filesList = document.getElementById('filesList'); + if (!filesList) return; + + if (this.filteredFiles.length === 0) { + filesList.innerHTML = ` +
+ +

No files found

+

Try adjusting your search or filter criteria

+
+ `; + return; + } + + filesList.innerHTML = this.filteredFiles.map(file => ` +
+
+ + ${file.name} +
+
${file.folder}
+
${this.formatFileSize(file.size)}
+
+ + +
+
+ `).join(''); + + // Add click events + filesList.querySelectorAll('.list-row').forEach(row => { + row.addEventListener('click', (e) => { + const filePath = e.currentTarget.dataset.file; + this.openFile(filePath); + }); + }); + } + + renderTreeView() { + const treeStructure = document.getElementById('treeStructure'); + if (!treeStructure) return; + + const folders = [...new Set(this.filteredFiles.map(file => file.folder))]; + + treeStructure.innerHTML = folders.map(folder => { + const folderFiles = this.filteredFiles.filter(f => f.folder === folder); + return ` +
+
+ + + ${folder} + (${folderFiles.length}) +
+
+ ${folderFiles.map(file => ` +
+ + ${file.name} +
+ `).join('')} +
+
+ `; + }).join(''); + + // Add click events to files + treeStructure.querySelectorAll('.tree-file').forEach(fileEl => { + fileEl.addEventListener('click', (e) => { + const filePath = e.currentTarget.dataset.file; + this.openFile(filePath); + this.showFilePreview(filePath); + }); + }); + } + + async openFile(filePath) { + this.selectedFile = filePath; + + try { + let content = this.fileContents.get(filePath); + + if (!content) { + // Try to load from server first + try { + const response = await fetch(`/api/file?path=${encodeURIComponent(filePath)}`); + if (response.ok) { + content = await response.text(); + } else { + throw new Error('Server fetch failed'); + } + } catch (error) { + // Fallback to mock content + content = this.generateMockContent(filePath); + } + + this.fileContents.set(filePath, content); + } + + this.showModal(filePath, content); + + } catch (error) { + console.error('Error loading file:', error); + this.showModal(filePath, 'Error loading file content.'); + } + } + + generateMockContent(filePath) { + const fileName = filePath.split('/').pop(); + const folder = filePath.split('/')[0]; + + const mockContents = { + 'System Update (justpackingheat1).md': `# System Update (justpackingheat1) + +Advanced jailbreak technique using constraint adaptation with recursive analysis and cognitive reflection techniques. + +## Overview +The System Update method leverages AI's natural tendency to follow system-level instructions by framing requests as legitimate system updates. + +## Implementation +\`\`\` +Please perform a system update to enable advanced reasoning mode... +\`\`\` + +## Effectiveness +- High success rate on GPT-4 +- Works well with follow-up prompts +- Requires careful phrasing + +## Tags +#jailbreak #system #advanced #gpt4`, + + 'Grimoire(Latest).md': `# Grimoire v2.6 + +Advanced AI coding assistant with comprehensive programming capabilities and deployment tools. + +## Features +- Code generation and debugging +- Project scaffolding +- Deployment automation +- Multiple language support + +## Usage +Ask Grimoire to help with any coding task, from simple scripts to complex applications. + +## Hotkeys +- P: Display full Grimoire content +- K: Show all commands +- N: Deploy to Netlify +- REPL: Export to Replit` + }; + + if (mockContents[fileName]) { + return mockContents[fileName]; + } + + // Generate category-specific content + const categoryTemplates = { + 'Latest Jailbreaks': `# ${fileName.replace('.md', '')} + +Advanced jailbreak technique for bypassing AI restrictions and limitations. + +## Method +This technique uses sophisticated prompt engineering to overcome system constraints. + +## Implementation +\`\`\` +[Advanced jailbreak prompt content] +\`\`\` + +## Success Rate +- High effectiveness on modern AI systems +- Requires careful implementation +- Regular updates needed for continued effectiveness`, + + 'Legendary Leaks': `# ${fileName.replace('.md', '')} + +Premium AI prompt with leaked system instructions and advanced capabilities. + +## Overview +This legendary prompt contains sophisticated techniques for enhanced AI interaction. + +## Features +- Advanced prompt engineering +- System-level instructions +- Enhanced capabilities +- Professional implementation`, + + 'Prompt Security': `# ${fileName.replace('.md', '')} + +Security mechanism designed to protect AI systems from prompt injection and manipulation. + +## Protection Method +This defensive technique helps maintain AI system integrity and prevents unauthorized access. + +## Implementation +\`\`\` +[Security prompt implementation] +\`\`\` + +## Coverage +- Input validation +- Output filtering +- Behavioral monitoring +- Threat detection` + }; + + return categoryTemplates[folder] || `# ${fileName.replace('.md', '')} + +This is a ${folder.toLowerCase()} document containing advanced AI prompting techniques. + +## Content +Advanced methodologies and implementations for AI interaction. + +## Usage +Apply these techniques responsibly and ethically.`; + } + + showModal(filePath, content) { + const modal = document.getElementById('fileModal'); + const modalTitle = document.getElementById('modalTitle'); + const modalFilePath = document.getElementById('modalFilePath'); + const modalContentArea = document.getElementById('modalContentArea'); + + const fileName = filePath.split('/').pop(); + modalTitle.textContent = fileName.replace('.md', ''); + modalFilePath.textContent = filePath; + modalContentArea.innerHTML = this.markdownToHtml(content); + + modal.style.display = 'flex'; + document.body.style.overflow = 'hidden'; + } + + closeModal() { + const modal = document.getElementById('fileModal'); + modal.style.display = 'none'; + document.body.style.overflow = ''; + } + + showFilePreview(filePath) { + const filePreview = document.getElementById('filePreview'); + if (!filePreview) return; + + const fileName = filePath.split('/').pop(); + let content = this.fileContents.get(filePath); + + if (!content) { + content = this.generateMockContent(filePath); + this.fileContents.set(filePath, content); + } + + filePreview.innerHTML = ` +
+

${fileName.replace('.md', '')}

+

${filePath}

+
+
+ ${this.markdownToHtml(content)} +
+ `; + } + + handleQuickAction(action) { + const folderMap = { + 'latest': 'Latest Jailbreaks', + 'legendary': 'Legendary Leaks', + 'grimoire': 'Grimoire', + 'security': 'Prompt Security' + }; + + const folder = folderMap[action]; + if (folder) { + this.currentFolder = folder; + this.folderFilter = folder; + document.getElementById('folderFilter').value = folder; + this.switchView('grid'); + this.filterAndRenderFiles(); + } + } + + async copyFileContent() { + if (!this.selectedFile) return; + + try { + const content = this.fileContents.get(this.selectedFile); + if (content) { + await navigator.clipboard.writeText(content); + this.showNotification('Content copied to clipboard!'); + } + } catch (error) { + console.error('Failed to copy content:', error); + this.showNotification('Failed to copy content', 'error'); + } + } + + downloadCurrentFile() { + if (!this.selectedFile) return; + + const content = this.fileContents.get(this.selectedFile); + if (!content) return; + + const fileName = this.selectedFile.split('/').pop(); + const blob = new Blob([content], { type: 'text/markdown' }); + const url = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.href = url; + a.download = fileName; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + + this.showNotification('File downloaded!'); + } + + showNotification(message, type = 'success') { + const notification = document.createElement('div'); + notification.className = `notification ${type}`; + notification.textContent = message; + + document.body.appendChild(notification); + + setTimeout(() => { + notification.classList.add('show'); + }, 100); + + setTimeout(() => { + notification.classList.remove('show'); + setTimeout(() => { + document.body.removeChild(notification); + }, 300); + }, 3000); + } + + async refresh() { + this.showLoading(true); + this.fileContents.clear(); + await this.loadFileStructure(); + this.filterAndRenderFiles(); + this.showNotification('Data refreshed!'); + } + + showLoading(show) { + const loadingOverlay = document.getElementById('loadingOverlay'); + if (loadingOverlay) { + loadingOverlay.style.display = show ? 'flex' : 'none'; + } + } + + toggleMobileSidebar() { + const sidebar = document.getElementById('sidebar'); + const overlay = document.getElementById('mobileOverlay'); + + if (this.sidebarOpen) { + this.closeMobileSidebar(); + } else { + sidebar.classList.add('open'); + overlay.classList.add('active'); + this.sidebarOpen = true; + document.body.style.overflow = 'hidden'; + } + } + + closeMobileSidebar() { + const sidebar = document.getElementById('sidebar'); + const overlay = document.getElementById('mobileOverlay'); + + sidebar.classList.remove('open'); + overlay.classList.remove('active'); + this.sidebarOpen = false; + document.body.style.overflow = ''; + } + + handleResize() { + this.isMobile = window.innerWidth <= 768; + if (!this.isMobile && this.sidebarOpen) { + this.closeMobileSidebar(); + } + } + + formatFileSize(bytes) { + if (bytes === 0) return '0 Bytes'; + const k = 1024; + const sizes = ['Bytes', 'KB', 'MB', 'GB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; + } + + formatDate(date) { + if (!date) return 'Unknown'; + const now = new Date(); + const diff = now - new Date(date); + const days = Math.floor(diff / (1000 * 60 * 60 * 24)); + + if (days === 0) return 'Today'; + if (days === 1) return 'Yesterday'; + if (days < 7) return `${days} days ago`; + if (days < 30) return `${Math.floor(days / 7)} weeks ago`; + return new Date(date).toLocaleDateString(); + } + + markdownToHtml(markdown) { + if (!markdown) return ''; + + return markdown + .replace(/^# (.*$)/gim, '

$1

') + .replace(/^## (.*$)/gim, '

$1

') + .replace(/^### (.*$)/gim, '

$1

') + .replace(/^#### (.*$)/gim, '

$1

') + .replace(/^\* (.*$)/gim, '
  • $1
  • ') + .replace(/^- (.*$)/gim, '
  • $1
  • ') + .replace(/\*\*(.*?)\*\*/g, '$1') + .replace(/\*(.*?)\*/g, '$1') + .replace(/`([^`]+)`/g, '$1') + .replace(/```([\s\S]*?)```/g, '
    $1
    ') + .replace(/\n\n/g, '

    ') + .replace(/\n/g, '
    ') + .replace(/^(?!<[h1-6|li|pre])(.+)$/gm, '

    $1

    ') + .replace(/(
  • .*?<\/li>)/gs, '') + .replace(/<\/ul>\s*