Added a manifest check in the www/ directory.

This is where the manifest is located in cordova Chrome apps.
Also refactored to remove duplicate code.