Fixing issue #740 by wrapping the find.js and script.js scripts in IIFEs per @dryan suggestion. Some notes:
The functions setLatLng and localInitMap in find.js need to be global since they are invoked in the _template.html file. I've attached them to the window object explicitly at the top of the find.js IIFE.
I'm unclear how the script.js script is supposed to work for the following reasongs:
The lat/lon combos in the file seem to be hardcoded to Virginia and Baltimore locations, and don't seem to get amended by a user's location search, so the markers referenced in other functions in the file aren't accurate.
Many of the functions don't seem to be invoked at all, either within the file or globally (e.g. initFindRideMap, initGiveRideMap, initMyRidesMap, initMiniMap). Couldn't find references after grepping the codebase.
Many of the event handlers in the script (e.g. $('.results-box .result').hover, $('.results-box .result').click) don't seem to work properly since the .result DOM nodes they are referencing often don't exist on the page at load time when the listeners are attached. A simple fix to this would be to use event delegation to listen for events on the .results-box as a whole, instead of the individual nodes. I tried implementing this, but it still didn't work because of the hardcoded lat/lon combos mentioned above.
I checked to make sure the map loaded correctly and recentered itself properly after a search - beyond that, I'm not sure which functionality this change would affect.
Fixing issue #740 by wrapping the
find.js
andscript.js
scripts in IIFEs per @dryan suggestion. Some notes:setLatLng
andlocalInitMap
infind.js
need to be global since they are invoked in the_template.html
file. I've attached them to thewindow
object explicitly at the top of thefind.js
IIFE.script.js
script is supposed to work for the following reasongs:initFindRideMap
,initGiveRideMap
,initMyRidesMap
,initMiniMap
). Couldn't find references aftergrep
ping the codebase.$('.results-box .result').hover
,$('.results-box .result').click
) don't seem to work properly since the.result
DOM nodes they are referencing often don't exist on the page at load time when the listeners are attached. A simple fix to this would be to use event delegation to listen for events on the.results-box
as a whole, instead of the individual nodes. I tried implementing this, but it still didn't work because of the hardcoded lat/lon combos mentioned above.I checked to make sure the map loaded correctly and recentered itself properly after a search - beyond that, I'm not sure which functionality this change would affect.