PhoneGap 1.5版本 cordova.js 简析 3
在基本升级了phonegap1.5后,发现原有的phonegap插件基本还是能够工作的,而因为项目原因我需要重写phonegap的定位能力,却发现无法找到类似phonegap 1.4的定义代码
PhoneGap.addConstructor(function() {navigator._geo = new Geolocation();// No native geolocation object for Android 1.x, so use PhoneGap// geolocationif (typeof navigator.geolocation === 'undefined') {navigator.geolocation = navigator._geo;Geolocation.usingPhoneGap = true;}//Geolocation.usePhoneGap();});
// Drop the common globals into the window object, but be nice// and don't overwrite anything.builder.build(base.objects).intoButDontClobber(window);// Drop the platform-specific globals into the window object and// do it like a honey badger does it.builder.build(platform.objects).intoAndClobberTheFOutOf(window);// Call the platform-specific initializationplatform.initialize();
function include(parent, objects, clobber) {each(objects, function(obj, key) {try {var result = obj.path ? require(obj.path) : {};if (clobber) {// Clobber if it doesn't exist or if an// override is specified.if (typeof parent[key] === 'undefined'|| typeof obj.path !== 'undefined') {parent[key] = result;}result = parent[key];} else {// Don't clobber if something already exists// thereif (typeof parent[key] == 'undefined') {parent[key] = result;} else {// Set result to what already exists, so// we can build children into it if they// exist.result = parent[key];}}if (obj.children) {include(result, obj.children, clobber);}} catch (e) {alert('Exception building cordova JS globals: '+ e + ' for key "' + key + '"');}});}
window.cordova.JSCallback : "cordova/plugin/android/callback"window.cordova.JSCallbackPolling : "cordova/plugin/android/polling"window.navigator.app : "cordova/plugin/android/app"window.device : "cordova/plugin/android/device"window.File : "cordova/plugin/File"window.FileReader : "cordova/plugin/FileReader"window.FileError : "cordova/plugin/FileError"