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 2012/04/06 03:20:42 UTC
[15/40] git commit: plugins are back
plugins are back
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/f27246fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/f27246fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/f27246fc
Branch: refs/heads/master
Commit: f27246fce644117ee6b5a82ed823977583c64d45
Parents: 8d3f106
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Mar 30 10:44:55 2012 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Mar 30 10:44:55 2012 -0700
----------------------------------------------------------------------
lib/wp7/plugin/wp7/CordovaCommandResult.js | 37 ++++++++++
lib/wp7/plugin/wp7/console.js | 40 +++++++++++
lib/wp7/plugin/wp7/device.js | 85 +++++++++++++++++++++++
3 files changed, 162 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f27246fc/lib/wp7/plugin/wp7/CordovaCommandResult.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/CordovaCommandResult.js b/lib/wp7/plugin/wp7/CordovaCommandResult.js
new file mode 100644
index 0000000..92b71be
--- /dev/null
+++ b/lib/wp7/plugin/wp7/CordovaCommandResult.js
@@ -0,0 +1,37 @@
+
+console.log("CordovaComandResult is being added");
+var cordova = require('cordova');
+var channel = require('cordova/channel');
+
+//module.exports = {
+ // singular WP7 callback function attached to window, status is used to determin if it is a success or error
+var CordovaCommandResult = function(status,callbackId,args,cast) {
+ if(status === "backbutton") {
+ cordova.fireEvent(document,"backbutton");
+ return "true";
+ }
+ else if(status === "resume") {
+ channel.onResume.fire();
+ return "true";
+ }
+ else if(status === "pause") {
+
+ channel.onPause.fire();
+ return "true";
+ }
+
+ var safeStatus = parseInt(status, 10);
+ if(safeStatus === cordova.callbackStatus.NO_RESULT ||
+ safeStatus === cordova.callbackStatus.OK) {
+ cordova.callbackSuccess(callbackId,args,cast);
+ }
+ else
+ {
+ cordova.callbackError(callbackId,args,cast);
+ }
+ };
+
+//}
+
+module.exports = CordovaCommandResult;
+console.log("CordovaComandResult is added");
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f27246fc/lib/wp7/plugin/wp7/console.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/console.js b/lib/wp7/plugin/wp7/console.js
new file mode 100644
index 0000000..af058cd
--- /dev/null
+++ b/lib/wp7/plugin/wp7/console.js
@@ -0,0 +1,40 @@
+
+console.log("console is being added");
+
+var exec = require('cordova/exec'),
+ channel = require('cordova/channel');
+var cordova = require("cordova");
+
+
+var debugConsole =
+{
+ log:function(msg){
+ cordova.exec(null,null,"DebugConsole","log",msg);
+ },
+ warn:function(msg){
+ cordova.exec(null,null,"DebugConsole","warn",msg);
+ },
+ error:function(msg){
+ cordova.exec(null,null,"DebugConsole","error",msg);
+ }
+};
+
+
+if(typeof window.console == "undefined")
+{
+ window.console = debugConsole;
+}
+else
+{
+ console.log("window.console is already defined");
+}
+
+// output any errors to console log, created above.
+window.onerror=function(e)
+{
+ debugConsole.error(JSON.stringify(e));
+};
+
+module.exports = debugConsole;
+
+console.log("console is added");
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/f27246fc/lib/wp7/plugin/wp7/device.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/device.js b/lib/wp7/plugin/wp7/device.js
new file mode 100644
index 0000000..729c22a
--- /dev/null
+++ b/lib/wp7/plugin/wp7/device.js
@@ -0,0 +1,85 @@
+/**
+ * this represents the mobile device, and provides properties for inspecting the model, version, UUID of the
+ * phone, etc.
+ * @constructor
+ */
+
+console.log("device is being added");
+
+var cordova = require("cordova");
+var exec = require('cordova/exec'),
+ channel = require('cordova/channel');
+var utils = require('cordova/utils');
+
+
+var Device = function() {
+ console.log("device constructor");
+ this.platform = null;
+ this.version = null;
+ this.name = null;
+ this.cordova = null;
+ this.uuid = null;
+
+ var me = this;
+ this.getInfo(function (res) {
+ console.log("Device.gotInfo::" + res);
+ var info = JSON.parse(res);
+ console.log("GotDeviceInfo :: " + info.version);
+ me.available = true;
+ me.platform = info.platform;
+ me.version = info.version;
+ me.name = info.name;
+ me.uuid = info.uuid;
+ me.cordova = info.cordova;
+
+ channel.onCordovaInfoReady.fire();
+ },
+ function(e) {
+ me.available = false;
+ console.log("Error initializing Cordova: " + e);
+ });
+
+};
+
+/**
+ * Get device info
+ *
+ * @param {Function} successCallback The function to call when the heading data is available
+ * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
+ */
+Device.prototype.getInfo = function(successCallback, errorCallback) {
+
+ console.log("device.getInfo");
+ // successCallback required
+ if (typeof successCallback !== "function") {
+ console.log("Device Error: successCallback is not a function");
+ return;
+ }
+
+ // errorCallback optional
+ if (errorCallback && (typeof errorCallback !== "function")) {
+ console.log("Device Error: errorCallback is not a function");
+ return;
+ }
+
+ // Get info
+ //exec(successCallback, errorCallback, "Device", "Get");
+};
+
+Device.prototype.setInfo = function(info) {
+ console.log("setting device info " + info);
+ try {
+ this.platform = info.platform;
+ this.version = info.version;
+ this.name = info.name;
+ this.cordova = info.gap;
+ this.uuid = info.uuid;
+ channel.onCordovaInfoReady.fire();
+ } catch(e) {
+ alert('Error during device info setting in cordova/plugin/ios/device!');
+ }
+};
+
+module.exports = new Device();
+
+console.log("device is live + done");