Refactored application js and widget js to be more object oriented