<commit_before>/*
 * full-screen-helper.js 0.2.0
 *
 * Copyright (c) 2017 <NAME> (<EMAIL>)
 *
 * Released under the MIT license
 */

(function (d, w) {
    "use strict";

    var sy = 0,
        sx = 0,
        wso,
        html,
        body,
        target,
        timer = 0,
        currentElement,
        detectOnMS = false,
        clsRE = /(^|\s+)full-screen-helper($|\s+)/i,
        clsNSRE = /(^|\s+)fsh-infullscreen($|\s+)/i,
        eventsFS = [
            "webkitfullscreenchange",
            "mozfullscreenchange",
            "fullscreenchange",
            "MSFullscreenChange"
        ];

    function isHTMLElement(obj) {
        if (w.HTMLElement) {
            return obj instanceof w.HTMLElement;
        }

        return obj && obj.nodeType === 1 && obj.ownerDocument;
    }

    function msDetectEscTrigger(e) {
        if (currentElement && wso) {
            e = e || w.event;

            if (e && e.keyCode == 27) {
                wso.SendKeys("{F11}");
            }
        }
    }

    function msFS() {
        if (detectOnMS) {
            var iw = w.outerWidth || w.innerWidth || d.width;

            if (!html) {
                return false;
            }

            if (!clsNSRE.test(html.className)) {
                html.className += " fsh-infullscreen";
            }

            return (iw || html.clientWidth) == w.screen.width;
        }

        return !!(
            d.fullscreenElement ||
            d.mozFullScreenElement ||
            d.webkitFullscreenElement ||
            d.msFullscreenElement ||
            false
        );
    }

    function detectFSChange(e) {
        if (currentElement) {
            clearTimeout(timer);
            timer = setTimeout(toggleFSClass, detectOnMS ? 100 : 10);
        }
    }

    function getMainElements() {
        if (!html) {
            body = d.body;
            html = d.documentElement || (body && body.parentNode);
        }
    }

    function getScrollPosition() {
        getMainElements();

        if (target) {
            sx = target.scrollLeft;
            sy = target.scrollTop;
        } else {
            sx = w.pageXOffset || w.scrollX || html.scrollLeft || body.scrollLeft || 0;
            sy = w.pageYOffset || w.scrollY || html.scrollTop || body.scrollTop || 0;
        }
    }

    function toggleFSClass() {
        if (!currentElement) {
            return;
        }

        if (msFS()) {
            if (!clsRE.test(currentElement.className)) {
                currentElement.className += " full-screen-helper";
            }
        } else {
            currentElement.className = currentElement.className.replace(clsRE, " ");
            currentElement = null;

            getMainElements();

            if (html) {
                html.className = html.className.replace(clsNSRE, " ");

                if (target && (sy || sx)) {
                    target.scrollLeft = sx;
                    target.scrollTop = sy;
                } else {
                    w.scrollTo(sx, sy);
                }
            }
        }
    }

    function getWSO() {
        if (typeof wso === "undefined") {
            try {
                wso = new w.ActiveXObject("WScript.Shell");
                d.attachEvent("onkeydown", msDetectEscTrigger);

                detectOnMS = true;

                w.attachEvent("onresize", detectFSChange);
            } catch (ee) {
                wso = null;
            }
        }
    }

    function msToggleFS(element) {
        if (typeof w.ActiveXObject === "undefined") {
            wso = null;
        }

        getWSO();

        if (wso !== null) {
            currentElement = element;

            getScrollPosition();

            wso.SendKeys("{F11}");
        }
    }

    function isSupported() {
        return !!(
            detectOnMS ||
            d.exitFullscreen ||<commit_msg>Fixed bug in getWSO<commit_after>/*
 * full-screen-helper.js 0.2.0
 *
 * Copyright (c) 2017 <NAME> (<EMAIL>)
 *
 * Released under the MIT license
 */

(function (d, w) {
    "use strict";

    var sy = 0,
        sx = 0,
        wso,
        html,
        body,
        target,
        timer = 0,
        currentElement,
        detectOnMS = false,
        clsRE = /(^|\s+)full-screen-helper($|\s+)/i,
        clsNSRE = /(^|\s+)fsh-infullscreen($|\s+)/i,
        eventsFS = [
            "webkitfullscreenchange",
            "mozfullscreenchange",
            "fullscreenchange",
            "MSFullscreenChange"
        ];

    function isHTMLElement(obj) {
        if (w.HTMLElement) {
            return obj instanceof w.HTMLElement;
        }

        return obj && obj.nodeType === 1 && obj.ownerDocument;
    }

    function msDetectEscTrigger(e) {
        if (currentElement && wso) {
            e = e || w.event;

            if (e && e.keyCode == 27) {
                wso.SendKeys("{F11}");
            }
        }
    }

    function msFS() {
        if (detectOnMS) {
            var iw = w.outerWidth || w.innerWidth || d.width;

            if (!html) {
                return false;
            }

            if (!clsNSRE.test(html.className)) {
                html.className += " fsh-infullscreen";
            }

            return (iw || html.clientWidth) == w.screen.width;
        }

        return !!(
            d.fullscreenElement ||
            d.mozFullScreenElement ||
            d.webkitFullscreenElement ||
            d.msFullscreenElement ||
            false
        );
    }

    function detectFSChange(e) {
        if (currentElement) {
            clearTimeout(timer);
            timer = setTimeout(toggleFSClass, detectOnMS ? 100 : 10);
        }
    }

    function getMainElements() {
        if (!html) {
            body = d.body;
            html = d.documentElement || (body && body.parentNode);
        }
    }

    function getScrollPosition() {
        getMainElements();

        if (target) {
            sx = target.scrollLeft;
            sy = target.scrollTop;
        } else {
            sx = w.pageXOffset || w.scrollX || html.scrollLeft || body.scrollLeft || 0;
            sy = w.pageYOffset || w.scrollY || html.scrollTop || body.scrollTop || 0;
        }
    }

    function toggleFSClass() {
        if (!currentElement) {
            return;
        }

        if (msFS()) {
            if (!clsRE.test(currentElement.className)) {
                currentElement.className += " full-screen-helper";
            }
        } else {
            currentElement.className = currentElement.className.replace(clsRE, " ");
            currentElement = null;

            getMainElements();

            if (html) {
                html.className = html.className.replace(clsNSRE, " ");

                if (target && (sy || sx)) {
                    target.scrollLeft = sx;
                    target.scrollTop = sy;
                } else {
                    w.scrollTo(sx, sy);
                }
            }
        }
    }

    function getWSO() {
        if (typeof w.ActiveXObject === "undefined") {
            wso = null;
        }

        if (typeof wso === "undefined") {
            try {
                wso = new w.ActiveXObject("WScript.Shell");
                d.attachEvent("onkeydown", msDetectEscTrigger);

                detectOnMS = true;

                w.attachEvent("onresize", detectFSChange);
            } catch (ee) {
                wso = null;
            }
        }
    }

    function msToggleFS(element) {
        getWSO();

        if (wso !== null) {
            currentElement = element;

            getScrollPosition();

            wso.SendKeys("{F11}");
        }
    }

    function isSupported() {
        return !!(
            detectOnMS ||
            d.exitFullscreen ||
{'fraction_non_alphanumeric': 0.12480660134089737, 'fraction_numerical': 0.006188757091284167, 'mean_word_length': 1.3127608825283243, 'pattern_counts': {'":': 0, '<': 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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5134286', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2167, 'n_words': 421}