When implementing user preferences in vanilla JS with localStorage:
- •Use a single, versioned storage key (do not scatter multiple keys).
- •Default:
standupGenerator.settings.v1
- •Default:
- •Store a small JSON object. Example shape:
- •
{ "rememberRepoPath": boolean, "repoPath": string }
- •
- •Read path (on page load):
- •Wrap
JSON.parseintry/catch. - •If parsing fails or the shape is invalid, fall back to defaults.
- •Validate types:
- •
rememberRepoPathmust be boolean (defaultfalse). - •
repoPathmust be a string (default empty string).
- •
- •Trim
repoPath.
- •Wrap
- •Write path:
- •Only persist
repoPathwhenrememberRepoPathis true. - •If the user disables remembering, clear the saved
repoPath(or remove the key entirely).
- •Only persist
- •UX requirements:
- •Add a checkbox labeled “Remember this repo path”.
- •If a saved repoPath exists, prefill the input on load.
- •Refreshing the page should not wipe the repo path when remembering is enabled.
- •Keep the implementation minimal:
- •No frameworks.
- •No backend changes unless explicitly requested.
- •Keep DOM updates small and readable.
Output expectations:
- •Provide the smallest set of HTML/JS changes.
- •Use clear function names like
loadSettings()andsaveSettings(). - •Do not store sensitive data in localStorage.