Adding a Frontend Feature
You are adding a new feature to the FoxESS Battery Monitor dashboard. The entire frontend is a single file: public/index.html.
Before Starting
- •Read
public/index.htmlto understand the current structure - •Identify where the new feature fits (header, stats grid, weather panel, settings, etc.)
- •Plan the changes needed: HTML, CSS, and JS
iOS 12 Compatibility (MANDATORY)
All JavaScript in public/index.html MUST work on iOS 12 Safari:
- •Use
var— neverletorconst - •Use
function() {}— never arrow functions() => {} - •Use string concatenation — never template literals
- •Use indexed
forloops — neverfor...of - •Use
XMLHttpRequest— neverfetch() - •No destructuring, spread, rest, optional chaining, nullish coalescing
Implementation Steps
- •Add HTML in the appropriate section of the file
- •Add CSS in the
<style>block, following existing patterns:- •Dark theme: background
#1a1a2e, cards#16213e, text#e0e0e0 - •Accent colors: green
#4ade80, blue#60a5fa, yellow#fbbf24 - •Use existing class naming conventions
- •Dark theme: background
- •Add JavaScript:
- •Cache new DOM elements in
initializeElements()and add to theelementsobject - •Store any user config in the
configobject (persisted to localStorage) - •If adding a settings toggle, add it to the settings panel HTML,
loadSettings(), andsaveSettings() - •If fetching external data, use
XMLHttpRequestwithonreadystatechange - •If using Open-Meteo time data, use
&timeformat=unixtimeandnew Date(timestamp * 1000)
- •Cache new DOM elements in
- •Bump version: Update
<meta name="app-version" content="X.Y.Z">(semver)
Validation Checklist
Before finishing, grep for these patterns that would break iOS 12:
- •Arrow functions:
=> - •Let/const:
\blet\b,\bconst\b(in JS, not CSS) - •Template literals: backtick characters
- •For...of:
for.*of
After Implementation
- •Ask the user if they want to commit and push
- •If committing, use a concise message with
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> - •Run
/reflectto update documentation if the change is significant