Commits

Anonymous committed 07efcf8

Immediate neighbours

Comments (0)

Files changed (1)

     return neighbours;
 }
 
-function same_color_neighbours(row, col) {
-    var neighbours = cell_neighbours(row, col);
+function same_color_pack(row, col) {
+    var same = cell_neighbours(row, col);
+    same.push([row, col]);
     var src = img_at(row, col).attr('src');
-    return $.grep(neighbours, 
+    return $.grep(same, 
         function(coords) {
             var img = img_at(coords[0], coords[1]);
             return img.attr('src') == src;
 }
 
 function on_click(row, col) {
-    img_at(row, col).fadeOut('slow').fadeIn('slow');
+    var same_color = same_color_pack(row, col);
+    $.each(same_color, function () {
+            img_at(this[0], this[1]).fadeOut('slow').fadeIn('slow');
+        }
+    );
 }
 
 function make_handler(row, col) {