Updated JS for cordova 3