<commit_before>/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
/*global easyXDM: true, window, escape, unescape */

// From http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
function isHostMethod(object, property){
    var t = typeof object[property];
    return t == 'function' ||
    (!!(t == 'object' && object[property])) ||
    t == 'unknown';
}

function isHostObject(object, property){
    return !!(typeof(object[property]) == 'object' && object[property]);
}

function undef(v){
    return typeof v === "undefined";
}

/** 
 * @class easyXDM
 * A javascript library providing cross-browser, cross-domain messaging/RPC.<br/>
 * easyXDM.Debug and the easyXDM.configuration namespace is only available in the debug version.
 * @version %%version%%
 * @singleton
 */
easyXDM = {

    /**
     * The version of the library
     * @type {String}
     */
    version: "%%version%%",
    
    /**
     * Applies properties from the source object to the target object.<br/>
     * This is a destructive method.
     * @param {Object} target The target of the properties.
     * @param {Object} source The source of the properties.
     * @param {Boolean} onlyNew Set to True to only set non-existing properties.
     */
    apply: function(target, source, onlyNew){
        if (!source) {
            return;
        }
        for (var key in source) {
            if (source.hasOwnProperty(key) && (!onlyNew || !target[key])) {
                target[key] = source[key];
            }
        }
    },
    
    /**
     * Prepares an array of stack-elements suitable for the current configuration
     * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
     * @return {Array} An array of stack-elements with the TransportElement at index 0.
     */
    prepareTransportStack: function(config){
        var query = easyXDM.Url.Query(), u = easyXDM.Url, protocol = config.protocol, stackEls;
        config.isHost = config.isHost || undef(query.xdm_p);
        // #ifdef debug
        this._trace("preparing transport stack");
        // #endif
        if (!config.isHost) {
            // #ifdef debug
            this._trace("using parameters from query");
            // #endif
            config.channel = query.xdm_c;
            config.remote = decodeURIComponent(query.xdm_e);
            protocol = query.xdm_p;
        }
        else if (undef(protocol)) {
            config.remote = u.resolveUrl(config.remote);
            config.channel = config.channel || "default";
            if (isHostMethod(window, "postMessage")) {
                protocol = "1";
            }
            else if (config.remoteHelper) {
                config.remoteHelper = u.resolveUrl(config.remoteHelper);
                protocol = "2";
            }
            else {
                protocol = "0";
            }
            // #ifdef debug
            this._trace("selecting protocol: " + protocol);
            // #endif
        }
        // #ifdef debug
        else {
            this._trace("using protocol: " + protocol);
        }
        // #endif
        
        switch (protocol) {
            case "0":// 0 = HashTransport
                this.apply(config, {
                    interval: 300,
                    delay: 2000,
                    useResize: true,
                    useParent: false,
                    usePolling: false
                }, true);
                if (config.isHost) {
                    if (!config.local) {
                        // #ifdef debug
                        this._trace("looking for image to use as local");
                        // #endif
                        // If no local is set then we need to find an image hosted on the current domain
                        var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), i = images.length, image;
                        while (i--) {<commit_msg>Minor refactoring<commit_after>/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
/*global easyXDM: true, window, escape, unescape */

// From http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
function isHostMethod(object, property){
    var t = typeof object[property];
    return t == 'function' ||
    (!!(t == 'object' && object[property])) ||
    t == 'unknown';
}

function isHostObject(object, property){
    return !!(typeof(object[property]) == 'object' && object[property]);
}

function undef(v){
    return typeof v === "undefined";
}

/** 
 * @class easyXDM
 * A javascript library providing cross-browser, cross-domain messaging/RPC.<br/>
 * easyXDM.Debug and the easyXDM.configuration namespace is only available in the debug version.
 * @version %%version%%
 * @singleton
 */
easyXDM = {

    /**
     * The version of the library
     * @type {String}
     */
    version: "%%version%%",
    
    /**
     * Applies properties from the source object to the target object.<br/>
     * This is a destructive method.
     * @param {Object} target The target of the properties.
     * @param {Object} source The source of the properties.
     * @param {Boolean} onlyNew Set to True to only set non-existing properties.
     */
    apply: function(target, source, onlyNew){
        if (!source) {
            return;
        }
        for (var key in source) {
            if (source.hasOwnProperty(key) && (!onlyNew || !target[key])) {
                target[key] = source[key];
            }
        }
    },
    
    /**
     * Prepares an array of stack-elements suitable for the current configuration
     * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
     * @return {Array} An array of stack-elements with the TransportElement at index 0.
     */
    prepareTransportStack: function(config){
        var query = easyXDM.Url.Query(), u = easyXDM.Url, protocol = config.protocol, stackEls;
        config.isHost = config.isHost || undef(query.xdm_p);
        // #ifdef debug
        this._trace("preparing transport stack");
        // #endif
        if (!config.isHost) {
            // #ifdef debug
            this._trace("using parameters from query");
            // #endif
            config.channel = query.xdm_c;
            config.remote = decodeURIComponent(query.xdm_e);
            protocol = query.xdm_p;
        }
        else {
            config.remote = u.resolveUrl(config.remote);
            config.channel = config.channel || "default";
            if (undef(protocol)) {
                if (isHostMethod(window, "postMessage")) {
                    protocol = "1";
                }
                else if (config.remoteHelper) {
                    config.remoteHelper = u.resolveUrl(config.remoteHelper);
                    protocol = "2";
                }
                else {
                    protocol = "0";
                }
                // #ifdef debug
                this._trace("selecting protocol: " + protocol);
                // #endif
            }
            // #ifdef debug
            else {
                this._trace("using protocol: " + protocol);
            }
            // #endif
        }
        
        switch (protocol) {
            case "0":// 0 = HashTransport
                this.apply(config, {
                    interval: 300,
                    delay: 2000,
                    useResize: true,
                    useParent: false,
                    usePolling: false
                }, true);
                if (config.isHost) {
                    if (!config.local) {
                        // #ifdef debug
                        this._trace("looking for image to use as local");
                        // #endif
                        // If no local is set then we need to find an image hosted on the current domain
                        var domain = location.protocol + "//" + location.host, images = document.body.getElementsByTagName("img"), i = images.length, image;
                        while (i--) {
{'fraction_non_alphanumeric': 0.11745953898970084, 'fraction_numerical': 0.0031878371750858263, 'mean_word_length': 1.684990125082291, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4175866', 'n_tokens_mistral': 2189, 'n_tokens_neox': 2100, 'n_words': 611}