3.3 KiB
3.3 KiB
URL State Management
Current Status
URL state management is implemented in the current frontend.
The quiz now supports:
- Shareable URLs for in-progress quiz state
- Direct links to product detail views
- Browser refresh without losing the current route context
- Browser back/forward support
- Share buttons on results and product-detail views
Current URL Parameters
b- accumulated bitwise state for the user selectionsq- current question key orresultsp- product code for direct product-detail views
Examples:
/quiz/?b=16401&q=results
/quiz/?p=404&b=16401
/quiz/product/404
What Is Implemented
Core State Handling
accumulatedBitValueis tracked in the frontendBIT_DEFINITIONSconstants are present inscript.jsproduct_bitwise.jsonis loaded during startupupdateBitValue()updates the accumulated bitmask from answer filtersupdateURL()writesbandqparams without reloading the pageinitFromURL()restores the app from query params or direct product routesrestoreStateFromBitValue()rebuilds the key quiz selections from the bitmaskstartOver()clears the URL state
Product Deep Linking
- Product cards open detail views through
showProductByCode() - Product detail views push the selected product code into the URL
- Direct query-string product links are supported with
?p=<code> - Direct Flask routes are supported with
/quiz/product/<product_code>
Share and Navigation Support
shareCurrentPage()copies the current URL to the clipboard when supported- A notification helper is shown after successful copy
- Share buttons exist on results and product detail screens
- A
popstatelistener handles browser back/forward navigation
Implementation Notes
The current implementation restores the primary quiz state used by filtering:
- base type
- subtype
- material
- color
That is enough to reopen result sets and product-detail pages consistently.
Dimension data is still primarily driven by the current session flow rather than fully reconstructed from the URL alone.
Validation Checklist
- Bitwise data loads at startup
- URLs update as quiz answers are selected
- Results pages can be shared with
bandq - Product pages can be shared with
p - Browser refresh restores route context
- Browser back button is handled in code
- Browser forward button is handled in code
- Full manual regression testing across all quiz paths
Known Limits
- URL restoration is designed around the current bitwise filter model, not a complete replay of every form interaction.
- Conditional question metadata exists in the navigation data, but the frontend does not yet use a fully generic conditional-resolution engine.
Related Files
app/static/js/script.jsapp/data/product_bitwise.jsoninformation/BITWISE_USAGE_GUIDE.mdinformation/REQUIRED_CODE_CHANGES.md
Recommended Next Steps
- Manually test refresh and back/forward behavior on all major quiz branches.
- Extend restoration if dimension-specific deep linking becomes a requirement.
- Finish generic conditional navigation so URL restoration and question skipping use the same rules.