This project is a 12-year-old codebase with zero modern dependencies. It uses a custom build system and a legacy "global-state" architecture. Here are the most critical things to know when working on it:
The Gruntfile.js contains a concat task with a very aggressive process function.
- Pattern Stripping: It uses regexes to strip certain code patterns during concatenation to make the file "runnable standalone".
- The "window" Trap: Specifically, the line
.replace(/(^|\n)[ \t]*const .* = window/g, '')will silently delete anyconstorvarinitialization that sources fromwindow.- Bad:
const rawSpot = window.SpotCache[id];-> becomes.SpotCache[id];(Syntax Error). - Good:
const rawSpot = SpotCache[id];(and ensureSpotCacheis in the/* globals ... */list for JSHint).
- Bad:
- Code is wrapped in a closure:
($ => { ... })(Object);. - The
Object(likeSpot,Nav,Http) is used to export functions to the global scope. // require('./x.js');comments are purely documentary. The actual order of file concatenation is handled byGruntfile.js(alphabetical by default, sobase.jsis first andz.jsis last).
_('#id')is a shortcut fordocument.getElementById._('.class')is a shortcut fordocument.querySelectorAll.t('key')is the translation helper.
The project is strictly linted with JSHint.
- Every file starts with a
/* globals ... */block. - If you introduce a new global (like
window.SpotCache), you must add it to these blocks in every file that uses it, or JSHint will fail the build.
- The legacy PHP backend is defunct.
- Calls to
query5j.phpare replaced with fan-out POST requests to Firebase Cloud Functions. - Request Format: Firebase functions require the payload to be wrapped in a
dataobject:{"data": { ... }}. - Spot IDs: IDs are no longer numeric. They are alphanumeric Firebase IDs (~20 chars). Many regexes in
nav.jsandsearch.jswere originally\d+and had to be updated to\w+.
- The build system injects a
<base>tag. - Maintenance: Ensure it only has
target="_blank"and nohref="..."if you want to avoid interfering with local development or relative pathing logic in the new cloud function calls.