Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AAEA89C1B for ; Fri, 20 Apr 2012 00:08:14 +0000 (UTC) Received: (qmail 33511 invoked by uid 500); 20 Apr 2012 00:08:14 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 33444 invoked by uid 500); 20 Apr 2012 00:08:14 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 33429 invoked by uid 99); 20 Apr 2012 00:08:14 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Apr 2012 00:08:14 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3BFE1DA09; Fri, 20 Apr 2012 00:08:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [2/7] git commit: the great tab conversion commit! Message-Id: <20120420000814.3BFE1DA09@tyr.zones.apache.org> Date: Fri, 20 Apr 2012 00:08:14 +0000 (UTC) the great tab conversion commit! 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/e944b086 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/e944b086 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/e944b086 Branch: refs/heads/master Commit: e944b0865a6f459d9024155c5c4b0108dd7fbe66 Parents: 8ea3711 Author: Fil Maj Authored: Wed Apr 18 11:11:08 2012 -0700 Committer: Fil Maj Committed: Thu Apr 19 16:38:51 2012 -0700 ---------------------------------------------------------------------- lib/android/plugin/android/app.js | 2 +- lib/android/plugin/android/device.js | 12 +- lib/common/plugin/Camera.js | 14 +- lib/common/plugin/CaptureAudioOptions.js | 12 +- lib/common/plugin/CaptureImageOptions.js | 8 +- lib/common/plugin/CaptureVideoOptions.js | 12 +- lib/common/plugin/Connection.js | 14 +- lib/common/plugin/Contact.js | 6 +- lib/common/plugin/File.js | 10 +- lib/common/plugin/Media.js | 2 +- lib/common/plugin/MediaFile.js | 8 +- lib/common/plugin/MediaFileData.js | 10 +- lib/common/plugin/Position.js | 4 +- lib/common/plugin/battery.js | 38 +- lib/common/plugin/capture.js | 6 +- lib/common/plugin/compass.js | 36 +- lib/cordova.js | 6 +- lib/ios/platform.js | 8 +- lib/ios/plugin/ios/Contact.js | 44 ++-- lib/ios/plugin/ios/Entry.js | 4 +- lib/ios/plugin/ios/console.js | 28 +- lib/ios/plugin/ios/contacts.js | 48 ++-- lib/wp7/exec.js | 358 +++++++++--------- lib/wp7/platform.js | 48 ++-- lib/wp7/plugin/wp7/CordovaCommandResult.js | 86 +++--- lib/wp7/plugin/wp7/CordovaMediaonStatus.js | 6 +- lib/wp7/plugin/wp7/XHRPatch.js | 334 ++++++++-------- lib/wp7/plugin/wp7/console.js | 18 +- lib/wp7/plugin/wp7/requestFileSystem.js | 2 +- lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js | 2 +- 30 files changed, 593 insertions(+), 593 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/android/plugin/android/app.js ---------------------------------------------------------------------- diff --git a/lib/android/plugin/android/app.js b/lib/android/plugin/android/app.js index f858829..1671f86 100644 --- a/lib/android/plugin/android/app.js +++ b/lib/android/plugin/android/app.js @@ -56,7 +56,7 @@ module.exports = { * Note: The user should not have to call this method. Instead, when the user * registers for the "backbutton" event, this is automatically done. * - * @param override T=override, F=cancel override + * @param override T=override, F=cancel override */ overrideBackbutton:function(override) { exec(null, null, "App", "overrideBackbutton", [override]); http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/android/plugin/android/device.js ---------------------------------------------------------------------- diff --git a/lib/android/plugin/android/device.js b/lib/android/plugin/android/device.js index 21a2ba3..7596d2a 100644 --- a/lib/android/plugin/android/device.js +++ b/lib/android/plugin/android/device.js @@ -64,8 +64,8 @@ Device.prototype.getInfo = function(successCallback, errorCallback) { * You must explicitly override the back button. */ Device.prototype.overrideBackButton = function() { - console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true)."); - navigator.app.overrideBackbutton(true); + console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true)."); + navigator.app.overrideBackbutton(true); }; /* @@ -75,8 +75,8 @@ Device.prototype.overrideBackButton = function() { * This resets the back button to the default behaviour */ Device.prototype.resetBackButton = function() { - console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false)."); - navigator.app.overrideBackbutton(false); + console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false)."); + navigator.app.overrideBackbutton(false); }; /* @@ -86,8 +86,8 @@ Device.prototype.resetBackButton = function() { * This terminates the activity! */ Device.prototype.exitApp = function() { - console.log("Device.exitApp() is deprecated. Use App.exitApp()."); - navigator.app.exitApp(); + console.log("Device.exitApp() is deprecated. Use App.exitApp()."); + navigator.app.exitApp(); }; module.exports = new Device(); http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/Camera.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/Camera.js b/lib/common/plugin/Camera.js index d104707..7bcdb59 100644 --- a/lib/common/plugin/Camera.js +++ b/lib/common/plugin/Camera.js @@ -82,21 +82,21 @@ cameraExport.getPicture = function(successCallback, errorCallback, options) { } var allowEdit = false; if (typeof options.allowEdit == "boolean") { - allowEdit = options.allowEdit; + allowEdit = options.allowEdit; } else if (typeof options.allowEdit == "number") { - allowEdit = options.allowEdit <= 0 ? false : true; + allowEdit = options.allowEdit <= 0 ? false : true; } var correctOrientation = false; if (typeof options.correctOrientation == "boolean") { - correctOrientation = options.correctOrientation; + correctOrientation = options.correctOrientation; } else if (typeof options.correctOrientation == "number") { - correctOrientation = options.correctOrientation <=0 ? false : true; + correctOrientation = options.correctOrientation <=0 ? false : true; } var saveToPhotoAlbum = false; - if (typeof options.saveToPhotoAlbum == "boolean") { - saveToPhotoAlbum = options.saveToPhotoAlbum; + if (typeof options.saveToPhotoAlbum == "boolean") { + saveToPhotoAlbum = options.saveToPhotoAlbum; } else if (typeof options.saveToPhotoAlbum == "number") { - saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true; + saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true; } exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation, saveToPhotoAlbum]); http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/CaptureAudioOptions.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/CaptureAudioOptions.js b/lib/common/plugin/CaptureAudioOptions.js index ee07932..6f7e253 100644 --- a/lib/common/plugin/CaptureAudioOptions.js +++ b/lib/common/plugin/CaptureAudioOptions.js @@ -2,12 +2,12 @@ * Encapsulates all audio capture operation configuration options. */ var CaptureAudioOptions = function(){ - // Upper limit of sound clips user can record. Value must be equal or greater than 1. - this.limit = 1; - // Maximum duration of a single sound clip in seconds. - this.duration = 0; - // The selected audio mode. Must match with one of the elements in supportedAudioModes array. - this.mode = null; + // Upper limit of sound clips user can record. Value must be equal or greater than 1. + this.limit = 1; + // Maximum duration of a single sound clip in seconds. + this.duration = 0; + // The selected audio mode. Must match with one of the elements in supportedAudioModes array. + this.mode = null; }; module.exports = CaptureAudioOptions; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/CaptureImageOptions.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/CaptureImageOptions.js b/lib/common/plugin/CaptureImageOptions.js index c90e8d4..a1138ff 100644 --- a/lib/common/plugin/CaptureImageOptions.js +++ b/lib/common/plugin/CaptureImageOptions.js @@ -2,10 +2,10 @@ * Encapsulates all image capture operation configuration options. */ var CaptureImageOptions = function(){ - // Upper limit of images user can take. Value must be equal or greater than 1. - this.limit = 1; - // The selected image mode. Must match with one of the elements in supportedImageModes array. - this.mode = null; + // Upper limit of images user can take. Value must be equal or greater than 1. + this.limit = 1; + // The selected image mode. Must match with one of the elements in supportedImageModes array. + this.mode = null; }; module.exports = CaptureImageOptions; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/CaptureVideoOptions.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/CaptureVideoOptions.js b/lib/common/plugin/CaptureVideoOptions.js index 5583ddb..736d94d 100644 --- a/lib/common/plugin/CaptureVideoOptions.js +++ b/lib/common/plugin/CaptureVideoOptions.js @@ -2,12 +2,12 @@ * Encapsulates all video capture operation configuration options. */ var CaptureVideoOptions = function(){ - // Upper limit of videos user can record. Value must be equal or greater than 1. - this.limit = 1; - // Maximum duration of a single video clip in seconds. - this.duration = 0; - // The selected video mode. Must match with one of the elements in supportedVideoModes array. - this.mode = null; + // Upper limit of videos user can record. Value must be equal or greater than 1. + this.limit = 1; + // Maximum duration of a single video clip in seconds. + this.duration = 0; + // The selected video mode. Must match with one of the elements in supportedVideoModes array. + this.mode = null; }; module.exports = CaptureVideoOptions; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/Connection.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/Connection.js b/lib/common/plugin/Connection.js index 1a7fea8..8152e03 100644 --- a/lib/common/plugin/Connection.js +++ b/lib/common/plugin/Connection.js @@ -2,11 +2,11 @@ * Network status */ module.exports = { - UNKNOWN: "unknown", - ETHERNET: "ethernet", - WIFI: "wifi", - CELL_2G: "2g", - CELL_3G: "3g", - CELL_4G: "4g", - NONE: "none" + UNKNOWN: "unknown", + ETHERNET: "ethernet", + WIFI: "wifi", + CELL_2G: "2g", + CELL_3G: "3g", + CELL_4G: "4g", + NONE: "none" }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/Contact.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/Contact.js b/lib/common/plugin/Contact.js index 261bb12..3c09fbc 100644 --- a/lib/common/plugin/Contact.js +++ b/lib/common/plugin/Contact.js @@ -157,7 +157,7 @@ Contact.prototype.save = function(successCB, errorCB) { var fail = function(code) { errorCB(new ContactError(code)); }; - var success = function(result) { + var success = function(result) { if (result) { if (typeof successCB === 'function') { var fullContact = require('cordova/plugin/contacts').create(result); @@ -169,8 +169,8 @@ Contact.prototype.save = function(successCB, errorCB) { fail(ContactError.UNKNOWN_ERROR); } }; - var dupContact = convertOut(utils.clone(this)); - exec(success, fail, "Contacts", "save", [dupContact]); + var dupContact = convertOut(utils.clone(this)); + exec(success, fail, "Contacts", "save", [dupContact]); }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/File.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/File.js b/lib/common/plugin/File.js index 96de0d7..7ac22cc 100644 --- a/lib/common/plugin/File.js +++ b/lib/common/plugin/File.js @@ -8,11 +8,11 @@ */ var File = function(name, fullPath, type, lastModifiedDate, size){ - this.name = name || ''; - this.fullPath = fullPath || null; - this.type = type || null; - this.lastModifiedDate = lastModifiedDate || null; - this.size = size || 0; + this.name = name || ''; + this.fullPath = fullPath || null; + this.type = type || null; + this.lastModifiedDate = lastModifiedDate || null; + this.size = size || 0; }; module.exports = File; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/Media.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/Media.js b/lib/common/plugin/Media.js index d5f44fa..5bf1e83 100644 --- a/lib/common/plugin/Media.js +++ b/lib/common/plugin/Media.js @@ -175,7 +175,7 @@ Media.onStatus = function(id, msg, value) { } else if (msg === Media.MEDIA_ERROR) { if (media.errorCallback) { - // value should be a MediaError object when msg == MEDIA_ERROR + // value should be a MediaError object when msg == MEDIA_ERROR media.errorCallback(value); } } http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/MediaFile.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/MediaFile.js b/lib/common/plugin/MediaFile.js index e73716b..d8b0964 100644 --- a/lib/common/plugin/MediaFile.js +++ b/lib/common/plugin/MediaFile.js @@ -24,11 +24,11 @@ utils.extend(MediaFile, File); * @param {Function} errorCB */ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) { - if (typeof this.fullPath === "undefined" || this.fullPath === null) { - errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); - } else { + if (typeof this.fullPath === "undefined" || this.fullPath === null) { + errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); + } else { exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]); - } + } }; /** http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/MediaFileData.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/MediaFileData.js b/lib/common/plugin/MediaFileData.js index ea5c2a3..2d2a43a 100644 --- a/lib/common/plugin/MediaFileData.js +++ b/lib/common/plugin/MediaFileData.js @@ -8,11 +8,11 @@ * @param {float} duration */ var MediaFileData = function(codecs, bitrate, height, width, duration){ - this.codecs = codecs || null; - this.bitrate = bitrate || 0; - this.height = height || 0; - this.width = width || 0; - this.duration = duration || 0; + this.codecs = codecs || null; + this.bitrate = bitrate || 0; + this.height = height || 0; + this.width = width || 0; + this.duration = duration || 0; }; module.exports = MediaFileData; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/Position.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/Position.js b/lib/common/plugin/Position.js index 25096c4..2651969 100644 --- a/lib/common/plugin/Position.js +++ b/lib/common/plugin/Position.js @@ -1,8 +1,8 @@ var Coordinates = require('cordova/plugin/Coordinates'); var Position = function(coords, timestamp) { - this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy); - this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime(); + this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy); + this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime(); }; module.exports = Position; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/battery.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/battery.js b/lib/common/plugin/battery.js index 5649356..f7ef49b 100644 --- a/lib/common/plugin/battery.js +++ b/lib/common/plugin/battery.js @@ -50,29 +50,29 @@ Battery.prototype.onUnsubscribe = function() { /** * Callback for battery status * - * @param {Object} info keys: level, isPlugged + * @param {Object} info keys: level, isPlugged */ Battery.prototype._status = function(info) { - if (info) { - var me = battery; + if (info) { + var me = battery; var level = info.level; - if (me._level !== level || me._isPlugged !== info.isPlugged) { - // Fire batterystatus event - cordova.fireWindowEvent("batterystatus", info); + if (me._level !== level || me._isPlugged !== info.isPlugged) { + // Fire batterystatus event + cordova.fireWindowEvent("batterystatus", info); - // Fire low battery event - if (level === 20 || level === 5) { - if (level === 20) { - cordova.fireWindowEvent("batterylow", info); - } - else { - cordova.fireWindowEvent("batterycritical", info); - } - } - } - me._level = level; - me._isPlugged = info.isPlugged; - } + // Fire low battery event + if (level === 20 || level === 5) { + if (level === 20) { + cordova.fireWindowEvent("batterylow", info); + } + else { + cordova.fireWindowEvent("batterycritical", info); + } + } + } + me._level = level; + me._isPlugged = info.isPlugged; + } }; /** http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/capture.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/capture.js b/lib/common/plugin/capture.js index e088ba6..ba7ae36 100644 --- a/lib/common/plugin/capture.js +++ b/lib/common/plugin/capture.js @@ -30,9 +30,9 @@ function _capture(type, successCallback, errorCallback, options) { * The Capture interface exposes an interface to the camera and microphone of the hosting device. */ function Capture() { - this.supportedAudioModes = []; - this.supportedImageModes = []; - this.supportedVideoModes = []; + this.supportedAudioModes = []; + this.supportedImageModes = []; + this.supportedVideoModes = []; } /** http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/common/plugin/compass.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/compass.js b/lib/common/plugin/compass.js index fae9d27..06b723c 100644 --- a/lib/common/plugin/compass.js +++ b/lib/common/plugin/compass.js @@ -66,17 +66,17 @@ var exec = require('cordova/exec'), } var id = utils.createUUID(); - if (filter > 0) { - // is an iOS request for watch by filter, no timer needed - timers[id] = "iOS"; - compass.getCurrentHeading(successCallback, errorCallback, options); - } else { - // Start watch timer to get headings - timers[id] = window.setInterval(function() { - compass.getCurrentHeading(successCallback, errorCallback); - }, frequency); - } - + if (filter > 0) { + // is an iOS request for watch by filter, no timer needed + timers[id] = "iOS"; + compass.getCurrentHeading(successCallback, errorCallback, options); + } else { + // Start watch timer to get headings + timers[id] = window.setInterval(function() { + compass.getCurrentHeading(successCallback, errorCallback); + }, frequency); + } + return id; }, @@ -87,13 +87,13 @@ var exec = require('cordova/exec'), clearWatch:function(id) { // Stop javascript timer & remove from timer list if (id && timers[id]) { - if (timers[id] != "iOS") { - clearInterval(timers[id]); - } else { - // is iOS watch by filter so call into device to stop - exec(null, null, "Compass", "stopHeading", []); - } - delete timers[id]; + if (timers[id] != "iOS") { + clearInterval(timers[id]); + } else { + // is iOS watch by filter so call into device to stop + exec(null, null, "Compass", "stopHeading", []); + } + delete timers[id]; } } }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/cordova.js ---------------------------------------------------------------------- diff --git a/lib/cordova.js b/lib/cordova.js index c7917e6..7c0e3b9 100644 --- a/lib/cordova.js +++ b/lib/cordova.js @@ -93,9 +93,9 @@ function createEvent(type, data) { if(typeof window.console === "undefined") { - window.console = { - log:function(){} - }; + window.console = { + log:function(){} + }; } var cordova = { http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/ios/platform.js ---------------------------------------------------------------------- diff --git a/lib/ios/platform.js b/lib/ios/platform.js index 5c032c7..6e6b151 100644 --- a/lib/ios/platform.js +++ b/lib/ios/platform.js @@ -24,9 +24,9 @@ module.exports = { } }, merges:{ - Contact:{ - path: "cordova/plugin/ios/Contact" - }, + Contact:{ + path: "cordova/plugin/ios/Contact" + }, Entry:{ path: "cordova/plugin/ios/Entry" }, @@ -39,7 +39,7 @@ module.exports = { path:"cordova/plugin/ios/notification" }, contacts:{ - path:"cordova/plugin/ios/contacts" + path:"cordova/plugin/ios/contacts" } } } http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/ios/plugin/ios/Contact.js ---------------------------------------------------------------------- diff --git a/lib/ios/plugin/ios/Contact.js b/lib/ios/plugin/ios/Contact.js index 676fd46..bc511a5 100644 --- a/lib/ios/plugin/ios/Contact.js +++ b/lib/ios/plugin/ios/Contact.js @@ -1,30 +1,30 @@ var exec = require('cordova/exec'), - ContactError = require('cordova/plugin/ContactError'); + ContactError = require('cordova/plugin/ContactError'); /** * Provides iOS Contact.display API. */ module.exports = { - display : function(errorCB, options) { - /* - * Display a contact using the iOS Contact Picker UI - * NOT part of W3C spec so no official documentation - * - * @param errorCB error callback - * @param options object - * allowsEditing: boolean AS STRING - * "true" to allow editing the contact - * "false" (default) display contact - */ + display : function(errorCB, options) { + /* + * Display a contact using the iOS Contact Picker UI + * NOT part of W3C spec so no official documentation + * + * @param errorCB error callback + * @param options object + * allowsEditing: boolean AS STRING + * "true" to allow editing the contact + * "false" (default) display contact + */ - if (this.id == null) { - if (typeof errorCB === "function") { - var errorObj = new ContactError(ContactError.UNKNOWN_ERROR); - errorCB(errorObj); - } - } - else { - exec(null, errorCB, "Contacts","displayContact", [this.id, options]); - } - } + if (this.id == null) { + if (typeof errorCB === "function") { + var errorObj = new ContactError(ContactError.UNKNOWN_ERROR); + errorCB(errorObj); + } + } + else { + exec(null, errorCB, "Contacts","displayContact", [this.id, options]); + } + } }; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/ios/plugin/ios/Entry.js ---------------------------------------------------------------------- diff --git a/lib/ios/plugin/ios/Entry.js b/lib/ios/plugin/ios/Entry.js index 1be783a..e56bf19 100644 --- a/lib/ios/plugin/ios/Entry.js +++ b/lib/ios/plugin/ios/Entry.js @@ -5,7 +5,7 @@ module.exports = { return "file://localhost" + this.fullPath; }, toURI: function() { - console.log("DEPRECATED: Update your code to use 'toURL'"); - return "file://localhost" + this.fullPath; + console.log("DEPRECATED: Update your code to use 'toURL'"); + return "file://localhost" + this.fullPath; } }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/ios/plugin/ios/console.js ---------------------------------------------------------------------- diff --git a/lib/ios/plugin/ios/console.js b/lib/ios/plugin/ios/console.js index 3645912..339f707 100644 --- a/lib/ios/plugin/ios/console.js +++ b/lib/ios/plugin/ios/console.js @@ -15,21 +15,21 @@ DebugConsole.INFO_LEVEL = 1; DebugConsole.WARN_LEVEL = 2; DebugConsole.ERROR_LEVEL = 4; DebugConsole.NONE_LEVEL = 8; - + DebugConsole.prototype.setLevel = function(level) { this.logLevel = level; }; var stringify = function(message) { - try { - if (typeof message === "object" && JSON && JSON.stringify) { - return JSON.stringify(message); - } else { - return message.toString(); - } - } catch (e) { - return e.toString(); - } + try { + if (typeof message === "object" && JSON && JSON.stringify) { + return JSON.stringify(message); + } else { + return message.toString(); + } + } catch (e) { + return e.toString(); + } } /** @@ -39,10 +39,10 @@ var stringify = function(message) { DebugConsole.prototype.log = function(message) { if (this.logLevel <= DebugConsole.INFO_LEVEL) { exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'INFO' } ]); - } + } else if (this.winConsole && this.winConsole.log) { this.winConsole.log(message); - } + } }; /** @@ -65,10 +65,10 @@ DebugConsole.prototype.warn = function(message) { DebugConsole.prototype.error = function(message) { if (this.logLevel <= DebugConsole.ERROR_LEVEL) { exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'ERROR' } ]); - } + } else if (this.winConsole && this.winConsole.error){ this.winConsole.error(message); - } + } }; module.exports = new DebugConsole(); http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/ios/plugin/ios/contacts.js ---------------------------------------------------------------------- diff --git a/lib/ios/plugin/ios/contacts.js b/lib/ios/plugin/ios/contacts.js index f3affec..d04887b 100644 --- a/lib/ios/plugin/ios/contacts.js +++ b/lib/ios/plugin/ios/contacts.js @@ -4,28 +4,28 @@ var exec = require('cordova/exec'); * Provides iOS enhanced contacts API. */ module.exports = { - newContactUI : function(successCallback) { - /* - * Create a contact using the iOS Contact Picker UI - * NOT part of W3C spec so no official documentation - * - * returns: the id of the created contact as param to successCallback - */ - exec(successCallback, null, "Contacts","newContact", []); - }, - chooseContact : function(successCallback, options) { - /* - * Select a contact using the iOS Contact Picker UI - * NOT part of W3C spec so no official documentation - * - * @param errorCB error callback - * @param options object - * allowsEditing: boolean AS STRING - * "true" to allow editing the contact - * "false" (default) display contact - * - * returns: the id of the selected contact as param to successCallback - */ - exec(successCallback, null, "Contacts","chooseContact", [options]); - } + newContactUI : function(successCallback) { + /* + * Create a contact using the iOS Contact Picker UI + * NOT part of W3C spec so no official documentation + * + * returns: the id of the created contact as param to successCallback + */ + exec(successCallback, null, "Contacts","newContact", []); + }, + chooseContact : function(successCallback, options) { + /* + * Select a contact using the iOS Contact Picker UI + * NOT part of W3C spec so no official documentation + * + * @param errorCB error callback + * @param options object + * allowsEditing: boolean AS STRING + * "true" to allow editing the contact + * "false" (default) display contact + * + * returns: the id of the selected contact as param to successCallback + */ + exec(successCallback, null, "Contacts","chooseContact", [options]); + } }; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/exec.js ---------------------------------------------------------------------- diff --git a/lib/wp7/exec.js b/lib/wp7/exec.js index 6b1f929..3be3c99 100644 --- a/lib/wp7/exec.js +++ b/lib/wp7/exec.js @@ -19,164 +19,164 @@ var cordova = require('cordova'); /* this will become a programmatic way to gen the named args ... TODO: -jm var NamedArgs = { - File:{ - getFileMetadata:["fullPath"], - readAsText:["fileName","encoding"], - readAsDataURL:["fileName"], - getDirectory:["fullPath","path","options"], - removeRecursively:["fullPath"], - getFile:["fullPath","path","options"], - readEntries:["fullPath"], - write:["fileName","data","position"], - truncate:["fileName","size"] - } + File:{ + getFileMetadata:["fullPath"], + readAsText:["fileName","encoding"], + readAsDataURL:["fileName"], + getDirectory:["fullPath","path","options"], + removeRecursively:["fullPath"], + getFile:["fullPath","path","options"], + readEntries:["fullPath"], + write:["fileName","data","position"], + truncate:["fileName","size"] + } } */ var MonkeyPatch = { - File: - { - "getFileMetadata":function(arg) - { - return {fullPath:arg[0]}; - }, - "readAsText":function(arg) - { //[this.fileName, enc] - return {fileName:arg[0],encoding:arg[1]}; - }, - "readAsDataURL":function(arg) - { - return {fileName:arg[0]}; - }, - "getDirectory":function(arg) - { - return {fullPath:arg[0],path:arg[1],options:arg[2]}; - }, - "removeRecursively":function(arg) - { - return {fullPath:arg[0]}; - }, - "getFile":function(arg) - { - return {fullPath:arg[0],path:arg[1],options:arg[2]}; - }, - "readEntries":function(arg) - { - return {fullPath:arg[0]}; - }, - "write":function(arg) - { - return {fileName:arg[0],data:arg[1],position:arg[2]}; - }, - "truncate":function(arg) - { - return {fileName:arg[0],size:arg[1]}; - } + File: + { + "getFileMetadata":function(arg) + { + return {fullPath:arg[0]}; + }, + "readAsText":function(arg) + { //[this.fileName, enc] + return {fileName:arg[0],encoding:arg[1]}; + }, + "readAsDataURL":function(arg) + { + return {fileName:arg[0]}; + }, + "getDirectory":function(arg) + { + return {fullPath:arg[0],path:arg[1],options:arg[2]}; + }, + "removeRecursively":function(arg) + { + return {fullPath:arg[0]}; + }, + "getFile":function(arg) + { + return {fullPath:arg[0],path:arg[1],options:arg[2]}; + }, + "readEntries":function(arg) + { + return {fullPath:arg[0]}; + }, + "write":function(arg) + { + return {fileName:arg[0],data:arg[1],position:arg[2]}; + }, + "truncate":function(arg) + { + return {fileName:arg[0],size:arg[1]}; + } - }, - FileTransfer: - { - // [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode] - "upload":function(arg) - { - // note, chuncked mode is not supported in WP7 currently - return {filePath:arg[0],server:arg[1],fileKey:arg[2],fileName:arg[3],mimeType:arg[4],params:arg[5],debug:arg[6]}; - } - }, - Contacts: - { - "remove":function(arg) // actually caught by our other case inside exec - { - return arg[0]; - }, - "save":function(arg) // actually caught by our other case inside exec - { - return arg[0]; - }, - "search":function(arg) - { - return {fields:arg[0],options:arg[1]}; - } - }, - Capture: - { - captureAudio:function(arg)// actually caught by our other case inside exec - { - return arg[0]; - }, - captureVideo:function(arg)// actually caught by our other case inside exec - { - return arg[0]; - }, - captureImage:function(arg)// actually caught by our other case inside exec - { - return arg[0]; - } - }, - Media: - { - create:function(arg) - { - return {id:arg[0],src:arg[1]}; - }, - startPlayingAudio:function(arg) - { - return {id:arg[0],src:arg[1],milliseconds:arg[2]}; - }, - stopPlayingAudio:function(arg) - { - return {id:arg[0]}; - }, - seekToAudio:function(arg) - { - return {id:arg[0],milliseconds:arg[1]}; - }, - pausePlayingAudio:function(arg) - { - return {id:arg[0]}; - }, - getCurrentPositionAudio:function(arg) - { - return {id:arg[0]}; - }, - startRecordingAudio:function(arg) - { - return {id:arg[0],src:arg[1]}; - }, - stopRecordingAudio:function(arg) - { - return {id:arg[0]}; - }, - release:function(arg) - { - return {id:arg[0]}; - }, - setVolume:function(arg) - { - return {id:arg[0],volume:arg[1]}; - } - }, - Notification: - { - "alert":function(arg) - { - return {message:arg[0],title:arg[1],buttonLabel:arg[2]}; - }, - "confirm":function(arg) - { - return {message:arg[0],title:arg[1],buttonLabel:arg[2]}; - } - }, - Camera: - { - "takePicture":function(arg) - { - //"takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]); - return {quality:arg[0],destinationType:arg[1],sourceType:arg[2],targetWidth:arg[3],targetHeight:arg[4],encodingType:arg[5]}; - } - } - + }, + FileTransfer: + { + // [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode] + "upload":function(arg) + { + // note, chuncked mode is not supported in WP7 currently + return {filePath:arg[0],server:arg[1],fileKey:arg[2],fileName:arg[3],mimeType:arg[4],params:arg[5],debug:arg[6]}; + } + }, + Contacts: + { + "remove":function(arg) // actually caught by our other case inside exec + { + return arg[0]; + }, + "save":function(arg) // actually caught by our other case inside exec + { + return arg[0]; + }, + "search":function(arg) + { + return {fields:arg[0],options:arg[1]}; + } + }, + Capture: + { + captureAudio:function(arg)// actually caught by our other case inside exec + { + return arg[0]; + }, + captureVideo:function(arg)// actually caught by our other case inside exec + { + return arg[0]; + }, + captureImage:function(arg)// actually caught by our other case inside exec + { + return arg[0]; + } + }, + Media: + { + create:function(arg) + { + return {id:arg[0],src:arg[1]}; + }, + startPlayingAudio:function(arg) + { + return {id:arg[0],src:arg[1],milliseconds:arg[2]}; + }, + stopPlayingAudio:function(arg) + { + return {id:arg[0]}; + }, + seekToAudio:function(arg) + { + return {id:arg[0],milliseconds:arg[1]}; + }, + pausePlayingAudio:function(arg) + { + return {id:arg[0]}; + }, + getCurrentPositionAudio:function(arg) + { + return {id:arg[0]}; + }, + startRecordingAudio:function(arg) + { + return {id:arg[0],src:arg[1]}; + }, + stopRecordingAudio:function(arg) + { + return {id:arg[0]}; + }, + release:function(arg) + { + return {id:arg[0]}; + }, + setVolume:function(arg) + { + return {id:arg[0],volume:arg[1]}; + } + }, + Notification: + { + "alert":function(arg) + { + return {message:arg[0],title:arg[1],buttonLabel:arg[2]}; + }, + "confirm":function(arg) + { + return {message:arg[0],title:arg[1],buttonLabel:arg[2]}; + } + }, + Camera: + { + "takePicture":function(arg) + { + //"takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]); + return {quality:arg[0],destinationType:arg[1],sourceType:arg[2],targetWidth:arg[3],targetHeight:arg[4],encodingType:arg[5]}; + } + } + }; module.exports = function(success, fail, service, action, args) @@ -184,38 +184,38 @@ module.exports = function(success, fail, service, action, args) var callbackId = service + cordova.callbackId++; if (typeof success == "function" || typeof fail == "function") - { + { cordova.callbacks[callbackId] = {success:success, fail:fail}; } // generate a new command string, ex. DebugConsole/log/DebugConsole23/{"message":"wtf dude?"} - - if(MonkeyPatch[service] && MonkeyPatch[service][action]) - { - //console.log("MonkeyPatching " + service + "." + action); - args = MonkeyPatch[service][action](args); - } - else if(args && args.length && args.length == 1) - { - args = args[0]; - } - + + if(MonkeyPatch[service] && MonkeyPatch[service][action]) + { + //console.log("MonkeyPatching " + service + "." + action); + args = MonkeyPatch[service][action](args); + } + else if(args && args.length && args.length == 1) + { + args = args[0]; + } + var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args); // pass it on to Notify - try - { - if(window.external) - { - window.external.Notify(command); - } - else - { - console.log("window.external not available :: command=" + command); - } - } - catch(e) - { - console.log("Exception calling native with command :: " + command + " :: exception=" + e); - } + try + { + if(window.external) + { + window.external.Notify(command); + } + else + { + console.log("window.external not available :: command=" + command); + } + } + catch(e) + { + console.log("Exception calling native with command :: " + command + " :: exception=" + e); + } }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/platform.js ---------------------------------------------------------------------- diff --git a/lib/wp7/platform.js b/lib/wp7/platform.js index 09c51c5..233db13 100644 --- a/lib/wp7/platform.js +++ b/lib/wp7/platform.js @@ -17,7 +17,7 @@ module.exports = { - // INject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners + // INject a lsitener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners var backButtonChannel = cordova.addDocumentEventHandler('backbutton', { onSubscribe:function() { if (this.numHandlers === 1) { @@ -30,21 +30,21 @@ module.exports = { } } }); - }, + }, objects: { - CordovaCommandResult: { - path:"cordova/plugin/wp7/CordovaCommandResult" - }, - CordovaMediaonStatus: { - path:"cordova/plugin/wp7/CordovaMediaonStatus" - }, - requestFileSystem: { - path:"cordova/plugin/wp7/requestFileSystem" - }, - resolveLocalFileSystemURI: { - path:"cordova/plugin/wp7/resolveLocalFileSystemURI" - }, - File: { + CordovaCommandResult: { + path:"cordova/plugin/wp7/CordovaCommandResult" + }, + CordovaMediaonStatus: { + path:"cordova/plugin/wp7/CordovaMediaonStatus" + }, + requestFileSystem: { + path:"cordova/plugin/wp7/requestFileSystem" + }, + resolveLocalFileSystemURI: { + path:"cordova/plugin/wp7/resolveLocalFileSystemURI" + }, + File: { path: "cordova/plugin/File" }, FileReader: { @@ -60,16 +60,16 @@ module.exports = { children: { device: { path: "cordova/plugin/wp7/device", - children:{ - capture:{ - path:"cordova/plugin/capture" - } - } + children:{ + capture:{ + path:"cordova/plugin/capture" + } + } }, - console: { - path: "cordova/plugin/wp7/console" - - } + console: { + path: "cordova/plugin/wp7/console" + + } } }, device:{ http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/plugin/wp7/CordovaCommandResult.js ---------------------------------------------------------------------- diff --git a/lib/wp7/plugin/wp7/CordovaCommandResult.js b/lib/wp7/plugin/wp7/CordovaCommandResult.js index 9b7f390..737d715 100644 --- a/lib/wp7/plugin/wp7/CordovaCommandResult.js +++ b/lib/wp7/plugin/wp7/CordovaCommandResult.js @@ -5,50 +5,50 @@ var channel = require('cordova/channel'); // singular WP7 callback function attached to window, status is used to determin if it is a success or error module.exports = function(status,callbackId,args,cast) { - if(status === "backbutton") { - cordova.fireDocumentEvent("backbutton"); - return "true"; - } - else if(status === "resume") { - channel.onResume.fire(); - return "true"; - } - else if(status === "pause") { - channel.onPause.fire(); - return "true"; - } - - var parsedArgs; - try - { - parsedArgs = JSON.parse(args); - - } - catch(ex) - { - console.log("Parse error in CordovaCommandResult :: " + ex); - return; - } - - try - { - // For some commands, the message is a JSON encoded string - // and other times, it is just a string, the try/catch handles the - // case where message was indeed, just a string. - parsedArgs.message = JSON.parse(parsedArgs.message); - } - catch(ex) - { + if(status === "backbutton") { + cordova.fireDocumentEvent("backbutton"); + return "true"; + } + else if(status === "resume") { + channel.onResume.fire(); + return "true"; + } + else if(status === "pause") { + channel.onPause.fire(); + return "true"; + } + + var parsedArgs; + try + { + parsedArgs = JSON.parse(args); + + } + catch(ex) + { + console.log("Parse error in CordovaCommandResult :: " + ex); + return; + } + + try + { + // For some commands, the message is a JSON encoded string + // and other times, it is just a string, the try/catch handles the + // case where message was indeed, just a string. + parsedArgs.message = JSON.parse(parsedArgs.message); + } + catch(ex) + { - } - var safeStatus = parseInt(status, 10); - if(safeStatus === cordova.callbackStatus.NO_RESULT || - safeStatus === cordova.callbackStatus.OK) { - cordova.callbackSuccess(callbackId,parsedArgs,cast); - } - else { - cordova.callbackError(callbackId,parsedArgs,cast); - } + } + var safeStatus = parseInt(status, 10); + if(safeStatus === cordova.callbackStatus.NO_RESULT || + safeStatus === cordova.callbackStatus.OK) { + cordova.callbackSuccess(callbackId,parsedArgs,cast); + } + else { + cordova.callbackError(callbackId,parsedArgs,cast); + } }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/plugin/wp7/CordovaMediaonStatus.js ---------------------------------------------------------------------- diff --git a/lib/wp7/plugin/wp7/CordovaMediaonStatus.js b/lib/wp7/plugin/wp7/CordovaMediaonStatus.js index b77415d..6fc0550 100644 --- a/lib/wp7/plugin/wp7/CordovaMediaonStatus.js +++ b/lib/wp7/plugin/wp7/CordovaMediaonStatus.js @@ -2,8 +2,8 @@ var cordova = require('cordova'); module.exports = function(args) { - - console.log("media on status :: " + args); - //var res = JSON.parse(args); + + console.log("media on status :: " + args); + //var res = JSON.parse(args); //require("cordova/media").onStatus(res.id, res.msg, res.value); }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/plugin/wp7/XHRPatch.js ---------------------------------------------------------------------- diff --git a/lib/wp7/plugin/wp7/XHRPatch.js b/lib/wp7/plugin/wp7/XHRPatch.js index e6a1441..a3a6dd1 100644 --- a/lib/wp7/plugin/wp7/XHRPatch.js +++ b/lib/wp7/plugin/wp7/XHRPatch.js @@ -24,173 +24,173 @@ if (!docDomain || docDomain.length == 0) { win.XMLHttpRequest.DONE = 4; win.XMLHttpRequest.prototype = - { - UNSENT: 0, - OPENED: 1, - HEADERS_RECEIVED: 2, - LOADING: 3, - DONE: 4, - - isAsync: false, - onreadystatechange: null, - readyState: 0, - _url: "", - timeout: 0, - withCredentials: false, - _requestHeaders: null, - open: function (reqType, uri, isAsync, user, password) { - - if (uri && uri.indexOf("http") == 0) { - if (!this.wrappedXHR) { - this.wrappedXHR = new aliasXHR(); - var self = this; - - // timeout - if (this.timeout > 0) { - this.wrappedXHR.timeout = this.timeout; - } - Object.defineProperty(this, "timeout", { - set: function (val) { - this.wrappedXHR.timeout = val; - }, - get: function () { - return this.wrappedXHR.timeout; - } - }); - - - - if (this.withCredentials) { - this.wrappedXHR.withCredentials = this.withCredentials; - } - Object.defineProperty(this, "withCredentials", { - set: function (val) { - this.wrappedXHR.withCredentials = val; - }, - get: function () { - return this.wrappedXHR.withCredentials; - } - }); - - - Object.defineProperty(this, "status", { get: function () { - return this.wrappedXHR.status; - } - }); - Object.defineProperty(this, "responseText", { get: function () { - return this.wrappedXHR.responseText; - } - }); - Object.defineProperty(this, "statusText", { get: function () { - return this.wrappedXHR.statusText; - } - }); - - Object.defineProperty(this, "responseXML", { get: function () { - return this.wrappedXHR.responseXML; - } - }); - - this.getResponseHeader = function (header) { - return this.wrappedXHR.getResponseHeader(header); - }; - this.getAllResponseHeaders = function () { - return this.wrappedXHR.getAllResponseHeaders(); - }; - - this.wrappedXHR.onreadystatechange = function () { - self.changeReadyState(self.wrappedXHR.readyState); - }; - } - return this.wrappedXHR.open(reqType, uri, isAsync, user, password); - } - else { - // x-wmapp1://app/www/page2.html - // need to work some magic on the actual url/filepath - var newUrl = uri; - if (newUrl.indexOf(":/") > -1) { - newUrl = newUrl.split(":/")[1]; - } - - if (newUrl.lastIndexOf("/") === newUrl.length - 1) { - newUrl += "index.html"; // default page is index.html, when call is to a dir/ ( why not ...? ) - } - this._url = newUrl; - } - }, - statusText: "", - changeReadyState: function (newState) { - this.readyState = newState; - if (this.onreadystatechange) { - this.onreadystatechange(); - } - }, - setRequestHeader: function (header, value) { - if (this.wrappedXHR) { - this.wrappedXHR.setRequestHeader(header, value); - } - }, - getResponseHeader: function (header) { - return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : ""; - }, - getAllResponseHeaders: function () { - return this.wrappedXHR ? this.wrappedXHR.getAllResponseHeaders() : ""; - }, - responseText: "", - responseXML: "", - onResult: function (res) { - this.status = 200; - this.responseText = res; - this.responseXML = res; - this.changeReadyState(this.DONE); - }, - onError: function (err) { - this.status = 404; - this.changeReadyState(this.DONE); - }, - - abort: function () { - if (this.wrappedXHR) { - return this.wrappedXHR.abort(); - } - }, - - send: function (data) { - if (this.wrappedXHR) { - return this.wrappedXHR.send(data); - } - else { - this.changeReadyState(this.OPENED); - - var alias = this; - - function fail(evt) { - alias.onError(evt.code); - } - - function gotFile(file) { - var reader = new FileReader(); - reader.onloadend = function (evt) - { - alias.onResult.apply(alias,[evt.target.result]); - }; - reader.readAsText(file); - } - - function gotEntry(entry) { - entry.file(gotFile, fail); - } - - function gotFS(fs) { - fs.root.getFile(alias._url, null, gotEntry, fail); - } - - window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); - - } - }, - status: 404 - }; + { + UNSENT: 0, + OPENED: 1, + HEADERS_RECEIVED: 2, + LOADING: 3, + DONE: 4, + + isAsync: false, + onreadystatechange: null, + readyState: 0, + _url: "", + timeout: 0, + withCredentials: false, + _requestHeaders: null, + open: function (reqType, uri, isAsync, user, password) { + + if (uri && uri.indexOf("http") == 0) { + if (!this.wrappedXHR) { + this.wrappedXHR = new aliasXHR(); + var self = this; + + // timeout + if (this.timeout > 0) { + this.wrappedXHR.timeout = this.timeout; + } + Object.defineProperty(this, "timeout", { + set: function (val) { + this.wrappedXHR.timeout = val; + }, + get: function () { + return this.wrappedXHR.timeout; + } + }); + + + + if (this.withCredentials) { + this.wrappedXHR.withCredentials = this.withCredentials; + } + Object.defineProperty(this, "withCredentials", { + set: function (val) { + this.wrappedXHR.withCredentials = val; + }, + get: function () { + return this.wrappedXHR.withCredentials; + } + }); + + + Object.defineProperty(this, "status", { get: function () { + return this.wrappedXHR.status; + } + }); + Object.defineProperty(this, "responseText", { get: function () { + return this.wrappedXHR.responseText; + } + }); + Object.defineProperty(this, "statusText", { get: function () { + return this.wrappedXHR.statusText; + } + }); + + Object.defineProperty(this, "responseXML", { get: function () { + return this.wrappedXHR.responseXML; + } + }); + + this.getResponseHeader = function (header) { + return this.wrappedXHR.getResponseHeader(header); + }; + this.getAllResponseHeaders = function () { + return this.wrappedXHR.getAllResponseHeaders(); + }; + + this.wrappedXHR.onreadystatechange = function () { + self.changeReadyState(self.wrappedXHR.readyState); + }; + } + return this.wrappedXHR.open(reqType, uri, isAsync, user, password); + } + else { + // x-wmapp1://app/www/page2.html + // need to work some magic on the actual url/filepath + var newUrl = uri; + if (newUrl.indexOf(":/") > -1) { + newUrl = newUrl.split(":/")[1]; + } + + if (newUrl.lastIndexOf("/") === newUrl.length - 1) { + newUrl += "index.html"; // default page is index.html, when call is to a dir/ ( why not ...? ) + } + this._url = newUrl; + } + }, + statusText: "", + changeReadyState: function (newState) { + this.readyState = newState; + if (this.onreadystatechange) { + this.onreadystatechange(); + } + }, + setRequestHeader: function (header, value) { + if (this.wrappedXHR) { + this.wrappedXHR.setRequestHeader(header, value); + } + }, + getResponseHeader: function (header) { + return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : ""; + }, + getAllResponseHeaders: function () { + return this.wrappedXHR ? this.wrappedXHR.getAllResponseHeaders() : ""; + }, + responseText: "", + responseXML: "", + onResult: function (res) { + this.status = 200; + this.responseText = res; + this.responseXML = res; + this.changeReadyState(this.DONE); + }, + onError: function (err) { + this.status = 404; + this.changeReadyState(this.DONE); + }, + + abort: function () { + if (this.wrappedXHR) { + return this.wrappedXHR.abort(); + } + }, + + send: function (data) { + if (this.wrappedXHR) { + return this.wrappedXHR.send(data); + } + else { + this.changeReadyState(this.OPENED); + + var alias = this; + + function fail(evt) { + alias.onError(evt.code); + } + + function gotFile(file) { + var reader = new FileReader(); + reader.onloadend = function (evt) + { + alias.onResult.apply(alias,[evt.target.result]); + }; + reader.readAsText(file); + } + + function gotEntry(entry) { + entry.file(gotFile, fail); + } + + function gotFS(fs) { + fs.root.getFile(alias._url, null, gotEntry, fail); + } + + window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); + + } + }, + status: 404 + }; } // if doc domain // end closure wrap http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/plugin/wp7/console.js ---------------------------------------------------------------------- diff --git a/lib/wp7/plugin/wp7/console.js b/lib/wp7/plugin/wp7/console.js index 2488f81..3758c7d 100644 --- a/lib/wp7/plugin/wp7/console.js +++ b/lib/wp7/plugin/wp7/console.js @@ -4,15 +4,15 @@ var exec = require('cordova/exec'), var cordova = require("cordova"); var debugConsole = { - log:function(msg){ - exec(null,null,"DebugConsole","log",msg); - }, - warn:function(msg){ - exec(null,null,"DebugConsole","warn",msg); - }, - error:function(msg){ - exec(null,null,"DebugConsole","error",msg); - } + log:function(msg){ + exec(null,null,"DebugConsole","log",msg); + }, + warn:function(msg){ + exec(null,null,"DebugConsole","warn",msg); + }, + error:function(msg){ + exec(null,null,"DebugConsole","error",msg); + } }; module.exports = debugConsole; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/plugin/wp7/requestFileSystem.js ---------------------------------------------------------------------- diff --git a/lib/wp7/plugin/wp7/requestFileSystem.js b/lib/wp7/plugin/wp7/requestFileSystem.js index a22d4a3..2634b16 100644 --- a/lib/wp7/plugin/wp7/requestFileSystem.js +++ b/lib/wp7/plugin/wp7/requestFileSystem.js @@ -11,7 +11,7 @@ var FileError = require('cordova/plugin/FileError'), * @param errorCallback invoked if error occurs retrieving file system */ var requestFileSystem = function(type, size, successCallback, errorCallback) { - // wp7 custom imp + // wp7 custom imp var fail = function(code) { if (typeof errorCallback === 'function') { errorCallback(new FileError(code)); http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e944b086/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js ---------------------------------------------------------------------- diff --git a/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js b/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js index f00c339..717f490 100644 --- a/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js +++ b/lib/wp7/plugin/wp7/resolveLocalFileSystemURI.js @@ -3,7 +3,7 @@ var DirectoryEntry = require('cordova/plugin/DirectoryEntry'), FileEntry = require('cordova/plugin/FileEntry'), exec = require('cordova/exec'); - + module.exports = function(uri, successCallback, errorCallback) { // error callback var fail = function(error) {