You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/03/27 19:45:08 UTC

[1/6] js commit: [CB-2305] Add InAppBrowser.executeScript and InAppBrowser.insertCSS APIs

Updated Branches:
  refs/heads/2.6.x 47593b2bc -> a2c5b0e22


[CB-2305] Add InAppBrowser.executeScript and InAppBrowser.insertCSS APIs


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/9a65e32a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/9a65e32a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/9a65e32a

Branch: refs/heads/2.6.x
Commit: 9a65e32a21a696f94fb41cf39cf7ce7b1830c915
Parents: bbf1562
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Mar 15 23:27:55 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Sat Mar 23 12:59:42 2013 -0400

----------------------------------------------------------------------
 lib/common/plugin/InAppBrowser.js |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/9a65e32a/lib/common/plugin/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/InAppBrowser.js b/lib/common/plugin/InAppBrowser.js
index 6422315..6e0b79b 100644
--- a/lib/common/plugin/InAppBrowser.js
+++ b/lib/common/plugin/InAppBrowser.js
@@ -49,6 +49,34 @@ 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');
+        }
     }
 };
 


[2/6] js commit: Fix all lint warnings.

Posted by pu...@apache.org.
Fix all lint warnings.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/188648bf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/188648bf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/188648bf

Branch: refs/heads/2.6.x
Commit: 188648bfa74650f7692d71f9ba6a1fa69e1a3877
Parents: 9a65e32
Author: Andrew Grieve <ag...@chromium.org>
Authored: Sat Mar 23 13:05:45 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Sat Mar 23 13:05:45 2013 -0400

----------------------------------------------------------------------
 lib/blackberry/plugin/qnx/file.js         |    1 +
 lib/blackberry/plugin/qnx/fileTransfer.js |    1 +
 lib/common/plugin/FileTransfer.js         |   18 +++++-------------
 lib/common/plugin/InAppBrowser.js         |    2 +-
 lib/osx/exec.js                           |    6 +++---
 lib/tizen/plugin/tizen/ContactUtils.js    |    7 +------
 lib/webos/platform.js                     |    2 ++
 7 files changed, 14 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188648bf/lib/blackberry/plugin/qnx/file.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/file.js b/lib/blackberry/plugin/qnx/file.js
index 8bf9b86..d611daf 100644
--- a/lib/blackberry/plugin/qnx/file.js
+++ b/lib/blackberry/plugin/qnx/file.js
@@ -20,6 +20,7 @@
 */
 
 /*global WebKitBlobBuilder:false */
+/*global Blob:false */
 var cordova = require('cordova'),
     FileError = require('cordova/plugin/FileError'),
     DirectoryEntry = require('cordova/plugin/DirectoryEntry'),

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188648bf/lib/blackberry/plugin/qnx/fileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/fileTransfer.js b/lib/blackberry/plugin/qnx/fileTransfer.js
index 7148e17..6848516 100644
--- a/lib/blackberry/plugin/qnx/fileTransfer.js
+++ b/lib/blackberry/plugin/qnx/fileTransfer.js
@@ -19,6 +19,7 @@
  *
 */
 
+/*global Blob:false */
 var cordova = require('cordova'),
     FileEntry = require('cordova/plugin/FileEntry'),
     FileTransferError = require('cordova/plugin/FileTransferError'),

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188648bf/lib/common/plugin/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/FileTransfer.js b/lib/common/plugin/FileTransfer.js
index 2e4c980..20c0eb2 100644
--- a/lib/common/plugin/FileTransfer.js
+++ b/lib/common/plugin/FileTransfer.js
@@ -45,7 +45,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);
         }
@@ -97,12 +97,8 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
 
     var basicAuthHeader = getBasicAuthHeader(server);
     if (basicAuthHeader) {
-        if (!options) {
-            options = new FileUploadOptions();
-        }
-        if (!options.headers) {
-            options.headers = {};
-        }
+        options = options || {};
+        options.headers = options.headers || {};
         options.headers[basicAuthHeader.name] = basicAuthHeader.value;
     }
 
