Refactored PhoneGap deviceReady boilerplate code