Refactoring syntax.php simplifying javascript