<commit_before>var cmsCommentFetchRaw;
var cmsCommentFetchData;

function cmsCommentFetchGet() {
    if (cmsCommentFetchData.length != 0) {
        $.ajax({
            url: $("#comments").data("url")+"/"+cmsCommentFetchData[0],
            type: "GET",
            dataType: "json",
            timeout: 5000,
            success: function(data, status, xhr) {
                if (!xhr.responseJSON) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchGet();
                    return;
                }
                if (!xhr.responseJSON.contents || !xhr.responseJSON.comment_id) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchGet();
                    return;
                }
                if ($("#comments > div").length == 0) {
                    $("#nocomments").fadeOut(300, function() {
                        $(this).remove();
                        $(xhr.responseJSON.contents).prependTo('#comments').hide().fadeIn(300, function() {
                            cmsTimeAgo("#timeago_comment_"+xhr.responseJSON.comment_id);
                            cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_1");
                            cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_2");
                            cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_1");
                            cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_2");
                            cmsCommentFetchData.splice(0, 1);
                            cmsCommentFetchGet();
                        });
                    });
                } else {
                    $(xhr.responseJSON.contents).prependTo('#comments').hide().slideDown(300, function() {
                        cmsTimeAgo("#timeago_comment_"+xhr.responseJSON.comment_id);
                        cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_1");
                        cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_2");
                        cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_1");
                        cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_2");
                        cmsCommentFetchData.splice(0, 1);
                        cmsCommentFetchGet();
                    });
                }
            },
            error: function(xhr, status, error) {
                cmsCommentFetchData.splice(0, 1);
                cmsCommentFetchGet();
            }
        });
        return;
    }

    if ($("#comments > div").length == 0 && $("#comments > p").length == 0) {
        $("<p id=\"nocomments\">There are currently no comments.</p>").prependTo("#comments").hide().fadeIn(300, function(){
            cmsCommentLock = false;
            cmsCommentFetch();
        });
    } else {
        cmsCommentLock = false;
        cmsCommentFetch();
    }
}

function cmsCommentFetchNew() {
    var length = cmsCommentFetchRaw.length;
    cmsCommentFetchData = new Array();

    for (var i = 0; i < length; i++) {
        var ok = false;
        $("#comments > div").each(function() {
            if ($(this).data('pk') == cmsCommentFetchRaw[i].comment_id) {
                ok = true;
            }
        });

        if (ok == false) {
            cmsCommentFetchData.push(cmsCommentFetchRaw[i].comment_id);
        }
    }

    cmsCommentFetchGet();
}

function cmsCommentFetchReplace() {
    if (cmsCommentFetchData.length != 0) {
        $.ajax({
            url: $("#comments").data("url")+"/"+cmsCommentFetchData[0],
            type: "GET",
            dataType: "json",
            timeout: 5000,
            success: function(data, status, xhr) {
                if (!xhr.responseJSON) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchReplace();
                    return;
                }
                if (!xhr.responseJSON.main || !xhr.responseJSON.comment_id || !xhr.responseJSON.comment_ver || !xhr.responseJSON.comment_text) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchReplace();
                    return;
                }
                $("#comment_"+xhr.responseJSON.comment_id+" > .hidden-xs > div > .pull-right > .editable").data("ver") = xhr.responseJSON.comment_ver;
                $("#comment_"+xhr.responseJSON.comment_id+" > .visible-xs > div > .pull-right > .editable").data("ver") = xhr.responseJSON.comment_ver;
                $("#comment_"+xhr.responseJSON.comment_id+" > div > .main").text = xhr.responseJSON.comment_text;
                cmsCommentFetchData.splice(0, 1);
                cmsCommentFetchReplace();
            },
            error: function(xhr, status, error) {
                cmsCommentFetchData.splice(0, 1);
                cmsCommentFetchReplace();
            }
        });
        return;
    }

    cmsCommentFetchNew();
}

function cmsCommentFetchUpdate() {
    var length = cmsCommentFetchRaw.length;
    cmsCommentFetchData = new Array();

    for (var i = 0; i < length; i++) {
        var ok = false;
        $("#comments > .hidden-xs > div > .pull-right > .editable").each(function() {
            if ($(this).data('ver') == cmsCommentFetchRaw[i].comment_ver) {
                ok = true;
            }
        });

        if (ok == false) {
            cmsCommentFetchData.push(cmsCommentFetchRaw[i].comment_id);
        }
    }

    cmsCommentFetchReplace();
}

