adapted from html5-kitchensink-cordova-xdk-af