Refactoring jQuery soup into an object-oriented approach