js slider refactoring