fix: avoid null error
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Deploy MinIO Explorer / deploy (push) Successful in 44s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Deploy MinIO Explorer / deploy (push) Successful in 44s
				
			This commit is contained in:
		
							
								
								
									
										71
									
								
								script.js
									
									
									
									
									
								
							
							
						
						
									
										71
									
								
								script.js
									
									
									
									
									
								
							| @@ -21,14 +21,24 @@ function initializeApp() { | ||||
|  | ||||
| function setupEventListeners() { | ||||
|     // Formulaire de développement | ||||
|     document.getElementById('url-form').addEventListener('submit', handleUrlFormSubmit); | ||||
|     const urlForm = document.getElementById('url-form'); | ||||
|     if (urlForm) { | ||||
|         urlForm.addEventListener('submit', handleUrlFormSubmit); | ||||
|     } | ||||
|      | ||||
|     // Gestion de la navigation arrière/avant du navigateur | ||||
|     window.addEventListener('popstate', handlePopState); | ||||
|      | ||||
|     // Gestionnaires pour la prévisualisation | ||||
|     document.getElementById('close-preview').addEventListener('click', hidePreview); | ||||
|     document.getElementById('download-file').addEventListener('click', downloadCurrentFile); | ||||
|     const closePreview = document.getElementById('close-preview'); | ||||
|     if (closePreview) { | ||||
|         closePreview.addEventListener('click', hidePreview); | ||||
|     } | ||||
|      | ||||
|     const downloadFile = document.getElementById('download-file'); | ||||
|     if (downloadFile) { | ||||
|         downloadFile.addEventListener('click', downloadCurrentFile); | ||||
|     } | ||||
| } | ||||
|  | ||||
| function handlePopState(event) { | ||||
| @@ -67,6 +77,8 @@ function handleUrlFormSubmit(event) { | ||||
|     event.preventDefault(); | ||||
|      | ||||
|     const urlInput = document.getElementById('minio-url'); | ||||
|     if (!urlInput) return; | ||||
|      | ||||
|     const minioUrl = urlInput.value.trim(); | ||||
|      | ||||
|     if (!minioUrl) { | ||||
| @@ -112,7 +124,9 @@ function updateConfigDisplay() { | ||||
|  | ||||
| function showDevForm() { | ||||
|     const devForm = document.getElementById('dev-form'); | ||||
|     devForm.style.display = 'block'; | ||||
|     if (devForm) { | ||||
|         devForm.style.display = 'block'; | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -120,31 +134,38 @@ function showError(message) { | ||||
|     const errorSection = document.getElementById('error-section'); | ||||
|     const errorMessage = document.getElementById('error-message'); | ||||
|      | ||||
|     errorMessage.textContent = message; | ||||
|     errorSection.style.display = 'block'; | ||||
|     if (errorMessage) { | ||||
|         errorMessage.textContent = message; | ||||
|     } | ||||
|      | ||||
|     // Masquer l'erreur après 5 secondes | ||||
|     setTimeout(() => { | ||||
|         errorSection.style.display = 'none'; | ||||
|     }, 5000); | ||||
|     if (errorSection) { | ||||
|         errorSection.style.display = 'block'; | ||||
|          | ||||
|         // Masquer l'erreur après 5 secondes | ||||
|         setTimeout(() => { | ||||
|             errorSection.style.display = 'none'; | ||||
|         }, 5000); | ||||
|     } | ||||
| } | ||||
|  | ||||
| function showLoading(show = true) { | ||||
|     const loading = document.getElementById('loading'); | ||||
|     const table = document.getElementById('files-table'); | ||||
|      | ||||
|     if (show) { | ||||
|         loading.style.display = 'block'; | ||||
|         table.style.display = 'none'; | ||||
|     } else { | ||||
|         loading.style.display = 'none'; | ||||
|         table.style.display = 'table'; | ||||
|     if (loading) { | ||||
|         loading.style.display = show ? 'block' : 'none'; | ||||
|     } | ||||
|      | ||||
|     if (table) { | ||||
|         table.style.display = show ? 'none' : 'table'; | ||||
|     } | ||||
| } | ||||
|  | ||||
| function updateCurrentPathDisplay() { | ||||
|     const pathDisplay = document.getElementById('current-path'); | ||||
|     pathDisplay.textContent = '/' + config.currentPath; | ||||
|     if (pathDisplay) { | ||||
|         pathDisplay.textContent = '/' + config.currentPath; | ||||
|     } | ||||
| } | ||||
|  | ||||
| async function loadBucketContents(path = '', pushToHistory = true) { | ||||
| @@ -292,6 +313,8 @@ function parseMinioXML(xmlText) { | ||||
|  | ||||
| function displayContents(contents) { | ||||
|     const tbody = document.getElementById('files-tbody'); | ||||
|     if (!tbody) return; | ||||
|      | ||||
|     tbody.innerHTML = ''; | ||||
|      | ||||
|     // Bouton parent directory si on n'est pas à la racine | ||||
| @@ -314,7 +337,10 @@ function displayContents(contents) { | ||||
|     }); | ||||
|      | ||||
|     // Afficher le tableau | ||||
|     document.getElementById('files-table').style.display = 'table'; | ||||
|     const filesTable = document.getElementById('files-table'); | ||||
|     if (filesTable) { | ||||
|         filesTable.style.display = 'table'; | ||||
|     } | ||||
|      | ||||
|     // Chercher et ouvrir automatiquement index.rst s'il existe | ||||
|     autoOpenIndexRst(contents.files); | ||||
| @@ -473,6 +499,11 @@ function showPreview(fileUrl, fileName) { | ||||
|     const previewTitle = document.getElementById('preview-title'); | ||||
|     const previewContent = document.getElementById('preview-content'); | ||||
|      | ||||
|     if (!previewSection || !previewTitle || !previewContent) { | ||||
|         console.error('Éléments de prévisualisation non trouvés'); | ||||
|         return; | ||||
|     } | ||||
|      | ||||
|     previewTitle.textContent = `Prévisualisation: ${fileName}`; | ||||
|     previewContent.innerHTML = '<div style="text-align: center; padding: 20px;">Chargement...</div>'; | ||||
|      | ||||
| @@ -585,7 +616,9 @@ function showUnsupportedPreview(fileName, container) { | ||||
|  | ||||
| function hidePreview() { | ||||
|     const previewSection = document.getElementById('preview-section'); | ||||
|     previewSection.style.display = 'none'; | ||||
|     if (previewSection) { | ||||
|         previewSection.style.display = 'none'; | ||||
|     } | ||||
|      | ||||
|     currentPreviewFile = { url: '', name: '' }; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user