@@ -155,12 +151,8 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
 
     var basicAuthHeader = getBasicAuthHeader(source);
     if (basicAuthHeader) {
-        if (!options) {
-            options = {};
-        }
-        if (!options.headers) {
-            options.headers = {};
-        }
+        options = options || {};
+        options.headers = options.headers || {};
         options.headers[basicAuthHeader.name] = basicAuthHeader.value;
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188648bf/lib/common/plugin/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/InAppBrowser.js b/lib/common/plugin/InAppBrowser.js
index 6e0b79b..618befd 100644
--- a/lib/common/plugin/InAppBrowser.js
+++ b/lib/common/plugin/InAppBrowser.js
@@ -67,7 +67,7 @@ InAppBrowser.prototype = {
         var script,
             sourceString;
         if (injectDetails.code) {
-       	    sourceString = JSON.stringify(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) {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188648bf/lib/osx/exec.js
----------------------------------------------------------------------
diff --git a/lib/osx/exec.js b/lib/osx/exec.js
index 0e9faf7..6eebb7b 100644
--- a/lib/osx/exec.js
+++ b/lib/osx/exec.js
@@ -114,9 +114,9 @@ function OSXExec() {
 
 
 OSXExec.nativeCallback = function(callbackId, status, message, keepCallback) {
-	var success = status === 0 || status === 1;
-	var args = convertMessageToArgsNativeToJs(message);
-	cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
+    var success = status === 0 || status === 1;
+    var args = convertMessageToArgsNativeToJs(message);
+    cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
 };
 
 module.exports = OSXExec;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188648bf/lib/tizen/plugin/tizen/ContactUtils.js
----------------------------------------------------------------------
diff --git a/lib/tizen/plugin/tizen/ContactUtils.js b/lib/tizen/plugin/tizen/ContactUtils.js
index 7ac05f3..de1c7aa 100644
--- a/lib/tizen/plugin/tizen/ContactUtils.js
+++ b/lib/tizen/plugin/tizen/ContactUtils.js
@@ -61,15 +61,10 @@ var fieldMappings = {
  */
 var allFields = [];
 
-(function initializeAllFieldsMapping() {
-
+(function() {
     for ( var key in fieldMappings) {
         allFields.push(key);
     }
-    // as we want it to be executed once
-    function initializeAllFieldsMapping() {
-    }
-
 })();
 
 /**

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188648bf/lib/webos/platform.js
----------------------------------------------------------------------
diff --git a/lib/webos/platform.js b/lib/webos/platform.js
index 69626d0..f59ab5b 100644
--- a/lib/webos/platform.js
+++ b/lib/webos/platform.js
@@ -19,6 +19,8 @@
  *
 */
 
+/*global Mojo:false */
+
 var service=require('cordova/plugin/webos/service'),
     cordova = require('cordova');
 


[5/6] js commit: Merge branch '2.6.x' of https://git-wip-us.apache.org/repos/asf/cordova-js into 2.6.x

Posted by pu...@apache.org.
Merge branch '2.6.x' of https://git-wip-us.apache.org/repos/asf/cordova-js into 2.6.x


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/dad383ce
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/dad383ce
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/dad383ce

Branch: refs/heads/2.6.x
Commit: dad383ce2fbccdc219e5d840cb1b1e32aeb014bd
Parents: 32b9e1c 47593b2
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Mar 27 10:23:10 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Mar 27 10:23:10 2013 -0700

----------------------------------------------------------------------
 VERSION                                     |    2 +-
 lib/bada/plugin/bada/device.js              |    2 +-
 lib/blackberry/plugin/air/device.js         |    2 +-
 lib/blackberry/plugin/qnx/device.js         |    2 +-
 lib/tizen/plugin/tizen/Device.js            |    2 +-
 lib/windows8/plugin/windows8/DeviceProxy.js |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------



[3/6] js commit: [CB-2806] ios fix for script_loader xhr response of 0.

Posted by pu...@apache.org.
[CB-2806] ios fix for script_loader xhr response of 0.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/5f56a0d3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/5f56a0d3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/5f56a0d3

Branch: refs/heads/2.6.x
Commit: 5f56a0d3f1d38d82edb5817589d4f6a787651e05
Parents: 188648b
Author: Michal Mocny <mm...@gmail.com>
Authored: Mon Mar 25 17:59:25 2013 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Mon Mar 25 17:59:25 2013 -0400

----------------------------------------------------------------------
 lib/scripts/plugin_loader.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5f56a0d3/lib/scripts/plugin_loader.js
----------------------------------------------------------------------
diff --git a/lib/scripts/plugin_loader.js b/lib/scripts/plugin_loader.js
index ef4f446..03a7381 100644
--- a/lib/scripts/plugin_loader.js
+++ b/lib/scripts/plugin_loader.js
@@ -101,7 +101,7 @@
 
         // 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.
-        if (this.status == 200) {
+        if (this.status == 200 || this.status == 0) {
             var obj = JSON.parse(this.responseText);
             if (obj && obj instanceof Array && obj.length > 0) {
                 handlePluginsObject(obj);


[4/6] js commit: [CB-2806] Fix plugin loading when XHR doesn't return valid JSON

Posted by pu...@apache.org.
[CB-2806] Fix plugin loading when XHR doesn't return valid JSON

Take two!


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/32b9e1c3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/32b9e1c3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/32b9e1c3

Branch: refs/heads/2.6.x
Commit: 32b9e1c30649d228faa397bbc6216548c437742c
Parents: 5f56a0d
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Mar 26 09:54:30 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Mar 26 10:40:55 2013 -0400

----------------------------------------------------------------------
 lib/scripts/plugin_loader.js |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/32b9e1c3/lib/scripts/plugin_loader.js
----------------------------------------------------------------------
diff --git a/lib/scripts/plugin_loader.js b/lib/scripts/plugin_loader.js
index 03a7381..8e4161d 100644
--- a/lib/scripts/plugin_loader.js
+++ b/lib/scripts/plugin_loader.js
@@ -94,24 +94,19 @@
 
     // Try to XHR the cordova_plugins.json file asynchronously.
     var xhr = new context.XMLHttpRequest();
-    xhr.onreadystatechange = function() {
-        if (this.readyState != 4) { // not DONE
-            return;
-        }
-
+    xhr.onload = function() {
         // 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.
-        if (this.status == 200 || this.status == 0) {
-            var obj = JSON.parse(this.responseText);
-            if (obj && obj instanceof Array && obj.length > 0) {
-                handlePluginsObject(obj);
-            } else {
-                finishPluginLoading();
-            }
+        var obj = JSON.parse(this.responseText);
+        if (obj && obj instanceof Array && obj.length > 0) {
+            handlePluginsObject(obj);
         } else {
             finishPluginLoading();
         }
     };
+    xhr.onerror = function() {
+        finishPluginLoading();
+    };
     xhr.open('GET', 'cordova_plugins.json', true); // Async
     xhr.send();
 }(window));


[6/6] js commit: catch XHR exception in cordova_plugins.json loading code

Posted by pu...@apache.org.
catch XHR exception in cordova_plugins.json loading code


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/a2c5b0e2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/a2c5b0e2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/a2c5b0e2

Branch: refs/heads/2.6.x
Commit: a2c5b0e22026926f04df300436e9fb4574377a62
Parents: dad383c
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Mar 27 11:44:05 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Mar 27 11:44:05 2013 -0700

----------------------------------------------------------------------
 lib/scripts/plugin_loader.js |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/a2c5b0e2/lib/scripts/plugin_loader.js
----------------------------------------------------------------------
diff --git a/lib/scripts/plugin_loader.js b/lib/scripts/plugin_loader.js
index 8e4161d..5223221 100644
--- a/lib/scripts/plugin_loader.js
+++ b/lib/scripts/plugin_loader.js
@@ -92,22 +92,28 @@
         }
     }
 
+
     // Try to XHR the cordova_plugins.json file asynchronously.
-    var xhr = new context.XMLHttpRequest();
-    xhr.onload = function() {
-        // 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);
-        } else {
+    try { // we commented we were going to try, so let us actually try and catch 
+        var xhr = new context.XMLHttpRequest();
+        xhr.onload = function() {
+            // 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);
+            } else {
+                finishPluginLoading();
+            }
+        };
+        xhr.onerror = function() {
             finishPluginLoading();
-        }
-    };
-    xhr.onerror = function() {
+        };
+        xhr.open('GET', 'cordova_plugins.json', true); // Async
+        xhr.send();
+    }
+    catch(err){
         finishPluginLoading();
-    };
-    xhr.open('GET', 'cordova_plugins.json', true); // Async
-    xhr.send();
+    }
 }(window));