- Extract UI components into separate JS files - Centralize configuration values in config.js - Introduce a dedicated logger module - Improve file tree drag-and-drop and undo functionality - Refactor modal handling to a single manager - Add URL routing support for SPA navigation - Implement view mode for read-only access
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /**
 | |
|  * File Upload Module
 | |
|  * Handles file upload dialog for uploading files to the file tree
 | |
|  */
 | |
| 
 | |
| /**
 | |
|  * Show file upload dialog
 | |
|  * @param {string} targetPath - The target directory path
 | |
|  * @param {Function} onUpload - Callback function to handle file upload
 | |
|  */
 | |
| function showFileUploadDialog(targetPath, onUpload) {
 | |
|     const input = document.createElement('input');
 | |
|     input.type = 'file';
 | |
|     input.multiple = true;
 | |
| 
 | |
|     input.addEventListener('change', async (e) => {
 | |
|         const files = Array.from(e.target.files);
 | |
|         if (files.length === 0) return;
 | |
| 
 | |
|         for (const file of files) {
 | |
|             try {
 | |
|                 await onUpload(targetPath, file);
 | |
|             } catch (error) {
 | |
|                 Logger.error('Upload failed:', error);
 | |
|                 if (window.showNotification) {
 | |
|                     window.showNotification(`Failed to upload ${file.name}`, 'error');
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     });
 | |
| 
 | |
|     input.click();
 | |
| }
 | |
| 
 | |
| // Make function globally available
 | |
| window.showFileUploadDialog = showFileUploadDialog;
 | |
| 
 |