<commit_before>
function Utils() {

    var that = this;
    this.apiQueue = [];

    
    
    /* adapted from djangoproject.com */
    /* Static method */
    Utils.prototype.getCookie = function(name){
        var cookieValue;
        if(document.cookie){
            var cookies = document.cookie.split(';');
            for(var i=0;i<cookies.length;i++){
                var cookie = $.trim(cookies[i]);
                if(cookie.substring(0, name.length+1) == name + '='){
                    return decodeURIComponent(cookie.substring(name.length+1));
                }   
            }   
        }   
    } 

    /* Static method to make single API requests */
    Utils.prototype.makeApiRequest = function(request) {

        console.log("doing request",request);
        $.ajax({
            url: request.url,
            type: request.type,
            data: request.data,
            headers: {'X-CSRFToken':Utils.getCookie('csrftoken')},
            error: (function(error){
                return function(e){
                    //$('.saving-info').text('Saving failed! Best option for now is to do a refresh.');
                }
            })(request.error),
            success: (function(success){
                return function(data){
                    success(data);
                    console.log("request complete!",request);
                }
            })(request.success)
        });
    }

    /* Object method to add a request to the API queue */
    Utils.prototype.makeApiQueueRequest = function(request){

        this.apiQueue.push(request);

        /* adapted from djangoproject.com */
        function getCookie(name){
            var cookieValue;
            if(document.cookie){
                var cookies = document.cookie.split(';');
                for(var i=0;i<cookies.length;i++){
                    var cookie = $.trim(cookies[i]);
                    if(cookie.substring(0, name.length+1) == name + '='){
                        return decodeURIComponent(cookie.substring(name.length+1));
                    }   
                }   
            }   
        }   

        if(this.apiQueue.length == 1){ 
            (function doApiRequest(){
                if(that.apiQueue.length == 0){ 
                    //$('.saving-info').removeClass('saving');
                    return;
                }   
                    //$('.saving-info').addClass('saving');
                var request = that.apiQueue.pop(0); //popleft? legit!
                console.log("doing request",request);
                $.ajax({
                    url: request.url,
                    type: request.type,
                    data: request.data,
                    headers: {'X-CSRFToken':getCookie('csrftoken')},
                    error: (function(error){
                        return function(e){
                            //$('.saving-info').text('Saving failed! Best option for now is to do a refresh.');
                        }
                    })(request.error),
                    success: (function(success){
                        return function(data){
                            success(data);
                            console.log("request complete!",request);
                            setTimeout(doApiRequest,0);
                        }
                    })(request.success)
                });
            })();
        }
    };
}
<commit_msg>Changed getcookie to static method, commented out some debugging<commit_after>
function Utils() {

    var that = this;
    this.apiQueue = [];

    
    
    /* adapted from djangoproject.com */
    /* Static method */
    function getCookie(name) {
        var cookieValue;
        if(document.cookie){
            var cookies = document.cookie.split(';');
            for(var i=0;i<cookies.length;i++){
                var cookie = $.trim(cookies[i]);
                if(cookie.substring(0, name.length+1) == name + '='){
                    return decodeURIComponent(cookie.substring(name.length+1));
                }   
            }   
        }   
    } 

    /* Static method to make single API requests */
    Utils.prototype.makeApiRequest = function(request) {

        //console.log("doing request",request);
        $.ajax({
            url: request.url,
            type: request.type,
            data: request.data,
            headers: {'X-CSRFToken':getCookie('csrftoken')},
            error: (function(error){
                return function(e){
                    //$('.saving-info').text('Saving failed! Best option for now is to do a refresh.');
                }
            })(request.error),
            success: (function(success){
                return function(data){
                    success(data);
                    //console.log("request complete!",request);
                }
            })(request.success)
        });
    }

    /* Object method to add a request to the API queue */
    Utils.prototype.makeApiQueueRequest = function(request){

        this.apiQueue.push(request);

        /* adapted from djangoproject.com */
        function getCookie(name){
            var cookieValue;
            if(document.cookie){
                var cookies = document.cookie.split(';');
                for(var i=0;i<cookies.length;i++){
                    var cookie = $.trim(cookies[i]);
                    if(cookie.substring(0, name.length+1) == name + '='){
                        return decodeURIComponent(cookie.substring(name.length+1));
                    }   
                }   
            }   
        }   

        if(this.apiQueue.length == 1){ 
            (function doApiRequest(){
                if(that.apiQueue.length == 0){ 
                    //$('.saving-info').removeClass('saving');
                    return;
                }   
                    //$('.saving-info').addClass('saving');
                var request = that.apiQueue.pop(0); //popleft? legit!
                console.log("doing request",request);
                $.ajax({
                    url: request.url,
                    type: request.type,
                    data: request.data,
                    headers: {'X-CSRFToken':getCookie('csrftoken')},
                    error: (function(error){
                        return function(e){
                            //$('.saving-info').text('Saving failed! Best option for now is to do a refresh.');
                        }
                    })(request.error),
                    success: (function(success){
                        return function(data){
                            success(data);
                            console.log("request complete!",request);
                            setTimeout(doApiRequest,0);
                        }
                    })(request.success)
                });
            })();
        }
    };
}

{'fraction_non_alphanumeric': 0.12415062287655719, 'fraction_numerical': 0.0033975084937712344, 'mean_word_length': 1.1711739397664414, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '7347608', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1665, 'n_words': 324}