<commit_before>/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

function removeVisualBan(map)
{
    mapElement = document.getElementById(map);
    mapElement.className = "map";
    mapElement.style.backgroundImage = "url('img/"+map+".jpg')";
    mapElement.setAttribute('onclick', 'ban('+map+')');
}

function applyVisualBan(map)
{
    mapElement = document.getElementById(map);
    mapElement.className += " banned";
    mapElement.style.backgroundImage = "url('img/"+map+"_ban.jpg')";
    mapElement.setAttribute('onclick', '');
}

function ban(map)
{
    xhttp = new XMLHttpRequest();
//    xhttp.onreadystatechange = function(){
//        if(xhttp.readyState === 4 && xhttp.status === 200)
//            if(xhttp.response === "true")
//                removeVisualBan(map);
//    };
    token = encodeURIComponent("<KEY>);
    xhttp.open("GET", "banRequest.php?token="+token+"&map="+map, true);
    xhttp.send();
}

function listener()
{
    listen();
}

function listen()
{
    xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function hear(){
        if(xhttp.readyState === 4 && xhttp.status === 200) {
            if(xhttp.response !== 'false')
            {
                maps = JSON.parse(xhttp.response);
                for(i = 0; i < maps.length; i++) {
                    applyVisualBan(maps[i]);
                }
                listen(); // Should be delayed by about 1000ms by server
            }
        }
    };
    // txt cache
    token = encodeURIComponent("<KEY>);
    xhttp.open("GET", "listener.php?token="+token+"&step=0", true);
    xhttp.send();
}<commit_msg>Fixed xhttp globals into local variables.<commit_after>/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* globals */
var step = 0;
var token = null;

function init()
{
    token = encodeURIComponent("<KEY>);
    listen();
}

function removeVisualBan(map)
{
    var mapElement = document.getElementById(map);
    mapElement.className = "map";
    mapElement.style.backgroundImage = "url('img/"+map+".jpg')";
    mapElement.setAttribute('onclick', 'ban('+map+')');
}

function applyVisualBan(map)
{
    var mapElement = document.getElementById(map);
    mapElement.className += " banned";
    mapElement.style.backgroundImage = "url('img/"+map+"_ban.jpg')";
    mapElement.setAttribute('onclick', '');
}

function ban(map)
{
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function confirmBan(){
        if(xhttp.readyState === 4 && xhttp.status === 200)
        {
            if(xhttp.response === "true")
            {
                applyVisualBan(map);
                step += 1;
            }
        }
    };
    xhttp.open("GET", "banRequest.php?token="+token+"&map="+map+"&step="+step, true);
    xhttp.send();
}

function listen()
{
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function hear(){
        if(xhttp.readyState === 4 && xhttp.status === 200) {
            if(xhttp.response !== 'false')
            {
                maps = JSON.parse(xhttp.response);
                // Error code for no-updates
                if(maps[0] === -1) {
                    listen();
                }
                else {
                    step = maps[0];
                    for(i = 1; i < maps.length; i++)
                        applyVisualBan(maps[i]);
                    listen(); // Should be delayed by about 1000ms by server
                }
            }
        }
    };
    xhttp.open("GET", "listener.php?token="+token+"&step="+step, true);
    xhttp.send();
}
{'fraction_non_alphanumeric': 0.1555438780872307, 'fraction_numerical': 0.008407777193904361, 'mean_word_length': 2.3104347826086955, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '6847729', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1115, 'n_words': 241}