<commit_before>/* This is the javascript for the opt-in page. It sets/deletes
   a cookie which controls whether the flashproxy javascript
   code should run or disable itself. */

var COOKIE_NAME = "flashproxy";
/* max-age is not supported in IE. */
var COOKIE_LIFETIME = "Thu, 01 Jan 2020 00:00:00 GMT";

window.addEventListener("load", function () {

    /* This checks if cookies are enabled in the browser.
       document.cookie has special behavior, if cookies
       are disabled it will not retain any values stored in it. */
    function cookies_enabled() {
        /*Not supported in all browsers.*/
        if (navigator.cookieEnabled) {
            return true;
        } else if (navigator.cookieEnabled === undefined) {
            document.cookie = "test";
            if (document.cookie.indexOf("test") !== -1)
                return true;
        }
        return false;
    }

    /* Updates the text telling the user what his current setting is.*/
    function update_setting_text() {
        var setting = document.getElementById("setting");
        var prefix = "<p>Your current setting is: ";

        if (document.cookie.indexOf(COOKIE_NAME) !== -1) {
            setting.innerHTML = prefix + "use my browser as a proxy. " +
                                         "Click no below to change your setting.</p>";
        } else {
            setting.innerHTML = prefix + "do not use my browser as a proxy. " +
                                         "Click yes below to change your setting.</p>";
        }
    }

    function set_cookie() {
        document.cookie = COOKIE_NAME + "= ;path=/ ;expires=" + COOKIE_LIFETIME;
    }

    function del_cookie() {
        document.cookie = COOKIE_NAME + "= ;path=/ ;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }

    if (cookies_enabled()) {
        var buttons = document.getElementById("buttons");
        buttons.addEventListener("click", update_setting_text);
        document.getElementById("yes").addEventListener("click", set_cookie);
        document.getElementById("no").addEventListener("click", del_cookie);
        buttons.style.display = "block";<commit_msg>Check for cookie by iterating through cookie names.<commit_after>/* This is the javascript for the opt-in page. It sets/deletes
   a cookie which controls whether the flashproxy javascript
   code should run or disable itself. */

var COOKIE_NAME = "flashproxy";
/* max-age is not supported in IE. */
var COOKIE_LIFETIME = "Thu, 01 Jan 2020 00:00:00 GMT";

window.addEventListener("load", function () {

    /* This checks if cookies are enabled in the browser.
       document.cookie has special behavior, if cookies
       are disabled it will not retain any values stored in it. */
    function cookies_enabled() {
        /*Not supported in all browsers.*/
        if (navigator.cookieEnabled) {
            return true;
        } else if (navigator.cookieEnabled === undefined) {
            document.cookie = "test";
            if (cookie_present("test"))
                return true;
        }
        return false;
    }

    /* Checks for a cookie with name cookie */
    function cookie_present(cookie) {
        var cookies = document.cookie.split(";");

        for (i in cookies) {
            var name = cookies[i].split("=")[0];

            while (name[0] === " ")
                name = name.substr(1);
            if (cookie === name)
                return true;
        }
        return false;
    }

    /* Updates the text telling the user what his current setting is.*/
    function update_setting_text() {
        var setting = document.getElementById("setting");
        var prefix = "<p>Your current setting is: ";

        if (cookie_present(COOKIE_NAME)) {
            setting.innerHTML = prefix + "use my browser as a proxy. " +
                                         "Click no below to change your setting.</p>";
        } else {
            setting.innerHTML = prefix + "do not use my browser as a proxy. " +
                                         "Click yes below to change your setting.</p>";
        }
    }

    function set_cookie() {
        document.cookie = COOKIE_NAME + "= ;path=/ ;expires=" + COOKIE_LIFETIME;
    }

    function del_cookie() {
        document.cookie = COOKIE_NAME + "= ;path=/ ;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }

    if (cookies_enabled()) {
        var buttons = document.getElementById("buttons");
        buttons.addEventListener("click", update_setting_text);
        document.getElementById("yes").addEventListener("click", set_cookie);
        document.getElementById("no").addEventListener("click", del_cookie);
        buttons.style.display = "block";
{'fraction_non_alphanumeric': 0.11011332050459696, 'fraction_numerical': 0.011332050459696387, 'mean_word_length': 2.193174061433447, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7272672', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1190, 'n_words': 400}