[misc] Improved codestyle, fixed a JS error in view mode