Background
map_expedition_filter.js and map_compilation_filter.js are nearly identical — they share the same highlight state management, label building, table layout logic, hover wiring, and slug→row index. This duplication means any future fix (e.g. hover debounce changes, selector escaping, layout tweaks) must be applied twice, and it is easy to miss one file.
This was flagged during Copilot review of PR #16 (ksalamy fork) and deferred to keep that PR focused.
Proposed approach
-
Create smdb/smdb/static/js/map_filter_shared.js with a single factory function:
function initMapFilter({ mapId, tableWrapperId }) { ... }
containing all shared logic: highlight state, clearAllMissionHighlights(), highlightMission(), slugRowIndex building, label positioning, nav-track GeoJSON styling, initTableLayout(), and attachTableRowHover().
-
Reduce map_expedition_filter.js and map_compilation_filter.js to ~20 lines each — just load the GeoJSON, call initMapFilter() with their respective IDs, and handle any page-specific overrides.
-
Update expedition_filter.html and compilation_filter.html to load map_filter_shared.js before the page-specific script.
-
Docker image rebuild required (static JS files are compressed at build time).
-
Full test run to confirm no regressions.
Files affected
smdb/smdb/static/js/map_expedition_filter.js
smdb/smdb/static/js/map_compilation_filter.js
smdb/smdb/static/js/map_filter_shared.js (new)
smdb/smdb/templates/smdb/expedition_filter.html
smdb/smdb/templates/smdb/compilation_filter.html
Background
map_expedition_filter.jsandmap_compilation_filter.jsare nearly identical — they share the same highlight state management, label building, table layout logic, hover wiring, and slug→row index. This duplication means any future fix (e.g. hover debounce changes, selector escaping, layout tweaks) must be applied twice, and it is easy to miss one file.This was flagged during Copilot review of PR #16 (ksalamy fork) and deferred to keep that PR focused.
Proposed approach
Create
smdb/smdb/static/js/map_filter_shared.jswith a single factory function:containing all shared logic: highlight state,
clearAllMissionHighlights(),highlightMission(),slugRowIndexbuilding, label positioning, nav-track GeoJSON styling,initTableLayout(), andattachTableRowHover().Reduce
map_expedition_filter.jsandmap_compilation_filter.jsto ~20 lines each — just load the GeoJSON, callinitMapFilter()with their respective IDs, and handle any page-specific overrides.Update
expedition_filter.htmlandcompilation_filter.htmlto loadmap_filter_shared.jsbefore the page-specific script.Docker image rebuild required (static JS files are compressed at build time).
Full test run to confirm no regressions.
Files affected
smdb/smdb/static/js/map_expedition_filter.jssmdb/smdb/static/js/map_compilation_filter.jssmdb/smdb/static/js/map_filter_shared.js(new)smdb/smdb/templates/smdb/expedition_filter.htmlsmdb/smdb/templates/smdb/compilation_filter.html