Fixed check in javascript on mode checking