Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rtajio/ESEN/llms.txt
Use this file to discover all available pages before exploring further.
app.js contains all client-side logic for ESEN. Every function is globally scoped and called either from inline onclick attributes in index.html or from other functions within app.js. The file is organized into labeled sections separated by comments. The following reference documents each function’s signature, parameters, behavior, and side effects, grouped by logical concern.
Authentication
Authentication
These three functions manage the full login/logout lifecycle. They read from and write to the global
Called when the user clicks the “Administrador” or “Estudiante” tab on the login screen.
Validates credentials and, on success, transitions the UI from the login screen to the application shell.
Ends the session and returns to the login screen.
currentUser, currentRole, and the DOM.setLoginRole(r)- Sets
currentRoletor('admin'or'estudiante'). - Toggles the
.activeclass on#tab-adminand#tab-est. - Pre-fills
#l-userand#l-passwith the matching demo credentials (admin01/admin123orest2021/est123).
doLogin()- Reads
#l-userand#l-passinput values. - Looks up a matching entry in
USUARIOSwhereuser,pass, androlall match. - If no match: displays
#login-errorand returns early. - If match:
- Sets
currentUserto the matched user object. - Hides
#login-screen, shows#app. - Shows
#nav-adminor#nav-estdepending onrol. - Sets the sidebar display name and username label.
- Writes today’s date to
#topbar-date. - Calls
showView('dashboard')for admin orshowView('mi-historial')for students.
- Sets
logout()- Sets
#apptodisplay: none. - Sets
#login-screentodisplay: flex. - Sets
currentUsertonull.
Logout does not clear form state in the activity modal or search inputs. Refreshing the page is the only way to fully reset all in-memory data.
Navigation
Navigation
Activity management (admin)
Activity management (admin)
openModal(mode, id)- Clears all form fields (
f-nombre,f-horas,f-res,f-fecha,f-desc,f-part). - If
mode === 'edit'andidis provided: finds the activity by ID, populates every field, setseditId = id, and changes the modal title to “Modificar actividad”. - If
modeis anything else: sets the modal title to “Registrar actividad” and leaveseditId = null. - Adds
.opento#modal-actand focuses#f-nombre.
saveActividad()-
f-nombre— activity name -
f-horas— hours (parsed as integer; must be > 0) -
f-res— resolution number -
f-fecha— date -
If
editIdis set: finds the activity and applies changes withObject.assign. -
If
editIdis null: pushes a new object withid: nextId++andactivo: true. -
Closes the modal, calls
renderActTable(), and shows a success toast.
closeModal(id).open class from the element with the given id.toggleActivo(id)activo boolean for the activity with the given id, re-renders the table, and shows a toast confirming the new state.deleteAct(id)actividades array after the user confirms the browser confirm() dialog. Re-renders the table and shows a toast. This operation cannot be undone.Render functions
Render functions
Each render function reads from the global
actividades, estudiantes, and currentUser variables and writes HTML directly to a target element’s innerHTML.renderDash()Computes four stat values from actividades:- Total active activities
- Unique participants (via
Set) - Total accumulated hours (active activities × participants per activity)
- Number of unique resolution numbers
#stat-total, #stat-est, #stat-hrs, and #stat-res. Renders the first six activities into #dash-table.renderActTable()Reads #filter-cat and #filter-month values and applies them as filters to a copy of actividades. Renders the filtered result into #act-table, including edit/toggle/delete action buttons on each row.renderEstTable()Reads the #est-search input and filters estudiantes by name or student code (case-insensitive). For each student, calls getEstActs() and getEstHoras() to compute participation counts. Renders into #est-table.renderReportes()Renders three sections:- A CSS bar chart in
#report-catsshowing total hours per category, normalized to the maximum. - General summary stats in
#report-gen(total activities, active activities, total hours, total participations, average hours per activity, student count). - A detail table in
#report-tablewith all activities.
renderHistorial()Filters actividades to those where participantes includes currentUser.nombre. Writes total activity count and hours to #s-act, #s-hrs, and #s-val. Renders the matching activities as history rows in #hist-list.renderPub()Filters actividades to activo === true only. Renders the result into #pub-table — a read-only view with no action buttons, shown to student accounts.Utilities
Utilities
catBadge(c)<span> with the appropriate badge class from CAT_COLORS. Falls back to badge-gray for unknown categories.statusBadge(activo)<span> for active (badge-green, text “Activo”) or inactive (badge-gray, text “Inactivo”) states.initials(nombre)nombre by spaces, takes the first character of the first two words, and returns them uppercased. Used to generate avatar text in the students table.showToast(msg)#toast-msg text to msg and adds the .show class to #toast, making it visible. Automatically removes .show after 2800 ms via setTimeout. Calling showToast again before the timer fires clears the previous timer with clearTimeout.formatDate(d)YYYY-MM-DD date string to DD/MM/YYYY format. Returns '—' if d is falsy.exportCSV()actividades with seven columns: Actividad, Categoría, Horas, Participantes, Resolución, Fecha, Estado. Prepends a UTF-8 BOM (\uFEFF) for correct Excel encoding. Creates a Blob, generates an object URL, programmatically clicks a temporary <a> element to trigger the download as reporte-actividades-esen.csv, then revokes the URL.Event listeners
Event listeners
Two global event listeners are registered at the bottom of
Modal backdrop clickCloses a modal when the user clicks the dimmed overlay area behind the modal panel. The
Escape keyPressing
app.js after all function definitions.Modal backdrop click
e.target === backdrop guard prevents the modal from closing when the user clicks inside the panel itself.Escape key
Escape closes all open modals and closes the mobile sidebar if it is open.