Sha256: 2e342315e6486e23992e039c6f3ad38548ca008ad40468b023cd5e925ad449be

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 KB

Contents

/*global Application Class ClientBridge */

if (window.location.search.indexOf("client=android") !== -1) {
    console.log('=> Using AndroidClient.js');

    // This should be in a mock file...
    if (!window.ClientBridge) {
        window.ClientBridge = {
            notify: function(obj) {
                window.console.debug(obj);
            }
        };
    }

    var Client = Class.extend({
        initialize: function() {

        },
        /**
         * Called by the web application to send values to the client.
         *
         * @param {Object} obj - a set of key/value parameters to send to client
         */
        notify: function(obj) {
            var arr = [];
            for (var prop in obj) {
                arr.push(prop +'='+ encodeURIComponent(obj[prop]));
            }
            ClientBridge.notify( arr.join('&') );
        },

        /**
         * Called by the client to set a value or trigger an action in the web page.
         *
         * @param {String} name
         * @param {Object} value (optional)
         */
        callback: function(name, value) {
            Application.onClientCallback(name, value);
        }
    });

    // Singleton
    Client = new Client();

    // Fix console as it doesn't appear to exist in Android WebView, and we frequently leave these statements in our code
    if (!window.console) {
        window.console = {};
        var f = function() {};
        ["debug", "info", "warn", "error", "assert", "dir", "dirxml", "trace", "group", "groupCollapsed",
        "groupEnd", "time", "timeEnd", "profile", "profileEnd", "count"].forEach(function(func) {
            window.console[func] = f;
        });
    }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sports_db-0.2.19 app/assets/javascripts/clients/android/client.js
sports_db-0.2.18 app/assets/javascripts/clients/android/client.js
sports_db-0.2.17 app/assets/javascripts/clients/android/client.js
sports_db-0.2.16 app/assets/javascripts/clients/android/client.js
sports_db-0.2.15 app/assets/javascripts/clients/android/client.js
sports_db-0.2.14 app/assets/javascripts/clients/android/client.js
sports_db-0.2.13 app/assets/javascripts/clients/android/client.js