Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/apursley2012/PunctuOwlity/llms.txt

Use this file to discover all available pages before exploring further.

app.js contains all client-side application logic for the PunctuOwlity web app and is loaded on every page via a <script src="app.js"> tag at the bottom of each HTML file’s <body>. Shared setup — logo injection, back-button wiring, password-toggle listeners, and the topbar menu — runs unconditionally on every page. Page-specific logic (event rendering, form submission handlers, and SMS preference routing) is gated behind checks on document.body.dataset.page, which is set as a data-page attribute in each HTML file.
Because app.js is shared by all pages, every function and constant defined at the top level is available in every page context. The events grid logic is guarded by if(document.body.dataset.page === 'main') and the add/edit form logic by if(document.body.dataset.page === 'add'); these are the only explicit dataset.page checks in the file. Form handlers on other pages (login, sign-up) attach via optional chaining (?.addEventListener) so they safely no-op on pages where the element is absent.

Event Storage

getEvents

const getEvents = () => { ... }
Reads the saved events array from localStorage. If the key is missing, the stored value is not a valid JSON array, or any exception is thrown during parsing, the function falls back to the built-in seedEvents array. Every record — whether loaded from storage or from the seed — is passed through normalizeEvent before being returned. Returns: Event[] — a normalized array of event objects ready for rendering.

saveEvents

const saveEvents = e => localStorage.setItem('punctuowlity-events', JSON.stringify(e))
Serializes the provided events array to JSON and writes it to localStorage under the key 'punctuowlity-events'. No validation is performed; callers are responsible for passing a well-formed array of event objects.
e
Event[]
required
The full array of event objects to persist. The previous value is overwritten entirely.

normalizeEvent

const normalizeEvent = event => { ... }
Transforms a raw or partially-formed event object into a fully normalized event. This function is the single source of truth for all display-ready field values. It is called on every event that passes through getEvents. Note that the add-event.html submit handler builds its item object manually rather than delegating to normalizeEvent; the resulting object is stored directly via saveEvents. The transformation steps are applied in order: Returns: A fully normalized Event object with all fields populated.

User / Account Storage

User records are stored in both localStorage and sessionStorage so that accounts survive browser restarts while also being available in private-browsing sessions where localStorage may be restricted.

getUsers

const getUsers = () => accountStorage.get()
Iterates the available storage backends (localStorage first, then sessionStorage) and returns the first array it successfully parses from the 'punctuowlity-users' key. Returns an empty array if no valid data is found in any storage. Returns: User[] — the array of registered user objects, or [] if none exist.

saveUsers

const saveUsers = users => accountStorage.set(users)
Serializes the users array to JSON and writes it to every available storage backend. Succeeds even if only one backend accepts the write.
users
User[]
required
The complete array of user objects to persist. Replaces any previously stored value.
Returns: booleantrue if at least one storage backend accepted the write; false if all writes failed (e.g. storage quota exceeded in all backends).

UI Helpers

toast

const toast = message => { ... }
Creates a transient notification element with the CSS class "toast" and appends it to document.body. Any existing .toast element is removed before the new one is inserted, so rapid successive calls never stack.
message
string
required
The text content to display in the notification. Rendered as textContent, not HTML.
The toast lifecycle:
  1. Element is created and appended.
  2. requestAnimationFrame triggers the "show" CSS class to start the entrance transition.
  3. After 2400 ms, the "show" class is removed to start the exit transition.
  4. After an additional 250 ms, the element is removed from the DOM.
Example calls from the application:
toast('Event Deleted');
toast('Event Added');
toast('Event Updated');
toast('Passwords do not match!');
toast('Invalid Username or Password');
toast('Account Created Successfully');

icon

const icon = name => `<svg aria-hidden="true"><use href="assets/icons.svg#${name}"/></svg>`
Returns an inline SVG string that references a symbol from the shared sprite sheet at assets/icons.svg. The aria-hidden="true" attribute ensures the icon is invisible to screen readers (all interactive elements provide their own aria-label).
name
string
required
The symbol ID within assets/icons.svg. Examples used in the application: "back", "search", "add-alarm", "edit", "delete", "alarm-on", "alarm-off".
Returns: string — an SVG HTML string suitable for use with innerHTML or insertAdjacentHTML.

Seed Events

The seedEvents constant is the fallback data set used when localStorage contains no valid events. All four objects are fully pre-normalized.
const seedEvents = [
  {
    id: 'project',
    day: 'SAT',
    date: '05',
    fullDate: '2025-04-05',
    rawTime: '',
    title: 'Project Two Due',
    time: 'ALL DAY',
    category: 'all',
    alert: false
  },
  {
    id: 'birthday',
    day: 'SAT',
    date: '12',
    fullDate: '2025-04-12',
    rawTime: '18:30',
    title: "Nich's Birthday",
    time: '06:30PM',
    category: 'birthday',
    alert: true
  },
  {
    id: 'dentist',
    day: 'MON',
    date: '14',
    fullDate: '2025-04-14',
    rawTime: '13:30',
    title: 'Dentist',
    time: '01:30PM',
    category: 'appointment',
    alert: false
  },
  {
    id: 'wedding',
    day: 'SUN',
    date: '20',
    fullDate: '2025-04-20',
    rawTime: '15:00',
    title: "Jessica's Wedding",
    time: '03:00PM',
    category: 'trip',
    alert: false
  }
];

Storage Keys Reference

The following table lists every key used by app.js across localStorage and sessionStorage.
KeyStorage typeValue typePurpose
punctuowlity-eventslocalStorageJSON array of Event objectsPersists all user-created events between sessions
punctuowlity-userslocalStorage + sessionStorageJSON array of User objectsStores registered user accounts
punctuowlity-authenticatedsessionStorageString "true"Tracks whether the current session is authenticated; cleared when the tab closes
punctuowlity-smslocalStorageString "allowed" or "denied"Records the user’s SMS/notification preference from sms.html; absence triggers a redirect to sms.html
punctuowlity-notified-{id}-{date}sessionStorageString "true"Prevents duplicate notifications for the same event on the same day

Build docs developers (and LLMs) love