<commit_before>/* QLib the modern compressed Javascript framework for Web developers
 Copyright CodeCubed 2015. Created by Faxity, maintained by CodeCubed*/
(function () {
    //"use strict";
    // Support check
    if (!document.querySelector || !window.addEventListener)
        throw "This browser does not support QLib. Please use Chrome or Firefox.";

    //<editor-fold desc="QLib Static Properties">
    /**
     * Initializes a new Q object
     * @param selector  {string|Element|NodeList} CSS selector as string or HTML element(s)
     * @returns {Q} Initialized Q object
     * @constructor
     */
    var Q = function (selector) {
        return new QLib(selector);
    };

    /**
     * Get this QLibs version
     * @type {string}
     */
    Q.version = "0.3.2";
    /**
     * Sends an AJAX request to the requested URL
     * @param obj {string|Object|FormData} Settings object to apply
     */
    Q.ajax = function (obj) {
        var settings = {
            url: "",
            method: "POST",
            async: true,
            data: null,
            user: "",
            password: "",
            success: null,
            error: null
        }, sendData = false, request = new XMLHttpRequest();

        // Override default settings
        for (var key in obj) {
            if (obj.hasOwnProperty(key) && settings.hasOwnProperty(key))
                settings[key] = obj[key];
        }

        // Parse data
        if (settings["data"] !== undefined && settings["data"] != null) {
            if (typeof settings["data"] != "string" && !(settings["data"] instanceof FormData)) {
                var list = [];
                for (var prop in settings["data"]) {
                    if (settings["data"].hasOwnProperty(prop))
                        list.push(encodeURIComponent(prop) + "=" + encodeURIComponent(settings["data"][prop]));
                }
                settings["data"] = list.join("&");
            }
            sendData = true;
        }

        // If GET append query to url
        if (sendData == true && settings["method"].toUpperCase() != "POST")
            settings["url"] += "?" + settings["data"];

        // Open the AJAX request
        request.open(settings["method"].toUpperCase(), settings["url"], settings["async"], settings["user"], settings["password"]);
        request.onreadystatechange = function () {
            if (request.readyState != 4) return;

            if (request.status == 200 && typeof settings["success"] == "function")
                settings["success"](request.responseText);
            else if (typeof settings["error"] == "function")
                settings["error"](request.status, request.statusText);
        };

        // If POST then url encode the data then send
        if (sendData == true && settings["method"].toUpperCase() == "POST") {
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.send(settings["data"]);
        }
        else
            request.send();
    };
    /**
     * Gets a parsed JSON from an url
     * @param url {string} URL to get json from.
     * @param callback {function} Callback to run when JSON has been loaded and parsed.
     * @param data {string|Object|FormData} Data to send to server.
     */
    Q.getJSON = function (url, callback, data) {
        if (url === undefined && callback === undefined)
            throw "Parameter Invalid in 'getJSON'. Parameters 'url' and 'data' cant be undefined.";
        Q.ajax({
            url: url,
            method: "GET",
            data: data,
            success: function (text) {
                callback(JSON.parse(text));
            },
            error: function (code, text) {
                throw "Error in 'getJSON'. Error: " + code + " " + text;
            }
        });
    };
    /**
     * Loads file from URL
     * @param url {string} URL location to file
     * @param callback {function} Callback to run when file has loaded.
     */
    Q.getFile = function (url, callback) {
        if (url === undefined && callback === undefined)
            throw "Parameter Invalid in 'getFile'. Parameter 'url' and 'callback' cant be undefined.";
        Q.ajax({
            url: url,
            method: "GET",
            success: function (text) {
                callback(text);
            },
            error: function (code, text) {
                throw "Error in 'getFile'. Error: " + code + " " + text;
            }
        });
    };
    /**
     * Checks if the specified object is a Number
     * @param n {*} Object to check
     * @returns {boolean} True or False
     */
    Q.isNumber = function (n) {
        return !isNaN(parseFloat(n)) && isFinite(n);
    };
    /**
     * Checks if the specified object is an HTMLNode
     * @param node {*} Object to check
     * @returns {boolean} True or False
     */
    Q.isNode = function (node) {
        return node && node.nodeType ? true : false;
    };
    Q.isBoolean = function (b) {
        return b === true || b === false;
    };
    /**
     * Used to extend multiple functions to QLib
     * @param obj {Object} An object with extensions in a key value pair.
     */
    Q.extend = function (obj) {
        for (var key in obj) {
            if (obj[key])
                Q.ex[key] = obj[key];
        }
    };
    /**
     * Event that executes after the page has been loaded and parsed
     * @param callback {function} Callback to call
     */
    Q.load = function (callback) {
        window.addEventListener("load", callback, false);
    };
    /**
     * Event that executes after the page has been loaded
     * @param callback {function} Callback to call
     */
    Q.ready = function (callback) {
        document.addEventListener("DOMContentLoaded", callback, false);
    };

    /**
     * QLib internal object
     * @param selector {string|Element|NodeList} CSS selector as string or HTML element(s)
     * @returns {QLib}
     */
    var QLib = function (selector) {
        var n;
        // Check if selector is undefined, null or ""
        if (!selector)
            this.length = 0;
        // Check if selector is a string
        else if (typeof selector === "string") {
            // Create element
            if (selector.charAt(0) === "<") {
                var elem = document.createElement("div");
                elem.innerHTML = selector;
                this[0] = elem.firstChild;
                this.length = 1;
            }
            else {
                selector = document.querySelectorAll(selector);
                n = this.length = selector.length;
                while (n--)
                    this[n] = selector[n];
            }
        }
        // Check if selector is a node
        else if (selector.nodeType || selector.window) {
            this[0] = selector;
            this.length = 1;
        }
        // Check if selector is an array
        else if (selector.length && Q.isNumber(selector.length)) {
            n = this.length = selector.length;
            while (n--)
                this[n] = selector[n];
        }
        // Selector is unknown
        else
            throw "Unknown parameter";
        // Return a new QLib object
        return this;<commit_msg>Bugfix in constructor<commit_after>/* QLib the modern compressed Javascript framework for Web developers
 Copyright CodeCubed 2015. Created by Faxity, maintained by CodeCubed*/
(function () {
    //"use strict";
    // Support check
    if (!document.querySelector || !window.addEventListener)
        throw "This browser does not support QLib. Please use Chrome or Firefox.";

    //<editor-fold desc="QLib Static Properties">
    /**
     * Initializes a new Q object
     * @param selector  {string|Element|NodeList} CSS selector as string or HTML element(s)
     * @returns {Q} Initialized Q object
     * @constructor
     */
    var Q = function (selector) {
        return new QLib(selector);
    };

    /**
     * Get this QLibs version
     * @type {string}
     */
    Q.version = "0.3.2";
    /**
     * Sends an AJAX request to the requested URL
     * @param obj {string|Object|FormData} Settings object to apply
     */
    Q.ajax = function (obj) {
        var settings = {
            url: "",
            method: "POST",
            async: true,
            data: null,
            user: "",
            password: "",
            success: null,
            error: null
        }, sendData = false, request = new XMLHttpRequest();

        // Override default settings
        for (var key in obj) {
            if (obj.hasOwnProperty(key) && settings.hasOwnProperty(key))
                settings[key] = obj[key];
        }

        // Parse data
        if (settings["data"] !== undefined && settings["data"] != null) {
            if (typeof settings["data"] != "string" && !(settings["data"] instanceof FormData)) {
                var list = [];
                for (var prop in settings["data"]) {
                    if (settings["data"].hasOwnProperty(prop))
                        list.push(encodeURIComponent(prop) + "=" + encodeURIComponent(settings["data"][prop]));
                }
                settings["data"] = list.join("&");
            }
            sendData = true;
        }

        // If GET append query to url
        if (sendData == true && settings["method"].toUpperCase() != "POST")
            settings["url"] += "?" + settings["data"];

        // Open the AJAX request
        request.open(settings["method"].toUpperCase(), settings["url"], settings["async"], settings["user"], settings["password"]);
        request.onreadystatechange = function () {
            if (request.readyState != 4) return;

            if (request.status == 200 && typeof settings["success"] == "function")
                settings["success"](request.responseText);
            else if (typeof settings["error"] == "function")
                settings["error"](request.status, request.statusText);
        };

        // If POST then url encode the data then send
        if (sendData == true && settings["method"].toUpperCase() == "POST") {
            request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            request.send(settings["data"]);
        }
        else
            request.send();
    };
    /**
     * Gets a parsed JSON from an url
     * @param url {string} URL to get json from.
     * @param callback {function} Callback to run when JSON has been loaded and parsed.
     * @param data {string|Object|FormData} Data to send to server.
     */
    Q.getJSON = function (url, callback, data) {
        if (url === undefined && callback === undefined)
            throw "Parameter Invalid in 'getJSON'. Parameters 'url' and 'data' cant be undefined.";
        Q.ajax({
            url: url,
            method: "GET",
            data: data,
            success: function (text) {
                callback(JSON.parse(text));
            },
            error: function (code, text) {
                throw "Error in 'getJSON'. Error: " + code + " " + text;
            }
        });
    };
    /**
     * Loads file from URL
     * @param url {string} URL location to file
     * @param callback {function} Callback to run when file has loaded.
     */
    Q.getFile = function (url, callback) {
        if (url === undefined && callback === undefined)
            throw "Parameter Invalid in 'getFile'. Parameter 'url' and 'callback' cant be undefined.";
        Q.ajax({
            url: url,
            method: "GET",
            success: function (text) {
                callback(text);
            },
            error: function (code, text) {
                throw "Error in 'getFile'. Error: " + code + " " + text;
            }
        });
    };
    /**
     * Checks if the specified object is a Number
     * @param n {*} Object to check
     * @returns {boolean} True or False
     */
    Q.isNumber = function (n) {
        return !isNaN(parseFloat(n)) && isFinite(n);
    };
    /**
     * Checks if the specified object is an HTMLNode
     * @param node {*} Object to check
     * @returns {boolean} True or False
     */
    Q.isNode = function (node) {
        return node && node.nodeType ? true : false;
    };
    Q.isBoolean = function (b) {
        return b === true || b === false;
    };
    /**
     * Used to extend multiple functions to QLib
     * @param obj {Object} An object with extensions in a key value pair.
     */
    Q.extend = function (obj) {
        for (var key in obj) {
            if (obj[key])
                Q.ex[key] = obj[key];
        }
    };
    /**
     * Event that executes after the page has been loaded and parsed
     * @param callback {function} Callback to call
     */
    Q.load = function (callback) {
        window.addEventListener("load", callback, false);
    };
    /**
     * Event that executes after the page has been loaded
     * @param callback {function} Callback to call
     */
    Q.ready = function (callback) {
        document.addEventListener("DOMContentLoaded", callback, false);
    };

    /**
     * QLib internal object
     * @param selector {string|Element|NodeList} CSS selector as string or HTML element(s)
     * @returns {QLib}
     */
    var QLib = function (selector) {
        var n;
        // Check if selector is undefined, null or ""
        if (!selector)
            this.length = 0;
        // Check if selector is a string
        else if (typeof selector === "string") {
            // Create element
            if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">") {
                var elem = document.createElement("div");
                elem.innerHTML = selector;
                this[0] = elem.removeChild(elem.firstChild);
                this.length = 1;
            }
            else {
                selector = document.querySelectorAll(selector);
                n = this.length = selector.length;
                while (n--)
                    this[n] = selector[n];
            }
        }
        // Check if selector is a node
        else if (selector.nodeType || selector.window) {
            this[0] = selector;
            this.length = 1;
        }
        // Check if selector is an array
        else if (selector.length && Q.isNumber(selector.length)) {
            n = this.length = selector.length;
            while (n--)
                this[n] = selector[n];
        }
        // Selector is unknown
        else
            throw "Unknown parameter";
        // Return a new QLib object
        return this;
{'fraction_non_alphanumeric': 0.12669126691266913, 'fraction_numerical': 0.0023916905835725025, 'mean_word_length': 1.7524920067707355, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6831926', 'n_tokens_mistral': 3898, 'n_tokens_neox': 3812, 'n_words': 1215}