You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ripple.apache.org by "Tomasz Trejderowski (JIRA)" <ji...@apache.org> on 2013/09/20 09:11:51 UTC

[jira] [Comment Edited] (RIPPLE-36) Ripple Emulator under Windows doesn't fire events

    [ https://issues.apache.org/jira/browse/RIPPLE-36?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13772827#comment-13772827 ] 

Tomasz Trejderowski edited comment on RIPPLE-36 at 9/20/13 7:11 AM:
--------------------------------------------------------------------

This is a [public repository|https://github.com/trejder/pg-demo-bootstrap], so you can browse / check / test code, whenever you have some spare time and willing to do so. Event binding is done in [/assets/app.js|https://github.com/trejder/pg-demo-bootstrap/blob/master/assets/app.js] and it goes like this (unrelated parts removed):

bq. var app = 
bq. {
bq.     initMode: false,
bq.     debugMode: window.tinyHippos != undefined,
bq.     
bq.     init: function()
bq.     {
bq.         app.initMode = true;
bq.         
bq.         document.addEventListener('deviceready', app.deviceReadyHandler, false);
bq.         if(app.debugMode) app.deviceReadyHandler();
bq.     },
bq. 
bq.     deviceReadyHandler: function()
bq.     {
bq.         /**
bq.          * Actual handler, to handle app's exits (back button press).
bq.          * 
bq.          * With fix for nasty bug of Ripple having deadly old PhoneGap 2.0.0 behind!
bq.          */
bq.         if(!app.debugMode) document.addEventListener("backbutton", app.backButtonHandler, true);
bq.         
bq.         /**
bq.          * Battery-related and menu button press events handlers.
bq.          * 
bq.          * Used as real events in this application -- i.e. has some function.
bq.          */
bq.         document.addEventListener('menubutton', app.menuButtonHandler, false);
bq.         
bq.         document.addEventListener('batterylow', app.batteryLowHandler, false);
bq.         document.addEventListener('batterystatus', app.batteryStatusHandler, false);
bq.         document.addEventListener('batterycritical', app.batteryCriticalHandler, false);
bq.
bq.         /**
bq.          * Demo purpose only events handlers.
bq.          * 
bq.          * Meaningless in this application, just throwing info to console / event log.
bq.          */
bq.         document.addEventListener('pause', app.pauseHandler, false);
bq.         document.addEventListener('resume', app.resumeHandler, false);
bq.         document.addEventListener('online', app.onlineHandler, false);
bq.         document.addEventListener('offline', app.offlineHandler, false);
bq.         document.addEventListener('searchbutton', app.searchButtonHandler, false);
bq.         document.addEventListener('endcallbutton', app.endCallButtonHandler, false);
bq.         document.addEventListener('volumeupbutton', app.volumeUpButtonHandler, false);
bq.         document.addEventListener('startcallbutton', app.startCallButtonHandler, false);
bq.         document.addEventListener('volumedownbutton', app.volumeDownButtonHandler, false);
bq.     }
bq.     ...
bq. };
bq. 
bq. app.init();

This works just fine on mobile device, but fails completely on Ripple. Ripple adds comment to console, that it is firing particular event (when proper button in UI is used), but it actually fails to do it. If (like in this example) important app's init part is written in {{deviceready}} event, then entire application fails to run under Ripple, because Ripple itself fails to fire that event (either manually fired or upon page load / refresh). In such situation I have to help myself with:

bq. document.addEventListener('deviceready', app.deviceReadyHandler, false);
bq. if(app.debugMode) app.deviceReadyHandler();

Or else I won't be able to debug entire application in Ripple at all.
                
      was (Author: trejder):
    This is a [public repository|https://github.com/trejder/pg-demo-bootstrap], so you can browse / check / test code, whenever you have some spare time and willing to do so. Event binding is done in [/assets/app.js|https://github.com/trejder/pg-demo-bootstrap/blob/master/assets/app.js] and it goes like this (unrelated parts removed):

bq. var app = 
{
    initMode: false,
    debugMode: window.tinyHippos != undefined,
    
    init: function()
    {
        app.initMode = true;
        
        document.addEventListener('deviceready', app.deviceReadyHandler, false);
        if(app.debugMode) app.deviceReadyHandler();
    },

    deviceReadyHandler: function()
    {
        /**
         * Actual handler, to handle app's exits (back button press).
         * 
         * With fix for nasty bug of Ripple having deadly old PhoneGap 2.0.0 behind!
         */
        if(!app.debugMode) document.addEventListener("backbutton", app.backButtonHandler, true);
        
        /**
         * Battery-related and menu button press events handlers.
         * 
         * Used as real events in this application -- i.e. has some function.
         */
        document.addEventListener('menubutton', app.menuButtonHandler, false);
        
        document.addEventListener('batterylow', app.batteryLowHandler, false);
        document.addEventListener('batterystatus', app.batteryStatusHandler, false);
        document.addEventListener('batterycritical', app.batteryCriticalHandler, false);
        
        /**
         * Demo purpose only events handlers.
         * 
         * Meaningless in this application, just throwing info to console / event log.
         */
        document.addEventListener('pause', app.pauseHandler, false);
        document.addEventListener('resume', app.resumeHandler, false);
        document.addEventListener('online', app.onlineHandler, false);
        document.addEventListener('offline', app.offlineHandler, false);
        document.addEventListener('searchbutton', app.searchButtonHandler, false);
        document.addEventListener('endcallbutton', app.endCallButtonHandler, false);
        document.addEventListener('volumeupbutton', app.volumeUpButtonHandler, false);
        document.addEventListener('startcallbutton', app.startCallButtonHandler, false);
        document.addEventListener('volumedownbutton', app.volumeDownButtonHandler, false);
    }
    ...
};

app.init();

This works just fine on mobile device, but fails completely on Ripple. Ripple adds comment to console, that it is firing particular event (when proper button in UI is used), but it actually fails to do it. If (like in this example) important app's init part is written in {{deviceready}} event, then entire application fails to run under Ripple, because Ripple itself fails to fire that event (either manually fired or upon page load / refresh). In such situation I have to help myself with:

bq. document.addEventListener('deviceready', app.deviceReadyHandler, false);
if(app.debugMode) app.deviceReadyHandler();

Or else I won't be able to debug entire application in Ripple at all.
                  
> Ripple Emulator under Windows doesn't fire events
> -------------------------------------------------
>
>                 Key: RIPPLE-36
>                 URL: https://issues.apache.org/jira/browse/RIPPLE-36
>             Project: Apache Ripple
>          Issue Type: Bug
>         Environment: Windows 7 Home Edition, x86, Chrome browser (newest stable version), Ripple Emulator extension for Chrome (newest stable version taken from Chrome Store).
>            Reporter: Tomasz Trejderowski
>
> Under Windows, Ripple Emulator doesn't fire events. Neither automatically (deviceready) nor manually (using 'Event' pane). After selecting event and clicking button to fire it, Ripple writes down info to console, that it fires particular event, but nothing happens -- application does not react at all. When main init code is moved to 'deviceready' event, application fails to start under Ripple Emulator, as this event isn't fired.
> Everything works just fine (both application startup and events' binding) under real mobile device -- problem limited to Ripple Emulator only and therfore code seems to be fine.
> Details at Stack Overflow: http://stackoverflow.com/questions/17701869/ripple-emulator-doesnt-fire-events

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira