Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: filmaj/incubator-cordova-js
base: acb911a3ca
...
head fork: filmaj/incubator-cordova-js
compare: 017a948047
Checking mergeability… Don't worry, you can still create the pull request.
  • 11 commits
  • 12 files changed
  • 0 commit comments
  • 4 contributors
View
2  .jshintrc
@@ -28,7 +28,7 @@
"dojo": false,
// Custom predefined globals.
- "predef": ["jasmine", "blackberry", "define", "alert", "prompt", "org"],
+ "predef": ["jasmine", "blackberry", "define", "alert", "prompt", "org", "deviceapis", "Osp"],
// Development
View
3  Jakefile
@@ -131,9 +131,6 @@ task('fixwhitespace', function() {
src = src.split('\t').join(' ');
}
- // convert carriage return + line feed to just a line feed
- src = src.replace(/\r\n/g, '\n');
-
// eliminate trailing white space
src = src.replace(/ +\n/g, '\n');
View
2  lib/bada/exec.js
@@ -15,4 +15,4 @@ module.exports = function(success, fail, service, action, args) {
console.log(e);
console.log(e.stack);
}
-}
+};
View
2  lib/bada/platform.js
@@ -15,4 +15,4 @@ module.exports = {
}
}
}
-}
+};
View
11 lib/bada/plugin/bada/Accelerometer.js
@@ -9,10 +9,8 @@ module.exports = {
};
var error = function(err) {
console.log("Accelermometer:getAcceleration:error");
- switch(err.code) {
- case err.TYPE_MISMATCH_ERR:
- console.log("TYPE MISMATCH ERROR");
- break;
+ if (err.code == err.TYPE_MISMATCH_ERR) {
+ console.log("TYPE MISMATCH ERROR");
}
errorCallback(err);
@@ -28,11 +26,6 @@ module.exports = {
};
var error = function(err) {
console.log("accelerometer:watchAcceleration:error");
- switch(err.code) {
- case err.TYPE_MISMATCH_ERR:
- break;
- }
-
errorCallback(err);
};
return deviceapis.accelerometer.watchAcceleration(success, error);
View
4 lib/bada/plugin/bada/NetworkStatus.js
@@ -7,7 +7,7 @@ var channel = require('cordova/channel');
module.exports = {
getConnectionInfo: function(success, fail) {
var Connection = require("cordova/plugin/Connection");
- var connectionType = Connection.NONE
+ var connectionType = Connection.NONE;
deviceapis.devicestatus.getPropertyValue(function(value) {
console.log("Device WiFi network status: "+value);
if(value == "connected") {
@@ -15,7 +15,7 @@ module.exports = {
}
channel.onCordovaConnectionReady.fire();
success(connectionType);
- },
+ },
function(error) {
console.log(JSON.stringify(error));
fail();
View
2  lib/bada/plugin/bada/Notification.js
@@ -8,7 +8,7 @@ module.exports = {
beep: function(times, milliseconds) {
try {
deviceapis.deviceinteraction.stopNotify();
- if(times == 0) {
+ if(times === 0) {
return;
}
deviceapis.deviceinteraction.startNotify(function() {
View
12 lib/bada/plugin/bada/device.js
@@ -6,10 +6,10 @@ function Device() {
this.version = null;
this.name = null;
this.uuid = null;
- this.cordova = null
+ this.cordova = null;
var me = this;
-
+
channel.onCordovaReady.subscribeOnce(function() {
me.getInfo(function (device) {
me.platform = device.platform;
@@ -26,7 +26,7 @@ function Device() {
console.log("error initializing cordova: " + e);
});
});
-};
+}
Device.prototype.getInfo = function(success, fail, args) {
@@ -34,7 +34,7 @@ Device.prototype.getInfo = function(success, fail, args) {
var properties = ["name", "uuid", "os_name", "os_vendor", "os_version"];
var me = this;
-
+
var name = null,
platform = null,
uuid = null,
@@ -44,7 +44,7 @@ Device.prototype.getInfo = function(success, fail, args) {
var checkProperties = function() {
properties.pop();
- if(properties.length == 0) {
+ if(properties.length === 0) {
me.name = name;
me.platform = os_vendor + " " + os_name;
me.version = os_version;
@@ -79,6 +79,6 @@ Device.prototype.getInfo = function(success, fail, args) {
os_vendor = value;
checkProperties();
}, fail, {aspect: "OperatingSystem", property: "vendor"});
-}
+};
module.exports = new Device();
View
2  lib/common/plugin/capture.js
@@ -69,4 +69,4 @@ Capture.prototype.captureVideo = function(successCallback, errorCallback, option
};
-module.exports = new Capture();
+module.exports = new Capture();
View
2  lib/ios/exec.js
@@ -68,7 +68,7 @@ module.exports = function() {
for (var i = 0; i < actionArgs.length; ++i) {
var arg = actionArgs[i];
if (arg === undefined || arg === null) { // nulls are pushed to the args now (becomes NSNull)
- continue; //command.arguments.push(arg);
+ command["arguments"].push(arg);
} else if (typeof(arg) == 'object' && !(arg instanceof Array)) {
command.options = arg;
} else {
View
4 lib/ios/plugin/ios/device.js
@@ -20,7 +20,7 @@ Device.prototype.setInfo = function(info) {
this.platform = info.platform;
this.version = info.version;
this.name = info.name;
- this.cordova = info.gap;
+ this.cordova = info.cordova;
this.uuid = info.uuid;
channel.onCordovaInfoReady.fire();
} catch(e) {
@@ -28,4 +28,4 @@ Device.prototype.setInfo = function(info) {
}
};
-module.exports = new Device();
+module.exports = new Device();
View
257 lib/wp7/exec.js
@@ -1,219 +1,104 @@
var cordova = require('cordova');
-/**
- * Execute a cordova command. It is up to the native side whether this action
- * is synchronous or asynchronous. The native side can return:
- * Synchronous: PluginResult object as a JSON string
- * Asynchrounous: Empty string ""
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success The success callback
- * @param {Function} fail The fail callback
- * @param {String} service The name of the service to use
- * @param {String} action Action to be run in cordova
- * @param {String[]} [args] Zero or more arguments to pass to the method
+ /* definition of named properties expected by the native side,
+ all arrays are stored in order of how they are received from common js code.
+ When other platforms evolve to using named args this will be removed.
*/
- /* this will become a programmatic way to gen the named args ... TODO: -jm
-var NamedArgs =
-{
+var NamedArgs = {
File:{
getFileMetadata:["fullPath"],
readAsText:["fileName","encoding"],
readAsDataURL:["fileName"],
getDirectory:["fullPath","path","options"],
+ remove:["fullPath"],
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]};
- }
-
},
- 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]};
- }
+ FileTransfer:{
+ upload:["filePath", "server", "fileKey", "fileName", "mimeType", "params", "debug", "chunkedMode"]
},
- 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]};
- }
+ Contacts:{
+ search:["fields","options"]
},
- 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:["id","src"],
+ startPlayingAudio:["id","src","milliseconds"],
+ //stopPlayingAudio
+ seekToAudio:["id","milliseconds"],
+ //pausePlayingAudio
+ //getCurrentPositionAudio
+ startRecordingAudio:["id","src"],
+ stopRecordingAudio:["id"],
+ release:["id"],
+ setVolume:["id","volume"]
},
- 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:["message","title","buttonLabel"],
+ confirm:["message","title","buttonLabel"]
},
- 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]};
- }
+ Camera:{
+ takePicture:["quality", "destinationType", "sourceType", "targetWidth", "targetHeight", "encodingType"]
}
-
};
-module.exports = function(success, fail, service, action, args)
-{
+/**
+ * Execute a cordova command. It is up to the native side whether this action
+ * is synchronous or asynchronous. The native side can return:
+ * Synchronous: PluginResult object as a JSON string
+ * Asynchrounous: Empty string ""
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success The success callback
+ * @param {Function} fail The fail callback
+ * @param {String} service The name of the service to use
+ * @param {String} action Action to be run in cordova
+ * @param {String[]} [args] Zero or more arguments to pass to the method
+
+ */
+
+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(NamedArgs[service] && NamedArgs[service][action]) {
+ var argNames = NamedArgs[service][action];
+ var newArgs = {};
+ var len = Math.min(args.length,argNames.length);
- var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
- // pass it on to Notify
- try
- {
- if(window.external)
- {
- window.external.Notify(command);
- }
- else
- {
+ for(var n = 0; n < len; n++) {
+ newArgs[argNames[n]] = args[n];
+ }
+
+ args = newArgs;
+ }
+ 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);
- }
-};
+ }
+ }
+ catch(e) {
+ console.log("Exception calling native with command :: " + command + " :: exception=" + e);
+ }
+};
+

No commit comments for this range

Something went wrong with that request. Please try again.