<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.<commit_msg>Added the AJAX features to the easyXDM object. This is to support proxying the RPC requests back to the server.<commit_after>/*jslint evil: true, browser: true, immed: true, passfail: true, undef: true, newcap: true*/
/*global easyXDM: true, window, escape, unescape, ActiveXObject */

// 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];
            }
        }
    },
    
    /**
     * Creates a cross-browser XMLHttpRequest object
     * @return {XMLHttpRequest} A XMLHttpRequest object.
     */
    createXmlHttpRequest: function(){
        if (undef(XMLHttpRequest)) {
            var item, list = ["Microsoft.XMLHTTP", "Msxml2.XMLHTTP", "Msxml3.XMLHTTP"], i = list.length;
            while (i--) {
                try {
                    item = list[i];
                    var obj = new ActiveXObject(item);
                    // we are still here!
                    obj = list = null;
                    break;
                } 
                catch (e) {
                }
            }
            this.createXmlHttpRequest = function(){
                return new ActiveXObject(item);
            };
        }
        else {
            this.createXmlHttpRequest = function(){
                return new XMLHttpRequest();
            };
        }
        return this.createXmlHttpRequest();
    },
    
    /**
     * Runs an asynchronous request using XMLHttpRequest
     * @param {String} method POST, HEAD or GET
     * @param {String} url The url to request
     * @param {Object} data Any data that should be sent.
     * @param {Function} success The callback function for successfull requests
     * @param {Function} error The callback function for errors
     */
    ajax: function(method, url, data, success, error){
        if (!error) {
            error = function(){
            };
        }
        var req = this.createXmlHttpRequest(), q = [];
        req.open(method, url, true);
        req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        req.setRequestHeader("X-Requested-With", "XMLHttpRequest");
        req.onreadystatechange = function(){
            if (req.readyState == 4) {
                if (req.status >= 200 && req.status < 300) {
                    var contentType = req.getResponseHeader("Content-Type");
                    if (contentType.substring(0, 16) === "application/json") {
                        success(JSON.parse(req.responseText));
                    }
                    else {
                        error("Invalid content type: " + contentType);
                    }
                }
                else {
                    error("An error occured. Status code: " + req.status);
                }
                req.onreadystatechange = null;
                delete req.onreadystatechange;
            }
        };
        if (data) {
            for (var key in data) {
                if (data.hasOwnProperty(key)) {
                    q.push(key + "=" + encodeURIComponent(data[key]));
                }
            }
        }
        req.send(q.join("&"));
    },
    
    /**
     * Prepares an array of stack-elements suitable for the current configuration
     * @param {Object} config The Transports configuration. See easyXDM.Socket for more.
{'fraction_non_alphanumeric': 0.12261196367052929, 'fraction_numerical': 0.0018791105543376136, 'mean_word_length': 2.0098963242224315, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 2}, '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': '2431822', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1707, 'n_words': 512}