Improved JavaScript for format bar.