Change the init time Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/ae91bf6c Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/ae91bf6c Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/ae91bf6c
Branch: refs/heads/master Commit: ae91bf6c783ed67b646df2f108a519f4f13a2879 Parents: 66fa8d3 Author: wangmingfeng <mingfengwan...@gmail.com> Authored: Thu Sep 27 09:43:44 2012 +0800 Committer: wangmingfeng <mingfengwan...@gmail.com> Committed: Thu Sep 27 09:43:44 2012 +0800 ---------------------------------------------------------------------- lib/windows8/exec.js | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/ae91bf6c/lib/windows8/exec.js ---------------------------------------------------------------------- diff --git a/lib/windows8/exec.js b/lib/windows8/exec.js index da6d35a..baa7a3a 100644 --- a/lib/windows8/exec.js +++ b/lib/windows8/exec.js @@ -24,23 +24,28 @@ var cordova = require('cordova'); -var CommandProxy = { - - "Accelerometer": require('cordova/plugin/windows8/AccelerometerProxy'), - "Camera":require('cordova/plugin/windows8/CameraProxy'), - "Capture":require('cordova/plugin/windows8/CaptureProxy'), - "Compass":require('cordova/plugin/windows8/CompassProxy'), - "Device":require('cordova/plugin/windows8/DeviceProxy'), - "File":require('cordova/plugin/windows8/FileProxy'), - "FileTransfer":require('cordova/plugin/windows8/FileTransferProxy'), - "Media":require('cordova/plugin/windows8/MediaProxy'), - "NetworkStatus":require('cordova/plugin/windows8/NetworkStatusProxy'), - "Notification":require('cordova/plugin/windows8/NotificationProxy') - +var CommandProxy; + +function getCP() { + if (!CommandProxy) { + CommandProxy = { + "Accelerometer": require('cordova/plugin/windows8/AccelerometerProxy'), + "Camera":require('cordova/plugin/windows8/CameraProxy'), + "Capture":require('cordova/plugin/windows8/CaptureProxy'), + "Compass":require('cordova/plugin/windows8/CompassProxy'), + "Device":require('cordova/plugin/windows8/DeviceProxy'), + "File":require('cordova/plugin/windows8/FileProxy'), + "FileTransfer":require('cordova/plugin/windows8/FileTransferProxy'), + "Media":require('cordova/plugin/windows8/MediaProxy'), + "NetworkStatus":require('cordova/plugin/windows8/NetworkStatusProxy'), + "Notification":require('cordova/plugin/windows8/NotificationProxy') + }; + } + return CommandProxy; }; module.exports = function(success, fail, service, action, args) { - + var CommandProxy = getCP(); if(CommandProxy[service] && CommandProxy[service][action]) { var callbackId = service + cordova.callbackId++; @@ -66,13 +71,13 @@ module.exports = function(success, fail, service, action, args) { // cordova.exec.addCommandProxy("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...); module.exports.addCommandProxy = function(id,proxyObj) { - + var CommandProxy = getCP(); CommandProxy[id] = proxyObj; }; // cordova.exec.removeCommandProxy("Accelerometer"); module.exports.removeCommandProxy = function(id) { - + var CommandProxy = getCP(); var proxy = CommandProxy[id]; delete CommandProxy[id]; CommandProxy[id] = null;