Refactor landing pages JS

...to keep things DRY.