Hotfix for main.js

Fixed error and commented code a little better. Also changed the hide
preview option to use jquery