template: move some js logic from home to base for further homes work