function cmsCommentFetchProcess() {
    var length = cmsCommentFetchRaw.length;
    var num = 0;
    var done = 0;

    $("#comments > div").each(function() {
        var ok = false;
        for (var i = 0; i < length; i++) {
            if ($(this).data('pk') == cmsCommentFetchRaw[i].comment_id) {
                ok = true;
            }
        }
        if (ok == false) {
            num++;
            $(this).slideUp(300, function() {
                $(this).remove();
                done++;
            });
        }
    });

    var cmsCommentNewCheck = setInterval(function() {
        if (num === done) {
            clearInterval(cmsCommentNewCheck);<commit_msg>Fixes<commit_after>var cmsCommentFetchRaw;
var cmsCommentFetchData;

function cmsCommentFetchGet() {
    if (cmsCommentFetchData.length != 0) {
        console.log('get - '+cmsCommentFetchData[0]);
        $.ajax({
            url: $("#comments").data("url")+"/"+cmsCommentFetchData[0],
            type: "GET",
            dataType: "json",
            timeout: 5000,
            success: function(data, status, xhr) {
                if (!xhr.responseJSON) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchGet();
                    return;
                }
                if (!xhr.responseJSON.contents || !xhr.responseJSON.comment_id) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchGet();
                    return;
                }
                if ($("#comments > div").length == 0) {
                    $("#nocomments").fadeOut(300, function() {
                        $(this).remove();
                        $(xhr.responseJSON.contents).prependTo('#comments').hide().fadeIn(300, function() {
                            cmsTimeAgo("#timeago_comment_"+xhr.responseJSON.comment_id);
                            cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_1");
                            cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_2");
                            cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_1");
                            cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_2");
                            cmsCommentFetchData.splice(0, 1);
                            cmsCommentFetchGet();
                        });
                    });
                } else {
                    $(xhr.responseJSON.contents).prependTo('#comments').hide().slideDown(300, function() {
                        cmsTimeAgo("#timeago_comment_"+xhr.responseJSON.comment_id);
                        cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_1");
                        cmsCommentEdit("#editable_comment_"+xhr.responseJSON.comment_id+"_2");
                        cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_1");
                        cmsCommentDelete("#deletable_comment_"+xhr.responseJSON.comment_id+"_2");
                        cmsCommentFetchData.splice(0, 1);
                        cmsCommentFetchGet();
                    });
                }
            },
            error: function(xhr, status, error) {
                cmsCommentFetchData.splice(0, 1);
                cmsCommentFetchGet();
            }
        });
        return;
    }

    if ($("#comments > div").length == 0 && $("#comments > p").length == 0) {
        $("<p id=\"nocomments\">There are currently no comments.</p>").prependTo("#comments").hide().fadeIn(300, function(){
            cmsCommentLock = false;
            cmsCommentFetch();
        });
    } else {
        cmsCommentLock = false;
        cmsCommentFetch();
    }
}

function cmsCommentFetchNew() {
    var length = cmsCommentFetchRaw.length;
    cmsCommentFetchData = new Array();

    for (var i = 0; i < length; i++) {
        var ok = false;
        $("#comments > div").each(function() {
            if ($(this).data('pk') == cmsCommentFetchRaw[i].comment_id) {
                ok = true;
            }
        });

        if (ok == false) {
            cmsCommentFetchData.push(cmsCommentFetchRaw[i].comment_id);
        }
    }

    cmsCommentFetchGet();
}

function cmsCommentFetchReplace() {
    if (cmsCommentFetchData.length != 0) {
        console.log('replace - '+cmsCommentFetchData[0]);
        $.ajax({
            url: $("#comments").data("url")+"/"+cmsCommentFetchData[0],
            type: "GET",
            dataType: "json",
            timeout: 5000,
            success: function(data, status, xhr) {
                if (!xhr.responseJSON) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchReplace();
                    return;
                }
                if (!xhr.responseJSON.main || !xhr.responseJSON.comment_id || !xhr.responseJSON.comment_ver || !xhr.responseJSON.comment_text) {
                    cmsCommentFetchData.splice(0, 1);
                    cmsCommentFetchReplace();
                    return;
                }
                $("#editable_comment_"+xhr.responseJSON.comment_id+"_1").data("ver") = xhr.responseJSON.comment_ver;
                $("#editable_comment_"+xhr.responseJSON.comment_id+"_2").data("ver") = xhr.responseJSON.comment_ver;
                $("#main_comment_"+xhr.responseJSON.comment_id).text = xhr.responseJSON.comment_text;
                console.log('updated comment to version '+xhr.responseJSON.comment_ver+'with text of '+xhr.responseJSON.comment_text);
                cmsCommentFetchData.splice(0, 1);
                cmsCommentFetchReplace();
            },
            error: function(xhr, status, error) {
                cmsCommentFetchData.splice(0, 1);
                cmsCommentFetchReplace();
            }
        });
        return;
    }

    cmsCommentFetchNew();
}

function cmsCommentFetchUpdate() {
    var length = cmsCommentFetchRaw.length;
    cmsCommentFetchData = new Array();

    for (var i = 0; i < length; i++) {
        var ok = false;
        $("#comments > .hidden-xs > div > .pull-right > .editable").each(function() {
            console.log('selected id '+$(this).data('dk'));
            if ($(this).data('dk') == cmsCommentFetchRaw[i].comment_id) {
                if ($(this).data('ver') == cmsCommentFetchRaw[i].comment_ver) {
                    ok = true;
                    console.log('validated the version');
                }
            }
        });

        if (ok == false) {
            console.log('old version detected');
            cmsCommentFetchData.push(cmsCommentFetchRaw[i].comment_id);
        }
    }

    cmsCommentFetchReplace();
}

function cmsCommentFetchProcess() {
    var length = cmsCommentFetchRaw.length;
    var num = 0;
    var done = 0;

    $("#comments > div").each(function() {
        var ok = false;
        for (var i = 0; i < length; i++) {
            if ($(this).data('pk') == cmsCommentFetchRaw[i].comment_id) {
                ok = true;
            }
        }
        if (ok == false) {
            num++;
            $(this).slideUp(300, function() {
                $(this).remove();
                done++;
            });
        }
    });

    var cmsCommentNewCheck = setInterval(function() {
        if (num === done) {
            clearInterval(cmsCommentNewCheck);
{'fraction_non_alphanumeric': 0.13775233970144637, 'fraction_numerical': 0.009745533297238766, 'mean_word_length': 1.6792374637380854, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 35, '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': '5371237', 'n_tokens_mistral': 3636, 'n_tokens_neox': 3447, 'n_words': 531}