incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deedu...@apache.org
Subject git commit: Add console.log functionality. Fix backlight detection.
Date Wed, 22 Feb 2012 13:42:21 GMT
Updated Branches:
  refs/heads/master e642ab6fe -> cebd5fd78


Add console.log functionality. Fix backlight detection.


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/cebd5fd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/cebd5fd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/cebd5fd7

Branch: refs/heads/master
Commit: cebd5fd7846d2bc19924c751034241a803085b85
Parents: e642ab6
Author: Drew Walters <deedubbu@gmail.com>
Authored: Wed Feb 22 07:41:40 2012 -0600
Committer: Drew Walters <deedubbu@gmail.com>
Committed: Wed Feb 22 07:41:40 2012 -0600

----------------------------------------------------------------------
 lib/platform/blackberry.js |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/cebd5fd7/lib/platform/blackberry.js
----------------------------------------------------------------------
diff --git a/lib/platform/blackberry.js b/lib/platform/blackberry.js
index de4e694..ce2f53d 100644
--- a/lib/platform/blackberry.js
+++ b/lib/platform/blackberry.js
@@ -7,6 +7,23 @@ module.exports = {
             blackberryManager = require('cordova/plugin/blackberry/manager'),
             app = require('cordova/plugin/blackberry/app');
 
+        // BB OS 5 does not define window.console.
+        if (typeof window.console === 'undefined') {
+            window.console = {};
+        }
+
+        // Override console.log with native logging ability.
+        // BB OS 7 devices define console.log for use with web inspector
+        // debugging. If console.log is already defined, invoke it in addition
+        // to native logging.
+        var origLog = window.console.log;
+        window.console.log = function(msg) {
+            if (typeof origLog === 'function') {
+                origLog.call(window.console, msg);
+            }
+            org.apache.cordova.Logger.log(''+msg);
+        }
+
         // TODO: is there a better way to do this? build-time
         // convention? how can we save the few bytes from
         // cordova/plugin/Entry + DirectoryEntry that will get
@@ -66,7 +83,7 @@ module.exports = {
             }
         }
 
-        // Fires off necessary shite to pause/resume app
+        // Fires off necessary code to pause/resume app
         var resume = function() {
             cordova.fireDocumentEvent('resume');
             blackberryManager.resume();
@@ -97,12 +114,12 @@ module.exports = {
             }
         };
         var backlightFail = function(e) {
-            console.log("Error deteching backlight on/off.");
+            console.log("Error detecting backlight on/off.");
         };
 
         // Override stock resume and pause listeners so we can trigger
         // some native methods during attach/remove
-        channel.onResume = channel.create('onResume', {
+        channel.onResume = cordova.addDocumentEventHandler('resume', {
             onSubscribe:function() {
                 // If we just attached the first handler and there are
                 // no pause handlers, start the backlight system
@@ -113,21 +130,13 @@ module.exports = {
             },
             onUnsubscribe:onUnsubscribe
         });
-        channel.onPause = channel.create('onPause', {
+        channel.onPause = cordova.addDocumentEventHandler('pause', {
             onSubscribe:function() {
                 // If we just attached the first handler and there are
                 // no resume handlers, start the backlight system
                 // listener on the native side.
                 if (channel.onResume.handlers.length === 0 && channel.onPause.handlers.length
=== 1) {
-                    exec(function(isOn) {
-                        if (isOn === true) {
-                            resume();
-                        } else {
-                            pause();
-                        }
-                    }, function(e) {
-                        console.log("Error deteching backlight on/off.");
-                    }, "App", "detectBacklight", []);
+                    exec(backlightWin, backlightFail, "App", "detectBacklight", []);
                 }
             },
             onUnsubscribe:onUnsubscribe


Mime
View raw message