Sha256: 1c42d7d59bd030557a06901244390a86725db79b3867870d9e732522ba38a7aa

Contents?: true

Size: 1.62 KB

Versions: 11

Compression:

Stored size: 1.62 KB

Contents

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

11 entries across 11 versions & 1 rubygems

Version Path
sports_db-0.2.12 app/assets/javascripts/clients/android/client.js
sports_db-0.2.11 app/assets/javascripts/clients/android/client.js
sports_db-0.2.10 app/assets/javascripts/clients/android/client.js
sports_db-0.2.9 app/assets/javascripts/clients/android/client.js
sports_db-0.2.8 app/assets/javascripts/clients/android/client.js
sports_db-0.2.7 app/assets/javascripts/clients/android/client.js
sports_db-0.2.6 app/assets/javascripts/clients/android/client.js
sports_db-0.2.5 app/assets/javascripts/clients/android/client.js
sports_db-0.2.4 app/assets/javascripts/clients/android/client.js
sports_db-0.2.3 app/assets/javascripts/clients/android/client.js
sports_db-0.2.2 app/assets/javascripts/clients/android/client.js