Fix the coding style in the orientation ext JavaScript

Fix valid cases pointed out by JSLint and avoid using
deprecated JavaScript methods.