Les Citations de Taha-Hassine Ferhat
/* Styles CSS (identiques à votre code, mais regroupés ici pour la clarté) */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: ‘Georgia’, serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
color: #333;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.header {
text-align: center;
margin-bottom: 40px;
color: white;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
font-weight: normal;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
.header .subtitle {
font-size: 1.2rem;
opacity: 0.9;
font-style: italic;
}
.citation-card {
background: linear-gradient(135deg, #f8f9ff, #e8f0ff);
border-left: 5px solid #667eea;
padding: 25px;
margin-bottom: 20px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.citation-card::before {
content: ‘ »‘;
font-size: 4rem;
color: rgba(102, 126, 234, 0.1);
position: absolute;
top: -10px;
left: 20px;
font-family: serif;
}
.citation-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.citation-text {
font-size: 1.1rem;
line-height: 1.6;
color: #444;
margin-bottom: 15px;
position: relative;
z-index: 1;
}
.citation-meta {
display: flex;
justify-content: space-between;
align-items: center;
color: #888;
font-size: 0.9rem;
}
.citation-tags {
display: flex;
gap: 8px;
}
.tag {
background: rgba(102, 126, 234, 0.1);
color: #667eea;
padding: 4px 12px;
border-radius: 15px;
font-size: 0.8rem;
}
.no-results {
text-align: center;
color: #888;
font-style: italic;
font-size: 1.1rem;
padding: 40px;
}
.sample-citations {
display: grid;
gap: 15px;
}
.loading-spinner {
display: none;
text-align: center;
padding: 40px;
color: #667eea;
}
.loading-spinner.show {
display: block;
}
.spinner {
width: 40px;
height: 40px;
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 20px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.load-more-btn {
display: block;
margin: 20px auto;
padding: 12px 30px;
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
border: none;
border-radius: 25px;
cursor: pointer;
font-size: 1rem;
transition: all 0.3s ease;
}
.load-more-btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.load-more-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
@media (max-width: 768px) {
.header h1 {
font-size: 2rem;
}
.filters {
justify-content: center;
}
.citation-meta {
flex-direction: column;
align-items: flex-start;
gap: 10px;
}
}
// Fonction pour afficher le loader
function showLoading(show) {
const loader = document.getElementById(‘loadingSpinner’);
loader.style.display = show ? ‘block’ : ‘none’;
}
// Fonction pour afficher un message d’erreur
function showError(message) {
const citationsList = document.getElementById(‘citationsList’);
citationsList.innerHTML = `
${message}
`;
}
// Fonction pour afficher les citations
function displayCitations(citationsToDisplay, searchTerm = ») {
const resultsContainer = document.getElementById(‘resultsContainer’);
const resultsCount = document.getElementById(‘resultsCount’);
const citationsList = document.getElementById(‘citationsList’);
const loadMoreBtn = document.getElementById(‘loadMoreBtn’);
const welcomeSection = document.getElementById(‘welcomeSection’);
// Masquer la section de bienvenue
welcomeSection.style.display = ‘none’;
if (citationsToDisplay.length === 0 && searchTerm === ») {
// Aucune citation à afficher et pas de recherche, afficher la section de bienvenue
resultsContainer.style.display = ‘none’;
welcomeSection.style.display = ‘block’;
return;
}
if (citationsToDisplay.length === 0) {
// Aucune citation trouvée
resultsCount.textContent = ‘Aucune citation ne correspond à votre recherche.’;
citationsList.innerHTML = ‘
Aucune citation ne correspond à votre recherche.
‘;
resultsContainer.style.display = ‘block’;
loadMoreBtn.style.display = ‘none’; // Masquer le bouton « Charger plus »
return;
}
// Afficher le nombre de citations
resultsCount.textContent = `${citationsToDisplay.length} citation${citationsToDisplay.length > 1 ? ‘s’ : »} trouvée${citationsToDisplay.length > 1 ? ‘s’ : »}`;
// Générer le HTML pour chaque citation
citationsList.innerHTML = citationsToDisplay.map(citation => {
const highlightedText = highlightSearchTerm(citation, searchTerm);
return `
`;
}).join( »);
// Afficher les résultats et le bouton « Charger plus »
resultsContainer.style.display = ‘block’;
loadMoreBtn.style.display = hasMoreCitations() ? ‘block’ : ‘none’;
}
// Fonction pour vérifier s’il y a plus de citations à charger
function hasMoreCitations() {
const startIndex = (currentPage – 1) * citationsPerPage;
return startIndex + citationsPerPage < allCitations.length;
}
// Fonction pour surligner le terme de recherche dans le texte de la citation
function highlightSearchTerm(text, searchTerm) {
if (!searchTerm) return text;
const regex = new RegExp(`(${searchTerm})`, 'gi');
return text.replace(regex, '<mark style="background: rgba(102, 126, 234, 0.3); padding: 2px