Refactored settings view JS code