Spaces:
Running
Running
lorsqu'on fait une recherche dans la note, il montre seulement les mots correspondants et ceux ressemblants - Follow Up Deployment
444bc2c verified Download index.html from pablo15364136/cool: direct link, hf CLI and curl.
- Browser
- Download file 24.4 kB
-
https://huggingface.co/spaces/pablo15364136/cool/resolve/main/index.html
- Command line
-
hf download hf://spaces/pablo15364136/cool/index.html
-
curl -L -o index.html https://huggingface.co/spaces/pablo15364136/cool/resolve/main/index.html
24.4 kB
| <html lang="fr"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Application de Notes</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .note-content { | |
| min-height: 300px; | |
| border: 1px solid #e5e7eb; | |
| padding: 1rem; | |
| border-radius: 0.5rem; | |
| background-color: white; | |
| } | |
| .note-item:hover { | |
| background-color: #f3f4f6; | |
| } | |
| .note-item.active { | |
| background-color: #e5e7eb; | |
| border-left: 4px solid #3b82f6; | |
| } | |
| .search-highlight { | |
| background-color: #fef08a; | |
| padding: 0 2px; | |
| } | |
| @media (max-width: 768px) { | |
| .main-container { | |
| flex-direction: column; | |
| } | |
| .notes-list { | |
| width: 100% ; | |
| max-height: 200px ; | |
| } | |
| .editor-container { | |
| width: 100% ; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <header class="mb-8"> | |
| <h1 class="text-3xl font-bold text-gray-800">Mon Espace Notes</h1> | |
| <p class="text-gray-600">Organisez et retrouvez facilement vos notes</p> | |
| </header> | |
| <!-- Barre de recherche globale --> | |
| <div class="mb-6 relative"> | |
| <input type="text" id="global-search" placeholder="Rechercher une note..." | |
| class="w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500"> | |
| <button id="clear-global-search" class="absolute right-3 top-2 text-gray-400 hover:text-gray-600"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="main-container flex flex-col md:flex-row gap-6"> | |
| <!-- Liste des notes --> | |
| <div class="notes-list w-full md:w-1/3 bg-white rounded-lg shadow overflow-hidden"> | |
| <div class="p-4 border-b border-gray-200 flex justify-between items-center"> | |
| <h2 class="text-lg font-semibold text-gray-700">Mes Notes</h2> | |
| <div class="flex space-x-2"> | |
| <button id="new-note" class="p-2 text-blue-500 hover:text-blue-700"> | |
| <i class="fas fa-plus"></i> | |
| </button> | |
| <label for="file-import" class="p-2 text-green-500 hover:text-green-700 cursor-pointer"> | |
| <i class="fas fa-file-import"></i> | |
| <input type="file" id="file-import" class="hidden" accept=".xlsx,.xls,.csv,image/*" multiple> | |
| </label> | |
| </div> | |
| </div> | |
| <div id="notes-container" class="overflow-y-auto max-h-[500px]"> | |
| <!-- Les notes seront ajoutées ici dynamiquement --> | |
| </div> | |
| </div> | |
| <!-- Éditeur de note --> | |
| <div class="editor-container w-full md:w-2/3"> | |
| <div class="bg-white rounded-lg shadow overflow-hidden"> | |
| <div class="p-4 border-b border-gray-200 flex justify-between items-center"> | |
| <input type="text" id="note-title" placeholder="Titre de la note" | |
| class="text-xl font-semibold w-full focus:outline-none"> | |
| <button id="save-note" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"> | |
| Enregistrer | |
| </button> | |
| </div> | |
| <!-- Barre de recherche dans la note --> | |
| <div class="p-2 border-b border-gray-200 relative"> | |
| <input type="text" id="in-note-search" placeholder="Rechercher dans cette note..." | |
| class="w-full px-3 py-1 text-sm rounded border border-gray-300 focus:outline-none focus:ring-1 focus:ring-blue-500"> | |
| <div class="absolute right-3 top-2 text-sm text-gray-500 flex items-center space-x-2"> | |
| <span id="search-count">0/0</span> | |
| <button id="search-prev" class="text-gray-400 hover:text-gray-600"> | |
| <i class="fas fa-chevron-up"></i> | |
| </button> | |
| <button id="search-next" class="text-gray-400 hover:text-gray-600"> | |
| <i class="fas fa-chevron-down"></i> | |
| </button> | |
| <button id="clear-search" class="text-gray-400 hover:text-gray-600"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div class="p-4"> | |
| <div id="note-content" class="note-content" contenteditable="true"> | |
| Commencez à écrire votre note ici... | |
| </div> | |
| </div> | |
| <!-- Zone d'affichage des fichiers importés --> | |
| <div id="attachments" class="p-4 border-t border-gray-200"> | |
| <h3 class="text-sm font-medium text-gray-500 mb-2">Fichiers joints</h3> | |
| <div id="files-container" class="flex flex-wrap gap-2"> | |
| <!-- Les fichiers importés seront affichés ici --> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Variables d'état | |
| let notes = JSON.parse(localStorage.getItem('notes')) || []; | |
| let currentNoteId = null; | |
| let searchResults = []; | |
| let currentSearchIndex = -1; | |
| // Éléments du DOM | |
| const notesContainer = document.getElementById('notes-container'); | |
| const noteTitle = document.getElementById('note-title'); | |
| const noteContent = document.getElementById('note-content'); | |
| const saveButton = document.getElementById('save-note'); | |
| const newNoteButton = document.getElementById('new-note'); | |
| const fileImport = document.getElementById('file-import'); | |
| const globalSearch = document.getElementById('global-search'); | |
| const clearGlobalSearch = document.getElementById('clear-global-search'); | |
| const inNoteSearch = document.getElementById('in-note-search'); | |
| const searchPrev = document.getElementById('search-prev'); | |
| const searchNext = document.getElementById('search-next'); | |
| const clearSearch = document.getElementById('clear-search'); | |
| const searchCount = document.getElementById('search-count'); | |
| const filesContainer = document.getElementById('files-container'); | |
| // Initialisation | |
| renderNotes(); | |
| if (notes.length > 0) { | |
| loadNote(notes[0].id); | |
| } | |
| // Événements | |
| saveButton.addEventListener('click', saveNote); | |
| newNoteButton.addEventListener('click', createNewNote); | |
| fileImport.addEventListener('change', handleFileImport); | |
| globalSearch.addEventListener('input', searchNotes); | |
| clearGlobalSearch.addEventListener('click', () => { | |
| globalSearch.value = ''; | |
| searchNotes(); | |
| }); | |
| inNoteSearch.addEventListener('input', searchInNote); | |
| searchPrev.addEventListener('click', () => navigateSearch(-1)); | |
| searchNext.addEventListener('click', () => navigateSearch(1)); | |
| clearSearch.addEventListener('click', clearNoteSearch); | |
| // Fonctions | |
| function renderNotes(filteredNotes = null) { | |
| const notesToRender = filteredNotes || notes; | |
| notesContainer.innerHTML = ''; | |
| if (notesToRender.length === 0) { | |
| notesContainer.innerHTML = '<p class="p-4 text-gray-500 text-center">Aucune note disponible</p>'; | |
| return; | |
| } | |
| notesToRender.forEach(note => { | |
| const noteElement = document.createElement('div'); | |
| noteElement.className = `note-item p-4 border-b border-gray-200 cursor-pointer flex justify-between items-center ${currentNoteId === note.id ? 'active' : ''}`; | |
| noteElement.innerHTML = ` | |
| <div> | |
| <h3 class="font-medium">${note.title || 'Sans titre'}</h3> | |
| <p class="text-sm text-gray-500 truncate">${note.content.replace(/<[^>]*>/g, '').substring(0, 50)}...</p> | |
| <p class="text-xs text-gray-400 mt-1">${new Date(note.updatedAt).toLocaleString()}</p> | |
| </div> | |
| <button class="delete-note text-red-400 hover:text-red-600 p-1" data-id="${note.id}"> | |
| <i class="fas fa-trash"></i> | |
| </button> | |
| `; | |
| noteElement.addEventListener('click', () => loadNote(note.id)); | |
| notesContainer.appendChild(noteElement); | |
| }); | |
| // Ajout des événements de suppression | |
| document.querySelectorAll('.delete-note').forEach(button => { | |
| button.addEventListener('click', function(e) { | |
| e.stopPropagation(); | |
| const id = this.getAttribute('data-id'); | |
| deleteNote(id); | |
| }); | |
| }); | |
| } | |
| function createNewNote() { | |
| currentNoteId = null; | |
| noteTitle.value = ''; | |
| noteContent.innerHTML = 'Commencez à écrire votre note ici...'; | |
| filesContainer.innerHTML = ''; | |
| document.querySelectorAll('.note-item').forEach(item => item.classList.remove('active')); | |
| } | |
| function loadNote(id) { | |
| const note = notes.find(n => n.id === id); | |
| if (note) { | |
| currentNoteId = id; | |
| noteTitle.value = note.title; | |
| noteContent.innerHTML = note.content; | |
| // Mettre à jour les fichiers joints | |
| filesContainer.innerHTML = ''; | |
| if (note.attachments && note.attachments.length > 0) { | |
| note.attachments.forEach(file => { | |
| const fileElement = document.createElement('div'); | |
| fileElement.className = 'flex items-center bg-gray-100 rounded px-3 py-2'; | |
| if (file.type.startsWith('image/')) { | |
| fileElement.innerHTML = ` | |
| <div class="w-10 h-10 bg-gray-200 rounded overflow-hidden mr-2"> | |
| <img src="${file.data}" alt="${file.name}" class="w-full h-full object-cover"> | |
| </div> | |
| <span class="text-sm truncate max-w-xs">${file.name}</span> | |
| `; | |
| } else { | |
| fileElement.innerHTML = ` | |
| <i class="fas fa-file-excel text-green-500 mr-2"></i> | |
| <span class="text-sm truncate max-w-xs">${file.name}</span> | |
| `; | |
| } | |
| filesContainer.appendChild(fileElement); | |
| }); | |
| } | |
| // Mettre en surbrillance la note active | |
| document.querySelectorAll('.note-item').forEach(item => { | |
| item.classList.remove('active'); | |
| if (item.querySelector('.delete-note').getAttribute('data-id') === id) { | |
| item.classList.add('active'); | |
| } | |
| }); | |
| } | |
| } | |
| function saveNote() { | |
| const title = noteTitle.value.trim(); | |
| const content = noteContent.innerHTML.trim(); | |
| if (!title && !content) return; | |
| const now = new Date(); | |
| if (currentNoteId) { | |
| // Mettre à jour la note existante | |
| const noteIndex = notes.findIndex(n => n.id === currentNoteId); | |
| if (noteIndex !== -1) { | |
| notes[noteIndex] = { | |
| ...notes[noteIndex], | |
| title, | |
| content, | |
| updatedAt: now | |
| }; | |
| } | |
| } else { | |
| // Créer une nouvelle note | |
| const newNote = { | |
| id: Date.now().toString(), | |
| title, | |
| content, | |
| createdAt: now, | |
| updatedAt: now, | |
| attachments: [] | |
| }; | |
| notes.unshift(newNote); | |
| currentNoteId = newNote.id; | |
| } | |
| localStorage.setItem('notes', JSON.stringify(notes)); | |
| renderNotes(); | |
| loadNote(currentNoteId); | |
| } | |
| function deleteNote(id) { | |
| if (confirm('Voulez-vous vraiment supprimer cette note ?')) { | |
| notes = notes.filter(note => note.id !== id); | |
| localStorage.setItem('notes', JSON.stringify(notes)); | |
| if (currentNoteId === id) { | |
| createNewNote(); | |
| } | |
| renderNotes(); | |
| // Si on a une recherche active, mettre à jour les résultats | |
| if (globalSearch.value.trim()) { | |
| searchNotes(); | |
| } | |
| } | |
| } | |
| function handleFileImport(e) { | |
| const files = Array.from(e.target.files); | |
| if (!files.length) return; | |
| if (!currentNoteId) { | |
| // Créer une nouvelle note si aucune n'est sélectionnée | |
| createNewNote(); | |
| noteTitle.value = 'Nouvelle note avec fichiers'; | |
| saveNote(); | |
| } | |
| files.forEach(file => { | |
| const reader = new FileReader(); | |
| reader.onload = function(e) { | |
| const fileData = { | |
| name: file.name, | |
| type: file.type, | |
| size: file.size, | |
| data: e.target.result | |
| }; | |
| // Traitement spécial pour les fichiers Excel | |
| if (file.name.endsWith('.xlsx') || file.name.endsWith('.xls')) { | |
| try { | |
| const data = new Uint8Array(e.target.result); | |
| const workbook = XLSX.read(data, { type: 'array' }); | |
| // Convertir la première feuille en HTML | |
| const firstSheet = workbook.Sheets[workbook.SheetNames[0]]; | |
| const html = XLSX.utils.sheet_to_html(firstSheet); | |
| // Ajouter le contenu à la note | |
| noteContent.innerHTML += `<div class="mt-4 p-4 bg-gray-100 rounded-lg"> | |
| <h4 class="font-bold mb-2">Contenu du fichier ${file.name}:</h4> | |
| ${html} | |
| </div>`; | |
| // Sauvegarder automatiquement | |
| saveNote(); | |
| } catch (error) { | |
| console.error('Erreur de lecture du fichier Excel:', error); | |
| alert('Erreur lors de la lecture du fichier Excel'); | |
| } | |
| } | |
| // Ajouter le fichier à la note actuelle | |
| const noteIndex = notes.findIndex(n => n.id === currentNoteId); | |
| if (noteIndex !== -1) { | |
| if (!notes[noteIndex].attachments) { | |
| notes[noteIndex].attachments = []; | |
| } | |
| notes[noteIndex].attachments.push(fileData); | |
| localStorage.setItem('notes', JSON.stringify(notes)); | |
| loadNote(currentNoteId); | |
| } | |
| }; | |
| if (file.type.startsWith('image/')) { | |
| reader.readAsDataURL(file); | |
| } else if (file.name.endsWith('.xlsx') || file.name.endsWith('.xls')) { | |
| reader.readAsArrayBuffer(file); | |
| } else { | |
| reader.readAsText(file); | |
| } | |
| }); | |
| // Réinitialiser l'input pour permettre de réimporter le même fichier | |
| e.target.value = ''; | |
| } | |
| function searchNotes() { | |
| const query = globalSearch.value.trim().toLowerCase(); | |
| if (!query) { | |
| renderNotes(); | |
| return; | |
| } | |
| const filteredNotes = notes.filter(note => { | |
| return note.title.toLowerCase().includes(query) || | |
| note.content.toLowerCase().includes(query); | |
| }); | |
| renderNotes(filteredNotes); | |
| } | |
| function searchInNote() { | |
| const query = inNoteSearch.value.trim(); | |
| if (!query) { | |
| clearNoteSearch(); | |
| return; | |
| } | |
| // Supprimer les surbrillances précédentes | |
| clearHighlights(); | |
| // Rechercher dans le contenu de la note | |
| const content = noteContent.textContent || noteContent.innerText; | |
| const regex = new RegExp(query, 'gi'); | |
| let match; | |
| searchResults = []; | |
| while ((match = regex.exec(content)) !== null) { | |
| searchResults.push({ | |
| start: match.index, | |
| end: match.index + match[0].length | |
| }); | |
| } | |
| if (searchResults.length > 0) { | |
| highlightMatches(); | |
| currentSearchIndex = 0; | |
| scrollToMatch(currentSearchIndex); | |
| updateSearchCounter(); | |
| } else { | |
| searchCount.textContent = '0/0'; | |
| } | |
| } | |
| function highlightMatches() { | |
| const content = noteContent.textContent || noteContent.innerText; | |
| let highlightedContent = ''; | |
| let lastIndex = 0; | |
| searchResults.forEach((match, index) => { | |
| highlightedContent += content.substring(lastIndex, match.start); | |
| highlightedContent += `<span class="search-highlight" data-index="${index}">${content.substring(match.start, match.end)}</span>`; | |
| lastIndex = match.end; | |
| }); | |
| highlightedContent += content.substring(lastIndex); | |
| noteContent.innerHTML = highlightedContent; | |
| } | |
| function clearHighlights() { | |
| const highlights = noteContent.querySelectorAll('.search-highlight'); | |
| highlights.forEach(highlight => { | |
| const text = document.createTextNode(highlight.textContent); | |
| highlight.parentNode.replaceChild(text, highlight); | |
| }); | |
| } | |
| function navigateSearch(direction) { | |
| if (searchResults.length === 0) return; | |
| currentSearchIndex += direction; | |
| if (currentSearchIndex < 0) { | |
| currentSearchIndex = searchResults.length - 1; | |
| } else if (currentSearchIndex >= searchResults.length) { | |
| currentSearchIndex = 0; | |
| } | |
| scrollToMatch(currentSearchIndex); | |
| updateSearchCounter(); | |
| } | |
| function scrollToMatch(index) { | |
| const highlight = noteContent.querySelector(`.search-highlight[data-index="${index}"]`); | |
| if (highlight) { | |
| highlight.scrollIntoView({ behavior: 'smooth', block: 'center' }); | |
| // Supprimer la classe active de tous les highlights | |
| document.querySelectorAll('.search-highlight').forEach(h => { | |
| h.classList.remove('bg-yellow-300'); | |
| }); | |
| // Ajouter la classe active au highlight actuel | |
| highlight.classList.add('bg-yellow-300'); | |
| } | |
| } | |
| function updateSearchCounter() { | |
| searchCount.textContent = `${currentSearchIndex + 1}/${searchResults.length}`; | |
| } | |
| function clearNoteSearch() { | |
| inNoteSearch.value = ''; | |
| clearHighlights(); | |
| searchResults = []; | |
| currentSearchIndex = -1; | |
| searchCount.textContent = '0/0'; | |
| } | |
| // Sauvegarde automatique lors de la perte de focus | |
| noteTitle.addEventListener('blur', saveNote); | |
| noteContent.addEventListener('blur', saveNote); | |
| // Sauvegarde périodique | |
| setInterval(saveNote, 30000); | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://deepsite.hf.co/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://deepsite.hf.co" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://deepsite.hf.co?remix=pablo15364136/cool" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |