You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ripple.apache.org by "Arzhan Kinzhalin (JIRA)" <ji...@apache.org> on 2015/05/15 06:26:59 UTC

[jira] [Created] (RIPPLE-85) notifications: button index is incremented twice

Arzhan Kinzhalin created RIPPLE-85:
--------------------------------------

             Summary: notifications: button index is incremented twice
                 Key: RIPPLE-85
                 URL: https://issues.apache.org/jira/browse/RIPPLE-85
             Project: Apache Ripple
          Issue Type: Bug
            Reporter: Arzhan Kinzhalin


[notifications.js:92|https://github.com/apache/incubator-ripple/blob/master/lib/client/notifications.js#L92]
{code:title=lib/client/notifications.js}
    btnArray.forEach(function(btnLabel,index) {
        var button = {};
        button["text"] = btnLabel;
        button["click"] = function () {
            if(resultCallback !== typeof "undefined")
                resultCallback(index+1);
            jQuery( this ).dialog( "close" );
        };
        buttons.push(button);
    });
{code}
[lib/client/platform/cordova/2.0.0/bridge/notification.js:43|https://github.com/apache/incubator-ripple/blob/master/lib/client/platform/cordova/2.0.0/bridge/notification.js#L43]
{code:title=lib/client/platform/cordova/2.0.0/bridge/notification.js}
        var callback = resultCallback && function(r) {
            resultCallback(++r);
        };

        notifications.confirmNotification(message, callback, title, buttonLabels);
    },
{code}
The latter calls the former and in both cases the index is adjusted to be 1-based instead of 0-based.

Also, the check {{if(resultCallback !== typeof "undefined")}} does not make any sense: it ensures {{resultCallback}} is not a string {{"string"}}. Should be just {{typeof resultCalback !== "undefined"}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)