<commit_before>var NUMROWS = 5;
var NUMCOLS = 6;
var GEMR = 75;
var COLORS = ["red", "blue", "green", "yellow", "purple", "pink"];
var ACTIVEGEM = 0;
var ACTIVE = false;
var LIST = [];

$(function() {
    for (col=0; col < NUMCOLS; col++) {
        for (row=0; row < NUMROWS; row++) {
            var random = Math.floor(Math.random() * 6);
            var gem = $("<div class='gem'> </div>");
            var number_id = row.toString() + col.toString();
            gem.attr("id", number_id);
            gem.addClass(COLORS[random]);
            // gem.css("background-color", COLORS[random]);
            gem.css("top", row*GEMR+"px");
            gem.css("left", col*GEMR+"px");
            gem.appendTo("#board");
        }
    }
    $(".gem").mouseover(move);
    $(".gem").mousedown(function() {
        ACTIVEGEM = $(this);
        ACTIVE = true;
        LIST = [];
    });
    $(".gem").mouseup(function() {
        removeCol();
        removeRow();
        gemFall();
        ACTIVE = false;
    });
});


function move() {
    if (ACTIVE) {
        moveGem(this, ACTIVEGEM);
    }
}

function moveGem(to, from) {
    var top = $(to).css("top");
    var left = $(to).css("left");
    var id_swap = $(to).attr("id");
    $(to).css("top", from.css("top"));
    $(to).css("left", from.css("left"));
    $(to).attr("id", from.attr('id'));
    from.css("top", top);
    from.css("left", left);
    from.attr('id', id_swap);
}




function removeCol() {
    for (col=0; col < NUMCOLS; col++) {
        var count = 0;
        var collection = [];
        while (count <= NUMROWS) {
            var gem = $("#" + count.toString() + col.toString());
            try {
                if (gem.attr('class').split(" ")[1] !== collection[0].attr('class').split(" ")[1]) {
                    if (collection.length >= 3) {
                        LIST.push(collection);
                    }
                    collection = [];
                }
            } catch(err) {
                if (collection.length >= 3) {
                    LIST.push(collection);
                }
                collection = [];
            }
            collection.push(gem);
            count++;
        }
    }
}

function removeRow() {
    for (row=0; row < NUMROWS; row++) {
        var count = 0;
        var collection = [];
        while (count <= NUMCOLS) {
            var gem = $("#" + row.toString() + count.toString());
            try {
                if (gem.attr('class').split(" ")[1] !== collection[0].attr('class').split(" ")[1]) {
                    if (collection.length >= 3) {
                        LIST.push(collection);
                    }
                    collection = [];
                }
            } catch(err) {
                if (collection.length >= 3) {
                    LIST.push(collection);
                }
                collection = [];
            }
            collection.push(gem);
            count++;
        }
    }
}

function gemFall() {
    for (collection=0; collection < LIST.length; collection++) {
        for (igem=0; igem < LIST[collection].length; igem++) {
            gem = LIST[collection][igem];
            if (!gem.hasClass("remove")) {
                gem.addClass("remove");
            }
        }
    }
    for (row = NUMROWS - 1; row > -1; row--) {
        var finishedWithThisRow = false;
        var col = 0;
        while (!finishedWithThisRow) {
            
        }
    }
}
<commit_msg>complete gemfall now trying to create new gems in empty spots<commit_after>var NUMROWS = 5;
var NUMCOLS = 6;
var GEMR = 75;
var COLORS = ["red", "blue", "green", "yellow", "purple", "pink"];
var ACTIVEGEM = 0;
var ACTIVE = false;
var LIST = [];

$(function() {
    makeGems();
    $(".gem").mouseover(move);
    $(".gem").mousedown(function() {
        ACTIVEGEM = $(this);
        ACTIVE = true;
        LIST = [];
    });
    $(".gem").mouseup(function() {
        remove();
        ACTIVE = false;
    });
});

function makeGems() {
    for (col=0; col < NUMCOLS; col++) {
        for (row=0; row < NUMROWS; row++) {
            var test = $("#" + row.toString() + col.toString());
            if (test.length === 0) {
                var random = Math.floor(Math.random() * 6);
                var gem = $("<div class='gem'> </div>");
                var number_id = row.toString() + col.toString();
                gem.attr("id", number_id);
                gem.addClass(COLORS[random]);
                // gem.css("background-color", COLORS[random]);
                gem.css("top", row*GEMR+"px");
                gem.css("left", col*GEMR+"px");
                gem.appendTo("#board");
            } else {
                console.log(test)
            }
        }
    }
}


function move() {
    if (ACTIVE) {
        moveGem(this, ACTIVEGEM);
    }
}

function moveGem(to, from) {
    var top = $(to).css("top");
    var left = $(to).css("left");
    var id_swap = $(to).attr("id");
    $(to).css("top", from.css("top"));
    $(to).css("left", from.css("left"));
    $(to).attr("id", from.attr('id'));
    from.css("top", top);
    from.css("left", left);
    from.attr('id', id_swap);
}

function remove() {
    removeCol();
    removeRow();
    if (LIST.length > 0) {
        gemFall();
    }
}


function removeCol() {
    for (col=0; col < NUMCOLS; col++) {
        var count = 0;
        var collection = [];
        while (count <= NUMROWS) {
            var gem = $("#" + count.toString() + col.toString());
            try {
                if (gem.attr('class').split(" ")[1] !== collection[0].attr('class').split(" ")[1]) {
                    if (collection.length >= 3) {
                        LIST.push(collection);
                    }
                    collection = [];
                }
            } catch(err) {
                if (collection.length >= 3) {
                    LIST.push(collection);
                }
                collection = [];
            }
            collection.push(gem);
            count++;
        }
    }
}

function removeRow() {
    for (row=0; row < NUMROWS; row++) {
        var count = 0;
        var collection = [];
        while (count <= NUMCOLS) {
            var gem = $("#" + row.toString() + count.toString());
            try {
                if (gem.attr('class').split(" ")[1] !== collection[0].attr('class').split(" ")[1]) {
                    if (collection.length >= 3) {
                        LIST.push(collection);
                    }
                    collection = [];
                }
            } catch(err) {
                if (collection.length >= 3) {
                    LIST.push(collection);
                }
                collection = [];
            }
            collection.push(gem);
            count++;
        }
    }
}

function gemFall() {
    for (collection=0; collection < LIST.length; collection++) {
        for (igem=0; igem < LIST[collection].length; igem++) {
            var gem = LIST[collection][igem];
            gem.remove();
        }
    }
    for (col = 0; col < NUMCOLS; col++) {
        for (bottom = NUMROWS - 1; bottom > 0; bottom--) {
            var row = bottom;
            while (row > -1) {
                var gem = $("#" + row.toString() + col.toString());
                if (gem.length) { // move to the bottom
                    gem.removeAttr("id");
                    gem.attr("#" + bottom.toString() + col.toString());
                    gem.css("top", bottom*GEMR+"px");
                    break;
                } else { // keep looking
                    row--;
                }
            }
        }
    }
    makeGems();
}

{'fraction_non_alphanumeric': 0.18011772400261608, 'fraction_numerical': 0.007455853499018967, 'mean_word_length': 1.4389154704944178, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 19, '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': '837860', 'n_tokens_mistral': 2363, 'n_tokens_neox': 2238, 'n_words': 473}