Updated Branches: refs/heads/master a2e1b796d -> 63efe5b3a
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/63efe5b3/lib/cordova.firefoxos.js ---------------------------------------------------------------------- diff --git a/lib/cordova.firefoxos.js b/lib/cordova.firefoxos.js index 7b263a3..ad24fd4 100644 --- a/lib/cordova.firefoxos.js +++ b/lib/cordova.firefoxos.js @@ -1,8 +1,8 @@ // Platform: firefoxos -// commit 4bbb9b5e9f232cc5f090e5065a0d92086b78628d +// commit 125dca530923a44a8f44f68f5e1970cbdd4e7faf -// File generated at :: Wed Mar 27 2013 15:35:48 GMT-0700 (PDT) +// File generated at :: Wed Apr 03 2013 16:15:48 GMT-0700 (PDT) /* Licensed to the Apache Software Foundation (ASF) under one @@ -798,8 +798,7 @@ define("cordova/exec", function(require, exports, module) { var plugins = { "Device": require('cordova/plugin/firefoxos/device'), "NetworkStatus": require('cordova/plugin/firefoxos/network'), - "Accelerometer": require('cordova/plugin/firefoxos/accelerometer'), - "Orientation": require('cordova/plugin/firefoxos/orientation') + "Accelerometer" : require('cordova/plugin/firefoxos/accelerometer') //"Notification" : require('cordova/plugin/firefoxos/notification') }; @@ -2532,7 +2531,7 @@ function getBasicAuthHeader(urlString) { var origin = protocol + url.host; // check whether there are the username:password credentials in the url - if (url.href.indexOf(origin) !== 0) { // credentials found + if (url.href.indexOf(origin) != 0) { // credentials found var atIndex = url.href.indexOf("@"); credentials = url.href.substring(protocol.length, atIndex); } @@ -2581,11 +2580,15 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro var params = null; var chunkedMode = true; var headers = null; - var httpMethod = null; + var basicAuthHeader = getBasicAuthHeader(server); if (basicAuthHeader) { - options = options || {}; - options.headers = options.headers || {}; + if (!options) { + options = new FileUploadOptions(); + } + if (!options.headers) { + options.headers = {}; + } options.headers[basicAuthHeader.name] = basicAuthHeader.value; } @@ -2594,12 +2597,6 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro fileName = options.fileName; mimeType = options.mimeType; headers = options.headers; - httpMethod = options.httpMethod || "POST"; - if (httpMethod.toUpperCase() == "PUT"){ - httpMethod = "PUT"; - } else { - httpMethod = "POST"; - } if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { chunkedMode = options.chunkedMode; } @@ -2626,7 +2623,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro successCallback && successCallback(result); } }; - exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]); + exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id]); }; /** @@ -2644,8 +2641,12 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro var basicAuthHeader = getBasicAuthHeader(source); if (basicAuthHeader) { - options = options || {}; - options.headers = options.headers || {}; + if (!options) { + options = {}; + } + if (!options.headers) { + options.headers = {}; + } options.headers[basicAuthHeader.name] = basicAuthHeader.value; } @@ -2684,11 +2685,12 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro }; /** - * Aborts the ongoing file transfer on this object. The original error - * callback for the file transfer will be called if necessary. + * Aborts the ongoing file transfer on this object + * @param successCallback {Function} Callback to be invoked upon success + * @param errorCallback {Function} Callback to be invoked upon error */ -FileTransfer.prototype.abort = function() { - exec(null, null, 'FileTransfer', 'abort', [this._id]); +FileTransfer.prototype.abort = function(successCallback, errorCallback) { + exec(successCallback, errorCallback, 'FileTransfer', 'abort', [this._id]); }; module.exports = FileTransfer; @@ -2732,13 +2734,12 @@ define("cordova/plugin/FileUploadOptions", function(require, exports, module) { * @param headers {Object} Keys are header names, values are header values. Multiple * headers of the same name are not supported. */ -var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) { +var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) { this.fileKey = fileKey || null; this.fileName = fileName || null; this.mimeType = mimeType || null; this.params = params || null; this.headers = headers || null; - this.httpMethod = httpMethod || null; }; module.exports = FileUploadOptions; @@ -3101,34 +3102,6 @@ InAppBrowser.prototype = { if (eventname in this.channels) { this.channels[eventname].unsubscribe(f); } - }, - executeScript: function(injectDetails, cb) { - var script, - sourceString; - if (injectDetails.code) { - exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code]); - } else if (injectDetails.file) { - sourceString = JSON.stringify(injectDetails.file); - script = "(function(d) { var c = d.createElement('script'); c.src = " + sourceString + "; d.body.appendChild(c); })(document)"; - exec(cb, null, "InAppBrowser", "injectScriptCode", [script]); - } else { - throw new Error('executeScript requires exactly one of code or file to be specified'); - } - }, - insertCSS: function(injectDetails, cb) { - var script, - sourceString; - if (injectDetails.code) { - sourceString = JSON.stringify(injectDetails.code); - script = "(function(d) { var c = d.createElement('style'); c.innerHTML = " + sourceString + "; d.body.appendChild(c); })(document)"; - exec(cb, null, "InAppBrowser", "injectScriptCode", [script]); - } else if (injectDetails.file) { - sourceString = JSON.stringify(injectDetails.file); - script = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet', c.type='text/css'; c.href = " + sourceString + "; d.body.appendChild(c); })(document)"; - exec(cb, null, "InAppBrowser", "injectScriptCode", [script]); - } else { - throw new Error('insertCSS requires exactly one of code or file to be specified'); - } } }; @@ -6083,27 +6056,31 @@ window.cordova = require('cordova'); } } - // Try to XHR the cordova_plugins.json file asynchronously. try { // we commented we were going to try, so let us actually try and catch var xhr = new context.XMLHttpRequest(); - xhr.onload = function() { + xhr.onreadystatechange = function() { + if (this.readyState != 4) { // not DONE + return; + } + // If the response is a JSON string which composes an array, call handlePluginsObject. // If the request fails, or the response is not a JSON array, just call finishPluginLoading. - var obj = JSON.parse(this.responseText); - if (obj && obj instanceof Array && obj.length > 0) { - handlePluginsObject(obj); + if (this.status == 200) { + var obj = JSON.parse(this.responseText); + if (obj && obj instanceof Array && obj.length > 0) { + handlePluginsObject(obj); + } else { + finishPluginLoading(); + } } else { finishPluginLoading(); } }; - xhr.onerror = function() { - finishPluginLoading(); - }; xhr.open('GET', 'cordova_plugins.json', true); // Async xhr.send(); } - catch(err){ + catch(err) { finishPluginLoading(); } }(window));
