diff --git a/404.html b/404.html index 83a5138..5fcfc4a 100644 --- a/404.html +++ b/404.html @@ -19,7 +19,7 @@ +
${col.descripcion || ''}
+ `; + card.addEventListener('click', () => { + showQuiz(); + updateUrlForCollection(col.id); + collectionSelect.value = col.id; + localStorage.setItem(COLLECTION_STORAGE_KEY, col.id); + loadQuestionsFromCollection(col.id); + updateCollectionTitleById(col.id); + }); + homeCarousel.appendChild(card); + }); +} + // --- Inicialización --- document.addEventListener('DOMContentLoaded', function() { @@ -85,6 +127,8 @@ document.addEventListener('DOMContentLoaded', function() { timeProgressDiv = document.getElementById('time-progress'); timeBarDiv = document.getElementById('time-bar'); timeRemainingSpan = document.getElementById('time-remaining'); + homeContainer = document.getElementById('home-container'); + homeCarousel = document.getElementById('home-carousel'); collectionSelect = document.getElementById('collection-select'); changeCollectionButton = document.getElementById('change-collection-button'); collectionModalOverlay = document.getElementById('collection-modal-overlay'); @@ -112,7 +156,7 @@ document.addEventListener('DOMContentLoaded', function() { !changeCollectionButton || !collectionModalOverlay || !collectionModal || !confirmCollectionButton || !configButton || !configModalOverlay || !configModal || !configRepsOnErrorInput || !configInitialRepsInput || !configThemeSelect || !saveConfigButton || !closeModalButton || !closeModalXButton || - !sidebar || !openSidebarButton || !closeSidebarButton || !collectionTitleSpan) { + !sidebar || !openSidebarButton || !closeSidebarButton || !collectionTitleSpan || !homeContainer || !homeCarousel) { console.error("Error: No se encontraron elementos esenciales del DOM (quiz, status, inputs, o elementos del modal)."); if(quizDiv) quizDiv.innerHTML = ""; return; @@ -128,6 +172,13 @@ document.addEventListener('DOMContentLoaded', function() { window.addEventListener('beforeunload', saveState); document.addEventListener('visibilitychange', handleVisibilityChange); autosaveIntervalId = setInterval(saveState, 10000); + window.addEventListener('popstate', () => { + if (isHomePath()) { + showHome(); + } else { + showQuiz(); + } + }); }); function setupEventListeners() { @@ -207,7 +258,8 @@ async function loadCollections() { availableCollections.forEach(c => { const opt = document.createElement('option'); opt.value = c.id; - opt.textContent = c.nombre; + const name = c.materia ? `${c.materia} - ${c.nombre}` : c.nombre; + opt.textContent = name; collectionSelect.appendChild(opt); }); customOption = document.createElement('option'); @@ -216,6 +268,13 @@ async function loadCollections() { customOption.disabled = true; collectionSelect.appendChild(customOption); + populateHomeCarousel(); + + if (isHomePath()) { + showHome(); + return; + } + const saved = localStorage.getItem(COLLECTION_STORAGE_KEY); const pathId = getCollectionIdFromPath(); @@ -339,7 +398,12 @@ function updateCollectionTitleById(id) { collectionTitleSpan.textContent = 'Personalizado'; } else { const col = availableCollections.find(c => c.id === id); - collectionTitleSpan.textContent = col ? col.nombre : 'Colección'; + if (col) { + const title = col.materia ? `${col.materia} - ${col.nombre}` : col.nombre; + collectionTitleSpan.innerHTML = title; + } else { + collectionTitleSpan.textContent = 'Colección'; + } } } diff --git a/styles.css b/styles.css index 6db5ddd..459ff34 100644 --- a/styles.css +++ b/styles.css @@ -38,6 +38,7 @@ --status-error-bg: #f8d7da; --status-error-color: #721c24; --status-error-border: #f5c6cb; + --subject-color: #d63384; --modal-bg: #fff; } @@ -81,6 +82,7 @@ body.dark-mode { --partial-selection-color: #fff2b3; --partial-selection-border: #b1922c; --modal-bg: #2a2a2a; + --subject-color: #e670a5; } html { @@ -765,3 +767,41 @@ body.sidebar-open #open-sidebar { border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); } + +/* --- Estilos para la pantalla de inicio --- */ +.home-container { + width: 90%; + max-width: 1000px; + margin: 2rem auto; + text-align: center; +} + +.home-carousel { + display: flex; + overflow-x: auto; + gap: 1rem; + padding: 1rem 0; +} + +.collection-card { + flex: 0 0 auto; + background-color: var(--container-bg); + border-radius: 8px; + box-shadow: 0 0 10px rgba(0,0,0,0.1); + padding: 1rem; + width: 220px; + cursor: pointer; + border: 2px solid transparent; + transition: border-color 0.3s ease; +} + +.collection-card:hover { + border-color: var(--option-selected-border); +} + +.collection-subject { + font-weight: bold; + color: var(--subject-color); + display: block; + margin-bottom: 0.5rem; +}