Search Notes -
- - - - -
-
-
-
+
+
+
+ NotesVault - Browse Notes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+ Browse Notes
++ Find & access uploaded notes from students & creators! +
-
-
+
+
+
+ Search Notes -
+ + + - -
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
- -
-
- -
Bookmarked Notes
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
\ No newline at end of file
+ // Generate Download Filename
+ function getDownloadFilename(note) {
+ return `${note.title.replace(/\s/g, '_')}.pdf`
+ }
+
+ // Open Note Modal
+ function openNoteDetailModal(note) {
+ modalElements.title.textContent = note.title
+ modalElements.branch.textContent = note.branch
+ modalElements.semester.textContent = note.semester
+ modalElements.description.textContent =
+ note.description || 'No description available'
+ modalElements.uploader.textContent = note.uploader
+ modalElements.uploadDate.textContent = note.uploadDate
+ ? new Date(note.uploadDate).toLocaleDateString()
+ : 'Unknown date'
+
+ if (note.filePath) {
+ modalElements.downloadButton.href = note.filePath
+ modalElements.downloadButton.setAttribute(
+ 'download',
+ getDownloadFilename(note)
+ )
+ modalElements.downloadButton.style.display = 'inline-flex'
+ } else {
+ modalElements.downloadButton.style.display = 'none'
+ }
+
+ noteDetailModal.style.display = 'flex'
+ document.body.style.overflow = 'hidden' // No Scrolling (Modal Open)
+ }
+
+ // Close Note Modal
+ function closeNoteDetailModal() {
+ noteDetailModal.style.display = 'none'
+ document.body.style.overflow = 'auto' // Enable Scrolling (Modal Close)
+ }
+
+ // Show Error Message
+ function showErrorMessage(message) {
+ const errorElement = document.createElement('p')
+ errorElement.className = 'error-message'
+ errorElement.textContent = message
+ notesGrid.appendChild(errorElement)
+ }
+
+ // Filter Notes Based On All Active Filters
+ function filterNotes() {
+ const searchQuery = searchInput.value.toLowerCase().trim()
+ const selectedBranch = branchFilter.value
+ const selectedSemester = semesterFilter.value
+
+ const filteredNotes = allNotes.filter((note) => {
+ // Text Search (Title & Uploader)
+ const matchesSearch =
+ searchQuery === '' ||
+ note.title.toLowerCase().includes(searchQuery) ||
+ (note.uploader &&
+ note.uploader.toLowerCase().includes(searchQuery))
+
+ // Branch Filter
+ const matchesBranch =
+ selectedBranch === '' || note.branch === selectedBranch
+
+ // Semester Filter
+ const matchesSemester =
+ selectedSemester === '' || note.semester === selectedSemester
+
+ return matchesSearch && matchesBranch && matchesSemester
+ })
+
+ displayNotes(filteredNotes)
+ }
+
+ // Reset All Filters
+ function resetAllFilters() {
+ searchInput.value = ''
+ branchFilter.value = ''
+ semesterFilter.value = ''
+ filterNotes()
+ }
+
+ // Setup Event Listeners
+ function setupEventListeners() {
+ // Search Input
+ searchInput.addEventListener('input', filterNotes)
+
+ // Filter Dropdown
+ branchFilter.addEventListener('change', filterNotes)
+ semesterFilter.addEventListener('change', filterNotes)
+
+ // Reset Filters Button
+ resetFiltersBtn.addEventListener('click', resetAllFilters)
+
+ // Modal Close Button
+ closeModalButton.addEventListener('click', closeNoteDetailModal)
+
+ // Close Modal When Clicking Outside Or Pressing Escape
+ window.addEventListener('click', (e) => {
+ if (e.target === noteDetailModal) closeNoteDetailModal()
+ })
+
+ window.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') closeNoteDetailModal()
+ })
+ }
+
+ // Initialize The Page
+ init()
+ })
+
+
+