NUMROWS = 7;
NUMCOLS = 6;
GEMR = 50;
COLORS = ["red", "blue", "green", "yellow", "purple", "pink"];
ACTIVEGEM = 0;
ACTIVE = false


$(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.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;
    });
    $(".gem").mouseup(function() {
        remove()
        ACTIVE = false;
    });
});


function move() {
    console.log(ACTIVE);
    if (ACTIVE) {
        var top = $(this).css("top");
        var left = $(this).css("left");
        var id_swap = $(this).attr("id");
        $(this).css("top", ACTIVEGEM.css("top"));
        $(this).css("left", ACTIVEGEM.css("left"));
        $(this).attr("id", ACTIVEGEM.attr('id'));
        ACTIVEGEM.css("top", top);
        ACTIVEGEM.css("left", left);
        ACTIVEGEM.attr('id', id_swap);
    }
}

COL1 = [00, 10, 20, 30, 40, 50, 60]


function remove() {
    var list = [];
    for( x=0; x < COL1.length; x++){
        var count = 1;
        while($("#"+COL1[x]).css("background-color") == $("#"+COL1[x+1]).css("background-color")){
            count += 1;
            x += 1;
        }
        if(count >= 3){
            for(y=0; y < count; y++){
                list.push(COL1[x-y]);
            }
        }
    }
    console.log(list)
}

@@ -1387,10 +1387,10 @@
  for
-(
  
+(
 x=0;
@@ -1411,16 +1411,17 @@
 th; x++)
+ 
 %7B%0A      
@@ -1454,15 +1454,18 @@
 hile
+ 
 ($(%22#%22
-+
+ + 
 COL1
@@ -1505,16 +1505,20 @@
 (%22#%22
-+
+ + 
 COL1%5Bx
-+
+ + 
 1%5D).
@@ -1541,16 +1541,17 @@
 color%22))
+ 
 %7B%0A      
@@ -1608,16 +1608,17 @@
       if
+ 
 (count %3E
@@ -1621,16 +1621,17 @@
 nt %3E= 3)
+ 
 %7B%0A      
@@ -1639,16 +1639,17 @@
      for
+ 
 (y=0; y 
@@ -1661,16 +1661,17 @@
 nt; y++)
+ 
 %7B%0A      

update syntax